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('autoreleasePoolStmt0')"><a name="autoreleasePoolStmt0Anchor">autoreleasePoolStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCAutoreleasePoolStmt.html">ObjCAutoreleasePoolStmt</a>>...</td></tr> 666<tr><td colspan="4" class="doc" id="autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement. 667 668Given 669 @autoreleasepool { 670 int x = 0; 671 } 672autoreleasePoolStmt(stmt()) matches the declaration of "x" 673inside the autorelease pool. 674</pre></td></tr> 675 676 677<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> 678<tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension). 679 680Example matches a ?: b 681 (a ?: b) + 42; 682</pre></td></tr> 683 684 685<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> 686<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. 687 688Example matches a || b 689 !(a || b) 690</pre></td></tr> 691 692 693<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> 694<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. 695 696Given 697 while (true) { break; } 698breakStmt() 699 matches 'break' 700</pre></td></tr> 701 702 703<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> 704<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. 705 706Example: Matches (int) 2.2f in 707 int i = (int) 2.2f; 708</pre></td></tr> 709 710 711<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> 712<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. 713 714Example matches x.y() and y() 715 X x; 716 x.y(); 717 y(); 718</pre></td></tr> 719 720 721<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> 722<tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. 723 724Given 725 switch(a) { case 42: break; default: break; } 726caseStmt() 727 matches 'case 42:'. 728</pre></td></tr> 729 730 731<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> 732<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. 733 734Example: castExpr() matches each of the following: 735 (int) 3; 736 const_cast<Expr *>(SubExpr); 737 char c = 0; 738but does not match 739 int i = (0); 740 int k = 0; 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('characterLiteral0')"><a name="characterLiteral0Anchor">characterLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>...</td></tr> 745<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). 746 747Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), 748though. 749 750Example matches 'a', L'a' 751 char ch = 'a'; 752 wchar_t chw = L'a'; 753</pre></td></tr> 754 755 756<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('compoundLiteralExpr0')"><a name="compoundLiteralExpr0Anchor">compoundLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>...</td></tr> 757<tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals 758 759Example match: {1}, (1, 2) 760 int array[4] = {1}; 761 vector int myvec = (vector int)(1, 2); 762</pre></td></tr> 763 764 765<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> 766<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. 767 768Example matches '{}' and '{{}}' in 'for (;;) {{}}' 769 for (;;) {{}} 770</pre></td></tr> 771 772 773<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> 774<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. 775 776Example matches a ? b : c 777 (a ? b : c) + 42 778</pre></td></tr> 779 780 781<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> 782<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. 783 784Given 785 while (true) { continue; } 786continueStmt() 787 matches 'continue' 788</pre></td></tr> 789 790 791<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> 792<tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression. 793 794Example matches, 795 kernel<<<i,j>>>(); 796</pre></td></tr> 797 798 799<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxBindTemporaryExpr0')"><a name="cxxBindTemporaryExpr0Anchor">cxxBindTemporaryExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>>...</td></tr> 800<tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created. 801 802Example matches FunctionTakesString(GetStringByValue()) 803 (matcher = cxxBindTemporaryExpr()) 804 FunctionTakesString(GetStringByValue()); 805 FunctionTakesStringByPointer(GetStringPointer()); 806</pre></td></tr> 807 808 809<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> 810<tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals. 811 812Example matches true 813 true 814</pre></td></tr> 815 816 817<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxCatchStmt0')"><a name="cxxCatchStmt0Anchor">cxxCatchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>>...</td></tr> 818<tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements. 819 820 try {} catch(int i) {} 821cxxCatchStmt() 822 matches 'catch(int i)' 823</pre></td></tr> 824 825 826<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxConstCastExpr0')"><a name="cxxConstCastExpr0Anchor">cxxConstCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>>...</td></tr> 827<tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression. 828 829Example: Matches const_cast<int*>(&r) in 830 int n = 42; 831 const int &r(n); 832 int* p = const_cast<int*>(&r); 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('cxxConstructExpr0')"><a name="cxxConstructExpr0Anchor">cxxConstructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>...</td></tr> 837<tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones). 838 839Example matches string(ptr, n) and ptr within arguments of f 840 (matcher = cxxConstructExpr()) 841 void f(const string &a, const string &b); 842 char *ptr; 843 int n; 844 f(string(ptr, n), ptr); 845</pre></td></tr> 846 847 848<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> 849<tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site. 850 851Example matches the CXXDefaultArgExpr placeholder inserted for the 852 default value of the second parameter in the call expression f(42) 853 (matcher = cxxDefaultArgExpr()) 854 void f(int x, int y = 0); 855 f(42); 856</pre></td></tr> 857 858 859<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> 860<tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions. 861 862Given 863 delete X; 864cxxDeleteExpr() 865 matches 'delete X'. 866</pre></td></tr> 867 868 869<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> 870<tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression. 871 872Example: 873 cxxDynamicCastExpr() 874matches 875 dynamic_cast<D*>(&b); 876in 877 struct B { virtual ~B() {} }; struct D : B {}; 878 B b; 879 D* p = dynamic_cast<D*>(&b); 880</pre></td></tr> 881 882 883<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> 884<tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements. 885 886cxxForRangeStmt() matches 'for (auto a : i)' 887 int i[] = {1, 2, 3}; for (auto a : i); 888 for(int j = 0; j < 5; ++j); 889</pre></td></tr> 890 891 892<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> 893<tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions 894 895Example: Matches Foo(bar); 896 Foo f = bar; 897 Foo g = (Foo) bar; 898 Foo h = Foo(bar); 899</pre></td></tr> 900 901 902<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> 903<tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions. 904 905Example matches x.y() 906 X x; 907 x.y(); 908</pre></td></tr> 909 910 911<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> 912<tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions. 913 914Given 915 new X; 916cxxNewExpr() 917 matches 'new X'. 918</pre></td></tr> 919 920 921<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> 922<tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal. 923</pre></td></tr> 924 925 926<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> 927<tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls. 928 929Note that if an operator isn't overloaded, it won't match. Instead, use 930binaryOperator matcher. 931Currently it does not match operators such as new delete. 932FIXME: figure out why these do not match? 933 934Example matches both operator<<((o << b), c) and operator<<(o, b) 935 (matcher = cxxOperatorCallExpr()) 936 ostream &operator<< (ostream &out, int i) { }; 937 ostream &o; int b = 1, c = 1; 938 o << b << c; 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('cxxReinterpretCastExpr0')"><a name="cxxReinterpretCastExpr0Anchor">cxxReinterpretCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>>...</td></tr> 943<tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. 944 945Either the source expression or the destination type can be matched 946using has(), but hasDestinationType() is more specific and can be 947more readable. 948 949Example matches reinterpret_cast<char*>(&p) in 950 void* p = reinterpret_cast<char*>(&p); 951</pre></td></tr> 952 953 954<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> 955<tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression. 956 957See also: hasDestinationType 958See also: reinterpretCast 959 960Example: 961 cxxStaticCastExpr() 962matches 963 static_cast<long>(8) 964in 965 long eight(static_cast<long>(8)); 966</pre></td></tr> 967 968 969<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> 970<tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions. 971 972Given 973 std::vector<int> a({ 1, 2, 3 }); 974 std::vector<int> b = { 4, 5 }; 975 int c[] = { 6, 7 }; 976 std::pair<int, int> d = { 8, 9 }; 977cxxStdInitializerListExpr() 978 matches "{ 1, 2, 3 }" and "{ 4, 5 }" 979</pre></td></tr> 980 981 982<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> 983<tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments 984 985Example: Matches Foo(bar, bar) 986 Foo h = Foo(bar, bar); 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('cxxThisExpr0')"><a name="cxxThisExpr0Anchor">cxxThisExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>>...</td></tr> 991<tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions. 992 993Example matches the implicit this expression in "return i". 994 (matcher = cxxThisExpr()) 995struct foo { 996 int i; 997 int f() { return i; } 998}; 999</pre></td></tr> 1000 1001 1002<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> 1003<tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions. 1004 1005 try { throw 5; } catch(int i) {} 1006cxxThrowExpr() 1007 matches 'throw 5' 1008</pre></td></tr> 1009 1010 1011<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> 1012<tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements. 1013 1014 try {} catch(int i) {} 1015cxxTryStmt() 1016 matches 'try {}' 1017</pre></td></tr> 1018 1019 1020<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> 1021<tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. 1022 1023Example matches T(t) in return statement of f 1024 (matcher = cxxUnresolvedConstructExpr()) 1025 template <typename T> 1026 void f(const T& t) { return T(t); } 1027</pre></td></tr> 1028 1029 1030<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> 1031<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. 1032 1033Example matches x in if (x) 1034 bool x; 1035 if (x) {} 1036</pre></td></tr> 1037 1038 1039<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> 1040<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. 1041 1042Given 1043 int a; 1044declStmt() 1045 matches 'int a'. 1046</pre></td></tr> 1047 1048 1049<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> 1050<tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. 1051 1052Given 1053 switch(a) { case 42: break; default: break; } 1054defaultStmt() 1055 matches 'default:'. 1056</pre></td></tr> 1057 1058 1059<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> 1060<tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8]. 1061 1062Example: Matches { [2].y = 1.0, [0].x = 1.0 } 1063 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; 1064</pre></td></tr> 1065 1066 1067<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> 1068<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. 1069 1070Given 1071 do {} while (true); 1072doStmt() 1073 matches 'do {} while(true)' 1074</pre></td></tr> 1075 1076 1077<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> 1078<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. 1079 1080Matches any cast expression written in user code, whether it be a 1081C-style cast, a functional-style cast, or a keyword cast. 1082 1083Does not match implicit conversions. 1084 1085Note: the name "explicitCast" is chosen to match Clang's terminology, as 1086Clang uses the term "cast" to apply to implicit conversions as well as to 1087actual cast expressions. 1088 1089See also: hasDestinationType. 1090 1091Example: matches all five of the casts in 1092 int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) 1093but does not match the implicit conversion in 1094 long ell = 42; 1095</pre></td></tr> 1096 1097 1098<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> 1099<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. 1100 1101Example matches x() 1102 void f() { x(); } 1103</pre></td></tr> 1104 1105 1106<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> 1107<tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end 1108of the sub-expression's evaluation. 1109 1110Example matches std::string() 1111 const std::string str = std::string(); 1112</pre></td></tr> 1113 1114 1115<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> 1116<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g. 11171.0, 1.0f, 1.0L and 1e10. 1118 1119Does not match implicit conversions such as 1120 float a = 10; 1121</pre></td></tr> 1122 1123 1124<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> 1125<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. 1126 1127Example matches 'for (;;) {}' 1128 for (;;) {} 1129 int i[] = {1, 2, 3}; for (auto a : i); 1130</pre></td></tr> 1131 1132 1133<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> 1134<tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. 1135</pre></td></tr> 1136 1137 1138<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> 1139<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. 1140 1141Given 1142 goto FOO; 1143 FOO: bar(); 1144gotoStmt() 1145 matches 'goto FOO' 1146</pre></td></tr> 1147 1148 1149<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> 1150<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. 1151 1152Example matches 'if (x) {}' 1153 if (x) {} 1154</pre></td></tr> 1155 1156 1157<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> 1158<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. 1159 1160This matches many different places, including function call return value 1161eliding, as well as any type conversions. 1162</pre></td></tr> 1163 1164 1165<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> 1166<tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions. 1167 1168Given 1169 point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; 1170implicitValueInitExpr() 1171 matches "[0].y" (implicitly) 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('initListExpr0')"><a name="initListExpr0Anchor">initListExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>>...</td></tr> 1176<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. 1177 1178Given 1179 int a[] = { 1, 2 }; 1180 struct B { int x, y; }; 1181 B b = { 5, 6 }; 1182initListExpr() 1183 matches "{ 1, 2 }" and "{ 5, 6 }" 1184</pre></td></tr> 1185 1186 1187<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> 1188<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g. 11891, 1L, 0x1 and 1U. 1190 1191Does not match character-encoded integers such as L'a'. 1192</pre></td></tr> 1193 1194 1195<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> 1196<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. 1197 1198Given 1199 goto FOO; 1200 FOO: bar(); 1201labelStmt() 1202 matches 'FOO:' 1203</pre></td></tr> 1204 1205 1206<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> 1207<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. 1208 1209Example matches [&](){return 5;} 1210 [&](){return 5;} 1211</pre></td></tr> 1212 1213 1214<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> 1215<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. 1216 1217Example: Given 1218 struct T {void func();}; 1219 T f(); 1220 void g(T); 1221materializeTemporaryExpr() matches 'f()' in these statements 1222 T u(f()); 1223 g(f()); 1224 f().func(); 1225but does not match 1226 f(); 1227</pre></td></tr> 1228 1229 1230<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> 1231<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. 1232 1233Given 1234 class Y { 1235 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 1236 int a; static int b; 1237 }; 1238memberExpr() 1239 matches this->x, x, y.x, a, this->b 1240</pre></td></tr> 1241 1242 1243<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> 1244<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. 1245 1246 foo();; 1247nullStmt() 1248 matches the second ';' 1249</pre></td></tr> 1250 1251 1252<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> 1253<tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements. 1254 1255Example matches @catch 1256 @try {} 1257 @catch (...) {} 1258</pre></td></tr> 1259 1260 1261<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> 1262<tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements. 1263 1264Example matches @finally 1265 @try {} 1266 @finally {} 1267</pre></td></tr> 1268 1269 1270<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcIvarRefExpr0')"><a name="objcIvarRefExpr0Anchor">objcIvarRefExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCIvarRefExpr.html">ObjCIvarRefExpr</a>>...</td></tr> 1271<tr><td colspan="4" class="doc" id="objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar. 1272 1273Example: matches "a" in "init" method: 1274@implementation A { 1275 NSString *a; 1276} 1277- (void) init { 1278 a = @"hello"; 1279} 1280} 1281</pre></td></tr> 1282 1283 1284<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> 1285<tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions. 1286 1287The innermost message send invokes the "alloc" class method on the 1288NSString class, while the outermost message send invokes the 1289"initWithString" instance method on the object returned from 1290NSString's "alloc". This matcher should match both message sends. 1291 [[NSString alloc] initWithString:@"Hello"] 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('objcThrowStmt0')"><a name="objcThrowStmt0Anchor">objcThrowStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCAtThrowStmt.html">ObjCAtThrowStmt</a>>...</td></tr> 1296<tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements. 1297 1298Example matches @throw obj; 1299</pre></td></tr> 1300 1301 1302<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> 1303<tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements. 1304 1305Example matches @try 1306 @try {} 1307 @catch (...) {} 1308</pre></td></tr> 1309 1310 1311<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> 1312<tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers 1313to reference another expressions and can be met 1314in BinaryConditionalOperators, for example. 1315 1316Example matches 'a' 1317 (a ?: c) + 42; 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('parenExpr0')"><a name="parenExpr0Anchor">parenExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenExpr.html">ParenExpr</a>>...</td></tr> 1322<tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions. 1323 1324Example matches (foo() + 1) 1325 int foo() { return 1; } 1326 int a = (foo() + 1); 1327</pre></td></tr> 1328 1329 1330<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> 1331<tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions. 1332ParenListExprs don't have a predefined type and are used for late parsing. 1333In the final AST, they can be met in template declarations. 1334 1335Given 1336 template<typename T> class X { 1337 void f() { 1338 X x(*this); 1339 int a = 0, b = 1; int i = (a, b); 1340 } 1341 }; 1342parenListExpr() matches "*this" but NOT matches (a, b) because (a, b) 1343has a predefined type and is a ParenExpr, not a ParenListExpr. 1344</pre></td></tr> 1345 1346 1347<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> 1348<tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2]. 1349 1350Example: Matches __func__ 1351 printf("%s", __func__); 1352</pre></td></tr> 1353 1354 1355<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> 1356<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. 1357 1358Given 1359 return 1; 1360returnStmt() 1361 matches 'return 1' 1362</pre></td></tr> 1363 1364 1365<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> 1366<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. 1367 1368Given 1369 { ++a; } 1370stmt() 1371 matches both the compound statement '{ ++a; }' and '++a'. 1372</pre></td></tr> 1373 1374 1375<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> 1376<tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension). 1377 1378Example match: ({ int X = 4; X; }) 1379 int C = ({ int X = 4; X; }); 1380</pre></td></tr> 1381 1382 1383<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> 1384<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). 1385 1386Example matches "abcd", L"abcd" 1387 char *s = "abcd"; 1388 wchar_t *ws = L"abcd"; 1389</pre></td></tr> 1390 1391 1392<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> 1393<tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. 1394 1395Given 1396 template <int N> 1397 struct A { static const int n = N; }; 1398 struct B : public A<42> {}; 1399substNonTypeTemplateParmExpr() 1400 matches "N" in the right-hand side of "static const int n = N;" 1401</pre></td></tr> 1402 1403 1404<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> 1405<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. 1406 1407Given 1408 switch(a) { case 42: break; default: break; } 1409switchCase() 1410 matches 'case 42:' and 'default:'. 1411</pre></td></tr> 1412 1413 1414<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> 1415<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. 1416 1417Given 1418 switch(a) { case 42: break; default: break; } 1419switchStmt() 1420 matches 'switch(a)'. 1421</pre></td></tr> 1422 1423 1424<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> 1425<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) 1426 1427Given 1428 Foo x = bar; 1429 int y = sizeof(x) + alignof(x); 1430unaryExprOrTypeTraitExpr() 1431 matches sizeof(x) and alignof(x) 1432</pre></td></tr> 1433 1434 1435<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> 1436<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. 1437 1438Example matches !a 1439 !a || b 1440</pre></td></tr> 1441 1442 1443<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> 1444<tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing 1445but could not be resolved to a specific declaration. 1446 1447Given 1448 template<typename T> 1449 T foo() { T a; return a; } 1450 template<typename T> 1451 void bar() { 1452 foo<T>(); 1453 } 1454unresolvedLookupExpr() 1455 matches foo<T>() </pre></td></tr> 1456 1457 1458<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> 1459<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. 1460 1461Example match: "foo"_suffix 1462</pre></td></tr> 1463 1464 1465<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> 1466<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. 1467 1468Given 1469 while (true) {} 1470whileStmt() 1471 matches 'while (true) {}'. 1472</pre></td></tr> 1473 1474 1475<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> 1476<tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. 1477 1478Given 1479 template <typename T> struct C {}; 1480 C<int> c; 1481templateArgument() 1482 matches 'int' in C<int>. 1483</pre></td></tr> 1484 1485 1486<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> 1487<tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name. 1488 1489Given 1490 template <typename T> class X { }; 1491 X<int> xi; 1492templateName() 1493 matches 'X' in X<int>. 1494</pre></td></tr> 1495 1496 1497<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> 1498<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. 1499</pre></td></tr> 1500 1501 1502<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> 1503<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. 1504 1505Given 1506 int a[] = { 2, 3 }; 1507 int b[4]; 1508 void f() { int c[a[0]]; } 1509arrayType() 1510 matches "int a[]", "int b[4]" and "int c[a[0]]"; 1511</pre></td></tr> 1512 1513 1514<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> 1515<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. 1516 1517Given 1518 _Atomic(int) i; 1519atomicType() 1520 matches "_Atomic(int) i" 1521</pre></td></tr> 1522 1523 1524<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> 1525<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. 1526 1527Given: 1528 auto n = 4; 1529 int v[] = { 2, 3 } 1530 for (auto i : v) { } 1531autoType() 1532 matches "auto n" and "auto i" 1533</pre></td></tr> 1534 1535 1536<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> 1537<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as 1538"void (^)(int)". 1539 1540The pointee is always required to be a FunctionType. 1541</pre></td></tr> 1542 1543 1544<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> 1545<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. 1546 1547Given 1548 struct A {}; 1549 A a; 1550 int b; 1551 float c; 1552 bool d; 1553builtinType() 1554 matches "int b", "float c" and "bool d" 1555</pre></td></tr> 1556 1557 1558<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> 1559<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. 1560 1561Given 1562 _Complex float f; 1563complexType() 1564 matches "_Complex float f" 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('constantArrayType0')"><a name="constantArrayType0Anchor">constantArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>>...</td></tr> 1569<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. 1570 1571Given 1572 void() { 1573 int a[2]; 1574 int b[] = { 2, 3 }; 1575 int c[b[0]]; 1576 } 1577constantArrayType() 1578 matches "int a[2]" 1579</pre></td></tr> 1580 1581 1582<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> 1583<tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type 1584Example matches i[] in declaration of f. 1585 (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) 1586Example matches i[1]. 1587 (matcher = expr(hasType(decayedType(hasDecayedType(pointerType()))))) 1588 void f(int i[]) { 1589 i[1] = 0; 1590 } 1591</pre></td></tr> 1592 1593 1594<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('decltypeType0')"><a name="decltypeType0Anchor">decltypeType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>>...</td></tr> 1595<tr><td colspan="4" class="doc" id="decltypeType0"><pre>Matches types nodes representing C++11 decltype(<expr>) types. 1596 1597Given: 1598 short i = 1; 1599 int j = 42; 1600 decltype(i + j) result = i + j; 1601decltypeType() 1602 matches "decltype(i + j)" 1603</pre></td></tr> 1604 1605 1606<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> 1607<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. 1608 1609Given 1610 template<typename T, int Size> 1611 class array { 1612 T data[Size]; 1613 }; 1614dependentSizedArrayType 1615 matches "T data[Size]" 1616</pre></td></tr> 1617 1618 1619<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> 1620<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a 1621qualified name. 1622 1623Given 1624 namespace N { 1625 namespace M { 1626 class D {}; 1627 } 1628 } 1629 class C {}; 1630 1631 class C c; 1632 N::M::D d; 1633 1634elaboratedType() matches the type of the variable declarations of both 1635c and d. 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('enumType0')"><a name="enumType0Anchor">enumType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>...</td></tr> 1640<tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types. 1641 1642Given 1643 enum C { Green }; 1644 enum class S { Red }; 1645 1646 C c; 1647 S s; 1648 1649enumType() matches the type of the variable declarations of both c and 1650s. 1651</pre></td></tr> 1652 1653 1654<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> 1655<tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes. 1656 1657Given 1658 int (*f)(int); 1659 void g(); 1660functionProtoType() 1661 matches "int (*f)(int)" and the type of "g" in C++ mode. 1662 In C mode, "g" is not matched because it does not contain a prototype. 1663</pre></td></tr> 1664 1665 1666<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> 1667<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. 1668 1669Given 1670 int (*f)(int); 1671 void g(); 1672functionType() 1673 matches "int (*f)(int)" and the type of "g". 1674</pre></td></tr> 1675 1676 1677<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> 1678<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. 1679 1680Given 1681 int a[] = { 2, 3 }; 1682 int b[42]; 1683 void f(int c[]) { int d[a[0]]; }; 1684incompleteArrayType() 1685 matches "int a[]" and "int c[]" 1686</pre></td></tr> 1687 1688 1689<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> 1690<tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types. 1691 1692Example matches S s, but not S<T> s. 1693 (matcher = parmVarDecl(hasType(injectedClassNameType()))) 1694 template <typename T> struct S { 1695 void f(S s); 1696 void g(S<T> s); 1697 }; 1698</pre></td></tr> 1699 1700 1701<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> 1702<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. 1703 1704Given: 1705 int *a; 1706 int &b = *a; 1707 int &&c = 1; 1708 auto &d = b; 1709 auto &&e = c; 1710 auto &&f = 2; 1711 int g = 5; 1712 1713lValueReferenceType() matches the types of b, d, and e. e is 1714matched since the type is deduced as int& by reference collapsing rules. 1715</pre></td></tr> 1716 1717 1718<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> 1719<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. 1720Given 1721 struct A { int i; } 1722 A::* ptr = A::i; 1723memberPointerType() 1724 matches "A::* ptr" 1725</pre></td></tr> 1726 1727 1728<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> 1729<tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from 1730a pointer type, despite being syntactically similar. 1731 1732Given 1733 int *a; 1734 1735 @interface Foo 1736 @end 1737 Foo *f; 1738pointerType() 1739 matches "Foo *f", but does not match "int *a". 1740</pre></td></tr> 1741 1742 1743<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> 1744<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. 1745 1746Given 1747 int (*ptr_to_array)[4]; 1748 int *array_of_ptrs[4]; 1749 1750varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not 1751array_of_ptrs. 1752</pre></td></tr> 1753 1754 1755<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> 1756<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer 1757types. 1758 1759Given 1760 int *a; 1761 int &b = *a; 1762 int c = 5; 1763 1764 @interface Foo 1765 @end 1766 Foo *f; 1767pointerType() 1768 matches "int *a", but does not match "Foo *f". 1769</pre></td></tr> 1770 1771 1772<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> 1773<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. 1774 1775Given: 1776 int *a; 1777 int &b = *a; 1778 int &&c = 1; 1779 auto &d = b; 1780 auto &&e = c; 1781 auto &&f = 2; 1782 int g = 5; 1783 1784rValueReferenceType() matches the types of c and f. e is not 1785matched as it is deduced to int& by reference collapsing rules. 1786</pre></td></tr> 1787 1788 1789<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> 1790<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). 1791 1792Given 1793 class C {}; 1794 struct S {}; 1795 1796 C c; 1797 S s; 1798 1799recordType() matches the type of the variable declarations of both c 1800and s. 1801</pre></td></tr> 1802 1803 1804<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> 1805<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. 1806 1807Given 1808 int *a; 1809 int &b = *a; 1810 int &&c = 1; 1811 auto &d = b; 1812 auto &&e = c; 1813 auto &&f = 2; 1814 int g = 5; 1815 1816referenceType() matches the types of b, c, d, e, and f. 1817</pre></td></tr> 1818 1819 1820<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> 1821<tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a 1822template type parameter. 1823 1824Given 1825 template <typename T> 1826 void F(T t) { 1827 int i = 1 + t; 1828 } 1829 1830substTemplateTypeParmType() matches the type of 't' but not '1' 1831</pre></td></tr> 1832 1833 1834<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> 1835<tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types). 1836 1837Given 1838 enum E {}; 1839 class C {}; 1840 1841 E e; 1842 C c; 1843 1844tagType() matches the type of the variable declarations of both e 1845and c. 1846</pre></td></tr> 1847 1848 1849<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> 1850<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. 1851 1852Given 1853 template <typename T> 1854 class C { }; 1855 1856 template class C<int>; A 1857 C<char> var; B 1858 1859templateSpecializationType() matches the type of the explicit 1860instantiation in A and the type of the variable declaration in B. 1861</pre></td></tr> 1862 1863 1864<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> 1865<tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types. 1866 1867Example matches T, but not int. 1868 (matcher = templateTypeParmType()) 1869 template <typename T> void f(int i); 1870</pre></td></tr> 1871 1872 1873<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> 1874<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. 1875</pre></td></tr> 1876 1877 1878<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> 1879<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. 1880 1881Given 1882 typedef int X; 1883typedefType() 1884 matches "typedef int X" 1885</pre></td></tr> 1886 1887 1888<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> 1889<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. 1890 1891Given: 1892 typedef __underlying_type(T) type; 1893unaryTransformType() 1894 matches "__underlying_type(T)" 1895</pre></td></tr> 1896 1897 1898<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> 1899<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an 1900integer-constant-expression. 1901 1902Given 1903 void f() { 1904 int a[] = { 2, 3 } 1905 int b[42]; 1906 int c[a[0]]; 1907 } 1908variableArrayType() 1909 matches "int c[a[0]]" 1910</pre></td></tr> 1911 1912<!--END_DECL_MATCHERS --> 1913</table> 1914 1915<!-- ======================================================================= --> 1916<h2 id="narrowing-matchers">Narrowing Matchers</h2> 1917<!-- ======================================================================= --> 1918 1919<p>Narrowing matchers match certain attributes on the current node, thus 1920narrowing down the set of nodes of the current type to match on.</p> 1921 1922<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) 1923which allow users to create more powerful match expressions.</p> 1924 1925<table> 1926<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 1927<!-- START_NARROWING_MATCHERS --> 1928 1929<tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 1930<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. 1931 1932Usable as: Any Matcher 1933</pre></td></tr> 1934 1935 1936<tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 1937<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. 1938 1939Usable as: Any Matcher 1940</pre></td></tr> 1941 1942 1943<tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> 1944<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. 1945 1946Useful when another matcher requires a child matcher, but there's no 1947additional constraint. This will often be used with an explicit conversion 1948to an internal::Matcher<> type such as TypeMatcher. 1949 1950Example: DeclarationMatcher(anything()) matches all declarations, e.g., 1951"int* p" and "void f()" in 1952 int* p; 1953 void f(); 1954 1955Usable as: Any Matcher 1956</pre></td></tr> 1957 1958 1959<tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> 1960<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. 1961 1962Example matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) 1963 class X {}; 1964 class Y {}; 1965 1966Usable as: Any Matcher 1967</pre></td></tr> 1968 1969 1970<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> 1971<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or 1972unary). 1973 1974Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 1975 !(a || b) 1976</pre></td></tr> 1977 1978 1979<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> 1980<tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators. 1981 1982Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) 1983 if (a == b) 1984 a += b; 1985 1986Example 2: matches s1 = s2 1987 (matcher = cxxOperatorCallExpr(isAssignmentOperator())) 1988 struct S { S& operator=(const S&); }; 1989 void x() { S s1, s2; s1 = s2; }) 1990</pre></td></tr> 1991 1992 1993<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> 1994<tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr> 1995 1996 1997<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> 1998<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT. 1999 2000Given 2001 f('false, 3.14, 42); 2002characterLiteral(equals(0)) 2003 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 2004 match false 2005floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 2006 match 3.14 2007integerLiteral(equals(42)) 2008 matches 42 2009 2010Note that you cannot directly match a negative numeric literal because the 2011minus sign is not part of the literal: It is a unary operator whose operand 2012is the positive numeric literal. Instead, you must use a unaryOperator() 2013matcher to match the minus sign: 2014 2015unaryOperator(hasOperatorName("-"), 2016 hasUnaryOperand(integerLiteral(equals(13)))) 2017 2018Usable 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>>, 2019 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>> 2020</pre></td></tr> 2021 2022 2023<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> 2024<tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr> 2025 2026 2027<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> 2028<tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr> 2029 2030 2031<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> 2032<tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. 2033 2034Given 2035 try { 2036 ... 2037 } catch (int) { 2038 ... 2039 } catch (...) { 2040 ... 2041 } 2042endcode 2043cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). 2044</pre></td></tr> 2045 2046 2047<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> 2048<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has 2049a specific number of arguments (including absent default arguments). 2050 2051Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 2052 void f(int x, int y); 2053 f(0, 0); 2054</pre></td></tr> 2055 2056 2057<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> 2058<tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. 2059</pre></td></tr> 2060 2061 2062<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> 2063<tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires 2064zero initialization. 2065 2066Given 2067void foo() { 2068 struct point { double x; double y; }; 2069 point pt[2] = { { 1.0, 2.0 } }; 2070} 2071initListExpr(has(cxxConstructExpr(requiresZeroInitialization())) 2072will match the implicit array filler for pt[1]. 2073</pre></td></tr> 2074 2075 2076<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> 2077<tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. 2078 2079Given 2080 struct S { 2081 S(); #1 2082 S(const S &); #2 2083 S(S &&); #3 2084 }; 2085cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. 2086</pre></td></tr> 2087 2088 2089<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> 2090<tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. 2091 2092Given 2093 struct S { 2094 S(); #1 2095 S(const S &); #2 2096 S(S &&); #3 2097 }; 2098cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. 2099</pre></td></tr> 2100 2101 2102<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> 2103<tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor. 2104 2105Given 2106 struct S { 2107 S(); #1 2108 S(int) {} #2 2109 S(S &&) : S() {} #3 2110 }; 2111 S::S() : S(0) {} #4 2112cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not 2113#1 or #2. 2114</pre></td></tr> 2115 2116 2117<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> 2118<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with 2119the explicit keyword. 2120 2121Given 2122 struct S { 2123 S(int); #1 2124 explicit S(double); #2 2125 operator int(); #3 2126 explicit operator bool(); #4 2127 }; 2128cxxConstructorDecl(isExplicit()) will match #2, but not #1. 2129cxxConversionDecl(isExplicit()) will match #4, but not #3. 2130</pre></td></tr> 2131 2132 2133<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> 2134<tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. 2135 2136Given 2137 struct S { 2138 S(); #1 2139 S(const S &); #2 2140 S(S &&); #3 2141 }; 2142cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. 2143</pre></td></tr> 2144 2145 2146<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> 2147<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with 2148the explicit keyword. 2149 2150Given 2151 struct S { 2152 S(int); #1 2153 explicit S(double); #2 2154 operator int(); #3 2155 explicit operator bool(); #4 2156 }; 2157cxxConstructorDecl(isExplicit()) will match #2, but not #1. 2158cxxConversionDecl(isExplicit()) will match #4, but not #3. 2159</pre></td></tr> 2160 2161 2162<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> 2163<tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as 2164opposed to a member. 2165 2166Given 2167 struct B {}; 2168 struct D : B { 2169 int I; 2170 D(int i) : I(i) {} 2171 }; 2172 struct E : B { 2173 E() : B() {} 2174 }; 2175cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) 2176 will match E(), but not match D(int). 2177</pre></td></tr> 2178 2179 2180<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> 2181<tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as 2182opposed to a base. 2183 2184Given 2185 struct B {}; 2186 struct D : B { 2187 int I; 2188 D(int i) : I(i) {} 2189 }; 2190 struct E : B { 2191 E() : B() {} 2192 }; 2193cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) 2194 will match D(int), but not match E(). 2195</pre></td></tr> 2196 2197 2198<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> 2199<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in 2200code (as opposed to implicitly added by the compiler). 2201 2202Given 2203 struct Foo { 2204 Foo() { } 2205 Foo(int) : foo_("A") { } 2206 string foo_; 2207 }; 2208cxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) 2209 will match Foo(int), but not Foo() 2210</pre></td></tr> 2211 2212 2213<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> 2214<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. 2215 2216Given 2217struct A { 2218 void foo() const; 2219 void bar(); 2220}; 2221 2222cxxMethodDecl(isConst()) matches A::foo() but not A::bar() 2223</pre></td></tr> 2224 2225 2226<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> 2227<tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment 2228operator. 2229 2230Given 2231struct A { 2232 A &operator=(const A &); 2233 A &operator=(A &&); 2234}; 2235 2236cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not 2237the second one. 2238</pre></td></tr> 2239 2240 2241<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> 2242<tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. 2243 2244Given: 2245 class A final {}; 2246 2247 struct B { 2248 virtual void f(); 2249 }; 2250 2251 struct C : B { 2252 void f() final; 2253 }; 2254matches A and C::f, but not B, C, or B::f 2255</pre></td></tr> 2256 2257 2258<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> 2259<tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment 2260operator. 2261 2262Given 2263struct A { 2264 A &operator=(const A &); 2265 A &operator=(A &&); 2266}; 2267 2268cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not 2269the first one. 2270</pre></td></tr> 2271 2272 2273<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> 2274<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. 2275 2276Given 2277 class A { 2278 public: 2279 virtual void x(); 2280 }; 2281 class B : public A { 2282 public: 2283 virtual void x(); 2284 }; 2285 matches B::x 2286</pre></td></tr> 2287 2288 2289<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> 2290<tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. 2291 2292Given 2293 class A { 2294 public: 2295 virtual void x() = 0; 2296 }; 2297 matches A::x 2298</pre></td></tr> 2299 2300 2301<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> 2302<tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided. 2303 2304Given 2305 struct S { 2306 S(); #1 2307 S(const S &) = default; #2 2308 S(S &&) = delete; #3 2309 }; 2310cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3. 2311</pre></td></tr> 2312 2313 2314<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> 2315<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. 2316 2317Given 2318 class A { 2319 public: 2320 virtual void x(); 2321 }; 2322 matches A::x 2323</pre></td></tr> 2324 2325 2326<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> 2327<tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual". 2328 2329Given 2330 class A { 2331 public: 2332 virtual void x(); 2333 }; 2334 class B : public A { 2335 public: 2336 void x(); 2337 }; 2338 matches A::x but not B::x 2339</pre></td></tr> 2340 2341 2342<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> 2343<tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions. 2344 2345Given: 2346 MyClass *p1 = new MyClass[10]; 2347cxxNewExpr(isArray()) 2348 matches the expression 'new MyClass[10]'. 2349</pre></td></tr> 2350 2351 2352<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> 2353<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. 2354 2355Matches overloaded operator names specified in strings without the 2356"operator" prefix: e.g. "<<". 2357 2358Given: 2359 class A { int operator*(); }; 2360 const A &operator<<(const A &a, const A &b); 2361 A a; 2362 a << a; <-- This matches 2363 2364cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the 2365specified line and 2366cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) 2367matches the declaration of A. 2368 2369Usable 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>> 2370</pre></td></tr> 2371 2372 2373<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> 2374<tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators. 2375 2376Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) 2377 if (a == b) 2378 a += b; 2379 2380Example 2: matches s1 = s2 2381 (matcher = cxxOperatorCallExpr(isAssignmentOperator())) 2382 struct S { S& operator=(const S&); }; 2383 void x() { S s1, s2; s1 = s2; }) 2384</pre></td></tr> 2385 2386 2387<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> 2388<tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined. 2389 2390Example matches x (matcher = cxxRecordDecl(hasDefinition())) 2391class x {}; 2392class y; 2393</pre></td></tr> 2394 2395 2396<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> 2397<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). 2398</pre></td></tr> 2399 2400 2401<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> 2402<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or 2403static member variable template instantiations. 2404 2405Given 2406 template<typename T> void A(T t) { } 2407 template<> void A(int N) { } 2408functionDecl(isExplicitTemplateSpecialization()) 2409 matches the specialization A<int>(). 2410 2411Usable 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>> 2412</pre></td></tr> 2413 2414 2415<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> 2416<tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. 2417 2418Given: 2419 class A final {}; 2420 2421 struct B { 2422 virtual void f(); 2423 }; 2424 2425 struct C : B { 2426 void f() final; 2427 }; 2428matches A and C::f, but not B, C, or B::f 2429</pre></td></tr> 2430 2431 2432<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> 2433<tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions. 2434 2435Given: 2436 auto x = []{}; 2437 2438cxxRecordDecl(isLambda()) matches the implicit class declaration of 2439decltype(x) 2440</pre></td></tr> 2441 2442 2443<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> 2444<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for 2445isSameOrDerivedFrom(hasName(...)). 2446</pre></td></tr> 2447 2448 2449<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> 2450<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static 2451member variable template instantiations. 2452 2453Given 2454 template <typename T> class X {}; class A {}; X<A> x; 2455or 2456 template <typename T> class X {}; class A {}; template class X<A>; 2457or 2458 template <typename T> class X {}; class A {}; extern template class X<A>; 2459cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2460 matches the template instantiation of X<A>. 2461 2462But given 2463 template <typename T> class X {}; class A {}; 2464 template <> class X<A> {}; X<A> x; 2465cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2466 does not match, as X<A> is an explicit template specialization. 2467 2468Usable 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>> 2469</pre></td></tr> 2470 2471 2472<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> 2473<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has 2474a specific number of arguments (including absent default arguments). 2475 2476Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 2477 void f(int x, int y); 2478 f(0, 0); 2479</pre></td></tr> 2480 2481 2482<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> 2483<tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind. 2484 2485Example: matches the implicit cast around 0 2486(matcher = castExpr(hasCastKind(CK_NullToPointer))) 2487 int *p = 0; 2488</pre></td></tr> 2489 2490 2491<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> 2492<tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr> 2493 2494 2495<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> 2496<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT. 2497 2498Given 2499 f('false, 3.14, 42); 2500characterLiteral(equals(0)) 2501 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 2502 match false 2503floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 2504 match 3.14 2505integerLiteral(equals(42)) 2506 matches 42 2507 2508Note that you cannot directly match a negative numeric literal because the 2509minus sign is not part of the literal: It is a unary operator whose operand 2510is the positive numeric literal. Instead, you must use a unaryOperator() 2511matcher to match the minus sign: 2512 2513unaryOperator(hasOperatorName("-"), 2514 hasUnaryOperand(integerLiteral(equals(13)))) 2515 2516Usable 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>>, 2517 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>> 2518</pre></td></tr> 2519 2520 2521<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> 2522<tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr> 2523 2524 2525<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> 2526<tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr> 2527 2528 2529<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> 2530<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. 2531 2532Given 2533 template<typename T> struct C {}; 2534 C<int> c; 2535classTemplateSpecializationDecl(templateArgumentCountIs(1)) 2536 matches C<int>. 2537</pre></td></tr> 2538 2539 2540<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> 2541<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of 2542child statements. 2543 2544Example: Given 2545 { for (;;) {} } 2546compoundStmt(statementCountIs(0))) 2547 matches '{}' 2548 but does not match the outer compound statement. 2549</pre></td></tr> 2550 2551 2552<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> 2553<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size. 2554 2555Given 2556 int a[42]; 2557 int b[2 * 21]; 2558 int c[41], d[43]; 2559 char *s = "abcd"; 2560 wchar_t *ws = L"abcd"; 2561 char *w = "a"; 2562constantArrayType(hasSize(42)) 2563 matches "int a[42]" and "int b[2 * 21]" 2564stringLiteral(hasSize(4)) 2565 matches "abcd", L"abcd" 2566</pre></td></tr> 2567 2568 2569<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> 2570<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of 2571declarations. 2572 2573Example: Given 2574 int a, b; 2575 int c; 2576 int d = 2, e; 2577declCountIs(2) 2578 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. 2579</pre></td></tr> 2580 2581 2582<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> 2583<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. 2584 2585Matches a node if it equals the node previously bound to ID. 2586 2587Given 2588 class X { int a; int b; }; 2589cxxRecordDecl( 2590 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2591 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2592 matches the class X, as a and b have the same type. 2593 2594Note that when multiple matches are involved via forEach* matchers, 2595equalsBoundNodes acts as a filter. 2596For example: 2597compoundStmt( 2598 forEachDescendant(varDecl().bind("d")), 2599 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2600will trigger a match for each combination of variable declaration 2601and reference to that variable declaration within a compound statement. 2602</pre></td></tr> 2603 2604 2605<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> 2606<tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node. 2607 2608Decl has pointer identity in the AST. 2609</pre></td></tr> 2610 2611 2612<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> 2613<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. 2614 2615Given 2616 __attribute__((device)) void f() { ... } 2617decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of 2618f. If the matcher is use from clang-query, attr::Kind parameter should be 2619passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). 2620</pre></td></tr> 2621 2622 2623<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> 2624<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is 2625partially matching a given regex. 2626 2627Example matches Y but not X 2628 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 2629 #include "ASTMatcher.h" 2630 class X {}; 2631ASTMatcher.h: 2632 class Y {}; 2633 2634Usable 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>> 2635</pre></td></tr> 2636 2637 2638<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> 2639<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. 2640 2641Example matches X but not Y 2642 (matcher = cxxRecordDecl(isExpansionInMainFile()) 2643 #include <Y.h> 2644 class X {}; 2645Y.h: 2646 class Y {}; 2647 2648Usable 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>> 2649</pre></td></tr> 2650 2651 2652<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> 2653<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. 2654 2655Example matches Y but not X 2656 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 2657 #include <SystemHeader.h> 2658 class X {}; 2659SystemHeader.h: 2660 class Y {}; 2661 2662Usable 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>> 2663</pre></td></tr> 2664 2665 2666<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> 2667<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added 2668by the compiler (eg. implicit defaultcopy constructors). 2669</pre></td></tr> 2670 2671 2672<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> 2673<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. 2674 2675Given 2676 class C { 2677 public: int a; 2678 protected: int b; 2679 private: int c; 2680 }; 2681fieldDecl(isPrivate()) 2682 matches 'int c;' 2683</pre></td></tr> 2684 2685 2686<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> 2687<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. 2688 2689Given 2690 class C { 2691 public: int a; 2692 protected: int b; 2693 private: int c; 2694 }; 2695fieldDecl(isProtected()) 2696 matches 'int b;' 2697</pre></td></tr> 2698 2699 2700<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> 2701<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. 2702 2703Given 2704 class C { 2705 public: int a; 2706 protected: int b; 2707 private: int c; 2708 }; 2709fieldDecl(isPublic()) 2710 matches 'int a;' 2711</pre></td></tr> 2712 2713 2714<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> 2715<tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain 2716a specific number of designators. 2717 2718Example: Given 2719 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; 2720 point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }; 2721designatorCountIs(2) 2722 matches '{ [2].y = 1.0, [0].x = 1.0 }', 2723 but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'. 2724</pre></td></tr> 2725 2726 2727<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> 2728<tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration. 2729 2730Example matches Y (matcher = enumDecl(isScoped())) 2731enum X {}; 2732enum class Y {}; 2733</pre></td></tr> 2734 2735 2736<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> 2737<tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified 2738bit width. 2739 2740Given 2741 class C { 2742 int a : 2; 2743 int b : 4; 2744 int c : 2; 2745 }; 2746fieldDecl(hasBitWidth(2)) 2747 matches 'int a;' and 'int c;' but not 'int b;'. 2748</pre></td></tr> 2749 2750 2751<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> 2752<tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields. 2753 2754Given 2755 class C { 2756 int a : 2; 2757 int b; 2758 }; 2759fieldDecl(isBitField()) 2760 matches 'int a;' but not 'int b;'. 2761</pre></td></tr> 2762 2763 2764<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> 2765<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT. 2766 2767Given 2768 f('false, 3.14, 42); 2769characterLiteral(equals(0)) 2770 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 2771 match false 2772floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 2773 match 3.14 2774integerLiteral(equals(42)) 2775 matches 42 2776 2777Note that you cannot directly match a negative numeric literal because the 2778minus sign is not part of the literal: It is a unary operator whose operand 2779is the positive numeric literal. Instead, you must use a unaryOperator() 2780matcher to match the minus sign: 2781 2782unaryOperator(hasOperatorName("-"), 2783 hasUnaryOperand(integerLiteral(equals(13)))) 2784 2785Usable 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>>, 2786 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>> 2787</pre></td></tr> 2788 2789 2790<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> 2791<tr><td colspan="4" class="doc" id="equals12"><pre></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('hasDynamicExceptionSpec0')"><a name="hasDynamicExceptionSpec0Anchor">hasDynamicExceptionSpec</a></td><td></td></tr> 2795<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification. 2796 2797Given: 2798 void f(); 2799 void g() noexcept; 2800 void h() noexcept(true); 2801 void i() noexcept(false); 2802 void j() throw(); 2803 void k() throw(int); 2804 void l() throw(...); 2805functionDecl(hasDynamicExceptionSpec()) and 2806 functionProtoType(hasDynamicExceptionSpec()) 2807 match the declarations of j, k, and l, but not f, g, h, or i. 2808</pre></td></tr> 2809 2810 2811<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> 2812<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. 2813 2814Matches overloaded operator names specified in strings without the 2815"operator" prefix: e.g. "<<". 2816 2817Given: 2818 class A { int operator*(); }; 2819 const A &operator<<(const A &a, const A &b); 2820 A a; 2821 a << a; <-- This matches 2822 2823cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the 2824specified line and 2825cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) 2826matches the declaration of A. 2827 2828Usable 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>> 2829</pre></td></tr> 2830 2831 2832<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> 2833<tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type. 2834 2835Example matches Y (matcher = functionDecl(hasTrailingReturn())) 2836int X() {} 2837auto Y() -> int {} 2838</pre></td></tr> 2839 2840 2841<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> 2842<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations, 2843 and if constexpr. 2844 2845Given: 2846 constexpr int foo = 42; 2847 constexpr int bar(); 2848 void baz() { if constexpr(1 > 0) {} } 2849varDecl(isConstexpr()) 2850 matches the declaration of foo. 2851functionDecl(isConstexpr()) 2852 matches the declaration of bar. 2853ifStmt(isConstexpr()) 2854 matches the if statement in baz. 2855</pre></td></tr> 2856 2857 2858<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> 2859<tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations. 2860 2861Given: 2862 class A { ~A(); }; 2863 class B { ~B() = default; }; 2864functionDecl(isDefaulted()) 2865 matches the declaration of ~B, but not ~A. 2866</pre></td></tr> 2867 2868 2869<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> 2870<tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached. 2871 2872Example matches A, va, fa 2873 class A {}; 2874 class B; Doesn't match, as it has no body. 2875 int va; 2876 extern int vb; Doesn't match, as it doesn't define the variable. 2877 void fa() {} 2878 void fb(); Doesn't match, as it has no body. 2879 @interface X 2880 - (void)ma; Doesn't match, interface is declaration. 2881 @end 2882 @implementation X 2883 - (void)ma {} 2884 @end 2885 2886Usable 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>>, 2887 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 2888</pre></td></tr> 2889 2890 2891<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> 2892<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. 2893 2894Given: 2895 void Func(); 2896 void DeletedFunc() = delete; 2897functionDecl(isDeleted()) 2898 matches the declaration of DeletedFunc, but not Func. 2899</pre></td></tr> 2900 2901 2902<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> 2903<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or 2904static member variable template instantiations. 2905 2906Given 2907 template<typename T> void A(T t) { } 2908 template<> void A(int N) { } 2909functionDecl(isExplicitTemplateSpecialization()) 2910 matches the specialization A<int>(). 2911 2912Usable 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>> 2913</pre></td></tr> 2914 2915 2916<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> 2917<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations. 2918 2919Given: 2920 extern "C" void f() {} 2921 extern "C" { void g() {} } 2922 void h() {} 2923 extern "C" int x = 1; 2924 extern "C" int y = 2; 2925 int z = 3; 2926functionDecl(isExternC()) 2927 matches the declaration of f and g, but not the declaration of h. 2928varDecl(isExternC()) 2929 matches the declaration of x and y, but not the declaration of z. 2930</pre></td></tr> 2931 2932 2933<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> 2934<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with 2935the inline keyword. 2936 2937Given 2938 inline void f(); 2939 void g(); 2940 namespace n { 2941 inline namespace m {} 2942 } 2943functionDecl(isInline()) will match ::f(). 2944namespaceDecl(isInline()) will match n::m. 2945</pre></td></tr> 2946 2947 2948<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isMain0')"><a name="isMain0Anchor">isMain</a></td><td></td></tr> 2949<tr><td colspan="4" class="doc" id="isMain0"><pre>Determines whether the function is "main", which is the entry point 2950into an executable program. 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('isNoReturn0')"><a name="isNoReturn0Anchor">isNoReturn</a></td><td></td></tr> 2955<tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute. 2956 2957Given 2958 void nope(); 2959 [[noreturn]] void a(); 2960 __attribute__((noreturn)) void b(); 2961 struct c { [[noreturn]] c(); }; 2962functionDecl(isNoReturn()) 2963 matches all of those except 2964 void nope(); 2965</pre></td></tr> 2966 2967 2968<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> 2969<tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification. 2970 2971Given: 2972 void f(); 2973 void g() noexcept; 2974 void h() throw(); 2975 void i() throw(int); 2976 void j() noexcept(false); 2977functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) 2978 match the declarations of g, and h, but not f, i or j. 2979</pre></td></tr> 2980 2981 2982<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> 2983<tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variablefunction declarations that have "static" storage 2984class specifier ("static" keyword) written in the source. 2985 2986Given: 2987 static void f() {} 2988 static int i = 0; 2989 extern int j; 2990 int k; 2991functionDecl(isStaticStorageClass()) 2992 matches the function declaration f. 2993varDecl(isStaticStorageClass()) 2994 matches the variable declaration i. 2995</pre></td></tr> 2996 2997 2998<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> 2999<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 3000member variable template instantiations. 3001 3002Given 3003 template <typename T> class X {}; class A {}; X<A> x; 3004or 3005 template <typename T> class X {}; class A {}; template class X<A>; 3006or 3007 template <typename T> class X {}; class A {}; extern template class X<A>; 3008cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 3009 matches the template instantiation of X<A>. 3010 3011But given 3012 template <typename T> class X {}; class A {}; 3013 template <> class X<A> {}; X<A> x; 3014cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 3015 does not match, as X<A> is an explicit template specialization. 3016 3017Usable 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>> 3018</pre></td></tr> 3019 3020 3021<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> 3022<tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. 3023 3024Example matches f, but not g or h. The function i will not match, even when 3025compiled in C mode. 3026 void f(...); 3027 void g(int); 3028 template <typename... Ts> void h(Ts...); 3029 void i(); 3030</pre></td></tr> 3031 3032 3033<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> 3034<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a 3035specific parameter count. 3036 3037Given 3038 void f(int i) {} 3039 void g(int i, int j) {} 3040 void h(int i, int j); 3041 void j(int i); 3042 void k(int x, int y, int z, ...); 3043functionDecl(parameterCountIs(2)) 3044 matches g and h 3045functionProtoType(parameterCountIs(2)) 3046 matches g and h 3047functionProtoType(parameterCountIs(3)) 3048 matches k 3049</pre></td></tr> 3050 3051 3052<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> 3053<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification. 3054 3055Given: 3056 void f(); 3057 void g() noexcept; 3058 void h() noexcept(true); 3059 void i() noexcept(false); 3060 void j() throw(); 3061 void k() throw(int); 3062 void l() throw(...); 3063functionDecl(hasDynamicExceptionSpec()) and 3064 functionProtoType(hasDynamicExceptionSpec()) 3065 match the declarations of j, k, and l, but not f, g, h, or i. 3066</pre></td></tr> 3067 3068 3069<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> 3070<tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification. 3071 3072Given: 3073 void f(); 3074 void g() noexcept; 3075 void h() throw(); 3076 void i() throw(int); 3077 void j() noexcept(false); 3078functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) 3079 match the declarations of g, and h, but not f, i or j. 3080</pre></td></tr> 3081 3082 3083<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> 3084<tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a 3085specific parameter count. 3086 3087Given 3088 void f(int i) {} 3089 void g(int i, int j) {} 3090 void h(int i, int j); 3091 void j(int i); 3092 void k(int x, int y, int z, ...); 3093functionDecl(parameterCountIs(2)) 3094 matches g and h 3095functionProtoType(parameterCountIs(2)) 3096 matches g and h 3097functionProtoType(parameterCountIs(3)) 3098 matches k 3099</pre></td></tr> 3100 3101 3102<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> 3103<tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations, 3104 and if constexpr. 3105 3106Given: 3107 constexpr int foo = 42; 3108 constexpr int bar(); 3109 void baz() { if constexpr(1 > 0) {} } 3110varDecl(isConstexpr()) 3111 matches the declaration of foo. 3112functionDecl(isConstexpr()) 3113 matches the declaration of bar. 3114ifStmt(isConstexpr()) 3115 matches the if statement in baz. 3116</pre></td></tr> 3117 3118 3119<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> 3120<tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr> 3121 3122 3123<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> 3124<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT. 3125 3126Given 3127 f('false, 3.14, 42); 3128characterLiteral(equals(0)) 3129 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 3130 match false 3131floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 3132 match 3.14 3133integerLiteral(equals(42)) 3134 matches 42 3135 3136Note that you cannot directly match a negative numeric literal because the 3137minus sign is not part of the literal: It is a unary operator whose operand 3138is the positive numeric literal. Instead, you must use a unaryOperator() 3139matcher to match the minus sign: 3140 3141unaryOperator(hasOperatorName("-"), 3142 hasUnaryOperand(integerLiteral(equals(13)))) 3143 3144Usable 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>>, 3145 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>> 3146</pre></td></tr> 3147 3148 3149<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> 3150<tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr> 3151 3152 3153<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> 3154<tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr> 3155 3156 3157<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> 3158<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 3159to '.'. 3160 3161Member calls on the implicit this pointer match as called with '->'. 3162 3163Given 3164 class Y { 3165 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 3166 int a; 3167 static int b; 3168 }; 3169memberExpr(isArrow()) 3170 matches this->x, x, y.x, a, this->b 3171</pre></td></tr> 3172 3173 3174<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> 3175<tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage. 3176 3177Example matches only z (matcher = varDecl(hasExternalFormalLinkage())) 3178void f() { 3179 int x; 3180 static int y; 3181} 3182int z; 3183 3184Example matches f() because it has external formal linkage despite being 3185unique to the translation unit as though it has internal likage 3186(matcher = functionDecl(hasExternalFormalLinkage())) 3187 3188namespace { 3189void f() {} 3190} 3191</pre></td></tr> 3192 3193 3194<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> 3195<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 3196 3197Supports specifying enclosing namespaces or classes by prefixing the name 3198with '<enclosing>::'. 3199Does not match typedefs of an underlying type with the given name. 3200 3201Example matches X (Name == "X") 3202 class X; 3203 3204Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 3205 namespace a { namespace b { class X; } } 3206</pre></td></tr> 3207 3208 3209<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> 3210<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain 3211a substring matched by the given RegExp. 3212 3213Supports specifying enclosing namespaces or classes by 3214prefixing the name with '<enclosing>::'. Does not match typedefs 3215of an underlying type with the given name. 3216 3217Example matches X (regexp == "::X") 3218 class X; 3219 3220Example matches X (regexp is one of "::X", "^foo::.*X", among others) 3221 namespace foo { namespace bar { class X; } } 3222</pre></td></tr> 3223 3224 3225<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> 3226<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. 3227 3228Given 3229 namespace n { 3230 namespace {} #1 3231 } 3232namespaceDecl(isAnonymous()) will match #1 but not ::n. 3233</pre></td></tr> 3234 3235 3236<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> 3237<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with 3238the inline keyword. 3239 3240Given 3241 inline void f(); 3242 void g(); 3243 namespace n { 3244 inline namespace m {} 3245 } 3246functionDecl(isInline()) will match ::f(). 3247namespaceDecl(isInline()) will match n::m. 3248</pre></td></tr> 3249 3250 3251<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> 3252<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has 3253a specific number of arguments (including absent default arguments). 3254 3255Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 3256 void f(int x, int y); 3257 f(0, 0); 3258</pre></td></tr> 3259 3260 3261<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> 3262<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector 3263 3264objCMessageExpr(hasKeywordSelector()) matches the generated setFrame 3265message expression in 3266 3267 UIWebView *webView = ...; 3268 CGRect bodyFrame = webView.frame; 3269 bodyFrame.size.height = self.bodyContentHeight; 3270 webView.frame = bodyFrame; 3271 ^---- matches here 3272</pre></td></tr> 3273 3274 3275<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> 3276<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector 3277 3278Matches only when the selector of the objCMessageExpr is NULL. This may 3279represent an error condition in the tree! 3280</pre></td></tr> 3281 3282 3283<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> 3284<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() 3285 3286 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); 3287 matches the outer message expr in the code below, but NOT the message 3288 invocation for self.bodyView. 3289 [self.bodyView loadHTMLString:html baseURL:NULL]; 3290</pre></td></tr> 3291 3292 3293<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> 3294<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector 3295 3296 matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); 3297 matches self.bodyView in the code below, but NOT the outer message 3298 invocation of "loadHTMLString:baseURL:". 3299 [self.bodyView loadHTMLString:html baseURL:NULL]; 3300</pre></td></tr> 3301 3302 3303<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('isInstanceMessage0')"><a name="isInstanceMessage0Anchor">isInstanceMessage</a></td><td></td></tr> 3304<tr><td colspan="4" class="doc" id="isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance. 3305 3306Example 3307matcher = objcMessagaeExpr(isInstanceMessage()) 3308matches 3309 NSString *x = @"hello"; 3310 [x containsString:@"h"]; 3311but not 3312 [NSString stringWithFormat:@"format"]; 3313</pre></td></tr> 3314 3315 3316<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> 3317<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains 3318a substring matched by the given RegExp. 3319 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message 3320 invocation for self.bodyView. 3321 [self.bodyView loadHTMLString:html baseURL:NULL]; 3322</pre></td></tr> 3323 3324 3325<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> 3326<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments 3327 3328 matcher = objCMessageExpr(numSelectorArgs(0)); 3329 matches self.bodyView in the code below 3330 3331 matcher = objCMessageExpr(numSelectorArgs(2)); 3332 matches the invocation of "loadHTMLString:baseURL:" but not that 3333 of self.bodyView 3334 [self.bodyView loadHTMLString:html baseURL:NULL]; 3335</pre></td></tr> 3336 3337 3338<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> 3339<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. 3340 3341Example matches A, va, fa 3342 class A {}; 3343 class B; Doesn't match, as it has no body. 3344 int va; 3345 extern int vb; Doesn't match, as it doesn't define the variable. 3346 void fa() {} 3347 void fb(); Doesn't match, as it has no body. 3348 @interface X 3349 - (void)ma; Doesn't match, interface is declaration. 3350 @end 3351 @implementation X 3352 - (void)ma {} 3353 @end 3354 3355Usable 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>>, 3356 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 3357</pre></td></tr> 3358 3359 3360<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> 3361<tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments. 3362 3363Example matches y (matcher = parmVarDecl(hasDefaultArgument())) 3364void x(int val) {} 3365void y(int val = 0) {} 3366</pre></td></tr> 3367 3368 3369<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> 3370<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 3371 3372Given 3373 class Y { public: void x(); }; 3374 void z() { Y* y; y->x(); } 3375cxxMemberCallExpr(on(hasType(asString("class Y *")))) 3376 matches y->x() 3377</pre></td></tr> 3378 3379 3380<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> 3381<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. 3382 3383Matches a node if it equals the node previously bound to ID. 3384 3385Given 3386 class X { int a; int b; }; 3387cxxRecordDecl( 3388 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3389 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3390 matches the class X, as a and b have the same type. 3391 3392Note that when multiple matches are involved via forEach* matchers, 3393equalsBoundNodes acts as a filter. 3394For example: 3395compoundStmt( 3396 forEachDescendant(varDecl().bind("d")), 3397 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3398will trigger a match for each combination of variable declaration 3399and reference to that variable declaration within a compound statement. 3400</pre></td></tr> 3401 3402 3403<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> 3404<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to 3405the node, not hidden within a typedef. 3406 3407Given 3408 typedef const int const_int; 3409 const_int i; 3410 int *const j; 3411 int *volatile k; 3412 int m; 3413varDecl(hasType(hasLocalQualifiers())) matches only j and k. 3414i is const-qualified but the qualifier is not local. 3415</pre></td></tr> 3416 3417 3418<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> 3419<tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type. 3420 3421Given 3422 void a(char); 3423 void b(wchar_t); 3424 void c(double); 3425functionDecl(hasAnyParameter(hasType(isAnyCharacter()))) 3426matches "a(char)", "b(wchar_t)", but not "c(double)". 3427</pre></td></tr> 3428 3429 3430<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> 3431<tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes 3432the Objective-C object pointer type, which is different despite being 3433syntactically similar. 3434 3435Given 3436 int *i = nullptr; 3437 3438 @interface Foo 3439 @end 3440 Foo *f; 3441 3442 int j; 3443varDecl(hasType(isAnyPointer())) 3444 matches "int *i" and "Foo *f", but not "int j". 3445</pre></td></tr> 3446 3447 3448<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> 3449<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 3450include "top-level" const. 3451 3452Given 3453 void a(int); 3454 void b(int const); 3455 void c(const int); 3456 void d(const int*); 3457 void e(int const) {}; 3458functionDecl(hasAnyParameter(hasType(isConstQualified()))) 3459 matches "void b(int const)", "void c(const int)" and 3460 "void e(int const) {}". It does not match d as there 3461 is no top-level const on the parameter type "const int *". 3462</pre></td></tr> 3463 3464 3465<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> 3466<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 3467 3468Given 3469 void a(int); 3470 void b(long); 3471 void c(double); 3472functionDecl(hasAnyParameter(hasType(isInteger()))) 3473matches "a(int)", "b(long)", but not "c(double)". 3474</pre></td></tr> 3475 3476 3477<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> 3478<tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type. 3479 3480Given 3481 void a(int); 3482 void b(unsigned long); 3483 void c(double); 3484functionDecl(hasAnyParameter(hasType(isSignedInteger()))) 3485matches "a(int)", but not "b(unsigned long)" and "c(double)". 3486</pre></td></tr> 3487 3488 3489<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> 3490<tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type. 3491 3492Given 3493 void a(int); 3494 void b(unsigned long); 3495 void c(double); 3496functionDecl(hasAnyParameter(hasType(isUnsignedInteger()))) 3497matches "b(unsigned long)", but not "a(int)" and "c(double)". 3498</pre></td></tr> 3499 3500 3501<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> 3502<tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that 3503include "top-level" volatile. 3504 3505Given 3506 void a(int); 3507 void b(int volatile); 3508 void c(volatile int); 3509 void d(volatile int*); 3510 void e(int volatile) {}; 3511functionDecl(hasAnyParameter(hasType(isVolatileQualified()))) 3512 matches "void b(int volatile)", "void c(volatile int)" and 3513 "void e(int volatile) {}". It does not match d as there 3514 is no top-level volatile on the parameter type "volatile int *". 3515</pre></td></tr> 3516 3517 3518<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> 3519<tr><td colspan="4" class="doc" id="isClass0"><pre>Matches RecordDecl object that are spelled with "class." 3520 3521Example matches C, but not S or U. 3522 struct S {}; 3523 class C {}; 3524 union U {}; 3525</pre></td></tr> 3526 3527 3528<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> 3529<tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches RecordDecl object that are spelled with "struct." 3530 3531Example matches S, but not C or U. 3532 struct S {}; 3533 class C {}; 3534 union U {}; 3535</pre></td></tr> 3536 3537 3538<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> 3539<tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches RecordDecl object that are spelled with "union." 3540 3541Example matches U, but not C or S. 3542 struct S {}; 3543 class C {}; 3544 union U {}; 3545</pre></td></tr> 3546 3547 3548<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> 3549<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. 3550 3551Matches a node if it equals the node previously bound to ID. 3552 3553Given 3554 class X { int a; int b; }; 3555cxxRecordDecl( 3556 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3557 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3558 matches the class X, as a and b have the same type. 3559 3560Note that when multiple matches are involved via forEach* matchers, 3561equalsBoundNodes acts as a filter. 3562For example: 3563compoundStmt( 3564 forEachDescendant(varDecl().bind("d")), 3565 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3566will trigger a match for each combination of variable declaration 3567and reference to that variable declaration within a compound statement. 3568</pre></td></tr> 3569 3570 3571<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> 3572<tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. 3573 3574Stmt has pointer identity in the AST. 3575</pre></td></tr> 3576 3577 3578<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> 3579<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is 3580partially matching a given regex. 3581 3582Example matches Y but not X 3583 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 3584 #include "ASTMatcher.h" 3585 class X {}; 3586ASTMatcher.h: 3587 class Y {}; 3588 3589Usable 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>> 3590</pre></td></tr> 3591 3592 3593<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> 3594<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. 3595 3596Example matches X but not Y 3597 (matcher = cxxRecordDecl(isExpansionInMainFile()) 3598 #include <Y.h> 3599 class X {}; 3600Y.h: 3601 class Y {}; 3602 3603Usable 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>> 3604</pre></td></tr> 3605 3606 3607<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> 3608<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. 3609 3610Example matches Y but not X 3611 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 3612 #include <SystemHeader.h> 3613 class X {}; 3614SystemHeader.h: 3615 class Y {}; 3616 3617Usable 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>> 3618</pre></td></tr> 3619 3620 3621<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> 3622<tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size. 3623 3624Given 3625 int a[42]; 3626 int b[2 * 21]; 3627 int c[41], d[43]; 3628 char *s = "abcd"; 3629 wchar_t *ws = L"abcd"; 3630 char *w = "a"; 3631constantArrayType(hasSize(42)) 3632 matches "int a[42]" and "int b[2 * 21]" 3633stringLiteral(hasSize(4)) 3634 matches "abcd", L"abcd" 3635</pre></td></tr> 3636 3637 3638<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> 3639<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 3640 3641Example matches A, va, fa 3642 class A {}; 3643 class B; Doesn't match, as it has no body. 3644 int va; 3645 extern int vb; Doesn't match, as it doesn't define the variable. 3646 void fa() {} 3647 void fb(); Doesn't match, as it has no body. 3648 @interface X 3649 - (void)ma; Doesn't match, interface is declaration. 3650 @end 3651 @implementation X 3652 - (void)ma {} 3653 @end 3654 3655Usable 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>>, 3656 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 3657</pre></td></tr> 3658 3659 3660<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> 3661<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. 3662 3663Note that 'Value' is a string as the template argument's value is 3664an arbitrary precision integer. 'Value' must be euqal to the canonical 3665representation of that integral value in base 10. 3666 3667Given 3668 template<int T> struct C {}; 3669 C<42> c; 3670classTemplateSpecializationDecl( 3671 hasAnyTemplateArgument(equalsIntegralValue("42"))) 3672 matches the implicit instantiation of C in C<42>. 3673</pre></td></tr> 3674 3675 3676<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> 3677<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. 3678 3679Given 3680 template<int T> struct C {}; 3681 C<42> c; 3682classTemplateSpecializationDecl( 3683 hasAnyTemplateArgument(isIntegral())) 3684 matches the implicit instantiation of C in C<42> 3685 with isIntegral() matching 42. 3686</pre></td></tr> 3687 3688 3689<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> 3690<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. 3691 3692Given 3693 template<typename T> struct C {}; 3694 C<int> c; 3695classTemplateSpecializationDecl(templateArgumentCountIs(1)) 3696 matches C<int>. 3697</pre></td></tr> 3698 3699 3700<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> 3701<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is 3702partially matching a given regex. 3703 3704Example matches Y but not X 3705 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 3706 #include "ASTMatcher.h" 3707 class X {}; 3708ASTMatcher.h: 3709 class Y {}; 3710 3711Usable 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>> 3712</pre></td></tr> 3713 3714 3715<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> 3716<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. 3717 3718Example matches X but not Y 3719 (matcher = cxxRecordDecl(isExpansionInMainFile()) 3720 #include <Y.h> 3721 class X {}; 3722Y.h: 3723 class Y {}; 3724 3725Usable 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>> 3726</pre></td></tr> 3727 3728 3729<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> 3730<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. 3731 3732Example matches Y but not X 3733 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 3734 #include <SystemHeader.h> 3735 class X {}; 3736SystemHeader.h: 3737 class Y {}; 3738 3739Usable 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>> 3740</pre></td></tr> 3741 3742 3743<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> 3744<tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool. 3745 3746Given 3747 struct S { bool func(); }; 3748functionDecl(returns(booleanType())) 3749 matches "bool func();" 3750</pre></td></tr> 3751 3752 3753<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> 3754<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. 3755 3756Matches a node if it equals the node previously bound to ID. 3757 3758Given 3759 class X { int a; int b; }; 3760cxxRecordDecl( 3761 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3762 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3763 matches the class X, as a and b have the same type. 3764 3765Note that when multiple matches are involved via forEach* matchers, 3766equalsBoundNodes acts as a filter. 3767For example: 3768compoundStmt( 3769 forEachDescendant(varDecl().bind("d")), 3770 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3771will trigger a match for each combination of variable declaration 3772and reference to that variable declaration within a compound statement. 3773</pre></td></tr> 3774 3775 3776<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> 3777<tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node. 3778 3779Type has pointer identity in the AST. 3780</pre></td></tr> 3781 3782 3783<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> 3784<tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double). 3785 3786Given 3787 int i; 3788 float f; 3789realFloatingPointType() 3790 matches "float f" but not "int i" 3791</pre></td></tr> 3792 3793 3794<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> 3795<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. 3796 3797Given 3798 struct S { void func(); }; 3799functionDecl(returns(voidType())) 3800 matches "void func();" 3801</pre></td></tr> 3802 3803 3804<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> 3805<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 3806 3807Given 3808 int x; 3809 int s = sizeof(x) + alignof(x) 3810unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 3811 matches sizeof(x) 3812</pre></td></tr> 3813 3814 3815<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> 3816<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 3817unary). 3818 3819Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 3820 !(a || b) 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('hasAutomaticStorageDuration0')"><a name="hasAutomaticStorageDuration0Anchor">hasAutomaticStorageDuration</a></td><td></td></tr> 3825<tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration. 3826 3827Example matches x, but not y, z, or a. 3828(matcher = varDecl(hasAutomaticStorageDuration()) 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('hasGlobalStorage0')"><a name="hasGlobalStorage0Anchor">hasGlobalStorage</a></td><td></td></tr> 3839<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. 3840 3841Example matches y and z (matcher = varDecl(hasGlobalStorage()) 3842void f() { 3843 int x; 3844 static int y; 3845} 3846int z; 3847</pre></td></tr> 3848 3849 3850<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> 3851<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a 3852non-static local variable. 3853 3854Example matches x (matcher = varDecl(hasLocalStorage()) 3855void f() { 3856 int x; 3857 static int y; 3858} 3859int z; 3860</pre></td></tr> 3861 3862 3863<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> 3864<tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration. 3865It includes the variable declared at namespace scope and those declared 3866with "static" and "extern" storage class specifiers. 3867 3868void f() { 3869 int x; 3870 static int y; 3871 thread_local int z; 3872} 3873int a; 3874static int b; 3875extern int c; 3876varDecl(hasStaticStorageDuration()) 3877 matches the function declaration y, a, b and c. 3878</pre></td></tr> 3879 3880 3881<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> 3882<tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration. 3883 3884Example matches z, but not x, z, or a. 3885(matcher = varDecl(hasThreadStorageDuration()) 3886void f() { 3887 int x; 3888 static int y; 3889 thread_local int z; 3890} 3891int a; 3892</pre></td></tr> 3893 3894 3895<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> 3896<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations, 3897 and if constexpr. 3898 3899Given: 3900 constexpr int foo = 42; 3901 constexpr int bar(); 3902 void baz() { if constexpr(1 > 0) {} } 3903varDecl(isConstexpr()) 3904 matches the declaration of foo. 3905functionDecl(isConstexpr()) 3906 matches the declaration of bar. 3907ifStmt(isConstexpr()) 3908 matches the if statement in baz. 3909</pre></td></tr> 3910 3911 3912<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> 3913<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 3914 3915Example matches A, va, fa 3916 class A {}; 3917 class B; Doesn't match, as it has no body. 3918 int va; 3919 extern int vb; Doesn't match, as it doesn't define the variable. 3920 void fa() {} 3921 void fb(); Doesn't match, as it has no body. 3922 @interface X 3923 - (void)ma; Doesn't match, interface is declaration. 3924 @end 3925 @implementation X 3926 - (void)ma {} 3927 @end 3928 3929Usable 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>>, 3930 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 3931</pre></td></tr> 3932 3933 3934<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> 3935<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from 3936a C++ catch block, or an Objective-C statement. 3937 3938Example matches x (matcher = varDecl(isExceptionVariable()) 3939void f(int y) { 3940 try { 3941 } catch (int x) { 3942 } 3943} 3944</pre></td></tr> 3945 3946 3947<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> 3948<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 3949static member variable template instantiations. 3950 3951Given 3952 template<typename T> void A(T t) { } 3953 template<> void A(int N) { } 3954functionDecl(isExplicitTemplateSpecialization()) 3955 matches the specialization A<int>(). 3956 3957Usable 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>> 3958</pre></td></tr> 3959 3960 3961<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> 3962<tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations. 3963 3964Given: 3965 extern "C" void f() {} 3966 extern "C" { void g() {} } 3967 void h() {} 3968 extern "C" int x = 1; 3969 extern "C" int y = 2; 3970 int z = 3; 3971functionDecl(isExternC()) 3972 matches the declaration of f and g, but not the declaration of h. 3973varDecl(isExternC()) 3974 matches the declaration of x and y, but not the declaration of z. 3975</pre></td></tr> 3976 3977 3978<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> 3979<tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variablefunction declarations that have "static" storage 3980class specifier ("static" keyword) written in the source. 3981 3982Given: 3983 static void f() {} 3984 static int i = 0; 3985 extern int j; 3986 int k; 3987functionDecl(isStaticStorageClass()) 3988 matches the function declaration f. 3989varDecl(isStaticStorageClass()) 3990 matches the variable declaration i. 3991</pre></td></tr> 3992 3993 3994<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> 3995<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 3996member variable template instantiations. 3997 3998Given 3999 template <typename T> class X {}; class A {}; X<A> x; 4000or 4001 template <typename T> class X {}; class A {}; template class X<A>; 4002or 4003 template <typename T> class X {}; class A {}; extern template class X<A>; 4004cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 4005 matches the template instantiation of X<A>. 4006 4007But given 4008 template <typename T> class X {}; class A {}; 4009 template <> class X<A> {}; X<A> x; 4010cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 4011 does not match, as X<A> is an explicit template specialization. 4012 4013Usable 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>> 4014</pre></td></tr> 4015 4016 4017<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> 4018<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside 4019template instantiations. 4020 4021Given 4022 template<typename T> void A(T t) { T i; } 4023 A(0); 4024 A(0U); 4025functionDecl(isInstantiated()) 4026 matches 'A(int) {...};' and 'A(unsigned) {...}'. 4027</pre></td></tr> 4028 4029 4030<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> 4031<tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as 4032GNU's __null, C++11's nullptr, or C's NULL macro. 4033 4034Given: 4035 void *v1 = NULL; 4036 void *v2 = nullptr; 4037 void *v3 = __null; GNU extension 4038 char *cp = (char *)0; 4039 int *ip = 0; 4040 int i = 0; 4041expr(nullPointerConstant()) 4042 matches the initializer for v1, v2, v3, cp, and ip. Does not match the 4043 initializer for i. 4044</pre></td></tr> 4045 4046 4047<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> 4048<tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names. 4049 4050This matcher is only provided as a performance optimization of hasName. 4051 hasAnyName(a, b, c) 4052 is equivalent to, but faster than 4053 anyOf(hasName(a), hasName(b), hasName(c)) 4054</pre></td></tr> 4055 4056 4057<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> 4058<tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the 4059Selector.getAsString() 4060 4061 matcher = objCMessageExpr(hasSelector("methodA:", "methodB:")); 4062 matches both of the expressions below: 4063 [myObj methodA:argA]; 4064 [myObj methodB:argB]; 4065</pre></td></tr> 4066 4067 4068<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> 4069<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. 4070 4071Given 4072 int j; 4073 template<typename T> void A(T t) { T i; j += 42;} 4074 A(0); 4075 A(0U); 4076declStmt(isInTemplateInstantiation()) 4077 matches 'int i;' and 'unsigned i'. 4078unless(stmt(isInTemplateInstantiation())) 4079 will NOT match j += 42; as it's shared between the template definition and 4080 instantiation. 4081</pre></td></tr> 4082 4083<!--END_NARROWING_MATCHERS --> 4084</table> 4085 4086<!-- ======================================================================= --> 4087<h2 id="traversal-matchers">AST Traversal Matchers</h2> 4088<!-- ======================================================================= --> 4089 4090<p>Traversal matchers specify the relationship to other nodes that are 4091reachable from the current node.</p> 4092 4093<p>Note that there are special traversal matchers (has, hasDescendant, forEach and 4094forEachDescendant) which work on all nodes and allow users to write more generic 4095match expressions.</p> 4096 4097<table> 4098<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 4099<!-- START_TRAVERSAL_MATCHERS --> 4100 4101<tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 4102<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. 4103 4104Unlike anyOf, eachOf will generate a match result for each 4105matching submatcher. 4106 4107For example, in: 4108 class A { int a; int b; }; 4109The matcher: 4110 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), 4111 has(fieldDecl(hasName("b")).bind("v")))) 4112will generate two results binding "v", the first of which binds 4113the field declaration of a, the second the field declaration of 4114b. 4115 4116Usable as: Any Matcher 4117</pre></td></tr> 4118 4119 4120<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> 4121<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 4122provided matcher. 4123 4124Example matches X, A, A::X, B, B::C, B::C::X 4125 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) 4126 class X {}; 4127 class A { class X {}; }; Matches A, because A::X is a class of name 4128 X inside A. 4129 class B { class C { class X {}; }; }; 4130 4131DescendantT must be an AST base type. 4132 4133As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 4134each result that matches instead of only on the first one. 4135 4136Note: Recursively combined ForEachDescendant can cause many matches: 4137 cxxRecordDecl(forEachDescendant(cxxRecordDecl( 4138 forEachDescendant(cxxRecordDecl()) 4139 ))) 4140will match 10 times (plus injected class name matches) on: 4141 class A { class B { class C { class D { class E {}; }; }; }; }; 4142 4143Usable as: Any Matcher 4144</pre></td></tr> 4145 4146 4147<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> 4148<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 4149provided matcher. 4150 4151Example matches X, Y, Y::X, Z::Y, Z::Y::X 4152 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) 4153 class X {}; 4154 class Y { class X {}; }; Matches Y, because Y::X is a class of name X 4155 inside Y. 4156 class Z { class Y { class X {}; }; }; Does not match Z. 4157 4158ChildT must be an AST base type. 4159 4160As opposed to 'has', 'forEach' will cause a match for each result that 4161matches instead of only on the first one. 4162 4163Usable as: Any Matcher 4164</pre></td></tr> 4165 4166 4167<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> 4168<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 4169matcher. 4170 4171Given 4172void f() { if (true) { int x = 42; } } 4173void g() { for (;;) { int x = 43; } } 4174expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 4175 4176Usable as: Any Matcher 4177</pre></td></tr> 4178 4179 4180<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> 4181<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 4182provided matcher. 4183 4184Example matches X, Y, Z 4185 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) 4186 class X {}; Matches X, because X::X is a class of name X inside X. 4187 class Y { class X {}; }; 4188 class Z { class Y { class X {}; }; }; 4189 4190DescendantT must be an AST base type. 4191 4192Usable as: Any Matcher 4193</pre></td></tr> 4194 4195 4196<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> 4197<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 4198provided matcher. 4199 4200Example matches X, Y 4201 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) 4202 class X {}; Matches X, because X::X is a class of name X inside X. 4203 class Y { class X {}; }; 4204 class Z { class Y { class X {}; }; }; Does not match Z. 4205 4206ChildT must be an AST base type. 4207 4208Usable as: Any Matcher 4209Note that has is direct matcher, so it also matches things like implicit 4210casts and paren casts. If you are matching with expr then you should 4211probably consider using ignoringParenImpCasts like: 4212has(ignoringParenImpCasts(expr())). 4213</pre></td></tr> 4214 4215 4216<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> 4217<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 4218matcher. 4219 4220Given 4221void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 4222compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 4223 4224Usable as: Any Matcher 4225</pre></td></tr> 4226 4227 4228<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> 4229<tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop, 4230switch statement or conditional operator. 4231 4232Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 4233 if (true) {} 4234</pre></td></tr> 4235 4236 4237<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> 4238<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator 4239(binary or ternary). 4240 4241Example matches b 4242 condition ? a : b 4243 condition ?: b 4244</pre></td></tr> 4245 4246 4247<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> 4248<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 4249 4250Example 1 (conditional ternary operator): matches a 4251 condition ? a : b 4252 4253Example 2 (conditional binary operator): matches opaqueValueExpr(condition) 4254 condition ?: b 4255</pre></td></tr> 4256 4257 4258<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> 4259<tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node 4260matches the given matcher. 4261 4262The associated declaration is: 4263- for type nodes, the declaration of the underlying type 4264- for CallExpr, the declaration of the callee 4265- for MemberExpr, the declaration of the referenced member 4266- for CXXConstructExpr, the declaration of the constructor 4267- for CXXNewExpr, the declaration of the operator new 4268- for ObjCIvarExpr, the declaration of the ivar 4269 4270For type nodes, hasDeclaration will generally match the declaration of the 4271sugared type. Given 4272 class X {}; 4273 typedef X Y; 4274 Y y; 4275in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4276typedefDecl. A common use case is to match the underlying, desugared type. 4277This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4278 varDecl(hasType(hasUnqualifiedDesugaredType( 4279 recordType(hasDeclaration(decl()))))) 4280In this matcher, the decl will match the CXXRecordDecl of class X. 4281 4282Usable 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>>, 4283 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>>, 4284 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>>, 4285 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>>, 4286 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>>, 4287 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>>, 4288 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4289</pre></td></tr> 4290 4291 4292<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> 4293<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 4294 4295Given 4296 int i[5]; 4297 void f() { i[1] = 42; } 4298arraySubscriptExpression(hasBase(implicitCastExpr( 4299 hasSourceExpression(declRefExpr())))) 4300 matches i[1] with the declRefExpr() matching i 4301</pre></td></tr> 4302 4303 4304<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> 4305<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 4306 4307Given 4308 int i[5]; 4309 void f() { i[1] = 42; } 4310arraySubscriptExpression(hasIndex(integerLiteral())) 4311 matches i[1] with the integerLiteral() matching 1 4312</pre></td></tr> 4313 4314 4315<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> 4316<tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions. 4317 4318Example matches a (matcher = binaryOperator(hasLHS())) 4319 a || b 4320</pre></td></tr> 4321 4322 4323<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> 4324<tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions. 4325 4326Example matches b (matcher = binaryOperator(hasRHS())) 4327 a || b 4328</pre></td></tr> 4329 4330 4331<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> 4332<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element 4333type. 4334 4335Given 4336 struct A {}; 4337 A a[7]; 4338 int b[7]; 4339arrayType(hasElementType(builtinType())) 4340 matches "int b[7]" 4341 4342Usable 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>> 4343</pre></td></tr> 4344 4345 4346<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> 4347<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element 4348type. 4349 4350Given 4351 struct A {}; 4352 A a[7]; 4353 int b[7]; 4354arrayType(hasElementType(builtinType())) 4355 matches "int b[7]" 4356 4357Usable 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>> 4358</pre></td></tr> 4359 4360 4361<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> 4362<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. 4363 4364Given 4365 _Atomic(int) i; 4366 _Atomic(float) f; 4367atomicType(hasValueType(isInteger())) 4368 matches "_Atomic(int) i" 4369 4370Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 4371</pre></td></tr> 4372 4373 4374<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> 4375<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. 4376 4377Given 4378 _Atomic(int) i; 4379 _Atomic(float) f; 4380atomicType(hasValueType(isInteger())) 4381 matches "_Atomic(int) i" 4382 4383Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 4384</pre></td></tr> 4385 4386 4387<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> 4388<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. 4389 4390Note: There is no TypeLoc for the deduced type and thus no 4391getDeducedLoc() matcher. 4392 4393Given 4394 auto a = 1; 4395 auto b = 2.0; 4396autoType(hasDeducedType(isInteger())) 4397 matches "auto a" 4398 4399Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> 4400</pre></td></tr> 4401 4402 4403<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> 4404<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 4405binary operator matches. 4406</pre></td></tr> 4407 4408 4409<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> 4410<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 4411 4412Example matches a (matcher = binaryOperator(hasLHS())) 4413 a || b 4414</pre></td></tr> 4415 4416 4417<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> 4418<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 4419 4420Example matches b (matcher = binaryOperator(hasRHS())) 4421 a || b 4422</pre></td></tr> 4423 4424 4425<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> 4426<tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a 4427block. 4428 4429Does not match the 'this' parameter of a method. 4430 4431Given 4432 class X { void f(int x, int y, int z) {} }; 4433cxxMethodDecl(hasAnyParameter(hasName("y"))) 4434 matches f(int x, int y, int z) {} 4435with hasAnyParameter(...) 4436 matching int y 4437 4438For ObjectiveC, given 4439 @interface I - (void) f:(int) y; @end 4440 4441the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 4442matches the declaration of method f with hasParameter 4443matching y. 4444 4445For blocks, given 4446 b = ^(int y) { printf("%d", y) }; 4447 4448the matcher blockDecl(hasAnyParameter(hasName("y"))) 4449matches the declaration of the block b with hasParameter 4450matching y. 4451</pre></td></tr> 4452 4453 4454<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> 4455<tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method 4456declaration or a block. 4457 4458Given 4459 class X { void f(int x) {} }; 4460cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 4461 matches f(int x) {} 4462with hasParameter(...) 4463 matching int x 4464 4465For ObjectiveC, given 4466 @interface I - (void) f:(int) y; @end 4467 4468the matcher objcMethodDecl(hasParameter(0, hasName("y"))) 4469matches the declaration of method f with hasParameter 4470matching y. 4471</pre></td></tr> 4472 4473 4474<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> 4475<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the 4476pointee matches a given matcher. 4477 4478Given 4479 int *a; 4480 int const *b; 4481 float const *f; 4482pointerType(pointee(isConstQualified(), isInteger())) 4483 matches "int const *b" 4484 4485Usable 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>>, 4486 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>> 4487</pre></td></tr> 4488 4489 4490<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> 4491<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the 4492pointee matches a given matcher. 4493 4494Given 4495 int *a; 4496 int const *b; 4497 float const *f; 4498pointerType(pointee(isConstQualified(), isInteger())) 4499 matches "int const *b" 4500 4501Usable 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>>, 4502 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>> 4503</pre></td></tr> 4504 4505 4506<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> 4507<tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl. 4508 4509Given 4510 void f(int i); 4511 int y; 4512 f(y); 4513callExpr( 4514 forEachArgumentWithParam( 4515 declRefExpr(to(varDecl(hasName("y")))), 4516 parmVarDecl(hasType(isInteger())) 4517)) 4518 matches f(y); 4519with declRefExpr(...) 4520 matching int y 4521and parmVarDecl(...) 4522 matching int i 4523</pre></td></tr> 4524 4525 4526<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> 4527<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call 4528expression, or an ObjC-message-send expression. 4529 4530Given 4531 void x(int, int, int) { int y; x(1, y, 42); } 4532callExpr(hasAnyArgument(declRefExpr())) 4533 matches x(1, y, 42) 4534with hasAnyArgument(...) 4535 matching y 4536 4537For ObjectiveC, given 4538 @interface I - (void) f:(int) y; @end 4539 void foo(I *i) { [i f:12]; } 4540objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 4541 matches [i f:12] 4542</pre></td></tr> 4543 4544 4545<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> 4546<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor 4547call expression. 4548 4549Example matches y in x(y) 4550 (matcher = callExpr(hasArgument(0, declRefExpr()))) 4551 void x(int) { int y; x(y); } 4552</pre></td></tr> 4553 4554 4555<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> 4556<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node 4557matches the given matcher. 4558 4559The associated declaration is: 4560- for type nodes, the declaration of the underlying type 4561- for CallExpr, the declaration of the callee 4562- for MemberExpr, the declaration of the referenced member 4563- for CXXConstructExpr, the declaration of the constructor 4564- for CXXNewExpr, the declaration of the operator new 4565- for ObjCIvarExpr, the declaration of the ivar 4566 4567For type nodes, hasDeclaration will generally match the declaration of the 4568sugared type. Given 4569 class X {}; 4570 typedef X Y; 4571 Y y; 4572in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4573typedefDecl. A common use case is to match the underlying, desugared type. 4574This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4575 varDecl(hasType(hasUnqualifiedDesugaredType( 4576 recordType(hasDeclaration(decl()))))) 4577In this matcher, the decl will match the CXXRecordDecl of class X. 4578 4579Usable 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>>, 4580 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>>, 4581 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>>, 4582 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>>, 4583 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>>, 4584 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>>, 4585 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4586</pre></td></tr> 4587 4588 4589<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> 4590<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. 4591 4592Given 4593 class A { A() : i(42), j(42) {} int i; int j; }; 4594cxxConstructorDecl(forEachConstructorInitializer( 4595 forField(decl().bind("x")) 4596)) 4597 will trigger two matches, binding for 'i' and 'j' respectively. 4598</pre></td></tr> 4599 4600 4601<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> 4602<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 4603 4604Given 4605 struct Foo { 4606 Foo() : foo_(1) { } 4607 int foo_; 4608 }; 4609cxxRecordDecl(has(cxxConstructorDecl( 4610 hasAnyConstructorInitializer(anything()) 4611))) 4612 record matches Foo, hasAnyConstructorInitializer matches foo_(1) 4613</pre></td></tr> 4614 4615 4616<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> 4617<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 4618 4619Given 4620 struct Foo { 4621 Foo() : foo_(1) { } 4622 int foo_; 4623 }; 4624cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 4625 forField(hasName("foo_")))))) 4626 matches Foo 4627with forField matching foo_ 4628</pre></td></tr> 4629 4630 4631<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> 4632<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 4633 4634Given 4635 struct Foo { 4636 Foo() : foo_(1) { } 4637 int foo_; 4638 }; 4639cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 4640 withInitializer(integerLiteral(equals(1))))))) 4641 matches Foo 4642with withInitializer matching (1) 4643</pre></td></tr> 4644 4645 4646<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> 4647<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'do while' statement or a function 4648definition that has a given body. 4649 4650Given 4651 for (;;) {} 4652hasBody(compoundStmt()) 4653 matches 'for (;;) {}' 4654with compoundStmt() 4655 matching '{}' 4656</pre></td></tr> 4657 4658 4659<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> 4660<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. 4661 4662Example: 4663 forStmt(hasLoopVariable(anything())) 4664matches 'int x' in 4665 for (int x : a) { } 4666</pre></td></tr> 4667 4668 4669<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> 4670<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. 4671 4672Example: 4673 forStmt(hasRangeInit(anything())) 4674matches 'a' in 4675 for (int x : a) { } 4676</pre></td></tr> 4677 4678 4679<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> 4680<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> 4681 4682 4683<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> 4684<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. 4685 4686Example matches y.x() 4687 (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))) 4688 class Y { public: void x(); }; 4689 void z() { Y y; y.x(); } 4690 4691FIXME: Overload to allow directly matching types? 4692</pre></td></tr> 4693 4694 4695<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> 4696<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 4697</pre></td></tr> 4698 4699 4700<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> 4701<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified 4702matcher, or is a pointer to a type that matches the InnerMatcher. 4703</pre></td></tr> 4704 4705 4706<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> 4707<tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may 4708produce multiple matches. 4709 4710Given 4711 class A { virtual void f(); }; 4712 class B : public A { void f(); }; 4713 class C : public B { void f(); }; 4714cxxMethodDecl(ofClass(hasName("C")), 4715 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") 4716 matches once, with "b" binding "A::f" and "d" binding "C::f" (Note 4717 that B::f is not overridden by C::f). 4718 4719The check can produce multiple matches in case of multiple inheritance, e.g. 4720 class A1 { virtual void f(); }; 4721 class A2 { virtual void f(); }; 4722 class C : public A1, public A2 { void f(); }; 4723cxxMethodDecl(ofClass(hasName("C")), 4724 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") 4725 matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and 4726 once with "b" binding "A2::f" and "d" binding "C::f". 4727</pre></td></tr> 4728 4729 4730<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> 4731<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 4732belongs to. 4733 4734FIXME: Generalize this for other kinds of declarations. 4735FIXME: What other kind of declarations would we need to generalize 4736this to? 4737 4738Example matches A() in the last line 4739 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( 4740 ofClass(hasName("A")))))) 4741 class A { 4742 public: 4743 A(); 4744 }; 4745 A a = A(); 4746</pre></td></tr> 4747 4748 4749<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> 4750<tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size. 4751 4752Given: 4753 MyClass *p1 = new MyClass[10]; 4754cxxNewExpr(hasArraySize(intgerLiteral(equals(10)))) 4755 matches the expression 'new MyClass[10]'. 4756</pre></td></tr> 4757 4758 4759<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> 4760<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node 4761matches the given matcher. 4762 4763The associated declaration is: 4764- for type nodes, the declaration of the underlying type 4765- for CallExpr, the declaration of the callee 4766- for MemberExpr, the declaration of the referenced member 4767- for CXXConstructExpr, the declaration of the constructor 4768- for CXXNewExpr, the declaration of the operator new 4769- for ObjCIvarExpr, the declaration of the ivar 4770 4771For type nodes, hasDeclaration will generally match the declaration of the 4772sugared type. Given 4773 class X {}; 4774 typedef X Y; 4775 Y y; 4776in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4777typedefDecl. A common use case is to match the underlying, desugared type. 4778This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4779 varDecl(hasType(hasUnqualifiedDesugaredType( 4780 recordType(hasDeclaration(decl()))))) 4781In this matcher, the decl will match the CXXRecordDecl of class X. 4782 4783Usable 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>>, 4784 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>>, 4785 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>>, 4786 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>>, 4787 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>>, 4788 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>>, 4789 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4790</pre></td></tr> 4791 4792 4793<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> 4794<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. 4795 4796Given: 4797 class A { void func(); }; 4798 class B { void member(); }; 4799 4800cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of 4801A but not B. 4802</pre></td></tr> 4803 4804 4805<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> 4806<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from 4807a class matching Base. 4808 4809Note that a class is not considered to be derived from itself. 4810 4811Example matches Y, Z, C (Base == hasName("X")) 4812 class X; 4813 class Y : public X {}; directly derived 4814 class Z : public Y {}; indirectly derived 4815 typedef X A; 4816 typedef A B; 4817 class C : public B {}; derived from a typedef of X 4818 4819In the following example, Bar matches isDerivedFrom(hasName("X")): 4820 class Foo; 4821 typedef Foo X; 4822 class Bar : public Foo {}; derived from a type that X is a typedef of 4823</pre></td></tr> 4824 4825 4826<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> 4827<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 4828match Base. 4829</pre></td></tr> 4830 4831 4832<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> 4833<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the 4834given matcher. 4835 4836Example matches y.x() (matcher = callExpr(callee( 4837 cxxMethodDecl(hasName("x"))))) 4838 class Y { public: void x(); }; 4839 void z() { Y y; y.x(); } 4840</pre></td></tr> 4841 4842 4843<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> 4844<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. 4845 4846Given 4847 class Y { void x() { this->x(); x(); Y y; y.x(); } }; 4848 void f() { f(); } 4849callExpr(callee(expr())) 4850 matches this->x(), x(), y.x(), f() 4851with callee(...) 4852 matching this->x, x, y.x, f respectively 4853 4854Note: Callee cannot take the more general internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> 4855because this introduces ambiguous overloads with calls to Callee taking a 4856internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely 4857implemented in terms of implicit casts. 4858</pre></td></tr> 4859 4860 4861<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> 4862<tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl. 4863 4864Given 4865 void f(int i); 4866 int y; 4867 f(y); 4868callExpr( 4869 forEachArgumentWithParam( 4870 declRefExpr(to(varDecl(hasName("y")))), 4871 parmVarDecl(hasType(isInteger())) 4872)) 4873 matches f(y); 4874with declRefExpr(...) 4875 matching int y 4876and parmVarDecl(...) 4877 matching int i 4878</pre></td></tr> 4879 4880 4881<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> 4882<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 4883expression, or an ObjC-message-send expression. 4884 4885Given 4886 void x(int, int, int) { int y; x(1, y, 42); } 4887callExpr(hasAnyArgument(declRefExpr())) 4888 matches x(1, y, 42) 4889with hasAnyArgument(...) 4890 matching y 4891 4892For ObjectiveC, given 4893 @interface I - (void) f:(int) y; @end 4894 void foo(I *i) { [i f:12]; } 4895objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 4896 matches [i f:12] 4897</pre></td></tr> 4898 4899 4900<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> 4901<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 4902call expression. 4903 4904Example matches y in x(y) 4905 (matcher = callExpr(hasArgument(0, declRefExpr()))) 4906 void x(int) { int y; x(y); } 4907</pre></td></tr> 4908 4909 4910<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> 4911<tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node 4912matches the given matcher. 4913 4914The associated declaration is: 4915- for type nodes, the declaration of the underlying type 4916- for CallExpr, the declaration of the callee 4917- for MemberExpr, the declaration of the referenced member 4918- for CXXConstructExpr, the declaration of the constructor 4919- for CXXNewExpr, the declaration of the operator new 4920- for ObjCIvarExpr, the declaration of the ivar 4921 4922For type nodes, hasDeclaration will generally match the declaration of the 4923sugared type. Given 4924 class X {}; 4925 typedef X Y; 4926 Y y; 4927in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4928typedefDecl. A common use case is to match the underlying, desugared type. 4929This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4930 varDecl(hasType(hasUnqualifiedDesugaredType( 4931 recordType(hasDeclaration(decl()))))) 4932In this matcher, the decl will match the CXXRecordDecl of class X. 4933 4934Usable 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>>, 4935 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>>, 4936 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>>, 4937 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>>, 4938 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>>, 4939 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>>, 4940 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4941</pre></td></tr> 4942 4943 4944<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> 4945<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range 4946extension, matches the constant given in the statement. 4947 4948Given 4949 switch (1) { case 1: case 1+1: case 3 ... 4: ; } 4950caseStmt(hasCaseConstant(integerLiteral())) 4951 matches "case 1:" 4952</pre></td></tr> 4953 4954 4955<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> 4956<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression 4957or opaque value's source expression matches the given matcher. 4958 4959Example 1: matches "a string" 4960(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) 4961class URL { URL(string); }; 4962URL url = "a string"; 4963 4964Example 2: matches 'b' (matcher = 4965opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) 4966int a = b ?: 1; 4967</pre></td></tr> 4968 4969 4970<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> 4971<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and 4972functionDecl that have at least one TemplateArgument matching the given 4973InnerMatcher. 4974 4975Given 4976 template<typename T> class A {}; 4977 template<> class A<double> {}; 4978 A<int> a; 4979 4980 template<typename T> f() {}; 4981 void func() { f<int>(); }; 4982 4983classTemplateSpecializationDecl(hasAnyTemplateArgument( 4984 refersToType(asString("int")))) 4985 matches the specialization A<int> 4986 4987functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 4988 matches the specialization f<int> 4989</pre></td></tr> 4990 4991 4992<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> 4993<tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration. 4994 4995Given 4996 tempalate<typename T> class A {}; 4997 typedef A<int> B; 4998classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl())) 4999 matches 'B' with classTemplateDecl() matching the class template 5000 declaration of 'A'. 5001</pre></td></tr> 5002 5003 5004<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> 5005<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and 5006functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 5007 5008Given 5009 template<typename T, typename U> class A {}; 5010 A<bool, int> b; 5011 A<int, bool> c; 5012 5013 template<typename T> void f() {} 5014 void func() { f<int>(); }; 5015classTemplateSpecializationDecl(hasTemplateArgument( 5016 1, refersToType(asString("int")))) 5017 matches the specialization A<bool, int> 5018 5019functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 5020 matches the specialization f<int> 5021</pre></td></tr> 5022 5023 5024<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> 5025<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element 5026type. 5027 5028Given 5029 struct A {}; 5030 A a[7]; 5031 int b[7]; 5032arrayType(hasElementType(builtinType())) 5033 matches "int b[7]" 5034 5035Usable 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>> 5036</pre></td></tr> 5037 5038 5039<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> 5040<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element 5041type. 5042 5043Given 5044 struct A {}; 5045 A a[7]; 5046 int b[7]; 5047arrayType(hasElementType(builtinType())) 5048 matches "int b[7]" 5049 5050Usable 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>> 5051</pre></td></tr> 5052 5053 5054<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> 5055<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 5056a given matcher. Also matches StmtExprs that have CompoundStmt as children. 5057 5058Given 5059 { {}; 1+2; } 5060hasAnySubstatement(compoundStmt()) 5061 matches '{ {}; 1+2; }' 5062with compoundStmt() 5063 matching '{}' 5064</pre></td></tr> 5065 5066 5067<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> 5068<tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whos decayed type matches InnerMatcher 5069</pre></td></tr> 5070 5071 5072<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> 5073<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node 5074matches the given matcher. 5075 5076The associated declaration is: 5077- for type nodes, the declaration of the underlying type 5078- for CallExpr, the declaration of the callee 5079- for MemberExpr, the declaration of the referenced member 5080- for CXXConstructExpr, the declaration of the constructor 5081- for CXXNewExpr, the declaration of the operator new 5082- for ObjCIvarExpr, the declaration of the ivar 5083 5084For type nodes, hasDeclaration will generally match the declaration of the 5085sugared type. Given 5086 class X {}; 5087 typedef X Y; 5088 Y y; 5089in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5090typedefDecl. A common use case is to match the underlying, desugared type. 5091This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5092 varDecl(hasType(hasUnqualifiedDesugaredType( 5093 recordType(hasDeclaration(decl()))))) 5094In this matcher, the decl will match the CXXRecordDecl of class X. 5095 5096Usable 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>>, 5097 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>>, 5098 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>>, 5099 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>>, 5100 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>>, 5101 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>>, 5102 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5103</pre></td></tr> 5104 5105 5106<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> 5107<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a 5108specific using shadow declaration. 5109 5110Given 5111 namespace a { void f() {} } 5112 using a::f; 5113 void g() { 5114 f(); Matches this .. 5115 a::f(); .. but not this. 5116 } 5117declRefExpr(throughUsingDecl(anything())) 5118 matches f() 5119</pre></td></tr> 5120 5121 5122<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> 5123<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 5124specified matcher. 5125 5126Example matches x in if(x) 5127 (matcher = declRefExpr(to(varDecl(hasName("x"))))) 5128 bool x; 5129 if (x) {} 5130</pre></td></tr> 5131 5132 5133<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> 5134<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 5135 5136Note that this does not work for global declarations because the AST 5137breaks up multiple-declaration DeclStmt's into multiple single-declaration 5138DeclStmt's. 5139Example: Given non-global declarations 5140 int a, b = 0; 5141 int c; 5142 int d = 2, e; 5143declStmt(containsDeclaration( 5144 0, varDecl(hasInitializer(anything())))) 5145 matches only 'int d = 2, e;', and 5146declStmt(containsDeclaration(1, varDecl())) 5147 matches 'int a, b = 0' as well as 'int d = 2, e;' 5148 but 'int c;' is not matched. 5149</pre></td></tr> 5150 5151 5152<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> 5153<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 5154 5155Given 5156 int a, b; 5157 int c; 5158declStmt(hasSingleDecl(anything())) 5159 matches 'int c;' but not 'int a, b;'. 5160</pre></td></tr> 5161 5162 5163<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> 5164<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches 5165the inner matcher. 5166 5167Given 5168 int x; 5169declaratorDecl(hasTypeLoc(loc(asString("int")))) 5170 matches int x 5171</pre></td></tr> 5172 5173 5174<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> 5175<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a 5176Decl, matches InnerMatcher. 5177 5178Given 5179 namespace N { 5180 namespace M { 5181 class D {}; 5182 } 5183 } 5184 5185cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the 5186declaration of class D. 5187</pre></td></tr> 5188 5189 5190<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>></td><td class="name" onclick="toggle('hasUnderlyingType0')"><a name="hasUnderlyingType0Anchor">hasUnderlyingType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 5191<tr><td colspan="4" class="doc" id="hasUnderlyingType0"><pre>Matches DecltypeType nodes to find out the underlying type. 5192 5193Given 5194 decltype(1) a = 1; 5195 decltype(2.0) b = 2.0; 5196decltypeType(hasUnderlyingType(isInteger())) 5197 matches "auto a" 5198 5199Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>> 5200</pre></td></tr> 5201 5202 5203<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> 5204<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'do while' statement or a function 5205definition that has a given body. 5206 5207Given 5208 for (;;) {} 5209hasBody(compoundStmt()) 5210 matches 'for (;;) {}' 5211with compoundStmt() 5212 matching '{}' 5213</pre></td></tr> 5214 5215 5216<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> 5217<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 5218switch statement or conditional operator. 5219 5220Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5221 if (true) {} 5222</pre></td></tr> 5223 5224 5225<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> 5226<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, 5227matches InnerMatcher if the qualifier exists. 5228 5229Given 5230 namespace N { 5231 namespace M { 5232 class D {}; 5233 } 5234 } 5235 N::M::D d; 5236 5237elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) 5238matches the type of the variable declaration of d. 5239</pre></td></tr> 5240 5241 5242<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> 5243<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. 5244 5245Given 5246 namespace N { 5247 namespace M { 5248 class D {}; 5249 } 5250 } 5251 N::M::D d; 5252 5253elaboratedType(namesType(recordType( 5254hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable 5255declaration of d. 5256</pre></td></tr> 5257 5258 5259<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> 5260<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node 5261matches the given matcher. 5262 5263The associated declaration is: 5264- for type nodes, the declaration of the underlying type 5265- for CallExpr, the declaration of the callee 5266- for MemberExpr, the declaration of the referenced member 5267- for CXXConstructExpr, the declaration of the constructor 5268- for CXXNewExpr, the declaration of the operator new 5269- for ObjCIvarExpr, the declaration of the ivar 5270 5271For type nodes, hasDeclaration will generally match the declaration of the 5272sugared type. Given 5273 class X {}; 5274 typedef X Y; 5275 Y y; 5276in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5277typedefDecl. A common use case is to match the underlying, desugared type. 5278This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5279 varDecl(hasType(hasUnqualifiedDesugaredType( 5280 recordType(hasDeclaration(decl()))))) 5281In this matcher, the decl will match the CXXRecordDecl of class X. 5282 5283Usable 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>>, 5284 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>>, 5285 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>>, 5286 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>>, 5287 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>>, 5288 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>>, 5289 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5290</pre></td></tr> 5291 5292 5293<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> 5294<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 5295 5296(Note: Clang's AST refers to other conversions as "casts" too, and calls 5297actual casts "explicit" casts.) 5298</pre></td></tr> 5299 5300 5301<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> 5302<tr><td colspan="4" class="doc" id="hasType4"><pre>Overloaded to match the declaration of the expression's or value 5303declaration's type. 5304 5305In case of a value declaration (for example a variable declaration), 5306this resolves one layer of indirection. For example, in the value 5307declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 5308X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 5309declaration of x. 5310 5311Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 5312 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 5313 and friend class X (matcher = friendDecl(hasType("X")) 5314 class X {}; 5315 void y(X &x) { x; X z; } 5316 class Y { friend class X; }; 5317 5318Usable 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>> 5319</pre></td></tr> 5320 5321 5322<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> 5323<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type 5324matcher. 5325 5326Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 5327 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 5328 and U (matcher = typedefDecl(hasType(asString("int"))) 5329 and friend class X (matcher = friendDecl(hasType("X")) 5330 class X {}; 5331 void y(X &x) { x; X z; } 5332 typedef int U; 5333 class Y { friend class X; }; 5334</pre></td></tr> 5335 5336 5337<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> 5338<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 5339are stripped off. 5340 5341Parentheses and explicit casts are not discarded. 5342Given 5343 int arr[5]; 5344 int a = 0; 5345 char b = 0; 5346 const int c = a; 5347 int *d = arr; 5348 long e = (long) 0l; 5349The matchers 5350 varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 5351 varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 5352would match the declarations for a, b, c, and d, but not e. 5353While 5354 varDecl(hasInitializer(integerLiteral())) 5355 varDecl(hasInitializer(declRefExpr())) 5356only match the declarations for b, c, and d. 5357</pre></td></tr> 5358 5359 5360<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> 5361<tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST 5362nodes are stripped off. 5363 5364Parentheses and explicit casts are not discarded. 5365Given 5366 class C {}; 5367 C a = C(); 5368 C b; 5369 C c = b; 5370The matchers 5371 varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr()))) 5372would match the declarations for a, b, and c. 5373While 5374 varDecl(hasInitializer(cxxConstructExpr())) 5375only match the declarations for b and c. 5376</pre></td></tr> 5377 5378 5379<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> 5380<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 5381casts are stripped off. 5382 5383Implicit and non-C Style casts are also discarded. 5384Given 5385 int a = 0; 5386 char b = (0); 5387 void* c = reinterpret_cast<char*>(0); 5388 char d = char(0); 5389The matcher 5390 varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 5391would match the declarations for a, b, c, and d. 5392while 5393 varDecl(hasInitializer(integerLiteral())) 5394only match the declaration for a. 5395</pre></td></tr> 5396 5397 5398<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> 5399<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 5400parentheses are stripped off. 5401 5402Explicit casts are not discarded. 5403Given 5404 int arr[5]; 5405 int a = 0; 5406 char b = (0); 5407 const int c = a; 5408 int *d = (arr); 5409 long e = ((long) 0l); 5410The matchers 5411 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 5412 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 5413would match the declarations for a, b, c, and d, but not e. 5414while 5415 varDecl(hasInitializer(integerLiteral())) 5416 varDecl(hasInitializer(declRefExpr())) 5417would only match the declaration for a. 5418</pre></td></tr> 5419 5420 5421<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> 5422<tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer. 5423 5424Given 5425 class C { 5426 int a = 2; 5427 int b = 3; 5428 int c; 5429 }; 5430fieldDecl(hasInClassInitializer(integerLiteral(equals(2)))) 5431 matches 'int a;' but not 'int b;'. 5432fieldDecl(hasInClassInitializer(anything())) 5433 matches 'int a;' and 'int b;' but not 'int c;'. 5434</pre></td></tr> 5435 5436 5437<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> 5438<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'do while' statement or a function 5439definition that has a given body. 5440 5441Given 5442 for (;;) {} 5443hasBody(compoundStmt()) 5444 matches 'for (;;) {}' 5445with compoundStmt() 5446 matching '{}' 5447</pre></td></tr> 5448 5449 5450<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> 5451<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 5452switch statement or conditional operator. 5453 5454Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5455 if (true) {} 5456</pre></td></tr> 5457 5458 5459<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> 5460<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 5461 5462Example: 5463 forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 5464matches '++x' in 5465 for (x; x < N; ++x) { } 5466</pre></td></tr> 5467 5468 5469<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> 5470<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 5471 5472Example: 5473 forStmt(hasLoopInit(declStmt())) 5474matches 'int x = 0' in 5475 for (int x = 0; x < N; ++x) { } 5476</pre></td></tr> 5477 5478 5479<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>></td><td class="name" onclick="toggle('hasType5')"><a name="hasType5Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5480<tr><td colspan="4" class="doc" id="hasType5"><pre>Overloaded to match the declaration of the expression's or value 5481declaration's type. 5482 5483In case of a value declaration (for example a variable declaration), 5484this resolves one layer of indirection. For example, in the value 5485declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 5486X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 5487declaration of x. 5488 5489Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 5490 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 5491 and friend class X (matcher = friendDecl(hasType("X")) 5492 class X {}; 5493 void y(X &x) { x; X z; } 5494 class Y { friend class X; }; 5495 5496Usable 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>> 5497</pre></td></tr> 5498 5499 5500<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</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> 5501<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type 5502matcher. 5503 5504Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 5505 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 5506 and U (matcher = typedefDecl(hasType(asString("int"))) 5507 and friend class X (matcher = friendDecl(hasType("X")) 5508 class X {}; 5509 void y(X &x) { x; X z; } 5510 typedef int U; 5511 class Y { friend class X; }; 5512</pre></td></tr> 5513 5514 5515<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> 5516<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a 5517block. 5518 5519Does not match the 'this' parameter of a method. 5520 5521Given 5522 class X { void f(int x, int y, int z) {} }; 5523cxxMethodDecl(hasAnyParameter(hasName("y"))) 5524 matches f(int x, int y, int z) {} 5525with hasAnyParameter(...) 5526 matching int y 5527 5528For ObjectiveC, given 5529 @interface I - (void) f:(int) y; @end 5530 5531the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 5532matches the declaration of method f with hasParameter 5533matching y. 5534 5535For blocks, given 5536 b = ^(int y) { printf("%d", y) }; 5537 5538the matcher blockDecl(hasAnyParameter(hasName("y"))) 5539matches the declaration of the block b with hasParameter 5540matching y. 5541</pre></td></tr> 5542 5543 5544<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> 5545<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and 5546functionDecl that have at least one TemplateArgument matching the given 5547InnerMatcher. 5548 5549Given 5550 template<typename T> class A {}; 5551 template<> class A<double> {}; 5552 A<int> a; 5553 5554 template<typename T> f() {}; 5555 void func() { f<int>(); }; 5556 5557classTemplateSpecializationDecl(hasAnyTemplateArgument( 5558 refersToType(asString("int")))) 5559 matches the specialization A<int> 5560 5561functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 5562 matches the specialization f<int> 5563</pre></td></tr> 5564 5565 5566<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> 5567<tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'do while' statement or a function 5568definition that has a given body. 5569 5570Given 5571 for (;;) {} 5572hasBody(compoundStmt()) 5573 matches 'for (;;) {}' 5574with compoundStmt() 5575 matching '{}' 5576</pre></td></tr> 5577 5578 5579<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> 5580<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method 5581declaration or a block. 5582 5583Given 5584 class X { void f(int x) {} }; 5585cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 5586 matches f(int x) {} 5587with hasParameter(...) 5588 matching int x 5589 5590For ObjectiveC, given 5591 @interface I - (void) f:(int) y; @end 5592 5593the matcher objcMethodDecl(hasParameter(0, hasName("y"))) 5594matches the declaration of method f with hasParameter 5595matching y. 5596</pre></td></tr> 5597 5598 5599<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> 5600<tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and 5601functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 5602 5603Given 5604 template<typename T, typename U> class A {}; 5605 A<bool, int> b; 5606 A<int, bool> c; 5607 5608 template<typename T> void f() {} 5609 void func() { f<int>(); }; 5610classTemplateSpecializationDecl(hasTemplateArgument( 5611 1, refersToType(asString("int")))) 5612 matches the specialization A<bool, int> 5613 5614functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 5615 matches the specialization f<int> 5616</pre></td></tr> 5617 5618 5619<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> 5620<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 5621 5622Given: 5623 class X { int f() { return 1; } }; 5624cxxMethodDecl(returns(asString("int"))) 5625 matches int f() { return 1; } 5626</pre></td></tr> 5627 5628 5629<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> 5630<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 5631switch statement or conditional operator. 5632 5633Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5634 if (true) {} 5635</pre></td></tr> 5636 5637 5638<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> 5639<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 5640 5641Given 5642 if (A* a = GetAPointer()) {} 5643hasConditionVariableStatement(...) 5644 matches 'A* a = GetAPointer()'. 5645</pre></td></tr> 5646 5647 5648<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> 5649<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. 5650 5651Examples matches the if statement 5652 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) 5653 if (false) false; else true; 5654</pre></td></tr> 5655 5656 5657<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> 5658<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. 5659 5660Examples matches the if statement 5661 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) 5662 if (false) true; else false; 5663</pre></td></tr> 5664 5665 5666<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> 5667<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 5668matcher. 5669 5670FIXME: Unit test this matcher 5671</pre></td></tr> 5672 5673 5674<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> 5675<tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions 5676(if expression have it). 5677</pre></td></tr> 5678 5679 5680<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> 5681<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node 5682matches the given matcher. 5683 5684The associated declaration is: 5685- for type nodes, the declaration of the underlying type 5686- for CallExpr, the declaration of the callee 5687- for MemberExpr, the declaration of the referenced member 5688- for CXXConstructExpr, the declaration of the constructor 5689- for CXXNewExpr, the declaration of the operator new 5690- for ObjCIvarExpr, the declaration of the ivar 5691 5692For type nodes, hasDeclaration will generally match the declaration of the 5693sugared type. Given 5694 class X {}; 5695 typedef X Y; 5696 Y y; 5697in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5698typedefDecl. A common use case is to match the underlying, desugared type. 5699This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5700 varDecl(hasType(hasUnqualifiedDesugaredType( 5701 recordType(hasDeclaration(decl()))))) 5702In this matcher, the decl will match the CXXRecordDecl of class X. 5703 5704Usable 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>>, 5705 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>>, 5706 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>>, 5707 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>>, 5708 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>>, 5709 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>>, 5710 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5711</pre></td></tr> 5712 5713 5714<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> 5715<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node 5716matches the given matcher. 5717 5718The associated declaration is: 5719- for type nodes, the declaration of the underlying type 5720- for CallExpr, the declaration of the callee 5721- for MemberExpr, the declaration of the referenced member 5722- for CXXConstructExpr, the declaration of the constructor 5723- for CXXNewExpr, the declaration of the operator new 5724- for ObjCIvarExpr, the declaration of the ivar 5725 5726For type nodes, hasDeclaration will generally match the declaration of the 5727sugared type. Given 5728 class X {}; 5729 typedef X Y; 5730 Y y; 5731in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5732typedefDecl. A common use case is to match the underlying, desugared type. 5733This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5734 varDecl(hasType(hasUnqualifiedDesugaredType( 5735 recordType(hasDeclaration(decl()))))) 5736In this matcher, the decl will match the CXXRecordDecl of class X. 5737 5738Usable 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>>, 5739 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>>, 5740 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>>, 5741 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>>, 5742 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>>, 5743 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>>, 5744 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5745</pre></td></tr> 5746 5747 5748<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> 5749<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node 5750matches the given matcher. 5751 5752The associated declaration is: 5753- for type nodes, the declaration of the underlying type 5754- for CallExpr, the declaration of the callee 5755- for MemberExpr, the declaration of the referenced member 5756- for CXXConstructExpr, the declaration of the constructor 5757- for CXXNewExpr, the declaration of the operator new 5758- for ObjCIvarExpr, the declaration of the ivar 5759 5760For type nodes, hasDeclaration will generally match the declaration of the 5761sugared type. Given 5762 class X {}; 5763 typedef X Y; 5764 Y y; 5765in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5766typedefDecl. A common use case is to match the underlying, desugared type. 5767This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5768 varDecl(hasType(hasUnqualifiedDesugaredType( 5769 recordType(hasDeclaration(decl()))))) 5770In this matcher, the decl will match the CXXRecordDecl of class X. 5771 5772Usable 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>>, 5773 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>>, 5774 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>>, 5775 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>>, 5776 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>>, 5777 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>>, 5778 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5779</pre></td></tr> 5780 5781 5782<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> 5783<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is 5784matched by a given matcher. 5785 5786Given 5787 struct X { int m; }; 5788 void f(X x) { x.m; m; } 5789memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))))) 5790 matches "x.m" and "m" 5791with hasObjectExpression(...) 5792 matching "x" and the implicit object expression of "m" which has type X*. 5793</pre></td></tr> 5794 5795 5796<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> 5797<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 5798given matcher. 5799 5800Given 5801 struct { int first, second; } first, second; 5802 int i(second.first); 5803 int j(first.second); 5804memberExpr(member(hasName("first"))) 5805 matches second.first 5806 but not first.second (because the member name there is "second"). 5807</pre></td></tr> 5808 5809 5810<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> 5811<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the 5812pointee matches a given matcher. 5813 5814Given 5815 int *a; 5816 int const *b; 5817 float const *f; 5818pointerType(pointee(isConstQualified(), isInteger())) 5819 matches "int const *b" 5820 5821Usable 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>>, 5822 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>> 5823</pre></td></tr> 5824 5825 5826<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> 5827<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the 5828pointee matches a given matcher. 5829 5830Given 5831 int *a; 5832 int const *b; 5833 float const *f; 5834pointerType(pointee(isConstQualified(), isInteger())) 5835 matches "int const *b" 5836 5837Usable 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>>, 5838 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>> 5839</pre></td></tr> 5840 5841 5842<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> 5843<tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given 5844matcher. 5845 5846Given 5847 namespace N { template<class T> void f(T t); } 5848 template <class T> void g() { using N::f; f(T()); } 5849unresolvedLookupExpr(hasAnyDeclaration( 5850 namedDecl(hasUnderlyingDecl(hasName("::N::f"))))) 5851 matches the use of f in g() . 5852</pre></td></tr> 5853 5854 5855<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> 5856<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 5857 5858Given 5859 struct A { struct B { struct C {}; }; }; 5860 A::B::C c; 5861nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 5862 matches "A::" 5863</pre></td></tr> 5864 5865 5866<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> 5867<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 5868given TypeLoc. 5869 5870Given 5871 struct A { struct B { struct C {}; }; }; 5872 A::B::C c; 5873nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 5874 hasDeclaration(cxxRecordDecl(hasName("A"))))))) 5875 matches "A::" 5876</pre></td></tr> 5877 5878 5879<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> 5880<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 5881 5882Given 5883 struct A { struct B { struct C {}; }; }; 5884 A::B::C c; 5885nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 5886 matches "A::" 5887</pre></td></tr> 5888 5889 5890<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> 5891<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 5892given namespace matcher. 5893 5894Given 5895 namespace ns { struct A {}; } 5896 ns::A a; 5897nestedNameSpecifier(specifiesNamespace(hasName("ns"))) 5898 matches "ns::" 5899</pre></td></tr> 5900 5901 5902<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> 5903<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 5904given QualType matcher without qualifiers. 5905 5906Given 5907 struct A { struct B { struct C {}; }; }; 5908 A::B::C c; 5909nestedNameSpecifier(specifiesType( 5910 hasDeclaration(cxxRecordDecl(hasName("A"))) 5911)) 5912 matches "A::" 5913</pre></td></tr> 5914 5915 5916<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> 5917<tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call 5918expression, or an ObjC-message-send expression. 5919 5920Given 5921 void x(int, int, int) { int y; x(1, y, 42); } 5922callExpr(hasAnyArgument(declRefExpr())) 5923 matches x(1, y, 42) 5924with hasAnyArgument(...) 5925 matching y 5926 5927For ObjectiveC, given 5928 @interface I - (void) f:(int) y; @end 5929 void foo(I *i) { [i f:12]; } 5930objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 5931 matches [i f:12] 5932</pre></td></tr> 5933 5934 5935<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> 5936<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor 5937call expression. 5938 5939Example matches y in x(y) 5940 (matcher = callExpr(hasArgument(0, declRefExpr()))) 5941 void x(int) { int y; x(y); } 5942</pre></td></tr> 5943 5944 5945<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasReceiver0')"><a name="hasReceiver0Anchor">hasReceiver</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 5946<tr><td colspan="4" class="doc" id="hasReceiver0"><pre>Matches if the Objective-C message is sent to an instance, 5947and the inner matcher matches on that instance. 5948 5949For example the method call in 5950 NSString *x = @"hello"; 5951 [x containsString:@"h"]; 5952is matched by 5953objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x")))))) 5954</pre></td></tr> 5955 5956 5957<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> 5958<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. 5959 5960Example 5961matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *"))); 5962matches the [webView ...] message invocation. 5963 NSString *webViewJavaScript = ... 5964 UIWebView *webView = ... 5965 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; 5966</pre></td></tr> 5967 5968 5969<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> 5970<tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a 5971block. 5972 5973Does not match the 'this' parameter of a method. 5974 5975Given 5976 class X { void f(int x, int y, int z) {} }; 5977cxxMethodDecl(hasAnyParameter(hasName("y"))) 5978 matches f(int x, int y, int z) {} 5979with hasAnyParameter(...) 5980 matching int y 5981 5982For ObjectiveC, given 5983 @interface I - (void) f:(int) y; @end 5984 5985the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 5986matches the declaration of method f with hasParameter 5987matching y. 5988 5989For blocks, given 5990 b = ^(int y) { printf("%d", y) }; 5991 5992the matcher blockDecl(hasAnyParameter(hasName("y"))) 5993matches the declaration of the block b with hasParameter 5994matching y. 5995</pre></td></tr> 5996 5997 5998<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> 5999<tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method 6000declaration or a block. 6001 6002Given 6003 class X { void f(int x) {} }; 6004cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 6005 matches f(int x) {} 6006with hasParameter(...) 6007 matching int x 6008 6009For ObjectiveC, given 6010 @interface I - (void) f:(int) y; @end 6011 6012the matcher objcMethodDecl(hasParameter(0, hasName("y"))) 6013matches the declaration of method f with hasParameter 6014matching y. 6015</pre></td></tr> 6016 6017 6018<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> 6019<tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression 6020or opaque value's source expression matches the given matcher. 6021 6022Example 1: matches "a string" 6023(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) 6024class URL { URL(string); }; 6025URL url = "a string"; 6026 6027Example 2: matches 'b' (matcher = 6028opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) 6029int a = b ?: 1; 6030</pre></td></tr> 6031 6032 6033<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> 6034<tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of 6035overloads matches the given matcher. 6036 6037Given 6038 template <typename T> void foo(T); 6039 template <typename T> void bar(T); 6040 template <typename T> void baz(T t) { 6041 foo(t); 6042 bar(t); 6043 } 6044unresolvedLookupExpr(hasAnyDeclaration( 6045 functionTemplateDecl(hasName("foo")))) 6046 matches foo in foo(t); but not bar in bar(t); 6047</pre></td></tr> 6048 6049 6050<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> 6051<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. 6052 6053Given 6054 int (*ptr_to_array)[4]; 6055 int (*ptr_to_func)(int); 6056 6057varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches 6058ptr_to_func but not ptr_to_array. 6059 6060Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> 6061</pre></td></tr> 6062 6063 6064<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> 6065<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the 6066pointee matches a given matcher. 6067 6068Given 6069 int *a; 6070 int const *b; 6071 float const *f; 6072pointerType(pointee(isConstQualified(), isInteger())) 6073 matches "int const *b" 6074 6075Usable 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>>, 6076 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>> 6077</pre></td></tr> 6078 6079 6080<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> 6081<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the 6082pointee matches a given matcher. 6083 6084Given 6085 int *a; 6086 int const *b; 6087 float const *f; 6088pointerType(pointee(isConstQualified(), isInteger())) 6089 matches "int const *b" 6090 6091Usable 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>>, 6092 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>> 6093</pre></td></tr> 6094 6095 6096<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> 6097<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. 6098 6099Given: 6100 typedef int &int_ref; 6101 int a; 6102 int_ref b = a; 6103 6104varDecl(hasType(qualType(referenceType()))))) will not match the 6105declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. 6106</pre></td></tr> 6107 6108 6109<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> 6110<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node 6111matches the given matcher. 6112 6113The associated declaration is: 6114- for type nodes, the declaration of the underlying type 6115- for CallExpr, the declaration of the callee 6116- for MemberExpr, the declaration of the referenced member 6117- for CXXConstructExpr, the declaration of the constructor 6118- for CXXNewExpr, the declaration of the operator new 6119- for ObjCIvarExpr, the declaration of the ivar 6120 6121For type nodes, hasDeclaration will generally match the declaration of the 6122sugared type. Given 6123 class X {}; 6124 typedef X Y; 6125 Y y; 6126in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6127typedefDecl. A common use case is to match the underlying, desugared type. 6128This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6129 varDecl(hasType(hasUnqualifiedDesugaredType( 6130 recordType(hasDeclaration(decl()))))) 6131In this matcher, the decl will match the CXXRecordDecl of class X. 6132 6133Usable 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>>, 6134 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>>, 6135 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>>, 6136 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>>, 6137 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>>, 6138 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>>, 6139 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6140</pre></td></tr> 6141 6142 6143<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> 6144<tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped. 6145 6146Given 6147 void (*fp)(void); 6148The matcher 6149 varDecl(hasType(pointerType(pointee(ignoringParens(functionType()))))) 6150would match the declaration for fp. 6151</pre></td></tr> 6152 6153 6154<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> 6155<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 6156</pre></td></tr> 6157 6158 6159<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> 6160<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type 6161matches the specified matcher. 6162 6163Example matches y->x() 6164 (matcher = cxxMemberCallExpr(on(hasType(pointsTo 6165 cxxRecordDecl(hasName("Y"))))))) 6166 class Y { public: void x(); }; 6167 void z() { Y *y; y->x(); } 6168</pre></td></tr> 6169 6170 6171<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> 6172<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 6173</pre></td></tr> 6174 6175 6176<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> 6177<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced 6178type matches the specified matcher. 6179 6180Example matches X &x and const X &y 6181 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) 6182 class X { 6183 void a(X b) { 6184 X &x = b; 6185 const X &y = b; 6186 } 6187 }; 6188</pre></td></tr> 6189 6190 6191<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> 6192<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node 6193matches the given matcher. 6194 6195The associated declaration is: 6196- for type nodes, the declaration of the underlying type 6197- for CallExpr, the declaration of the callee 6198- for MemberExpr, the declaration of the referenced member 6199- for CXXConstructExpr, the declaration of the constructor 6200- for CXXNewExpr, the declaration of the operator new 6201- for ObjCIvarExpr, the declaration of the ivar 6202 6203For type nodes, hasDeclaration will generally match the declaration of the 6204sugared type. Given 6205 class X {}; 6206 typedef X Y; 6207 Y y; 6208in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6209typedefDecl. A common use case is to match the underlying, desugared type. 6210This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6211 varDecl(hasType(hasUnqualifiedDesugaredType( 6212 recordType(hasDeclaration(decl()))))) 6213In this matcher, the decl will match the CXXRecordDecl of class X. 6214 6215Usable 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>>, 6216 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>>, 6217 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>>, 6218 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>>, 6219 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>>, 6220 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>>, 6221 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6222</pre></td></tr> 6223 6224 6225<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> 6226<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the 6227pointee matches a given matcher. 6228 6229Given 6230 int *a; 6231 int const *b; 6232 float const *f; 6233pointerType(pointee(isConstQualified(), isInteger())) 6234 matches "int const *b" 6235 6236Usable 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>>, 6237 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>> 6238</pre></td></tr> 6239 6240 6241<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> 6242<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the 6243pointee matches a given matcher. 6244 6245Given 6246 int *a; 6247 int const *b; 6248 float const *f; 6249pointerType(pointee(isConstQualified(), isInteger())) 6250 matches "int const *b" 6251 6252Usable 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>>, 6253 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>> 6254</pre></td></tr> 6255 6256 6257<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> 6258<tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement 6259 6260Given 6261 return a + b; 6262hasReturnValue(binaryOperator()) 6263 matches 'return a + b' 6264with binaryOperator() 6265 matching 'a + b' 6266</pre></td></tr> 6267 6268 6269<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> 6270<tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches 6271a given matcher. Also matches StmtExprs that have CompoundStmt as children. 6272 6273Given 6274 { {}; 1+2; } 6275hasAnySubstatement(compoundStmt()) 6276 matches '{ {}; 1+2; }' 6277with compoundStmt() 6278 matching '{}' 6279</pre></td></tr> 6280 6281 6282<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> 6283<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 6284alignof. 6285</pre></td></tr> 6286 6287 6288<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> 6289<tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to 6290 6291Given: 6292F& operator=(const F& o) { 6293 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); 6294 return *this; 6295} 6296returnStmt(forFunction(hasName("operator="))) 6297 matches 'return *this' 6298 but does match 'return > 0' 6299</pre></td></tr> 6300 6301 6302<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> 6303<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 6304sizeof. 6305</pre></td></tr> 6306 6307 6308<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> 6309<tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement 6310type that matches the provided matcher. 6311 6312Given 6313 template <typename T> 6314 double F(T t); 6315 int i; 6316 double j = F(i); 6317 6318substTemplateTypeParmType(hasReplacementType(type())) matches int 6319</pre></td></tr> 6320 6321 6322<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> 6323<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch 6324statement. This matcher may produce multiple matches. 6325 6326Given 6327 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } 6328switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") 6329 matches four times, with "c" binding each of "case 1:", "case 2:", 6330"case 3:" and "case 4:", and "s" respectively binding "switch (1)", 6331"switch (1)", "switch (2)" and "switch (2)". 6332</pre></td></tr> 6333 6334 6335<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> 6336<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 6337switch statement or conditional operator. 6338 6339Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 6340 if (true) {} 6341</pre></td></tr> 6342 6343 6344<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> 6345<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node 6346matches the given matcher. 6347 6348The associated declaration is: 6349- for type nodes, the declaration of the underlying type 6350- for CallExpr, the declaration of the callee 6351- for MemberExpr, the declaration of the referenced member 6352- for CXXConstructExpr, the declaration of the constructor 6353- for CXXNewExpr, the declaration of the operator new 6354- for ObjCIvarExpr, the declaration of the ivar 6355 6356For type nodes, hasDeclaration will generally match the declaration of the 6357sugared type. Given 6358 class X {}; 6359 typedef X Y; 6360 Y y; 6361in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6362typedefDecl. A common use case is to match the underlying, desugared type. 6363This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6364 varDecl(hasType(hasUnqualifiedDesugaredType( 6365 recordType(hasDeclaration(decl()))))) 6366In this matcher, the decl will match the CXXRecordDecl of class X. 6367 6368Usable 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>>, 6369 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>>, 6370 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>>, 6371 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>>, 6372 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>>, 6373 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>>, 6374 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6375</pre></td></tr> 6376 6377 6378<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> 6379<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. 6380 6381Given 6382 struct B { int next; }; 6383 template<int(B::*next_ptr)> struct A {}; 6384 A<&B::next> a; 6385templateSpecializationType(hasAnyTemplateArgument( 6386 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) 6387 matches the specialization A<&B::next> with fieldDecl(...) matching 6388 B::next 6389</pre></td></tr> 6390 6391 6392<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> 6393<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain 6394declaration. 6395 6396Given 6397 struct B { int next; }; 6398 template<int(B::*next_ptr)> struct A {}; 6399 A<&B::next> a; 6400classTemplateSpecializationDecl(hasAnyTemplateArgument( 6401 refersToDeclaration(fieldDecl(hasName("next"))))) 6402 matches the specialization A<&B::next> with fieldDecl(...) matching 6403 B::next 6404</pre></td></tr> 6405 6406 6407<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> 6408<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type. 6409 6410Given 6411 template<int T> struct C {}; 6412 C<42> c; 6413classTemplateSpecializationDecl( 6414 hasAnyTemplateArgument(refersToIntegralType(asString("int")))) 6415 matches the implicit instantiation of C in C<42>. 6416</pre></td></tr> 6417 6418 6419<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> 6420<tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template. 6421 6422Given 6423 template<template <typename> class S> class X {}; 6424 template<typename T> class Y {};" 6425 X<Y> xi; 6426classTemplateSpecializationDecl(hasAnyTemplateArgument( 6427 refersToTemplate(templateName()))) 6428 matches the specialization X<Y> 6429</pre></td></tr> 6430 6431 6432<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> 6433<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 6434 6435Given 6436 struct X {}; 6437 template<typename T> struct A {}; 6438 A<X> a; 6439classTemplateSpecializationDecl(hasAnyTemplateArgument( 6440 refersToType(class(hasName("X"))))) 6441 matches the specialization A<X> 6442</pre></td></tr> 6443 6444 6445<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> 6446<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and 6447functionDecl that have at least one TemplateArgument matching the given 6448InnerMatcher. 6449 6450Given 6451 template<typename T> class A {}; 6452 template<> class A<double> {}; 6453 A<int> a; 6454 6455 template<typename T> f() {}; 6456 void func() { f<int>(); }; 6457 6458classTemplateSpecializationDecl(hasAnyTemplateArgument( 6459 refersToType(asString("int")))) 6460 matches the specialization A<int> 6461 6462functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 6463 matches the specialization f<int> 6464</pre></td></tr> 6465 6466 6467<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> 6468<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node 6469matches the given matcher. 6470 6471The associated declaration is: 6472- for type nodes, the declaration of the underlying type 6473- for CallExpr, the declaration of the callee 6474- for MemberExpr, the declaration of the referenced member 6475- for CXXConstructExpr, the declaration of the constructor 6476- for CXXNewExpr, the declaration of the operator new 6477- for ObjCIvarExpr, the declaration of the ivar 6478 6479For type nodes, hasDeclaration will generally match the declaration of the 6480sugared type. Given 6481 class X {}; 6482 typedef X Y; 6483 Y y; 6484in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6485typedefDecl. A common use case is to match the underlying, desugared type. 6486This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6487 varDecl(hasType(hasUnqualifiedDesugaredType( 6488 recordType(hasDeclaration(decl()))))) 6489In this matcher, the decl will match the CXXRecordDecl of class X. 6490 6491Usable 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>>, 6492 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>>, 6493 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>>, 6494 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>>, 6495 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>>, 6496 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>>, 6497 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6498</pre></td></tr> 6499 6500 6501<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> 6502<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and 6503functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 6504 6505Given 6506 template<typename T, typename U> class A {}; 6507 A<bool, int> b; 6508 A<int, bool> c; 6509 6510 template<typename T> void f() {} 6511 void func() { f<int>(); }; 6512classTemplateSpecializationDecl(hasTemplateArgument( 6513 1, refersToType(asString("int")))) 6514 matches the specialization A<bool, int> 6515 6516functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 6517 matches the specialization f<int> 6518</pre></td></tr> 6519 6520 6521<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> 6522<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node 6523matches the given matcher. 6524 6525The associated declaration is: 6526- for type nodes, the declaration of the underlying type 6527- for CallExpr, the declaration of the callee 6528- for MemberExpr, the declaration of the referenced member 6529- for CXXConstructExpr, the declaration of the constructor 6530- for CXXNewExpr, the declaration of the operator new 6531- for ObjCIvarExpr, the declaration of the ivar 6532 6533For type nodes, hasDeclaration will generally match the declaration of the 6534sugared type. Given 6535 class X {}; 6536 typedef X Y; 6537 Y y; 6538in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6539typedefDecl. A common use case is to match the underlying, desugared type. 6540This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6541 varDecl(hasType(hasUnqualifiedDesugaredType( 6542 recordType(hasDeclaration(decl()))))) 6543In this matcher, the decl will match the CXXRecordDecl of class X. 6544 6545Usable 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>>, 6546 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>>, 6547 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>>, 6548 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>>, 6549 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>>, 6550 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>>, 6551 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6552</pre></td></tr> 6553 6554 6555<tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>const Matcher<T> Matcher</td></tr> 6556<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. 6557 6558Generates results for each match. 6559 6560For example, in: 6561 class A { class B {}; class C {}; }; 6562The matcher: 6563 cxxRecordDecl(hasName("::A"), 6564 findAll(cxxRecordDecl(isDefinition()).bind("m"))) 6565will generate results for A, B and C. 6566 6567Usable as: Any Matcher 6568</pre></td></tr> 6569 6570 6571<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</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> 6572<tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type 6573matcher. 6574 6575Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6576 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6577 and U (matcher = typedefDecl(hasType(asString("int"))) 6578 and friend class X (matcher = friendDecl(hasType("X")) 6579 class X {}; 6580 void y(X &x) { x; X z; } 6581 typedef int U; 6582 class Y { friend class X; }; 6583</pre></td></tr> 6584 6585 6586<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> 6587<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node 6588matches the given matcher. 6589 6590The associated declaration is: 6591- for type nodes, the declaration of the underlying type 6592- for CallExpr, the declaration of the callee 6593- for MemberExpr, the declaration of the referenced member 6594- for CXXConstructExpr, the declaration of the constructor 6595- for CXXNewExpr, the declaration of the operator new 6596- for ObjCIvarExpr, the declaration of the ivar 6597 6598For type nodes, hasDeclaration will generally match the declaration of the 6599sugared type. Given 6600 class X {}; 6601 typedef X Y; 6602 Y y; 6603in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6604typedefDecl. A common use case is to match the underlying, desugared type. 6605This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6606 varDecl(hasType(hasUnqualifiedDesugaredType( 6607 recordType(hasDeclaration(decl()))))) 6608In this matcher, the decl will match the CXXRecordDecl of class X. 6609 6610Usable 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>>, 6611 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>>, 6612 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>>, 6613 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>>, 6614 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>>, 6615 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>>, 6616 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6617</pre></td></tr> 6618 6619 6620<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> 6621<tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared 6622type of the matched node. 6623 6624For example, in: 6625 class A {}; 6626 using B = A; 6627The matcher type(hasUnqualifiedDesugaredType(recordType())) matches 6628both B and A. 6629</pre></td></tr> 6630 6631 6632<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> 6633<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 6634 6635Given 6636 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 6637unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 6638 matches sizeof(a) and alignof(c) 6639</pre></td></tr> 6640 6641 6642<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> 6643<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 6644 6645Example matches true (matcher = hasUnaryOperand( 6646 cxxBoolLiteral(equals(true)))) 6647 !true 6648</pre></td></tr> 6649 6650 6651<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> 6652<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node 6653matches the given matcher. 6654 6655The associated declaration is: 6656- for type nodes, the declaration of the underlying type 6657- for CallExpr, the declaration of the callee 6658- for MemberExpr, the declaration of the referenced member 6659- for CXXConstructExpr, the declaration of the constructor 6660- for CXXNewExpr, the declaration of the operator new 6661- for ObjCIvarExpr, the declaration of the ivar 6662 6663For type nodes, hasDeclaration will generally match the declaration of the 6664sugared type. Given 6665 class X {}; 6666 typedef X Y; 6667 Y y; 6668in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6669typedefDecl. A common use case is to match the underlying, desugared type. 6670This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6671 varDecl(hasType(hasUnqualifiedDesugaredType( 6672 recordType(hasDeclaration(decl()))))) 6673In this matcher, the decl will match the CXXRecordDecl of class X. 6674 6675Usable 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>>, 6676 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>>, 6677 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>>, 6678 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>>, 6679 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>>, 6680 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>>, 6681 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6682</pre></td></tr> 6683 6684 6685<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> 6686<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 6687 6688Given 6689 namespace X { void b(); } 6690 using X::b; 6691usingDecl(hasAnyUsingShadowDecl(hasName("b")))) 6692 matches using X::b </pre></td></tr> 6693 6694 6695<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> 6696<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 6697matched by the given matcher. 6698 6699Given 6700 namespace X { int a; void b(); } 6701 using X::a; 6702 using X::b; 6703usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 6704 matches using X::b but not using X::a </pre></td></tr> 6705 6706 6707<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType6')"><a name="hasType6Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6708<tr><td colspan="4" class="doc" id="hasType6"><pre>Overloaded to match the declaration of the expression's or value 6709declaration's type. 6710 6711In case of a value declaration (for example a variable declaration), 6712this resolves one layer of indirection. For example, in the value 6713declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 6714X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 6715declaration of x. 6716 6717Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6718 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6719 and friend class X (matcher = friendDecl(hasType("X")) 6720 class X {}; 6721 void y(X &x) { x; X z; } 6722 class Y { friend class X; }; 6723 6724Usable 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>> 6725</pre></td></tr> 6726 6727 6728<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType3')"><a name="hasType3Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 6729<tr><td colspan="4" class="doc" id="hasType3"><pre>Matches if the expression's or declaration's type matches a type 6730matcher. 6731 6732Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6733 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6734 and U (matcher = typedefDecl(hasType(asString("int"))) 6735 and friend class X (matcher = friendDecl(hasType("X")) 6736 class X {}; 6737 void y(X &x) { x; X z; } 6738 typedef int U; 6739 class Y { friend class X; }; 6740</pre></td></tr> 6741 6742 6743<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> 6744<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 6745that matches the given matcher. 6746 6747Example matches x (matcher = varDecl(hasInitializer(callExpr()))) 6748 bool y() { return true; } 6749 bool x = y(); 6750</pre></td></tr> 6751 6752 6753<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> 6754<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 6755expression. 6756 6757Given 6758 void f(int b) { 6759 int a[b]; 6760 } 6761variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 6762 varDecl(hasName("b"))))))) 6763 matches "int a[b]" 6764</pre></td></tr> 6765 6766 6767<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> 6768<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'do while' statement or a function 6769definition that has a given body. 6770 6771Given 6772 for (;;) {} 6773hasBody(compoundStmt()) 6774 matches 'for (;;) {}' 6775with compoundStmt() 6776 matching '{}' 6777</pre></td></tr> 6778 6779 6780<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> 6781<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 6782switch statement or conditional operator. 6783 6784Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 6785 if (true) {} 6786</pre></td></tr> 6787 6788 6789<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> 6790<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner 6791NestedNameSpecifier-matcher matches. 6792</pre></td></tr> 6793 6794 6795<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> 6796<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner 6797QualType-matcher matches. 6798</pre></td></tr> 6799 6800<!--END_TRAVERSAL_MATCHERS --> 6801</table> 6802 6803</div> 6804</body> 6805</html> 6806 6807 6808