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