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