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