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