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('isMain0')"><a name="isMain0Anchor">isMain</a></td><td></td></tr> 2923<tr><td colspan="4" class="doc" id="isMain0"><pre>Determines whether the function is "main", which is the entry point 2924into an executable program. 2925</pre></td></tr> 2926 2927 2928<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> 2929<tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute. 2930 2931Given 2932 void nope(); 2933 [[noreturn]] void a(); 2934 __attribute__((noreturn)) void b(); 2935 struct c { [[noreturn]] c(); }; 2936functionDecl(isNoReturn()) 2937 matches all of those except 2938 void nope(); 2939</pre></td></tr> 2940 2941 2942<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> 2943<tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification. 2944 2945Given: 2946 void f(); 2947 void g() noexcept; 2948 void h() throw(); 2949 void i() throw(int); 2950 void j() noexcept(false); 2951functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) 2952 match the declarations of g, and h, but not f, i or j. 2953</pre></td></tr> 2954 2955 2956<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isStaticStorageClass0')"><a name="isStaticStorageClass0Anchor">isStaticStorageClass</a></td><td></td></tr> 2957<tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variablefunction declarations that have "static" storage 2958class specifier ("static" keyword) written in the source. 2959 2960Given: 2961 static void f() {} 2962 static int i = 0; 2963 extern int j; 2964 int k; 2965functionDecl(isStaticStorageClass()) 2966 matches the function declaration f. 2967varDecl(isStaticStorageClass()) 2968 matches the variable declaration i. 2969</pre></td></tr> 2970 2971 2972<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> 2973<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 2974member variable template instantiations. 2975 2976Given 2977 template <typename T> class X {}; class A {}; X<A> x; 2978or 2979 template <typename T> class X {}; class A {}; template class X<A>; 2980or 2981 template <typename T> class X {}; class A {}; extern template class X<A>; 2982cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2983 matches the template instantiation of X<A>. 2984 2985But given 2986 template <typename T> class X {}; class A {}; 2987 template <> class X<A> {}; X<A> x; 2988cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2989 does not match, as X<A> is an explicit template specialization. 2990 2991Usable 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>> 2992</pre></td></tr> 2993 2994 2995<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> 2996<tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. 2997 2998Example matches f, but not g or h. The function i will not match, even when 2999compiled in C mode. 3000 void f(...); 3001 void g(int); 3002 template <typename... Ts> void h(Ts...); 3003 void i(); 3004</pre></td></tr> 3005 3006 3007<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> 3008<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a 3009specific parameter count. 3010 3011Given 3012 void f(int i) {} 3013 void g(int i, int j) {} 3014 void h(int i, int j); 3015 void j(int i); 3016 void k(int x, int y, int z, ...); 3017functionDecl(parameterCountIs(2)) 3018 matches g and h 3019functionProtoType(parameterCountIs(2)) 3020 matches g and h 3021functionProtoType(parameterCountIs(3)) 3022 matches k 3023</pre></td></tr> 3024 3025 3026<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> 3027<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification. 3028 3029Given: 3030 void f(); 3031 void g() noexcept; 3032 void h() noexcept(true); 3033 void i() noexcept(false); 3034 void j() throw(); 3035 void k() throw(int); 3036 void l() throw(...); 3037functionDecl(hasDynamicExceptionSpec()) and 3038 functionProtoType(hasDynamicExceptionSpec()) 3039 match the declarations of j, k, and l, but not f, g, h, or i. 3040</pre></td></tr> 3041 3042 3043<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> 3044<tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification. 3045 3046Given: 3047 void f(); 3048 void g() noexcept; 3049 void h() throw(); 3050 void i() throw(int); 3051 void j() noexcept(false); 3052functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) 3053 match the declarations of g, and h, but not f, i or j. 3054</pre></td></tr> 3055 3056 3057<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> 3058<tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a 3059specific parameter count. 3060 3061Given 3062 void f(int i) {} 3063 void g(int i, int j) {} 3064 void h(int i, int j); 3065 void j(int i); 3066 void k(int x, int y, int z, ...); 3067functionDecl(parameterCountIs(2)) 3068 matches g and h 3069functionProtoType(parameterCountIs(2)) 3070 matches g and h 3071functionProtoType(parameterCountIs(3)) 3072 matches k 3073</pre></td></tr> 3074 3075 3076<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> 3077<tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations, 3078 and if constexpr. 3079 3080Given: 3081 constexpr int foo = 42; 3082 constexpr int bar(); 3083 void baz() { if constexpr(1 > 0) {} } 3084varDecl(isConstexpr()) 3085 matches the declaration of foo. 3086functionDecl(isConstexpr()) 3087 matches the declaration of bar. 3088ifStmt(isConstexpr()) 3089 matches the if statement in baz. 3090</pre></td></tr> 3091 3092 3093<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> 3094<tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr> 3095 3096 3097<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> 3098<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT. 3099 3100Given 3101 f('false, 3.14, 42); 3102characterLiteral(equals(0)) 3103 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 3104 match false 3105floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 3106 match 3.14 3107integerLiteral(equals(42)) 3108 matches 42 3109 3110Note that you cannot directly match a negative numeric literal because the 3111minus sign is not part of the literal: It is a unary operator whose operand 3112is the positive numeric literal. Instead, you must use a unaryOperator() 3113matcher to match the minus sign: 3114 3115unaryOperator(hasOperatorName("-"), 3116 hasUnaryOperand(integerLiteral(equals(13)))) 3117 3118Usable 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>>, 3119 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>> 3120</pre></td></tr> 3121 3122 3123<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals13')"><a name="equals13Anchor">equals</a></td><td>double Value</td></tr> 3124<tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr> 3125 3126 3127<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> 3128<tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr> 3129 3130 3131<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> 3132<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 3133to '.'. 3134 3135Member calls on the implicit this pointer match as called with '->'. 3136 3137Given 3138 class Y { 3139 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 3140 int a; 3141 static int b; 3142 }; 3143memberExpr(isArrow()) 3144 matches this->x, x, y.x, a, this->b 3145</pre></td></tr> 3146 3147 3148<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> 3149<tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage. 3150 3151Example matches only z (matcher = varDecl(hasExternalFormalLinkage())) 3152void f() { 3153 int x; 3154 static int y; 3155} 3156int z; 3157 3158Example matches f() because it has external formal linkage despite being 3159unique to the translation unit as though it has internal likage 3160(matcher = functionDecl(hasExternalFormalLinkage())) 3161 3162namespace { 3163void f() {} 3164} 3165</pre></td></tr> 3166 3167 3168<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> 3169<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 3170 3171Supports specifying enclosing namespaces or classes by prefixing the name 3172with '<enclosing>::'. 3173Does not match typedefs of an underlying type with the given name. 3174 3175Example matches X (Name == "X") 3176 class X; 3177 3178Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 3179 namespace a { namespace b { class X; } } 3180</pre></td></tr> 3181 3182 3183<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> 3184<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain 3185a substring matched by the given RegExp. 3186 3187Supports specifying enclosing namespaces or classes by 3188prefixing the name with '<enclosing>::'. Does not match typedefs 3189of an underlying type with the given name. 3190 3191Example matches X (regexp == "::X") 3192 class X; 3193 3194Example matches X (regexp is one of "::X", "^foo::.*X", among others) 3195 namespace foo { namespace bar { class X; } } 3196</pre></td></tr> 3197 3198 3199<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> 3200<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. 3201 3202Given 3203 namespace n { 3204 namespace {} #1 3205 } 3206namespaceDecl(isAnonymous()) will match #1 but not ::n. 3207</pre></td></tr> 3208 3209 3210<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> 3211<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with 3212the inline keyword. 3213 3214Given 3215 inline void f(); 3216 void g(); 3217 namespace n { 3218 inline namespace m {} 3219 } 3220functionDecl(isInline()) will match ::f(). 3221namespaceDecl(isInline()) will match n::m. 3222</pre></td></tr> 3223 3224 3225<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> 3226<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has 3227a specific number of arguments (including absent default arguments). 3228 3229Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 3230 void f(int x, int y); 3231 f(0, 0); 3232</pre></td></tr> 3233 3234 3235<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> 3236<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector 3237 3238objCMessageExpr(hasKeywordSelector()) matches the generated setFrame 3239message expression in 3240 3241 UIWebView *webView = ...; 3242 CGRect bodyFrame = webView.frame; 3243 bodyFrame.size.height = self.bodyContentHeight; 3244 webView.frame = bodyFrame; 3245 ^---- matches here 3246</pre></td></tr> 3247 3248 3249<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasNullSelector0')"><a name="hasNullSelector0Anchor">hasNullSelector</a></td><td></td></tr> 3250<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector 3251 3252Matches only when the selector of the objCMessageExpr is NULL. This may 3253represent an error condition in the tree! 3254</pre></td></tr> 3255 3256 3257<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> 3258<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() 3259 3260 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); 3261 matches the outer message expr in the code below, but NOT the message 3262 invocation for self.bodyView. 3263 [self.bodyView loadHTMLString:html baseURL:NULL]; 3264</pre></td></tr> 3265 3266 3267<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> 3268<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector 3269 3270 matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); 3271 matches self.bodyView in the code below, but NOT the outer message 3272 invocation of "loadHTMLString:baseURL:". 3273 [self.bodyView loadHTMLString:html baseURL:NULL]; 3274</pre></td></tr> 3275 3276 3277<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('isInstanceMessage0')"><a name="isInstanceMessage0Anchor">isInstanceMessage</a></td><td></td></tr> 3278<tr><td colspan="4" class="doc" id="isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance. 3279 3280Example 3281matcher = objcMessagaeExpr(isInstanceMessage()) 3282matches 3283 NSString *x = @"hello"; 3284 [x containsString:@"h"]; 3285but not 3286 [NSString stringWithFormat:@"format"]; 3287</pre></td></tr> 3288 3289 3290<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> 3291<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains 3292a substring matched by the given RegExp. 3293 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message 3294 invocation for self.bodyView. 3295 [self.bodyView loadHTMLString:html baseURL:NULL]; 3296</pre></td></tr> 3297 3298 3299<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> 3300<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments 3301 3302 matcher = objCMessageExpr(numSelectorArgs(0)); 3303 matches self.bodyView in the code below 3304 3305 matcher = objCMessageExpr(numSelectorArgs(2)); 3306 matches the invocation of "loadHTMLString:baseURL:" but not that 3307 of self.bodyView 3308 [self.bodyView loadHTMLString:html baseURL:NULL]; 3309</pre></td></tr> 3310 3311 3312<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> 3313<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. 3314 3315Example matches A, va, fa 3316 class A {}; 3317 class B; Doesn't match, as it has no body. 3318 int va; 3319 extern int vb; Doesn't match, as it doesn't define the variable. 3320 void fa() {} 3321 void fb(); Doesn't match, as it has no body. 3322 @interface X 3323 - (void)ma; Doesn't match, interface is declaration. 3324 @end 3325 @implementation X 3326 - (void)ma {} 3327 @end 3328 3329Usable 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>>, 3330 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 3331</pre></td></tr> 3332 3333 3334<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> 3335<tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments. 3336 3337Example matches y (matcher = parmVarDecl(hasDefaultArgument())) 3338void x(int val) {} 3339void y(int val = 0) {} 3340</pre></td></tr> 3341 3342 3343<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> 3344<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 3345 3346Given 3347 class Y { public: void x(); }; 3348 void z() { Y* y; y->x(); } 3349cxxMemberCallExpr(on(hasType(asString("class Y *")))) 3350 matches y->x() 3351</pre></td></tr> 3352 3353 3354<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> 3355<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. 3356 3357Matches a node if it equals the node previously bound to ID. 3358 3359Given 3360 class X { int a; int b; }; 3361cxxRecordDecl( 3362 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3363 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3364 matches the class X, as a and b have the same type. 3365 3366Note that when multiple matches are involved via forEach* matchers, 3367equalsBoundNodes acts as a filter. 3368For example: 3369compoundStmt( 3370 forEachDescendant(varDecl().bind("d")), 3371 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3372will trigger a match for each combination of variable declaration 3373and reference to that variable declaration within a compound statement. 3374</pre></td></tr> 3375 3376 3377<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> 3378<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to 3379the node, not hidden within a typedef. 3380 3381Given 3382 typedef const int const_int; 3383 const_int i; 3384 int *const j; 3385 int *volatile k; 3386 int m; 3387varDecl(hasType(hasLocalQualifiers())) matches only j and k. 3388i is const-qualified but the qualifier is not local. 3389</pre></td></tr> 3390 3391 3392<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> 3393<tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type. 3394 3395Given 3396 void a(char); 3397 void b(wchar_t); 3398 void c(double); 3399functionDecl(hasAnyParameter(hasType(isAnyCharacter()))) 3400matches "a(char)", "b(wchar_t)", but not "c(double)". 3401</pre></td></tr> 3402 3403 3404<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> 3405<tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes 3406the Objective-C object pointer type, which is different despite being 3407syntactically similar. 3408 3409Given 3410 int *i = nullptr; 3411 3412 @interface Foo 3413 @end 3414 Foo *f; 3415 3416 int j; 3417varDecl(hasType(isAnyPointer())) 3418 matches "int *i" and "Foo *f", but not "int j". 3419</pre></td></tr> 3420 3421 3422<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> 3423<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 3424include "top-level" const. 3425 3426Given 3427 void a(int); 3428 void b(int const); 3429 void c(const int); 3430 void d(const int*); 3431 void e(int const) {}; 3432functionDecl(hasAnyParameter(hasType(isConstQualified()))) 3433 matches "void b(int const)", "void c(const int)" and 3434 "void e(int const) {}". It does not match d as there 3435 is no top-level const on the parameter type "const int *". 3436</pre></td></tr> 3437 3438 3439<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> 3440<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 3441 3442Given 3443 void a(int); 3444 void b(long); 3445 void c(double); 3446functionDecl(hasAnyParameter(hasType(isInteger()))) 3447matches "a(int)", "b(long)", but not "c(double)". 3448</pre></td></tr> 3449 3450 3451<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> 3452<tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type. 3453 3454Given 3455 void a(int); 3456 void b(unsigned long); 3457 void c(double); 3458functionDecl(hasAnyParameter(hasType(isSignedInteger()))) 3459matches "a(int)", but not "b(unsigned long)" and "c(double)". 3460</pre></td></tr> 3461 3462 3463<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> 3464<tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type. 3465 3466Given 3467 void a(int); 3468 void b(unsigned long); 3469 void c(double); 3470functionDecl(hasAnyParameter(hasType(isUnsignedInteger()))) 3471matches "b(unsigned long)", but not "a(int)" and "c(double)". 3472</pre></td></tr> 3473 3474 3475<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> 3476<tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that 3477include "top-level" volatile. 3478 3479Given 3480 void a(int); 3481 void b(int volatile); 3482 void c(volatile int); 3483 void d(volatile int*); 3484 void e(int volatile) {}; 3485functionDecl(hasAnyParameter(hasType(isVolatileQualified()))) 3486 matches "void b(int volatile)", "void c(volatile int)" and 3487 "void e(int volatile) {}". It does not match d as there 3488 is no top-level volatile on the parameter type "volatile int *". 3489</pre></td></tr> 3490 3491 3492<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> 3493<tr><td colspan="4" class="doc" id="isClass0"><pre>Matches RecordDecl object that are spelled with "class." 3494 3495Example matches C, but not S or U. 3496 struct S {}; 3497 class C {}; 3498 union U {}; 3499</pre></td></tr> 3500 3501 3502<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> 3503<tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches RecordDecl object that are spelled with "struct." 3504 3505Example matches S, but not C or U. 3506 struct S {}; 3507 class C {}; 3508 union U {}; 3509</pre></td></tr> 3510 3511 3512<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> 3513<tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches RecordDecl object that are spelled with "union." 3514 3515Example matches U, but not C or S. 3516 struct S {}; 3517 class C {}; 3518 union U {}; 3519</pre></td></tr> 3520 3521 3522<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> 3523<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. 3524 3525Matches a node if it equals the node previously bound to ID. 3526 3527Given 3528 class X { int a; int b; }; 3529cxxRecordDecl( 3530 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3531 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3532 matches the class X, as a and b have the same type. 3533 3534Note that when multiple matches are involved via forEach* matchers, 3535equalsBoundNodes acts as a filter. 3536For example: 3537compoundStmt( 3538 forEachDescendant(varDecl().bind("d")), 3539 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3540will trigger a match for each combination of variable declaration 3541and reference to that variable declaration within a compound statement. 3542</pre></td></tr> 3543 3544 3545<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> 3546<tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. 3547 3548Stmt has pointer identity in the AST. 3549</pre></td></tr> 3550 3551 3552<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> 3553<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is 3554partially matching a given regex. 3555 3556Example matches Y but not X 3557 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 3558 #include "ASTMatcher.h" 3559 class X {}; 3560ASTMatcher.h: 3561 class Y {}; 3562 3563Usable 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>> 3564</pre></td></tr> 3565 3566 3567<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> 3568<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. 3569 3570Example matches X but not Y 3571 (matcher = cxxRecordDecl(isExpansionInMainFile()) 3572 #include <Y.h> 3573 class X {}; 3574Y.h: 3575 class Y {}; 3576 3577Usable 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>> 3578</pre></td></tr> 3579 3580 3581<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> 3582<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. 3583 3584Example matches Y but not X 3585 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 3586 #include <SystemHeader.h> 3587 class X {}; 3588SystemHeader.h: 3589 class Y {}; 3590 3591Usable 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>> 3592</pre></td></tr> 3593 3594 3595<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> 3596<tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size. 3597 3598Given 3599 int a[42]; 3600 int b[2 * 21]; 3601 int c[41], d[43]; 3602 char *s = "abcd"; 3603 wchar_t *ws = L"abcd"; 3604 char *w = "a"; 3605constantArrayType(hasSize(42)) 3606 matches "int a[42]" and "int b[2 * 21]" 3607stringLiteral(hasSize(4)) 3608 matches "abcd", L"abcd" 3609</pre></td></tr> 3610 3611 3612<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> 3613<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 3614 3615Example matches A, va, fa 3616 class A {}; 3617 class B; Doesn't match, as it has no body. 3618 int va; 3619 extern int vb; Doesn't match, as it doesn't define the variable. 3620 void fa() {} 3621 void fb(); Doesn't match, as it has no body. 3622 @interface X 3623 - (void)ma; Doesn't match, interface is declaration. 3624 @end 3625 @implementation X 3626 - (void)ma {} 3627 @end 3628 3629Usable 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>>, 3630 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 3631</pre></td></tr> 3632 3633 3634<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> 3635<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. 3636 3637Note that 'Value' is a string as the template argument's value is 3638an arbitrary precision integer. 'Value' must be euqal to the canonical 3639representation of that integral value in base 10. 3640 3641Given 3642 template<int T> struct C {}; 3643 C<42> c; 3644classTemplateSpecializationDecl( 3645 hasAnyTemplateArgument(equalsIntegralValue("42"))) 3646 matches the implicit instantiation of C in C<42>. 3647</pre></td></tr> 3648 3649 3650<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> 3651<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. 3652 3653Given 3654 template<int T> struct C {}; 3655 C<42> c; 3656classTemplateSpecializationDecl( 3657 hasAnyTemplateArgument(isIntegral())) 3658 matches the implicit instantiation of C in C<42> 3659 with isIntegral() matching 42. 3660</pre></td></tr> 3661 3662 3663<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> 3664<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. 3665 3666Given 3667 template<typename T> struct C {}; 3668 C<int> c; 3669classTemplateSpecializationDecl(templateArgumentCountIs(1)) 3670 matches C<int>. 3671</pre></td></tr> 3672 3673 3674<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> 3675<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is 3676partially matching a given regex. 3677 3678Example matches Y but not X 3679 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 3680 #include "ASTMatcher.h" 3681 class X {}; 3682ASTMatcher.h: 3683 class Y {}; 3684 3685Usable 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>> 3686</pre></td></tr> 3687 3688 3689<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> 3690<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. 3691 3692Example matches X but not Y 3693 (matcher = cxxRecordDecl(isExpansionInMainFile()) 3694 #include <Y.h> 3695 class X {}; 3696Y.h: 3697 class Y {}; 3698 3699Usable 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>> 3700</pre></td></tr> 3701 3702 3703<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> 3704<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. 3705 3706Example matches Y but not X 3707 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 3708 #include <SystemHeader.h> 3709 class X {}; 3710SystemHeader.h: 3711 class Y {}; 3712 3713Usable 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>> 3714</pre></td></tr> 3715 3716 3717<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> 3718<tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool. 3719 3720Given 3721 struct S { bool func(); }; 3722functionDecl(returns(booleanType())) 3723 matches "bool func();" 3724</pre></td></tr> 3725 3726 3727<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> 3728<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. 3729 3730Matches a node if it equals the node previously bound to ID. 3731 3732Given 3733 class X { int a; int b; }; 3734cxxRecordDecl( 3735 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3736 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3737 matches the class X, as a and b have the same type. 3738 3739Note that when multiple matches are involved via forEach* matchers, 3740equalsBoundNodes acts as a filter. 3741For example: 3742compoundStmt( 3743 forEachDescendant(varDecl().bind("d")), 3744 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3745will trigger a match for each combination of variable declaration 3746and reference to that variable declaration within a compound statement. 3747</pre></td></tr> 3748 3749 3750<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> 3751<tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node. 3752 3753Type has pointer identity in the AST. 3754</pre></td></tr> 3755 3756 3757<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> 3758<tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double). 3759 3760Given 3761 int i; 3762 float f; 3763realFloatingPointType() 3764 matches "float f" but not "int i" 3765</pre></td></tr> 3766 3767 3768<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> 3769<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. 3770 3771Given 3772 struct S { void func(); }; 3773functionDecl(returns(voidType())) 3774 matches "void func();" 3775</pre></td></tr> 3776 3777 3778<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> 3779<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 3780 3781Given 3782 int x; 3783 int s = sizeof(x) + alignof(x) 3784unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 3785 matches sizeof(x) 3786</pre></td></tr> 3787 3788 3789<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> 3790<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 3791unary). 3792 3793Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 3794 !(a || b) 3795</pre></td></tr> 3796 3797 3798<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> 3799<tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration. 3800 3801Example matches x, but not y, z, or a. 3802(matcher = varDecl(hasAutomaticStorageDuration()) 3803void f() { 3804 int x; 3805 static int y; 3806 thread_local int z; 3807} 3808int a; 3809</pre></td></tr> 3810 3811 3812<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> 3813<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. 3814 3815Example matches y and z (matcher = varDecl(hasGlobalStorage()) 3816void f() { 3817 int x; 3818 static int y; 3819} 3820int z; 3821</pre></td></tr> 3822 3823 3824<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasLocalStorage0')"><a name="hasLocalStorage0Anchor">hasLocalStorage</a></td><td></td></tr> 3825<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a 3826non-static local variable. 3827 3828Example matches x (matcher = varDecl(hasLocalStorage()) 3829void f() { 3830 int x; 3831 static int y; 3832} 3833int z; 3834</pre></td></tr> 3835 3836 3837<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> 3838<tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration. 3839It includes the variable declared at namespace scope and those declared 3840with "static" and "extern" storage class specifiers. 3841 3842void f() { 3843 int x; 3844 static int y; 3845 thread_local int z; 3846} 3847int a; 3848static int b; 3849extern int c; 3850varDecl(hasStaticStorageDuration()) 3851 matches the function declaration y, a, b and c. 3852</pre></td></tr> 3853 3854 3855<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasThreadStorageDuration0')"><a name="hasThreadStorageDuration0Anchor">hasThreadStorageDuration</a></td><td></td></tr> 3856<tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration. 3857 3858Example matches z, but not x, z, or a. 3859(matcher = varDecl(hasThreadStorageDuration()) 3860void f() { 3861 int x; 3862 static int y; 3863 thread_local int z; 3864} 3865int a; 3866</pre></td></tr> 3867 3868 3869<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> 3870<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations, 3871 and if constexpr. 3872 3873Given: 3874 constexpr int foo = 42; 3875 constexpr int bar(); 3876 void baz() { if constexpr(1 > 0) {} } 3877varDecl(isConstexpr()) 3878 matches the declaration of foo. 3879functionDecl(isConstexpr()) 3880 matches the declaration of bar. 3881ifStmt(isConstexpr()) 3882 matches the if statement in baz. 3883</pre></td></tr> 3884 3885 3886<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> 3887<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 3888 3889Example matches A, va, fa 3890 class A {}; 3891 class B; Doesn't match, as it has no body. 3892 int va; 3893 extern int vb; Doesn't match, as it doesn't define the variable. 3894 void fa() {} 3895 void fb(); Doesn't match, as it has no body. 3896 @interface X 3897 - (void)ma; Doesn't match, interface is declaration. 3898 @end 3899 @implementation X 3900 - (void)ma {} 3901 @end 3902 3903Usable 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>>, 3904 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 3905</pre></td></tr> 3906 3907 3908<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> 3909<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from 3910a C++ catch block, or an Objective-C statement. 3911 3912Example matches x (matcher = varDecl(isExceptionVariable()) 3913void f(int y) { 3914 try { 3915 } catch (int x) { 3916 } 3917} 3918</pre></td></tr> 3919 3920 3921<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization1')"><a name="isExplicitTemplateSpecialization1Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr> 3922<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 3923static member variable template instantiations. 3924 3925Given 3926 template<typename T> void A(T t) { } 3927 template<> void A(int N) { } 3928functionDecl(isExplicitTemplateSpecialization()) 3929 matches the specialization A<int>(). 3930 3931Usable 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>> 3932</pre></td></tr> 3933 3934 3935<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> 3936<tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations. 3937 3938Given: 3939 extern "C" void f() {} 3940 extern "C" { void g() {} } 3941 void h() {} 3942 extern "C" int x = 1; 3943 extern "C" int y = 2; 3944 int z = 3; 3945functionDecl(isExternC()) 3946 matches the declaration of f and g, but not the declaration of h. 3947varDecl(isExternC()) 3948 matches the declaration of x and y, but not the declaration of z. 3949</pre></td></tr> 3950 3951 3952<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> 3953<tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variablefunction declarations that have "static" storage 3954class specifier ("static" keyword) written in the source. 3955 3956Given: 3957 static void f() {} 3958 static int i = 0; 3959 extern int j; 3960 int k; 3961functionDecl(isStaticStorageClass()) 3962 matches the function declaration f. 3963varDecl(isStaticStorageClass()) 3964 matches the variable declaration i. 3965</pre></td></tr> 3966 3967 3968<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> 3969<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 3970member variable template instantiations. 3971 3972Given 3973 template <typename T> class X {}; class A {}; X<A> x; 3974or 3975 template <typename T> class X {}; class A {}; template class X<A>; 3976or 3977 template <typename T> class X {}; class A {}; extern template class X<A>; 3978cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 3979 matches the template instantiation of X<A>. 3980 3981But given 3982 template <typename T> class X {}; class A {}; 3983 template <> class X<A> {}; X<A> x; 3984cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 3985 does not match, as X<A> is an explicit template specialization. 3986 3987Usable 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>> 3988</pre></td></tr> 3989 3990 3991<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> 3992<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside 3993template instantiations. 3994 3995Given 3996 template<typename T> void A(T t) { T i; } 3997 A(0); 3998 A(0U); 3999functionDecl(isInstantiated()) 4000 matches 'A(int) {...};' and 'A(unsigned) {...}'. 4001</pre></td></tr> 4002 4003 4004<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> 4005<tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as 4006GNU's __null, C++11's nullptr, or C's NULL macro. 4007 4008Given: 4009 void *v1 = NULL; 4010 void *v2 = nullptr; 4011 void *v3 = __null; GNU extension 4012 char *cp = (char *)0; 4013 int *ip = 0; 4014 int i = 0; 4015expr(nullPointerConstant()) 4016 matches the initializer for v1, v2, v3, cp, and ip. Does not match the 4017 initializer for i. 4018</pre></td></tr> 4019 4020 4021<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> 4022<tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names. 4023 4024This matcher is only provided as a performance optimization of hasName. 4025 hasAnyName(a, b, c) 4026 is equivalent to, but faster than 4027 anyOf(hasName(a), hasName(b), hasName(c)) 4028</pre></td></tr> 4029 4030 4031<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> 4032<tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the 4033Selector.getAsString() 4034 4035 matcher = objCMessageExpr(hasSelector("methodA:", "methodB:")); 4036 matches both of the expressions below: 4037 [myObj methodA:argA]; 4038 [myObj methodB:argB]; 4039</pre></td></tr> 4040 4041 4042<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> 4043<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. 4044 4045Given 4046 int j; 4047 template<typename T> void A(T t) { T i; j += 42;} 4048 A(0); 4049 A(0U); 4050declStmt(isInTemplateInstantiation()) 4051 matches 'int i;' and 'unsigned i'. 4052unless(stmt(isInTemplateInstantiation())) 4053 will NOT match j += 42; as it's shared between the template definition and 4054 instantiation. 4055</pre></td></tr> 4056 4057<!--END_NARROWING_MATCHERS --> 4058</table> 4059 4060<!-- ======================================================================= --> 4061<h2 id="traversal-matchers">AST Traversal Matchers</h2> 4062<!-- ======================================================================= --> 4063 4064<p>Traversal matchers specify the relationship to other nodes that are 4065reachable from the current node.</p> 4066 4067<p>Note that there are special traversal matchers (has, hasDescendant, forEach and 4068forEachDescendant) which work on all nodes and allow users to write more generic 4069match expressions.</p> 4070 4071<table> 4072<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 4073<!-- START_TRAVERSAL_MATCHERS --> 4074 4075<tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 4076<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. 4077 4078Unlike anyOf, eachOf will generate a match result for each 4079matching submatcher. 4080 4081For example, in: 4082 class A { int a; int b; }; 4083The matcher: 4084 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), 4085 has(fieldDecl(hasName("b")).bind("v")))) 4086will generate two results binding "v", the first of which binds 4087the field declaration of a, the second the field declaration of 4088b. 4089 4090Usable as: Any Matcher 4091</pre></td></tr> 4092 4093 4094<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> 4095<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 4096provided matcher. 4097 4098Example matches X, A, A::X, B, B::C, B::C::X 4099 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) 4100 class X {}; 4101 class A { class X {}; }; Matches A, because A::X is a class of name 4102 X inside A. 4103 class B { class C { class X {}; }; }; 4104 4105DescendantT must be an AST base type. 4106 4107As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 4108each result that matches instead of only on the first one. 4109 4110Note: Recursively combined ForEachDescendant can cause many matches: 4111 cxxRecordDecl(forEachDescendant(cxxRecordDecl( 4112 forEachDescendant(cxxRecordDecl()) 4113 ))) 4114will match 10 times (plus injected class name matches) on: 4115 class A { class B { class C { class D { class E {}; }; }; }; }; 4116 4117Usable as: Any Matcher 4118</pre></td></tr> 4119 4120 4121<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> 4122<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 4123provided matcher. 4124 4125Example matches X, Y, Y::X, Z::Y, Z::Y::X 4126 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) 4127 class X {}; 4128 class Y { class X {}; }; Matches Y, because Y::X is a class of name X 4129 inside Y. 4130 class Z { class Y { class X {}; }; }; Does not match Z. 4131 4132ChildT must be an AST base type. 4133 4134As opposed to 'has', 'forEach' will cause a match for each result that 4135matches instead of only on the first one. 4136 4137Usable as: Any Matcher 4138</pre></td></tr> 4139 4140 4141<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> 4142<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 4143matcher. 4144 4145Given 4146void f() { if (true) { int x = 42; } } 4147void g() { for (;;) { int x = 43; } } 4148expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 4149 4150Usable as: Any Matcher 4151</pre></td></tr> 4152 4153 4154<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> 4155<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 4156provided matcher. 4157 4158Example matches X, Y, Z 4159 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) 4160 class X {}; Matches X, because X::X is a class of name X inside X. 4161 class Y { class X {}; }; 4162 class Z { class Y { class X {}; }; }; 4163 4164DescendantT must be an AST base type. 4165 4166Usable as: Any Matcher 4167</pre></td></tr> 4168 4169 4170<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> 4171<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 4172provided matcher. 4173 4174Example matches X, Y 4175 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) 4176 class X {}; Matches X, because X::X is a class of name X inside X. 4177 class Y { class X {}; }; 4178 class Z { class Y { class X {}; }; }; Does not match Z. 4179 4180ChildT must be an AST base type. 4181 4182Usable as: Any Matcher 4183Note that has is direct matcher, so it also matches things like implicit 4184casts and paren casts. If you are matching with expr then you should 4185probably consider using ignoringParenImpCasts like: 4186has(ignoringParenImpCasts(expr())). 4187</pre></td></tr> 4188 4189 4190<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> 4191<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 4192matcher. 4193 4194Given 4195void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 4196compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 4197 4198Usable as: Any Matcher 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('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> 4203<tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop, 4204switch statement or conditional operator. 4205 4206Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 4207 if (true) {} 4208</pre></td></tr> 4209 4210 4211<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> 4212<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator 4213(binary or ternary). 4214 4215Example matches b 4216 condition ? a : b 4217 condition ?: b 4218</pre></td></tr> 4219 4220 4221<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> 4222<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 4223 4224Example 1 (conditional ternary operator): matches a 4225 condition ? a : b 4226 4227Example 2 (conditional binary operator): matches opaqueValueExpr(condition) 4228 condition ?: b 4229</pre></td></tr> 4230 4231 4232<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> 4233<tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node 4234matches the given matcher. 4235 4236The associated declaration is: 4237- for type nodes, the declaration of the underlying type 4238- for CallExpr, the declaration of the callee 4239- for MemberExpr, the declaration of the referenced member 4240- for CXXConstructExpr, the declaration of the constructor 4241- for CXXNewExpr, the declaration of the operator new 4242 4243For type nodes, hasDeclaration will generally match the declaration of the 4244sugared type. Given 4245 class X {}; 4246 typedef X Y; 4247 Y y; 4248in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4249typedefDecl. A common use case is to match the underlying, desugared type. 4250This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4251 varDecl(hasType(hasUnqualifiedDesugaredType( 4252 recordType(hasDeclaration(decl()))))) 4253In this matcher, the decl will match the CXXRecordDecl of class X. 4254 4255Usable 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>>, 4256 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>>, 4257 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>>, 4258 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>>, 4259 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>>, 4260 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>>, 4261 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4262</pre></td></tr> 4263 4264 4265<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>></td><td class="name" onclick="toggle('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> 4266<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 4267 4268Given 4269 int i[5]; 4270 void f() { i[1] = 42; } 4271arraySubscriptExpression(hasBase(implicitCastExpr( 4272 hasSourceExpression(declRefExpr())))) 4273 matches i[1] with the declRefExpr() matching i 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('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> 4278<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 4279 4280Given 4281 int i[5]; 4282 void f() { i[1] = 42; } 4283arraySubscriptExpression(hasIndex(integerLiteral())) 4284 matches i[1] with the integerLiteral() matching 1 4285</pre></td></tr> 4286 4287 4288<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> 4289<tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions. 4290 4291Example matches a (matcher = binaryOperator(hasLHS())) 4292 a || b 4293</pre></td></tr> 4294 4295 4296<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> 4297<tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions. 4298 4299Example matches b (matcher = binaryOperator(hasRHS())) 4300 a || b 4301</pre></td></tr> 4302 4303 4304<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> 4305<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element 4306type. 4307 4308Given 4309 struct A {}; 4310 A a[7]; 4311 int b[7]; 4312arrayType(hasElementType(builtinType())) 4313 matches "int b[7]" 4314 4315Usable 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>> 4316</pre></td></tr> 4317 4318 4319<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> 4320<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element 4321type. 4322 4323Given 4324 struct A {}; 4325 A a[7]; 4326 int b[7]; 4327arrayType(hasElementType(builtinType())) 4328 matches "int b[7]" 4329 4330Usable 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>> 4331</pre></td></tr> 4332 4333 4334<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> 4335<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. 4336 4337Given 4338 _Atomic(int) i; 4339 _Atomic(float) f; 4340atomicType(hasValueType(isInteger())) 4341 matches "_Atomic(int) i" 4342 4343Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 4344</pre></td></tr> 4345 4346 4347<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> 4348<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. 4349 4350Given 4351 _Atomic(int) i; 4352 _Atomic(float) f; 4353atomicType(hasValueType(isInteger())) 4354 matches "_Atomic(int) i" 4355 4356Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 4357</pre></td></tr> 4358 4359 4360<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> 4361<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. 4362 4363Note: There is no TypeLoc for the deduced type and thus no 4364getDeducedLoc() matcher. 4365 4366Given 4367 auto a = 1; 4368 auto b = 2.0; 4369autoType(hasDeducedType(isInteger())) 4370 matches "auto a" 4371 4372Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> 4373</pre></td></tr> 4374 4375 4376<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> 4377<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 4378binary operator matches. 4379</pre></td></tr> 4380 4381 4382<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> 4383<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 4384 4385Example matches a (matcher = binaryOperator(hasLHS())) 4386 a || b 4387</pre></td></tr> 4388 4389 4390<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> 4391<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 4392 4393Example matches b (matcher = binaryOperator(hasRHS())) 4394 a || b 4395</pre></td></tr> 4396 4397 4398<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> 4399<tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a 4400block. 4401 4402Does not match the 'this' parameter of a method. 4403 4404Given 4405 class X { void f(int x, int y, int z) {} }; 4406cxxMethodDecl(hasAnyParameter(hasName("y"))) 4407 matches f(int x, int y, int z) {} 4408with hasAnyParameter(...) 4409 matching int y 4410 4411For ObjectiveC, given 4412 @interface I - (void) f:(int) y; @end 4413 4414the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 4415matches the declaration of method f with hasParameter 4416matching y. 4417 4418For blocks, given 4419 b = ^(int y) { printf("%d", y) }; 4420 4421the matcher blockDecl(hasAnyParameter(hasName("y"))) 4422matches the declaration of the block b with hasParameter 4423matching y. 4424</pre></td></tr> 4425 4426 4427<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> 4428<tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method 4429declaration or a block. 4430 4431Given 4432 class X { void f(int x) {} }; 4433cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 4434 matches f(int x) {} 4435with hasParameter(...) 4436 matching int x 4437 4438For ObjectiveC, given 4439 @interface I - (void) f:(int) y; @end 4440 4441the matcher objcMethodDecl(hasParameter(0, hasName("y"))) 4442matches the declaration of method f with hasParameter 4443matching y. 4444</pre></td></tr> 4445 4446 4447<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> 4448<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the 4449pointee matches a given matcher. 4450 4451Given 4452 int *a; 4453 int const *b; 4454 float const *f; 4455pointerType(pointee(isConstQualified(), isInteger())) 4456 matches "int const *b" 4457 4458Usable 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>>, 4459 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>> 4460</pre></td></tr> 4461 4462 4463<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> 4464<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the 4465pointee matches a given matcher. 4466 4467Given 4468 int *a; 4469 int const *b; 4470 float const *f; 4471pointerType(pointee(isConstQualified(), isInteger())) 4472 matches "int const *b" 4473 4474Usable 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>>, 4475 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>> 4476</pre></td></tr> 4477 4478 4479<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> 4480<tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl. 4481 4482Given 4483 void f(int i); 4484 int y; 4485 f(y); 4486callExpr( 4487 forEachArgumentWithParam( 4488 declRefExpr(to(varDecl(hasName("y")))), 4489 parmVarDecl(hasType(isInteger())) 4490)) 4491 matches f(y); 4492with declRefExpr(...) 4493 matching int y 4494and parmVarDecl(...) 4495 matching int i 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('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> 4500<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call 4501expression, or an ObjC-message-send expression. 4502 4503Given 4504 void x(int, int, int) { int y; x(1, y, 42); } 4505callExpr(hasAnyArgument(declRefExpr())) 4506 matches x(1, y, 42) 4507with hasAnyArgument(...) 4508 matching y 4509 4510For ObjectiveC, given 4511 @interface I - (void) f:(int) y; @end 4512 void foo(I *i) { [i f:12]; } 4513objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 4514 matches [i f:12] 4515</pre></td></tr> 4516 4517 4518<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> 4519<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor 4520call expression. 4521 4522Example matches y in x(y) 4523 (matcher = callExpr(hasArgument(0, declRefExpr()))) 4524 void x(int) { int y; x(y); } 4525</pre></td></tr> 4526 4527 4528<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> 4529<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node 4530matches the given matcher. 4531 4532The associated declaration is: 4533- for type nodes, the declaration of the underlying type 4534- for CallExpr, the declaration of the callee 4535- for MemberExpr, the declaration of the referenced member 4536- for CXXConstructExpr, the declaration of the constructor 4537- for CXXNewExpr, the declaration of the operator new 4538 4539For type nodes, hasDeclaration will generally match the declaration of the 4540sugared type. Given 4541 class X {}; 4542 typedef X Y; 4543 Y y; 4544in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4545typedefDecl. A common use case is to match the underlying, desugared type. 4546This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4547 varDecl(hasType(hasUnqualifiedDesugaredType( 4548 recordType(hasDeclaration(decl()))))) 4549In this matcher, the decl will match the CXXRecordDecl of class X. 4550 4551Usable 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>>, 4552 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>>, 4553 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>>, 4554 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>>, 4555 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>>, 4556 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>>, 4557 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4558</pre></td></tr> 4559 4560 4561<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> 4562<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. 4563 4564Given 4565 class A { A() : i(42), j(42) {} int i; int j; }; 4566cxxConstructorDecl(forEachConstructorInitializer( 4567 forField(decl().bind("x")) 4568)) 4569 will trigger two matches, binding for 'i' and 'j' respectively. 4570</pre></td></tr> 4571 4572 4573<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> 4574<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 4575 4576Given 4577 struct Foo { 4578 Foo() : foo_(1) { } 4579 int foo_; 4580 }; 4581cxxRecordDecl(has(cxxConstructorDecl( 4582 hasAnyConstructorInitializer(anything()) 4583))) 4584 record matches Foo, hasAnyConstructorInitializer matches foo_(1) 4585</pre></td></tr> 4586 4587 4588<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> 4589<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 4590 4591Given 4592 struct Foo { 4593 Foo() : foo_(1) { } 4594 int foo_; 4595 }; 4596cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 4597 forField(hasName("foo_")))))) 4598 matches Foo 4599with forField matching foo_ 4600</pre></td></tr> 4601 4602 4603<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> 4604<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 4605 4606Given 4607 struct Foo { 4608 Foo() : foo_(1) { } 4609 int foo_; 4610 }; 4611cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 4612 withInitializer(integerLiteral(equals(1))))))) 4613 matches Foo 4614with withInitializer matching (1) 4615</pre></td></tr> 4616 4617 4618<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> 4619<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'do while' statement or a function 4620definition that has a given body. 4621 4622Given 4623 for (;;) {} 4624hasBody(compoundStmt()) 4625 matches 'for (;;) {}' 4626with compoundStmt() 4627 matching '{}' 4628</pre></td></tr> 4629 4630 4631<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> 4632<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. 4633 4634Example: 4635 forStmt(hasLoopVariable(anything())) 4636matches 'int x' in 4637 for (int x : a) { } 4638</pre></td></tr> 4639 4640 4641<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> 4642<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. 4643 4644Example: 4645 forStmt(hasRangeInit(anything())) 4646matches 'a' in 4647 for (int x : a) { } 4648</pre></td></tr> 4649 4650 4651<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> 4652<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> 4653 4654 4655<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> 4656<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. 4657 4658Example matches y.x() 4659 (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))) 4660 class Y { public: void x(); }; 4661 void z() { Y y; y.x(); } 4662 4663FIXME: Overload to allow directly matching types? 4664</pre></td></tr> 4665 4666 4667<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> 4668<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 4669</pre></td></tr> 4670 4671 4672<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> 4673<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified 4674matcher, or is a pointer to a type that matches the InnerMatcher. 4675</pre></td></tr> 4676 4677 4678<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> 4679<tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may 4680produce multiple matches. 4681 4682Given 4683 class A { virtual void f(); }; 4684 class B : public A { void f(); }; 4685 class C : public B { void f(); }; 4686cxxMethodDecl(ofClass(hasName("C")), 4687 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") 4688 matches once, with "b" binding "A::f" and "d" binding "C::f" (Note 4689 that B::f is not overridden by C::f). 4690 4691The check can produce multiple matches in case of multiple inheritance, e.g. 4692 class A1 { virtual void f(); }; 4693 class A2 { virtual void f(); }; 4694 class C : public A1, public A2 { void f(); }; 4695cxxMethodDecl(ofClass(hasName("C")), 4696 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") 4697 matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and 4698 once with "b" binding "A2::f" and "d" binding "C::f". 4699</pre></td></tr> 4700 4701 4702<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> 4703<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 4704belongs to. 4705 4706FIXME: Generalize this for other kinds of declarations. 4707FIXME: What other kind of declarations would we need to generalize 4708this to? 4709 4710Example matches A() in the last line 4711 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( 4712 ofClass(hasName("A")))))) 4713 class A { 4714 public: 4715 A(); 4716 }; 4717 A a = A(); 4718</pre></td></tr> 4719 4720 4721<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> 4722<tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size. 4723 4724Given: 4725 MyClass *p1 = new MyClass[10]; 4726cxxNewExpr(hasArraySize(intgerLiteral(equals(10)))) 4727 matches the expression 'new MyClass[10]'. 4728</pre></td></tr> 4729 4730 4731<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> 4732<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node 4733matches the given matcher. 4734 4735The associated declaration is: 4736- for type nodes, the declaration of the underlying type 4737- for CallExpr, the declaration of the callee 4738- for MemberExpr, the declaration of the referenced member 4739- for CXXConstructExpr, the declaration of the constructor 4740- for CXXNewExpr, the declaration of the operator new 4741 4742For type nodes, hasDeclaration will generally match the declaration of the 4743sugared type. Given 4744 class X {}; 4745 typedef X Y; 4746 Y y; 4747in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4748typedefDecl. A common use case is to match the underlying, desugared type. 4749This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4750 varDecl(hasType(hasUnqualifiedDesugaredType( 4751 recordType(hasDeclaration(decl()))))) 4752In this matcher, the decl will match the CXXRecordDecl of class X. 4753 4754Usable 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>>, 4755 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>>, 4756 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>>, 4757 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>>, 4758 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>>, 4759 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>>, 4760 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4761</pre></td></tr> 4762 4763 4764<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> 4765<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. 4766 4767Given: 4768 class A { void func(); }; 4769 class B { void member(); }; 4770 4771cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of 4772A but not B. 4773</pre></td></tr> 4774 4775 4776<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> 4777<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from 4778a class matching Base. 4779 4780Note that a class is not considered to be derived from itself. 4781 4782Example matches Y, Z, C (Base == hasName("X")) 4783 class X; 4784 class Y : public X {}; directly derived 4785 class Z : public Y {}; indirectly derived 4786 typedef X A; 4787 typedef A B; 4788 class C : public B {}; derived from a typedef of X 4789 4790In the following example, Bar matches isDerivedFrom(hasName("X")): 4791 class Foo; 4792 typedef Foo X; 4793 class Bar : public Foo {}; derived from a type that X is a typedef of 4794</pre></td></tr> 4795 4796 4797<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> 4798<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 4799match Base. 4800</pre></td></tr> 4801 4802 4803<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> 4804<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the 4805given matcher. 4806 4807Example matches y.x() (matcher = callExpr(callee( 4808 cxxMethodDecl(hasName("x"))))) 4809 class Y { public: void x(); }; 4810 void z() { Y y; y.x(); } 4811</pre></td></tr> 4812 4813 4814<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> 4815<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. 4816 4817Given 4818 class Y { void x() { this->x(); x(); Y y; y.x(); } }; 4819 void f() { f(); } 4820callExpr(callee(expr())) 4821 matches this->x(), x(), y.x(), f() 4822with callee(...) 4823 matching this->x, x, y.x, f respectively 4824 4825Note: Callee cannot take the more general internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> 4826because this introduces ambiguous overloads with calls to Callee taking a 4827internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely 4828implemented in terms of implicit casts. 4829</pre></td></tr> 4830 4831 4832<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('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> 4833<tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl. 4834 4835Given 4836 void f(int i); 4837 int y; 4838 f(y); 4839callExpr( 4840 forEachArgumentWithParam( 4841 declRefExpr(to(varDecl(hasName("y")))), 4842 parmVarDecl(hasType(isInteger())) 4843)) 4844 matches f(y); 4845with declRefExpr(...) 4846 matching int y 4847and parmVarDecl(...) 4848 matching int i 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('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> 4853<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 4854expression, or an ObjC-message-send expression. 4855 4856Given 4857 void x(int, int, int) { int y; x(1, y, 42); } 4858callExpr(hasAnyArgument(declRefExpr())) 4859 matches x(1, y, 42) 4860with hasAnyArgument(...) 4861 matching y 4862 4863For ObjectiveC, given 4864 @interface I - (void) f:(int) y; @end 4865 void foo(I *i) { [i f:12]; } 4866objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 4867 matches [i f:12] 4868</pre></td></tr> 4869 4870 4871<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> 4872<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 4873call expression. 4874 4875Example matches y in x(y) 4876 (matcher = callExpr(hasArgument(0, declRefExpr()))) 4877 void x(int) { int y; x(y); } 4878</pre></td></tr> 4879 4880 4881<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('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> 4882<tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node 4883matches the given matcher. 4884 4885The associated declaration is: 4886- for type nodes, the declaration of the underlying type 4887- for CallExpr, the declaration of the callee 4888- for MemberExpr, the declaration of the referenced member 4889- for CXXConstructExpr, the declaration of the constructor 4890- for CXXNewExpr, the declaration of the operator new 4891 4892For type nodes, hasDeclaration will generally match the declaration of the 4893sugared type. Given 4894 class X {}; 4895 typedef X Y; 4896 Y y; 4897in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4898typedefDecl. A common use case is to match the underlying, desugared type. 4899This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4900 varDecl(hasType(hasUnqualifiedDesugaredType( 4901 recordType(hasDeclaration(decl()))))) 4902In this matcher, the decl will match the CXXRecordDecl of class X. 4903 4904Usable 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>>, 4905 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>>, 4906 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>>, 4907 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>>, 4908 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>>, 4909 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>>, 4910 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4911</pre></td></tr> 4912 4913 4914<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> 4915<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range 4916extension, matches the constant given in the statement. 4917 4918Given 4919 switch (1) { case 1: case 1+1: case 3 ... 4: ; } 4920caseStmt(hasCaseConstant(integerLiteral())) 4921 matches "case 1:" 4922</pre></td></tr> 4923 4924 4925<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> 4926<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression 4927or opaque value's source expression matches the given matcher. 4928 4929Example 1: matches "a string" 4930(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) 4931class URL { URL(string); }; 4932URL url = "a string"; 4933 4934Example 2: matches 'b' (matcher = 4935opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) 4936int a = b ?: 1; 4937</pre></td></tr> 4938 4939 4940<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> 4941<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and 4942functionDecl that have at least one TemplateArgument matching the given 4943InnerMatcher. 4944 4945Given 4946 template<typename T> class A {}; 4947 template<> class A<double> {}; 4948 A<int> a; 4949 4950 template<typename T> f() {}; 4951 void func() { f<int>(); }; 4952 4953classTemplateSpecializationDecl(hasAnyTemplateArgument( 4954 refersToType(asString("int")))) 4955 matches the specialization A<int> 4956 4957functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 4958 matches the specialization f<int> 4959</pre></td></tr> 4960 4961 4962<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> 4963<tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration. 4964 4965Given 4966 tempalate<typename T> class A {}; 4967 typedef A<int> B; 4968classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl())) 4969 matches 'B' with classTemplateDecl() matching the class template 4970 declaration of 'A'. 4971</pre></td></tr> 4972 4973 4974<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> 4975<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and 4976functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 4977 4978Given 4979 template<typename T, typename U> class A {}; 4980 A<bool, int> b; 4981 A<int, bool> c; 4982 4983 template<typename T> void f() {} 4984 void func() { f<int>(); }; 4985classTemplateSpecializationDecl(hasTemplateArgument( 4986 1, refersToType(asString("int")))) 4987 matches the specialization A<bool, int> 4988 4989functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 4990 matches the specialization f<int> 4991</pre></td></tr> 4992 4993 4994<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> 4995<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element 4996type. 4997 4998Given 4999 struct A {}; 5000 A a[7]; 5001 int b[7]; 5002arrayType(hasElementType(builtinType())) 5003 matches "int b[7]" 5004 5005Usable 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>> 5006</pre></td></tr> 5007 5008 5009<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> 5010<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element 5011type. 5012 5013Given 5014 struct A {}; 5015 A a[7]; 5016 int b[7]; 5017arrayType(hasElementType(builtinType())) 5018 matches "int b[7]" 5019 5020Usable 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>> 5021</pre></td></tr> 5022 5023 5024<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> 5025<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 5026a given matcher. Also matches StmtExprs that have CompoundStmt as children. 5027 5028Given 5029 { {}; 1+2; } 5030hasAnySubstatement(compoundStmt()) 5031 matches '{ {}; 1+2; }' 5032with compoundStmt() 5033 matching '{}' 5034</pre></td></tr> 5035 5036 5037<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> 5038<tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whos decayed type matches InnerMatcher 5039</pre></td></tr> 5040 5041 5042<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> 5043<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node 5044matches the given matcher. 5045 5046The associated declaration is: 5047- for type nodes, the declaration of the underlying type 5048- for CallExpr, the declaration of the callee 5049- for MemberExpr, the declaration of the referenced member 5050- for CXXConstructExpr, the declaration of the constructor 5051- for CXXNewExpr, the declaration of the operator new 5052 5053For type nodes, hasDeclaration will generally match the declaration of the 5054sugared type. Given 5055 class X {}; 5056 typedef X Y; 5057 Y y; 5058in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5059typedefDecl. A common use case is to match the underlying, desugared type. 5060This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5061 varDecl(hasType(hasUnqualifiedDesugaredType( 5062 recordType(hasDeclaration(decl()))))) 5063In this matcher, the decl will match the CXXRecordDecl of class X. 5064 5065Usable 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>>, 5066 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>>, 5067 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>>, 5068 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>>, 5069 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>>, 5070 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>>, 5071 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5072</pre></td></tr> 5073 5074 5075<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> 5076<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a 5077specific using shadow declaration. 5078 5079Given 5080 namespace a { void f() {} } 5081 using a::f; 5082 void g() { 5083 f(); Matches this .. 5084 a::f(); .. but not this. 5085 } 5086declRefExpr(throughUsingDecl(anything())) 5087 matches f() 5088</pre></td></tr> 5089 5090 5091<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> 5092<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 5093specified matcher. 5094 5095Example matches x in if(x) 5096 (matcher = declRefExpr(to(varDecl(hasName("x"))))) 5097 bool x; 5098 if (x) {} 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('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> 5103<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 5104 5105Note that this does not work for global declarations because the AST 5106breaks up multiple-declaration DeclStmt's into multiple single-declaration 5107DeclStmt's. 5108Example: Given non-global declarations 5109 int a, b = 0; 5110 int c; 5111 int d = 2, e; 5112declStmt(containsDeclaration( 5113 0, varDecl(hasInitializer(anything())))) 5114 matches only 'int d = 2, e;', and 5115declStmt(containsDeclaration(1, varDecl())) 5116 matches 'int a, b = 0' as well as 'int d = 2, e;' 5117 but 'int c;' is not matched. 5118</pre></td></tr> 5119 5120 5121<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> 5122<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 5123 5124Given 5125 int a, b; 5126 int c; 5127declStmt(hasSingleDecl(anything())) 5128 matches 'int c;' but not 'int a, b;'. 5129</pre></td></tr> 5130 5131 5132<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> 5133<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches 5134the inner matcher. 5135 5136Given 5137 int x; 5138declaratorDecl(hasTypeLoc(loc(asString("int")))) 5139 matches int x 5140</pre></td></tr> 5141 5142 5143<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> 5144<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a 5145Decl, matches InnerMatcher. 5146 5147Given 5148 namespace N { 5149 namespace M { 5150 class D {}; 5151 } 5152 } 5153 5154cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the 5155declaration of class D. 5156</pre></td></tr> 5157 5158 5159<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> 5160<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'do while' statement or a function 5161definition that has a given body. 5162 5163Given 5164 for (;;) {} 5165hasBody(compoundStmt()) 5166 matches 'for (;;) {}' 5167with compoundStmt() 5168 matching '{}' 5169</pre></td></tr> 5170 5171 5172<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> 5173<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 5174switch statement or conditional operator. 5175 5176Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5177 if (true) {} 5178</pre></td></tr> 5179 5180 5181<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> 5182<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, 5183matches InnerMatcher if the qualifier exists. 5184 5185Given 5186 namespace N { 5187 namespace M { 5188 class D {}; 5189 } 5190 } 5191 N::M::D d; 5192 5193elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) 5194matches the type of the variable declaration of d. 5195</pre></td></tr> 5196 5197 5198<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> 5199<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. 5200 5201Given 5202 namespace N { 5203 namespace M { 5204 class D {}; 5205 } 5206 } 5207 N::M::D d; 5208 5209elaboratedType(namesType(recordType( 5210hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable 5211declaration of d. 5212</pre></td></tr> 5213 5214 5215<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> 5216<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node 5217matches the given matcher. 5218 5219The associated declaration is: 5220- for type nodes, the declaration of the underlying type 5221- for CallExpr, the declaration of the callee 5222- for MemberExpr, the declaration of the referenced member 5223- for CXXConstructExpr, the declaration of the constructor 5224- for CXXNewExpr, the declaration of the operator new 5225 5226For type nodes, hasDeclaration will generally match the declaration of the 5227sugared type. Given 5228 class X {}; 5229 typedef X Y; 5230 Y y; 5231in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5232typedefDecl. A common use case is to match the underlying, desugared type. 5233This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5234 varDecl(hasType(hasUnqualifiedDesugaredType( 5235 recordType(hasDeclaration(decl()))))) 5236In this matcher, the decl will match the CXXRecordDecl of class X. 5237 5238Usable 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>>, 5239 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>>, 5240 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>>, 5241 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>>, 5242 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>>, 5243 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>>, 5244 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5245</pre></td></tr> 5246 5247 5248<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> 5249<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 5250 5251(Note: Clang's AST refers to other conversions as "casts" too, and calls 5252actual casts "explicit" casts.) 5253</pre></td></tr> 5254 5255 5256<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> 5257<tr><td colspan="4" class="doc" id="hasType4"><pre>Overloaded to match the declaration of the expression's or value 5258declaration's type. 5259 5260In case of a value declaration (for example a variable declaration), 5261this resolves one layer of indirection. For example, in the value 5262declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 5263X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 5264declaration of x. 5265 5266Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 5267 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 5268 and friend class X (matcher = friendDecl(hasType("X")) 5269 class X {}; 5270 void y(X &x) { x; X z; } 5271 class Y { friend class X; }; 5272 5273Usable 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>> 5274</pre></td></tr> 5275 5276 5277<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> 5278<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type 5279matcher. 5280 5281Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 5282 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 5283 and U (matcher = typedefDecl(hasType(asString("int"))) 5284 and friend class X (matcher = friendDecl(hasType("X")) 5285 class X {}; 5286 void y(X &x) { x; X z; } 5287 typedef int U; 5288 class Y { friend class X; }; 5289</pre></td></tr> 5290 5291 5292<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> 5293<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 5294are stripped off. 5295 5296Parentheses and explicit casts are not discarded. 5297Given 5298 int arr[5]; 5299 int a = 0; 5300 char b = 0; 5301 const int c = a; 5302 int *d = arr; 5303 long e = (long) 0l; 5304The matchers 5305 varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 5306 varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 5307would match the declarations for a, b, c, and d, but not e. 5308While 5309 varDecl(hasInitializer(integerLiteral())) 5310 varDecl(hasInitializer(declRefExpr())) 5311only match the declarations for b, c, and d. 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('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> 5316<tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST 5317nodes are stripped off. 5318 5319Parentheses and explicit casts are not discarded. 5320Given 5321 class C {}; 5322 C a = C(); 5323 C b; 5324 C c = b; 5325The matchers 5326 varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr()))) 5327would match the declarations for a, b, and c. 5328While 5329 varDecl(hasInitializer(cxxConstructExpr())) 5330only match the declarations for b and c. 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('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> 5335<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 5336casts are stripped off. 5337 5338Implicit and non-C Style casts are also discarded. 5339Given 5340 int a = 0; 5341 char b = (0); 5342 void* c = reinterpret_cast<char*>(0); 5343 char d = char(0); 5344The matcher 5345 varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 5346would match the declarations for a, b, c, and d. 5347while 5348 varDecl(hasInitializer(integerLiteral())) 5349only match the declaration for a. 5350</pre></td></tr> 5351 5352 5353<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> 5354<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 5355parentheses are stripped off. 5356 5357Explicit casts are not discarded. 5358Given 5359 int arr[5]; 5360 int a = 0; 5361 char b = (0); 5362 const int c = a; 5363 int *d = (arr); 5364 long e = ((long) 0l); 5365The matchers 5366 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 5367 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 5368would match the declarations for a, b, c, and d, but not e. 5369while 5370 varDecl(hasInitializer(integerLiteral())) 5371 varDecl(hasInitializer(declRefExpr())) 5372would only match the declaration for a. 5373</pre></td></tr> 5374 5375 5376<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> 5377<tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer. 5378 5379Given 5380 class C { 5381 int a = 2; 5382 int b = 3; 5383 int c; 5384 }; 5385fieldDecl(hasInClassInitializer(integerLiteral(equals(2)))) 5386 matches 'int a;' but not 'int b;'. 5387fieldDecl(hasInClassInitializer(anything())) 5388 matches 'int a;' and 'int b;' but not 'int c;'. 5389</pre></td></tr> 5390 5391 5392<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> 5393<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'do while' statement or a function 5394definition that has a given body. 5395 5396Given 5397 for (;;) {} 5398hasBody(compoundStmt()) 5399 matches 'for (;;) {}' 5400with compoundStmt() 5401 matching '{}' 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('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> 5406<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 5407switch statement or conditional operator. 5408 5409Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5410 if (true) {} 5411</pre></td></tr> 5412 5413 5414<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> 5415<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 5416 5417Example: 5418 forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 5419matches '++x' in 5420 for (x; x < N; ++x) { } 5421</pre></td></tr> 5422 5423 5424<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> 5425<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 5426 5427Example: 5428 forStmt(hasLoopInit(declStmt())) 5429matches 'int x = 0' in 5430 for (int x = 0; x < N; ++x) { } 5431</pre></td></tr> 5432 5433 5434<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> 5435<tr><td colspan="4" class="doc" id="hasType5"><pre>Overloaded to match the declaration of the expression's or value 5436declaration's type. 5437 5438In case of a value declaration (for example a variable declaration), 5439this resolves one layer of indirection. For example, in the value 5440declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 5441X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 5442declaration of x. 5443 5444Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 5445 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 5446 and friend class X (matcher = friendDecl(hasType("X")) 5447 class X {}; 5448 void y(X &x) { x; X z; } 5449 class Y { friend class X; }; 5450 5451Usable 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>> 5452</pre></td></tr> 5453 5454 5455<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> 5456<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type 5457matcher. 5458 5459Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 5460 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 5461 and U (matcher = typedefDecl(hasType(asString("int"))) 5462 and friend class X (matcher = friendDecl(hasType("X")) 5463 class X {}; 5464 void y(X &x) { x; X z; } 5465 typedef int U; 5466 class Y { friend class X; }; 5467</pre></td></tr> 5468 5469 5470<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> 5471<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a 5472block. 5473 5474Does not match the 'this' parameter of a method. 5475 5476Given 5477 class X { void f(int x, int y, int z) {} }; 5478cxxMethodDecl(hasAnyParameter(hasName("y"))) 5479 matches f(int x, int y, int z) {} 5480with hasAnyParameter(...) 5481 matching int y 5482 5483For ObjectiveC, given 5484 @interface I - (void) f:(int) y; @end 5485 5486the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 5487matches the declaration of method f with hasParameter 5488matching y. 5489 5490For blocks, given 5491 b = ^(int y) { printf("%d", y) }; 5492 5493the matcher blockDecl(hasAnyParameter(hasName("y"))) 5494matches the declaration of the block b with hasParameter 5495matching y. 5496</pre></td></tr> 5497 5498 5499<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> 5500<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and 5501functionDecl that have at least one TemplateArgument matching the given 5502InnerMatcher. 5503 5504Given 5505 template<typename T> class A {}; 5506 template<> class A<double> {}; 5507 A<int> a; 5508 5509 template<typename T> f() {}; 5510 void func() { f<int>(); }; 5511 5512classTemplateSpecializationDecl(hasAnyTemplateArgument( 5513 refersToType(asString("int")))) 5514 matches the specialization A<int> 5515 5516functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 5517 matches the specialization f<int> 5518</pre></td></tr> 5519 5520 5521<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> 5522<tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'do while' statement or a function 5523definition that has a given body. 5524 5525Given 5526 for (;;) {} 5527hasBody(compoundStmt()) 5528 matches 'for (;;) {}' 5529with compoundStmt() 5530 matching '{}' 5531</pre></td></tr> 5532 5533 5534<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> 5535<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method 5536declaration or a block. 5537 5538Given 5539 class X { void f(int x) {} }; 5540cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 5541 matches f(int x) {} 5542with hasParameter(...) 5543 matching int x 5544 5545For ObjectiveC, given 5546 @interface I - (void) f:(int) y; @end 5547 5548the matcher objcMethodDecl(hasParameter(0, hasName("y"))) 5549matches the declaration of method f with hasParameter 5550matching y. 5551</pre></td></tr> 5552 5553 5554<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> 5555<tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and 5556functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 5557 5558Given 5559 template<typename T, typename U> class A {}; 5560 A<bool, int> b; 5561 A<int, bool> c; 5562 5563 template<typename T> void f() {} 5564 void func() { f<int>(); }; 5565classTemplateSpecializationDecl(hasTemplateArgument( 5566 1, refersToType(asString("int")))) 5567 matches the specialization A<bool, int> 5568 5569functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 5570 matches the specialization f<int> 5571</pre></td></tr> 5572 5573 5574<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> 5575<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 5576 5577Given: 5578 class X { int f() { return 1; } }; 5579cxxMethodDecl(returns(asString("int"))) 5580 matches int f() { return 1; } 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('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> 5585<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 5586switch statement or conditional operator. 5587 5588Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5589 if (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('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> 5594<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 5595 5596Given 5597 if (A* a = GetAPointer()) {} 5598hasConditionVariableStatement(...) 5599 matches 'A* a = GetAPointer()'. 5600</pre></td></tr> 5601 5602 5603<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> 5604<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. 5605 5606Examples matches the if statement 5607 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) 5608 if (false) false; else true; 5609</pre></td></tr> 5610 5611 5612<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> 5613<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. 5614 5615Examples matches the if statement 5616 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) 5617 if (false) true; else false; 5618</pre></td></tr> 5619 5620 5621<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> 5622<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 5623matcher. 5624 5625FIXME: Unit test this matcher 5626</pre></td></tr> 5627 5628 5629<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> 5630<tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions 5631(if expression have it). 5632</pre></td></tr> 5633 5634 5635<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> 5636<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node 5637matches the given matcher. 5638 5639The associated declaration is: 5640- for type nodes, the declaration of the underlying type 5641- for CallExpr, the declaration of the callee 5642- for MemberExpr, the declaration of the referenced member 5643- for CXXConstructExpr, the declaration of the constructor 5644- for CXXNewExpr, the declaration of the operator new 5645 5646For type nodes, hasDeclaration will generally match the declaration of the 5647sugared type. Given 5648 class X {}; 5649 typedef X Y; 5650 Y y; 5651in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5652typedefDecl. A common use case is to match the underlying, desugared type. 5653This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5654 varDecl(hasType(hasUnqualifiedDesugaredType( 5655 recordType(hasDeclaration(decl()))))) 5656In this matcher, the decl will match the CXXRecordDecl of class X. 5657 5658Usable 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>>, 5659 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>>, 5660 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>>, 5661 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>>, 5662 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>>, 5663 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>>, 5664 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5665</pre></td></tr> 5666 5667 5668<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> 5669<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node 5670matches the given matcher. 5671 5672The associated declaration is: 5673- for type nodes, the declaration of the underlying type 5674- for CallExpr, the declaration of the callee 5675- for MemberExpr, the declaration of the referenced member 5676- for CXXConstructExpr, the declaration of the constructor 5677- for CXXNewExpr, the declaration of the operator new 5678 5679For type nodes, hasDeclaration will generally match the declaration of the 5680sugared type. Given 5681 class X {}; 5682 typedef X Y; 5683 Y y; 5684in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5685typedefDecl. A common use case is to match the underlying, desugared type. 5686This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5687 varDecl(hasType(hasUnqualifiedDesugaredType( 5688 recordType(hasDeclaration(decl()))))) 5689In this matcher, the decl will match the CXXRecordDecl of class X. 5690 5691Usable 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>>, 5692 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>>, 5693 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>>, 5694 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>>, 5695 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>>, 5696 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>>, 5697 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5698</pre></td></tr> 5699 5700 5701<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> 5702<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node 5703matches the given matcher. 5704 5705The associated declaration is: 5706- for type nodes, the declaration of the underlying type 5707- for CallExpr, the declaration of the callee 5708- for MemberExpr, the declaration of the referenced member 5709- for CXXConstructExpr, the declaration of the constructor 5710- for CXXNewExpr, the declaration of the operator new 5711 5712For type nodes, hasDeclaration will generally match the declaration of the 5713sugared type. Given 5714 class X {}; 5715 typedef X Y; 5716 Y y; 5717in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5718typedefDecl. A common use case is to match the underlying, desugared type. 5719This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5720 varDecl(hasType(hasUnqualifiedDesugaredType( 5721 recordType(hasDeclaration(decl()))))) 5722In this matcher, the decl will match the CXXRecordDecl of class X. 5723 5724Usable 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>>, 5725 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>>, 5726 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>>, 5727 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>>, 5728 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>>, 5729 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>>, 5730 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5731</pre></td></tr> 5732 5733 5734<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> 5735<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is 5736matched by a given matcher. 5737 5738Given 5739 struct X { int m; }; 5740 void f(X x) { x.m; m; } 5741memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))))) 5742 matches "x.m" and "m" 5743with hasObjectExpression(...) 5744 matching "x" and the implicit object expression of "m" which has type X*. 5745</pre></td></tr> 5746 5747 5748<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('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> 5749<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 5750given matcher. 5751 5752Given 5753 struct { int first, second; } first, second; 5754 int i(second.first); 5755 int j(first.second); 5756memberExpr(member(hasName("first"))) 5757 matches second.first 5758 but not first.second (because the member name there is "second"). 5759</pre></td></tr> 5760 5761 5762<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> 5763<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the 5764pointee matches a given matcher. 5765 5766Given 5767 int *a; 5768 int const *b; 5769 float const *f; 5770pointerType(pointee(isConstQualified(), isInteger())) 5771 matches "int const *b" 5772 5773Usable 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>>, 5774 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>> 5775</pre></td></tr> 5776 5777 5778<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> 5779<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the 5780pointee matches a given matcher. 5781 5782Given 5783 int *a; 5784 int const *b; 5785 float const *f; 5786pointerType(pointee(isConstQualified(), isInteger())) 5787 matches "int const *b" 5788 5789Usable 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>>, 5790 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>> 5791</pre></td></tr> 5792 5793 5794<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> 5795<tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given 5796matcher. 5797 5798Given 5799 namespace N { template<class T> void f(T t); } 5800 template <class T> void g() { using N::f; f(T()); } 5801unresolvedLookupExpr(hasAnyDeclaration( 5802 namedDecl(hasUnderlyingDecl(hasName("::N::f"))))) 5803 matches the use of f in g() . 5804</pre></td></tr> 5805 5806 5807<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> 5808<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 5809 5810Given 5811 struct A { struct B { struct C {}; }; }; 5812 A::B::C c; 5813nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 5814 matches "A::" 5815</pre></td></tr> 5816 5817 5818<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> 5819<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 5820given TypeLoc. 5821 5822Given 5823 struct A { struct B { struct C {}; }; }; 5824 A::B::C c; 5825nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 5826 hasDeclaration(cxxRecordDecl(hasName("A"))))))) 5827 matches "A::" 5828</pre></td></tr> 5829 5830 5831<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> 5832<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 5833 5834Given 5835 struct A { struct B { struct C {}; }; }; 5836 A::B::C c; 5837nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 5838 matches "A::" 5839</pre></td></tr> 5840 5841 5842<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> 5843<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 5844given namespace matcher. 5845 5846Given 5847 namespace ns { struct A {}; } 5848 ns::A a; 5849nestedNameSpecifier(specifiesNamespace(hasName("ns"))) 5850 matches "ns::" 5851</pre></td></tr> 5852 5853 5854<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> 5855<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 5856given QualType matcher without qualifiers. 5857 5858Given 5859 struct A { struct B { struct C {}; }; }; 5860 A::B::C c; 5861nestedNameSpecifier(specifiesType( 5862 hasDeclaration(cxxRecordDecl(hasName("A"))) 5863)) 5864 matches "A::" 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('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> 5869<tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call 5870expression, or an ObjC-message-send expression. 5871 5872Given 5873 void x(int, int, int) { int y; x(1, y, 42); } 5874callExpr(hasAnyArgument(declRefExpr())) 5875 matches x(1, y, 42) 5876with hasAnyArgument(...) 5877 matching y 5878 5879For ObjectiveC, given 5880 @interface I - (void) f:(int) y; @end 5881 void foo(I *i) { [i f:12]; } 5882objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 5883 matches [i f:12] 5884</pre></td></tr> 5885 5886 5887<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> 5888<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor 5889call expression. 5890 5891Example matches y in x(y) 5892 (matcher = callExpr(hasArgument(0, declRefExpr()))) 5893 void x(int) { int y; x(y); } 5894</pre></td></tr> 5895 5896 5897<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasReceiver0')"><a name="hasReceiver0Anchor">hasReceiver</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 5898<tr><td colspan="4" class="doc" id="hasReceiver0"><pre>Matches if the Objective-C message is sent to an instance, 5899and the inner matcher matches on that instance. 5900 5901For example the method call in 5902 NSString *x = @"hello"; 5903 [x containsString:@"h"]; 5904is matched by 5905objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x")))))) 5906</pre></td></tr> 5907 5908 5909<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> 5910<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. 5911 5912Example 5913matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *"))); 5914matches the [webView ...] message invocation. 5915 NSString *webViewJavaScript = ... 5916 UIWebView *webView = ... 5917 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; 5918</pre></td></tr> 5919 5920 5921<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> 5922<tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a 5923block. 5924 5925Does not match the 'this' parameter of a method. 5926 5927Given 5928 class X { void f(int x, int y, int z) {} }; 5929cxxMethodDecl(hasAnyParameter(hasName("y"))) 5930 matches f(int x, int y, int z) {} 5931with hasAnyParameter(...) 5932 matching int y 5933 5934For ObjectiveC, given 5935 @interface I - (void) f:(int) y; @end 5936 5937the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 5938matches the declaration of method f with hasParameter 5939matching y. 5940 5941For blocks, given 5942 b = ^(int y) { printf("%d", y) }; 5943 5944the matcher blockDecl(hasAnyParameter(hasName("y"))) 5945matches the declaration of the block b with hasParameter 5946matching y. 5947</pre></td></tr> 5948 5949 5950<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> 5951<tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method 5952declaration or a block. 5953 5954Given 5955 class X { void f(int x) {} }; 5956cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 5957 matches f(int x) {} 5958with hasParameter(...) 5959 matching int x 5960 5961For ObjectiveC, given 5962 @interface I - (void) f:(int) y; @end 5963 5964the matcher objcMethodDecl(hasParameter(0, hasName("y"))) 5965matches the declaration of method f with hasParameter 5966matching y. 5967</pre></td></tr> 5968 5969 5970<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> 5971<tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression 5972or opaque value's source expression matches the given matcher. 5973 5974Example 1: matches "a string" 5975(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) 5976class URL { URL(string); }; 5977URL url = "a string"; 5978 5979Example 2: matches 'b' (matcher = 5980opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) 5981int a = b ?: 1; 5982</pre></td></tr> 5983 5984 5985<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> 5986<tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of 5987overloads matches the given matcher. 5988 5989Given 5990 template <typename T> void foo(T); 5991 template <typename T> void bar(T); 5992 template <typename T> void baz(T t) { 5993 foo(t); 5994 bar(t); 5995 } 5996unresolvedLookupExpr(hasAnyDeclaration( 5997 functionTemplateDecl(hasName("foo")))) 5998 matches foo in foo(t); but not bar in bar(t); 5999</pre></td></tr> 6000 6001 6002<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> 6003<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. 6004 6005Given 6006 int (*ptr_to_array)[4]; 6007 int (*ptr_to_func)(int); 6008 6009varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches 6010ptr_to_func but not ptr_to_array. 6011 6012Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> 6013</pre></td></tr> 6014 6015 6016<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> 6017<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the 6018pointee matches a given matcher. 6019 6020Given 6021 int *a; 6022 int const *b; 6023 float const *f; 6024pointerType(pointee(isConstQualified(), isInteger())) 6025 matches "int const *b" 6026 6027Usable 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>>, 6028 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>> 6029</pre></td></tr> 6030 6031 6032<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> 6033<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the 6034pointee matches a given matcher. 6035 6036Given 6037 int *a; 6038 int const *b; 6039 float const *f; 6040pointerType(pointee(isConstQualified(), isInteger())) 6041 matches "int const *b" 6042 6043Usable 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>>, 6044 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>> 6045</pre></td></tr> 6046 6047 6048<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> 6049<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. 6050 6051Given: 6052 typedef int &int_ref; 6053 int a; 6054 int_ref b = a; 6055 6056varDecl(hasType(qualType(referenceType()))))) will not match the 6057declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. 6058</pre></td></tr> 6059 6060 6061<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> 6062<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node 6063matches the given matcher. 6064 6065The associated declaration is: 6066- for type nodes, the declaration of the underlying type 6067- for CallExpr, the declaration of the callee 6068- for MemberExpr, the declaration of the referenced member 6069- for CXXConstructExpr, the declaration of the constructor 6070- for CXXNewExpr, the declaration of the operator new 6071 6072For type nodes, hasDeclaration will generally match the declaration of the 6073sugared type. Given 6074 class X {}; 6075 typedef X Y; 6076 Y y; 6077in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6078typedefDecl. A common use case is to match the underlying, desugared type. 6079This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6080 varDecl(hasType(hasUnqualifiedDesugaredType( 6081 recordType(hasDeclaration(decl()))))) 6082In this matcher, the decl will match the CXXRecordDecl of class X. 6083 6084Usable 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>>, 6085 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>>, 6086 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>>, 6087 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>>, 6088 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>>, 6089 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>>, 6090 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6091</pre></td></tr> 6092 6093 6094<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> 6095<tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped. 6096 6097Given 6098 void (*fp)(void); 6099The matcher 6100 varDecl(hasType(pointerType(pointee(ignoringParens(functionType()))))) 6101would match the declaration for fp. 6102</pre></td></tr> 6103 6104 6105<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> 6106<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 6107</pre></td></tr> 6108 6109 6110<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> 6111<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type 6112matches the specified matcher. 6113 6114Example matches y->x() 6115 (matcher = cxxMemberCallExpr(on(hasType(pointsTo 6116 cxxRecordDecl(hasName("Y"))))))) 6117 class Y { public: void x(); }; 6118 void z() { Y *y; y->x(); } 6119</pre></td></tr> 6120 6121 6122<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> 6123<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 6124</pre></td></tr> 6125 6126 6127<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> 6128<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced 6129type matches the specified matcher. 6130 6131Example matches X &x and const X &y 6132 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) 6133 class X { 6134 void a(X b) { 6135 X &x = b; 6136 const X &y = b; 6137 } 6138 }; 6139</pre></td></tr> 6140 6141 6142<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> 6143<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node 6144matches the given matcher. 6145 6146The associated declaration is: 6147- for type nodes, the declaration of the underlying type 6148- for CallExpr, the declaration of the callee 6149- for MemberExpr, the declaration of the referenced member 6150- for CXXConstructExpr, the declaration of the constructor 6151- for CXXNewExpr, the declaration of the operator new 6152 6153For type nodes, hasDeclaration will generally match the declaration of the 6154sugared type. Given 6155 class X {}; 6156 typedef X Y; 6157 Y y; 6158in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6159typedefDecl. A common use case is to match the underlying, desugared type. 6160This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6161 varDecl(hasType(hasUnqualifiedDesugaredType( 6162 recordType(hasDeclaration(decl()))))) 6163In this matcher, the decl will match the CXXRecordDecl of class X. 6164 6165Usable 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>>, 6166 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>>, 6167 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>>, 6168 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>>, 6169 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>>, 6170 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>>, 6171 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6172</pre></td></tr> 6173 6174 6175<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> 6176<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the 6177pointee matches a given matcher. 6178 6179Given 6180 int *a; 6181 int const *b; 6182 float const *f; 6183pointerType(pointee(isConstQualified(), isInteger())) 6184 matches "int const *b" 6185 6186Usable 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>>, 6187 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>> 6188</pre></td></tr> 6189 6190 6191<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> 6192<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the 6193pointee matches a given matcher. 6194 6195Given 6196 int *a; 6197 int const *b; 6198 float const *f; 6199pointerType(pointee(isConstQualified(), isInteger())) 6200 matches "int const *b" 6201 6202Usable 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>>, 6203 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>> 6204</pre></td></tr> 6205 6206 6207<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> 6208<tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement 6209 6210Given 6211 return a + b; 6212hasReturnValue(binaryOperator()) 6213 matches 'return a + b' 6214with binaryOperator() 6215 matching 'a + b' 6216</pre></td></tr> 6217 6218 6219<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> 6220<tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches 6221a given matcher. Also matches StmtExprs that have CompoundStmt as children. 6222 6223Given 6224 { {}; 1+2; } 6225hasAnySubstatement(compoundStmt()) 6226 matches '{ {}; 1+2; }' 6227with compoundStmt() 6228 matching '{}' 6229</pre></td></tr> 6230 6231 6232<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> 6233<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 6234alignof. 6235</pre></td></tr> 6236 6237 6238<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> 6239<tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to 6240 6241Given: 6242F& operator=(const F& o) { 6243 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); 6244 return *this; 6245} 6246returnStmt(forFunction(hasName("operator="))) 6247 matches 'return *this' 6248 but does match 'return > 0' 6249</pre></td></tr> 6250 6251 6252<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> 6253<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 6254sizeof. 6255</pre></td></tr> 6256 6257 6258<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> 6259<tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement 6260type that matches the provided matcher. 6261 6262Given 6263 template <typename T> 6264 double F(T t); 6265 int i; 6266 double j = F(i); 6267 6268substTemplateTypeParmType(hasReplacementType(type())) matches int 6269</pre></td></tr> 6270 6271 6272<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> 6273<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch 6274statement. This matcher may produce multiple matches. 6275 6276Given 6277 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } 6278switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") 6279 matches four times, with "c" binding each of "case 1:", "case 2:", 6280"case 3:" and "case 4:", and "s" respectively binding "switch (1)", 6281"switch (1)", "switch (2)" and "switch (2)". 6282</pre></td></tr> 6283 6284 6285<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> 6286<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 6287switch statement or conditional operator. 6288 6289Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 6290 if (true) {} 6291</pre></td></tr> 6292 6293 6294<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> 6295<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node 6296matches the given matcher. 6297 6298The associated declaration is: 6299- for type nodes, the declaration of the underlying type 6300- for CallExpr, the declaration of the callee 6301- for MemberExpr, the declaration of the referenced member 6302- for CXXConstructExpr, the declaration of the constructor 6303- for CXXNewExpr, the declaration of the operator new 6304 6305For type nodes, hasDeclaration will generally match the declaration of the 6306sugared type. Given 6307 class X {}; 6308 typedef X Y; 6309 Y y; 6310in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6311typedefDecl. A common use case is to match the underlying, desugared type. 6312This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6313 varDecl(hasType(hasUnqualifiedDesugaredType( 6314 recordType(hasDeclaration(decl()))))) 6315In this matcher, the decl will match the CXXRecordDecl of class X. 6316 6317Usable 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>>, 6318 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>>, 6319 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>>, 6320 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>>, 6321 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>>, 6322 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>>, 6323 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6324</pre></td></tr> 6325 6326 6327<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> 6328<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. 6329 6330Given 6331 struct B { int next; }; 6332 template<int(B::*next_ptr)> struct A {}; 6333 A<&B::next> a; 6334templateSpecializationType(hasAnyTemplateArgument( 6335 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) 6336 matches the specialization A<&B::next> with fieldDecl(...) matching 6337 B::next 6338</pre></td></tr> 6339 6340 6341<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> 6342<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain 6343declaration. 6344 6345Given 6346 struct B { int next; }; 6347 template<int(B::*next_ptr)> struct A {}; 6348 A<&B::next> a; 6349classTemplateSpecializationDecl(hasAnyTemplateArgument( 6350 refersToDeclaration(fieldDecl(hasName("next"))))) 6351 matches the specialization A<&B::next> with fieldDecl(...) matching 6352 B::next 6353</pre></td></tr> 6354 6355 6356<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> 6357<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type. 6358 6359Given 6360 template<int T> struct C {}; 6361 C<42> c; 6362classTemplateSpecializationDecl( 6363 hasAnyTemplateArgument(refersToIntegralType(asString("int")))) 6364 matches the implicit instantiation of C in C<42>. 6365</pre></td></tr> 6366 6367 6368<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> 6369<tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template. 6370 6371Given 6372 template<template <typename> class S> class X {}; 6373 template<typename T> class Y {};" 6374 X<Y> xi; 6375classTemplateSpecializationDecl(hasAnyTemplateArgument( 6376 refersToTemplate(templateName()))) 6377 matches the specialization X<Y> 6378</pre></td></tr> 6379 6380 6381<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> 6382<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 6383 6384Given 6385 struct X {}; 6386 template<typename T> struct A {}; 6387 A<X> a; 6388classTemplateSpecializationDecl(hasAnyTemplateArgument( 6389 refersToType(class(hasName("X"))))) 6390 matches the specialization A<X> 6391</pre></td></tr> 6392 6393 6394<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> 6395<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and 6396functionDecl that have at least one TemplateArgument matching the given 6397InnerMatcher. 6398 6399Given 6400 template<typename T> class A {}; 6401 template<> class A<double> {}; 6402 A<int> a; 6403 6404 template<typename T> f() {}; 6405 void func() { f<int>(); }; 6406 6407classTemplateSpecializationDecl(hasAnyTemplateArgument( 6408 refersToType(asString("int")))) 6409 matches the specialization A<int> 6410 6411functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 6412 matches the specialization f<int> 6413</pre></td></tr> 6414 6415 6416<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> 6417<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node 6418matches the given matcher. 6419 6420The associated declaration is: 6421- for type nodes, the declaration of the underlying type 6422- for CallExpr, the declaration of the callee 6423- for MemberExpr, the declaration of the referenced member 6424- for CXXConstructExpr, the declaration of the constructor 6425- for CXXNewExpr, the declaration of the operator new 6426 6427For type nodes, hasDeclaration will generally match the declaration of the 6428sugared type. Given 6429 class X {}; 6430 typedef X Y; 6431 Y y; 6432in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6433typedefDecl. A common use case is to match the underlying, desugared type. 6434This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6435 varDecl(hasType(hasUnqualifiedDesugaredType( 6436 recordType(hasDeclaration(decl()))))) 6437In this matcher, the decl will match the CXXRecordDecl of class X. 6438 6439Usable 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>>, 6440 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>>, 6441 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>>, 6442 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>>, 6443 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>>, 6444 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>>, 6445 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6446</pre></td></tr> 6447 6448 6449<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> 6450<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and 6451functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 6452 6453Given 6454 template<typename T, typename U> class A {}; 6455 A<bool, int> b; 6456 A<int, bool> c; 6457 6458 template<typename T> void f() {} 6459 void func() { f<int>(); }; 6460classTemplateSpecializationDecl(hasTemplateArgument( 6461 1, refersToType(asString("int")))) 6462 matches the specialization A<bool, int> 6463 6464functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 6465 matches the specialization f<int> 6466</pre></td></tr> 6467 6468 6469<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> 6470<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node 6471matches the given matcher. 6472 6473The associated declaration is: 6474- for type nodes, the declaration of the underlying type 6475- for CallExpr, the declaration of the callee 6476- for MemberExpr, the declaration of the referenced member 6477- for CXXConstructExpr, the declaration of the constructor 6478- for CXXNewExpr, the declaration of the operator new 6479 6480For type nodes, hasDeclaration will generally match the declaration of the 6481sugared type. Given 6482 class X {}; 6483 typedef X Y; 6484 Y y; 6485in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6486typedefDecl. A common use case is to match the underlying, desugared type. 6487This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6488 varDecl(hasType(hasUnqualifiedDesugaredType( 6489 recordType(hasDeclaration(decl()))))) 6490In this matcher, the decl will match the CXXRecordDecl of class X. 6491 6492Usable 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>>, 6493 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>>, 6494 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>>, 6495 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>>, 6496 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>>, 6497 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>>, 6498 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6499</pre></td></tr> 6500 6501 6502<tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>const Matcher<T> Matcher</td></tr> 6503<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. 6504 6505Generates results for each match. 6506 6507For example, in: 6508 class A { class B {}; class C {}; }; 6509The matcher: 6510 cxxRecordDecl(hasName("::A"), 6511 findAll(cxxRecordDecl(isDefinition()).bind("m"))) 6512will generate results for A, B and C. 6513 6514Usable as: Any Matcher 6515</pre></td></tr> 6516 6517 6518<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> 6519<tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type 6520matcher. 6521 6522Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6523 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6524 and U (matcher = typedefDecl(hasType(asString("int"))) 6525 and friend class X (matcher = friendDecl(hasType("X")) 6526 class X {}; 6527 void y(X &x) { x; X z; } 6528 typedef int U; 6529 class Y { friend class X; }; 6530</pre></td></tr> 6531 6532 6533<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> 6534<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node 6535matches the given matcher. 6536 6537The associated declaration is: 6538- for type nodes, the declaration of the underlying type 6539- for CallExpr, the declaration of the callee 6540- for MemberExpr, the declaration of the referenced member 6541- for CXXConstructExpr, the declaration of the constructor 6542- for CXXNewExpr, the declaration of the operator new 6543 6544For type nodes, hasDeclaration will generally match the declaration of the 6545sugared type. Given 6546 class X {}; 6547 typedef X Y; 6548 Y y; 6549in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6550typedefDecl. A common use case is to match the underlying, desugared type. 6551This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6552 varDecl(hasType(hasUnqualifiedDesugaredType( 6553 recordType(hasDeclaration(decl()))))) 6554In this matcher, the decl will match the CXXRecordDecl of class X. 6555 6556Usable 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>>, 6557 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>>, 6558 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>>, 6559 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>>, 6560 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>>, 6561 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>>, 6562 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6563</pre></td></tr> 6564 6565 6566<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> 6567<tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared 6568type of the matched node. 6569 6570For example, in: 6571 class A {}; 6572 using B = A; 6573The matcher type(hasUnqualifiedDesugaredType(recordType())) matches 6574both B and A. 6575</pre></td></tr> 6576 6577 6578<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> 6579<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 6580 6581Given 6582 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 6583unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 6584 matches sizeof(a) and alignof(c) 6585</pre></td></tr> 6586 6587 6588<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> 6589<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 6590 6591Example matches true (matcher = hasUnaryOperand( 6592 cxxBoolLiteral(equals(true)))) 6593 !true 6594</pre></td></tr> 6595 6596 6597<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> 6598<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node 6599matches the given matcher. 6600 6601The associated declaration is: 6602- for type nodes, the declaration of the underlying type 6603- for CallExpr, the declaration of the callee 6604- for MemberExpr, the declaration of the referenced member 6605- for CXXConstructExpr, the declaration of the constructor 6606- for CXXNewExpr, the declaration of the operator new 6607 6608For type nodes, hasDeclaration will generally match the declaration of the 6609sugared type. Given 6610 class X {}; 6611 typedef X Y; 6612 Y y; 6613in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6614typedefDecl. A common use case is to match the underlying, desugared type. 6615This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6616 varDecl(hasType(hasUnqualifiedDesugaredType( 6617 recordType(hasDeclaration(decl()))))) 6618In this matcher, the decl will match the CXXRecordDecl of class X. 6619 6620Usable 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>>, 6621 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>>, 6622 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>>, 6623 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>>, 6624 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>>, 6625 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>>, 6626 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6627</pre></td></tr> 6628 6629 6630<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> 6631<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 6632 6633Given 6634 namespace X { void b(); } 6635 using X::b; 6636usingDecl(hasAnyUsingShadowDecl(hasName("b")))) 6637 matches using X::b </pre></td></tr> 6638 6639 6640<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> 6641<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 6642matched by the given matcher. 6643 6644Given 6645 namespace X { int a; void b(); } 6646 using X::a; 6647 using X::b; 6648usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 6649 matches using X::b but not using X::a </pre></td></tr> 6650 6651 6652<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> 6653<tr><td colspan="4" class="doc" id="hasType6"><pre>Overloaded to match the declaration of the expression's or value 6654declaration's type. 6655 6656In case of a value declaration (for example a variable declaration), 6657this resolves one layer of indirection. For example, in the value 6658declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 6659X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 6660declaration of x. 6661 6662Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6663 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6664 and friend class X (matcher = friendDecl(hasType("X")) 6665 class X {}; 6666 void y(X &x) { x; X z; } 6667 class Y { friend class X; }; 6668 6669Usable 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>> 6670</pre></td></tr> 6671 6672 6673<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> 6674<tr><td colspan="4" class="doc" id="hasType3"><pre>Matches if the expression's or declaration's type matches a type 6675matcher. 6676 6677Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6678 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6679 and U (matcher = typedefDecl(hasType(asString("int"))) 6680 and friend class X (matcher = friendDecl(hasType("X")) 6681 class X {}; 6682 void y(X &x) { x; X z; } 6683 typedef int U; 6684 class Y { friend class X; }; 6685</pre></td></tr> 6686 6687 6688<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> 6689<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 6690that matches the given matcher. 6691 6692Example matches x (matcher = varDecl(hasInitializer(callExpr()))) 6693 bool y() { return true; } 6694 bool x = y(); 6695</pre></td></tr> 6696 6697 6698<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> 6699<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 6700expression. 6701 6702Given 6703 void f(int b) { 6704 int a[b]; 6705 } 6706variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 6707 varDecl(hasName("b"))))))) 6708 matches "int a[b]" 6709</pre></td></tr> 6710 6711 6712<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> 6713<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'do while' statement or a function 6714definition that has a given body. 6715 6716Given 6717 for (;;) {} 6718hasBody(compoundStmt()) 6719 matches 'for (;;) {}' 6720with compoundStmt() 6721 matching '{}' 6722</pre></td></tr> 6723 6724 6725<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> 6726<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 6727switch statement or conditional operator. 6728 6729Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 6730 if (true) {} 6731</pre></td></tr> 6732 6733 6734<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> 6735<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner 6736NestedNameSpecifier-matcher matches. 6737</pre></td></tr> 6738 6739 6740<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> 6741<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner 6742QualType-matcher matches. 6743</pre></td></tr> 6744 6745<!--END_TRAVERSAL_MATCHERS --> 6746</table> 6747 6748</div> 6749</body> 6750</html> 6751 6752 6753