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