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:'. 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:'. 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()); 1200 f().func(); 1201but does not match 1202 f(); 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 statements. 1259 1260Example matches @throw obj; 1261</pre></td></tr> 1262 1263 1264<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> 1265<tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements. 1266 1267Example matches @try 1268 @try {} 1269 @catch (...) {} 1270</pre></td></tr> 1271 1272 1273<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> 1274<tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers 1275to reference another expressions and can be met 1276in BinaryConditionalOperators, for example. 1277 1278Example matches 'a' 1279 (a ?: c) + 42; 1280</pre></td></tr> 1281 1282 1283<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> 1284<tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions. 1285 1286Example matches (foo() + 1) 1287 int foo() { return 1; } 1288 int a = (foo() + 1); 1289</pre></td></tr> 1290 1291 1292<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> 1293<tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions. 1294ParenListExprs don't have a predefined type and are used for late parsing. 1295In the final AST, they can be met in template declarations. 1296 1297Given 1298 template<typename T> class X { 1299 void f() { 1300 X x(*this); 1301 int a = 0, b = 1; int i = (a, b); 1302 } 1303 }; 1304parenListExpr() matches "*this" but NOT matches (a, b) because (a, b) 1305has a predefined type and is a ParenExpr, not a ParenListExpr. 1306</pre></td></tr> 1307 1308 1309<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> 1310<tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2]. 1311 1312Example: Matches __func__ 1313 printf("%s", __func__); 1314</pre></td></tr> 1315 1316 1317<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> 1318<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. 1319 1320Given 1321 return 1; 1322returnStmt() 1323 matches 'return 1' 1324</pre></td></tr> 1325 1326 1327<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> 1328<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. 1329 1330Given 1331 { ++a; } 1332stmt() 1333 matches both the compound statement '{ ++a; }' and '++a'. 1334</pre></td></tr> 1335 1336 1337<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> 1338<tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension). 1339 1340Example match: ({ int X = 4; X; }) 1341 int C = ({ int X = 4; X; }); 1342</pre></td></tr> 1343 1344 1345<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> 1346<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). 1347 1348Example matches "abcd", L"abcd" 1349 char *s = "abcd"; 1350 wchar_t *ws = L"abcd"; 1351</pre></td></tr> 1352 1353 1354<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> 1355<tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. 1356 1357Given 1358 template <int N> 1359 struct A { static const int n = N; }; 1360 struct B : public A<42> {}; 1361substNonTypeTemplateParmExpr() 1362 matches "N" in the right-hand side of "static const int n = N;" 1363</pre></td></tr> 1364 1365 1366<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('switchCase0')"><a name="switchCase0Anchor">switchCase</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>>...</td></tr> 1367<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. 1368 1369Given 1370 switch(a) { case 42: break; default: break; } 1371switchCase() 1372 matches 'case 42:' and 'default:'. 1373</pre></td></tr> 1374 1375 1376<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('switchStmt0')"><a name="switchStmt0Anchor">switchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>>...</td></tr> 1377<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. 1378 1379Given 1380 switch(a) { case 42: break; default: break; } 1381switchStmt() 1382 matches 'switch(a)'. 1383</pre></td></tr> 1384 1385 1386<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unaryExprOrTypeTraitExpr0')"><a name="unaryExprOrTypeTraitExpr0Anchor">unaryExprOrTypeTraitExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>>...</td></tr> 1387<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) 1388 1389Given 1390 Foo x = bar; 1391 int y = sizeof(x) + alignof(x); 1392unaryExprOrTypeTraitExpr() 1393 matches sizeof(x) and alignof(x) 1394</pre></td></tr> 1395 1396 1397<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> 1398<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. 1399 1400Example matches !a 1401 !a || b 1402</pre></td></tr> 1403 1404 1405<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> 1406<tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing 1407but could not be resolved to a specific declaration. 1408 1409Given 1410 template<typename T> 1411 T foo() { T a; return a; } 1412 template<typename T> 1413 void bar() { 1414 foo<T>(); 1415 } 1416unresolvedLookupExpr() 1417 matches foo<T>() </pre></td></tr> 1418 1419 1420<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> 1421<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. 1422 1423Example match: "foo"_suffix 1424</pre></td></tr> 1425 1426 1427<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> 1428<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. 1429 1430Given 1431 while (true) {} 1432whileStmt() 1433 matches 'while (true) {}'. 1434</pre></td></tr> 1435 1436 1437<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> 1438<tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. 1439 1440Given 1441 template <typename T> struct C {}; 1442 C<int> c; 1443templateArgument() 1444 matches 'int' in C<int>. 1445</pre></td></tr> 1446 1447 1448<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> 1449<tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name. 1450 1451Given 1452 template <typename T> class X { }; 1453 X<int> xi; 1454templateName() 1455 matches 'X' in X<int>. 1456</pre></td></tr> 1457 1458 1459<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> 1460<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. 1461</pre></td></tr> 1462 1463 1464<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> 1465<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. 1466 1467Given 1468 int a[] = { 2, 3 }; 1469 int b[4]; 1470 void f() { int c[a[0]]; } 1471arrayType() 1472 matches "int a[]", "int b[4]" and "int c[a[0]]"; 1473</pre></td></tr> 1474 1475 1476<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> 1477<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. 1478 1479Given 1480 _Atomic(int) i; 1481atomicType() 1482 matches "_Atomic(int) i" 1483</pre></td></tr> 1484 1485 1486<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> 1487<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. 1488 1489Given: 1490 auto n = 4; 1491 int v[] = { 2, 3 } 1492 for (auto i : v) { } 1493autoType() 1494 matches "auto n" and "auto i" 1495</pre></td></tr> 1496 1497 1498<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> 1499<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as 1500"void (^)(int)". 1501 1502The pointee is always required to be a FunctionType. 1503</pre></td></tr> 1504 1505 1506<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> 1507<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. 1508 1509Given 1510 struct A {}; 1511 A a; 1512 int b; 1513 float c; 1514 bool d; 1515builtinType() 1516 matches "int b", "float c" and "bool d" 1517</pre></td></tr> 1518 1519 1520<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> 1521<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. 1522 1523Given 1524 _Complex float f; 1525complexType() 1526 matches "_Complex float f" 1527</pre></td></tr> 1528 1529 1530<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('constantArrayType0')"><a name="constantArrayType0Anchor">constantArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>>...</td></tr> 1531<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. 1532 1533Given 1534 void() { 1535 int a[2]; 1536 int b[] = { 2, 3 }; 1537 int c[b[0]]; 1538 } 1539constantArrayType() 1540 matches "int a[2]" 1541</pre></td></tr> 1542 1543 1544<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('decayedType0')"><a name="decayedType0Anchor">decayedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>>...</td></tr> 1545<tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type 1546Example matches i[] in declaration of f. 1547 (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) 1548Example matches i[1]. 1549 (matcher = expr(hasType(decayedType(hasDecayedType(pointerType()))))) 1550 void f(int i[]) { 1551 i[1] = 0; 1552 } 1553</pre></td></tr> 1554 1555 1556<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> 1557<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. 1558 1559Given 1560 template<typename T, int Size> 1561 class array { 1562 T data[Size]; 1563 }; 1564dependentSizedArrayType 1565 matches "T data[Size]" 1566</pre></td></tr> 1567 1568 1569<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('elaboratedType0')"><a name="elaboratedType0Anchor">elaboratedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>>...</td></tr> 1570<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a 1571qualified name. 1572 1573Given 1574 namespace N { 1575 namespace M { 1576 class D {}; 1577 } 1578 } 1579 class C {}; 1580 1581 class C c; 1582 N::M::D d; 1583 1584elaboratedType() matches the type of the variable declarations of both 1585c and d. 1586</pre></td></tr> 1587 1588 1589<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> 1590<tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types. 1591 1592Given 1593 enum C { Green }; 1594 enum class S { Red }; 1595 1596 C c; 1597 S s; 1598 1599enumType() matches the type of the variable declarations of both c and 1600s. 1601</pre></td></tr> 1602 1603 1604<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> 1605<tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes. 1606 1607Given 1608 int (*f)(int); 1609 void g(); 1610functionProtoType() 1611 matches "int (*f)(int)" and the type of "g" in C++ mode. 1612 In C mode, "g" is not matched because it does not contain a prototype. 1613</pre></td></tr> 1614 1615 1616<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> 1617<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. 1618 1619Given 1620 int (*f)(int); 1621 void g(); 1622functionType() 1623 matches "int (*f)(int)" and the type of "g". 1624</pre></td></tr> 1625 1626 1627<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> 1628<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. 1629 1630Given 1631 int a[] = { 2, 3 }; 1632 int b[42]; 1633 void f(int c[]) { int d[a[0]]; }; 1634incompleteArrayType() 1635 matches "int a[]" and "int c[]" 1636</pre></td></tr> 1637 1638 1639<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> 1640<tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types. 1641 1642Example matches S s, but not S<T> s. 1643 (matcher = parmVarDecl(hasType(injectedClassNameType()))) 1644 template <typename T> struct S { 1645 void f(S s); 1646 void g(S<T> s); 1647 }; 1648</pre></td></tr> 1649 1650 1651<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('lValueReferenceType0')"><a name="lValueReferenceType0Anchor">lValueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType</a>>...</td></tr> 1652<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. 1653 1654Given: 1655 int *a; 1656 int &b = *a; 1657 int &&c = 1; 1658 auto &d = b; 1659 auto &&e = c; 1660 auto &&f = 2; 1661 int g = 5; 1662 1663lValueReferenceType() matches the types of b, d, and e. e is 1664matched since the type is deduced as int& by reference collapsing rules. 1665</pre></td></tr> 1666 1667 1668<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> 1669<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. 1670Given 1671 struct A { int i; } 1672 A::* ptr = A::i; 1673memberPointerType() 1674 matches "A::* ptr" 1675</pre></td></tr> 1676 1677 1678<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> 1679<tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from 1680a pointer type, despite being syntactically similar. 1681 1682Given 1683 int *a; 1684 1685 @interface Foo 1686 @end 1687 Foo *f; 1688pointerType() 1689 matches "Foo *f", but does not match "int *a". 1690</pre></td></tr> 1691 1692 1693<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> 1694<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. 1695 1696Given 1697 int (*ptr_to_array)[4]; 1698 int *array_of_ptrs[4]; 1699 1700varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not 1701array_of_ptrs. 1702</pre></td></tr> 1703 1704 1705<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> 1706<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer 1707types. 1708 1709Given 1710 int *a; 1711 int &b = *a; 1712 int c = 5; 1713 1714 @interface Foo 1715 @end 1716 Foo *f; 1717pointerType() 1718 matches "int *a", but does not match "Foo *f". 1719</pre></td></tr> 1720 1721 1722<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> 1723<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. 1724 1725Given: 1726 int *a; 1727 int &b = *a; 1728 int &&c = 1; 1729 auto &d = b; 1730 auto &&e = c; 1731 auto &&f = 2; 1732 int g = 5; 1733 1734rValueReferenceType() matches the types of c and f. e is not 1735matched as it is deduced to int& by reference collapsing rules. 1736</pre></td></tr> 1737 1738 1739<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> 1740<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). 1741 1742Given 1743 class C {}; 1744 struct S {}; 1745 1746 C c; 1747 S s; 1748 1749recordType() matches the type of the variable declarations of both c 1750and s. 1751</pre></td></tr> 1752 1753 1754<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> 1755<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. 1756 1757Given 1758 int *a; 1759 int &b = *a; 1760 int &&c = 1; 1761 auto &d = b; 1762 auto &&e = c; 1763 auto &&f = 2; 1764 int g = 5; 1765 1766referenceType() matches the types of b, c, d, e, and f. 1767</pre></td></tr> 1768 1769 1770<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> 1771<tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a 1772template type parameter. 1773 1774Given 1775 template <typename T> 1776 void F(T t) { 1777 int i = 1 + t; 1778 } 1779 1780substTemplateTypeParmType() matches the type of 't' but not '1' 1781</pre></td></tr> 1782 1783 1784<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> 1785<tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types). 1786 1787Given 1788 enum E {}; 1789 class C {}; 1790 1791 E e; 1792 C c; 1793 1794tagType() matches the type of the variable declarations of both e 1795and c. 1796</pre></td></tr> 1797 1798 1799<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> 1800<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. 1801 1802Given 1803 template <typename T> 1804 class C { }; 1805 1806 template class C<int>; A 1807 C<char> var; B 1808 1809templateSpecializationType() matches the type of the explicit 1810instantiation in A and the type of the variable declaration in B. 1811</pre></td></tr> 1812 1813 1814<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('templateTypeParmType0')"><a name="templateTypeParmType0Anchor">templateTypeParmType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>...</td></tr> 1815<tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types. 1816 1817Example matches T, but not int. 1818 (matcher = templateTypeParmType()) 1819 template <typename T> void f(int i); 1820</pre></td></tr> 1821 1822 1823<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('type0')"><a name="type0Anchor">type</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>>...</td></tr> 1824<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. 1825</pre></td></tr> 1826 1827 1828<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> 1829<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. 1830 1831Given 1832 typedef int X; 1833typedefType() 1834 matches "typedef int X" 1835</pre></td></tr> 1836 1837 1838<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('unaryTransformType0')"><a name="unaryTransformType0Anchor">unaryTransformType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryTransformType.html">UnaryTransformType</a>>...</td></tr> 1839<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. 1840 1841Given: 1842 typedef __underlying_type(T) type; 1843unaryTransformType() 1844 matches "__underlying_type(T)" 1845</pre></td></tr> 1846 1847 1848<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> 1849<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an 1850integer-constant-expression. 1851 1852Given 1853 void f() { 1854 int a[] = { 2, 3 } 1855 int b[42]; 1856 int c[a[0]]; 1857 } 1858variableArrayType() 1859 matches "int c[a[0]]" 1860</pre></td></tr> 1861 1862<!--END_DECL_MATCHERS --> 1863</table> 1864 1865<!-- ======================================================================= --> 1866<h2 id="narrowing-matchers">Narrowing Matchers</h2> 1867<!-- ======================================================================= --> 1868 1869<p>Narrowing matchers match certain attributes on the current node, thus 1870narrowing down the set of nodes of the current type to match on.</p> 1871 1872<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) 1873which allow users to create more powerful match expressions.</p> 1874 1875<table> 1876<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 1877<!-- START_NARROWING_MATCHERS --> 1878 1879<tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 1880<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. 1881 1882Usable as: Any Matcher 1883</pre></td></tr> 1884 1885 1886<tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 1887<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. 1888 1889Usable as: Any Matcher 1890</pre></td></tr> 1891 1892 1893<tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> 1894<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. 1895 1896Useful when another matcher requires a child matcher, but there's no 1897additional constraint. This will often be used with an explicit conversion 1898to an internal::Matcher<> type such as TypeMatcher. 1899 1900Example: DeclarationMatcher(anything()) matches all declarations, e.g., 1901"int* p" and "void f()" in 1902 int* p; 1903 void f(); 1904 1905Usable as: Any Matcher 1906</pre></td></tr> 1907 1908 1909<tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> 1910<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. 1911 1912Example matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) 1913 class X {}; 1914 class Y {}; 1915 1916Usable as: Any Matcher 1917</pre></td></tr> 1918 1919 1920<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> 1921<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or 1922unary). 1923 1924Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 1925 !(a || b) 1926</pre></td></tr> 1927 1928 1929<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> 1930<tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr> 1931 1932 1933<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>const ValueT Value</td></tr> 1934<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT. 1935 1936Given 1937 f('false, 3.14, 42); 1938characterLiteral(equals(0)) 1939 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 1940 match false 1941floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 1942 match 3.14 1943integerLiteral(equals(42)) 1944 matches 42 1945 1946Note that you cannot directly match a negative numeric literal because the 1947minus sign is not part of the literal: It is a unary operator whose operand 1948is the positive numeric literal. Instead, you must use a unaryOperator() 1949matcher to match the minus sign: 1950 1951unaryOperator(hasOperatorName("-"), 1952 hasUnaryOperand(integerLiteral(equals(13)))) 1953 1954Usable 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>>, 1955 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>> 1956</pre></td></tr> 1957 1958 1959<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> 1960<tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr> 1961 1962 1963<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> 1964<tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr> 1965 1966 1967<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> 1968<tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. 1969 1970Given 1971 try { 1972 ... 1973 } catch (int) { 1974 ... 1975 } catch (...) { 1976 ... 1977 } 1978endcode 1979cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). 1980</pre></td></tr> 1981 1982 1983<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> 1984<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has 1985a specific number of arguments (including absent default arguments). 1986 1987Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 1988 void f(int x, int y); 1989 f(0, 0); 1990</pre></td></tr> 1991 1992 1993<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> 1994<tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. 1995</pre></td></tr> 1996 1997 1998<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> 1999<tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires 2000zero initialization. 2001 2002Given 2003void foo() { 2004 struct point { double x; double y; }; 2005 point pt[2] = { { 1.0, 2.0 } }; 2006} 2007initListExpr(has(cxxConstructExpr(requiresZeroInitialization())) 2008will match the implicit array filler for pt[1]. 2009</pre></td></tr> 2010 2011 2012<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> 2013<tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. 2014 2015Given 2016 struct S { 2017 S(); #1 2018 S(const S &); #2 2019 S(S &&); #3 2020 }; 2021cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. 2022</pre></td></tr> 2023 2024 2025<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> 2026<tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. 2027 2028Given 2029 struct S { 2030 S(); #1 2031 S(const S &); #2 2032 S(S &&); #3 2033 }; 2034cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. 2035</pre></td></tr> 2036 2037 2038<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> 2039<tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor. 2040 2041Given 2042 struct S { 2043 S(); #1 2044 S(int) {} #2 2045 S(S &&) : S() {} #3 2046 }; 2047 S::S() : S(0) {} #4 2048cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not 2049#1 or #2. 2050</pre></td></tr> 2051 2052 2053<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> 2054<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with 2055the explicit keyword. 2056 2057Given 2058 struct S { 2059 S(int); #1 2060 explicit S(double); #2 2061 operator int(); #3 2062 explicit operator bool(); #4 2063 }; 2064cxxConstructorDecl(isExplicit()) will match #2, but not #1. 2065cxxConversionDecl(isExplicit()) will match #4, but not #3. 2066</pre></td></tr> 2067 2068 2069<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> 2070<tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. 2071 2072Given 2073 struct S { 2074 S(); #1 2075 S(const S &); #2 2076 S(S &&); #3 2077 }; 2078cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. 2079</pre></td></tr> 2080 2081 2082<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> 2083<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with 2084the explicit keyword. 2085 2086Given 2087 struct S { 2088 S(int); #1 2089 explicit S(double); #2 2090 operator int(); #3 2091 explicit operator bool(); #4 2092 }; 2093cxxConstructorDecl(isExplicit()) will match #2, but not #1. 2094cxxConversionDecl(isExplicit()) will match #4, but not #3. 2095</pre></td></tr> 2096 2097 2098<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> 2099<tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as 2100opposed to a member. 2101 2102Given 2103 struct B {}; 2104 struct D : B { 2105 int I; 2106 D(int i) : I(i) {} 2107 }; 2108 struct E : B { 2109 E() : B() {} 2110 }; 2111cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) 2112 will match E(), but not match D(int). 2113</pre></td></tr> 2114 2115 2116<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> 2117<tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as 2118opposed to a base. 2119 2120Given 2121 struct B {}; 2122 struct D : B { 2123 int I; 2124 D(int i) : I(i) {} 2125 }; 2126 struct E : B { 2127 E() : B() {} 2128 }; 2129cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) 2130 will match D(int), but not match E(). 2131</pre></td></tr> 2132 2133 2134<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> 2135<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in 2136code (as opposed to implicitly added by the compiler). 2137 2138Given 2139 struct Foo { 2140 Foo() { } 2141 Foo(int) : foo_("A") { } 2142 string foo_; 2143 }; 2144cxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) 2145 will match Foo(int), but not Foo() 2146</pre></td></tr> 2147 2148 2149<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> 2150<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. 2151 2152Given 2153struct A { 2154 void foo() const; 2155 void bar(); 2156}; 2157 2158cxxMethodDecl(isConst()) matches A::foo() but not A::bar() 2159</pre></td></tr> 2160 2161 2162<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> 2163<tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment 2164operator. 2165 2166Given 2167struct A { 2168 A &operator=(const A &); 2169 A &operator=(A &&); 2170}; 2171 2172cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not 2173the second one. 2174</pre></td></tr> 2175 2176 2177<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> 2178<tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. 2179 2180Given: 2181 class A final {}; 2182 2183 struct B { 2184 virtual void f(); 2185 }; 2186 2187 struct C : B { 2188 void f() final; 2189 }; 2190matches A and C::f, but not B, C, or B::f 2191</pre></td></tr> 2192 2193 2194<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> 2195<tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment 2196operator. 2197 2198Given 2199struct A { 2200 A &operator=(const A &); 2201 A &operator=(A &&); 2202}; 2203 2204cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not 2205the first one. 2206</pre></td></tr> 2207 2208 2209<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> 2210<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. 2211 2212Given 2213 class A { 2214 public: 2215 virtual void x(); 2216 }; 2217 class B : public A { 2218 public: 2219 virtual void x(); 2220 }; 2221 matches B::x 2222</pre></td></tr> 2223 2224 2225<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> 2226<tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. 2227 2228Given 2229 class A { 2230 public: 2231 virtual void x() = 0; 2232 }; 2233 matches A::x 2234</pre></td></tr> 2235 2236 2237<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> 2238<tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided. 2239 2240Given 2241 struct S { 2242 S(); #1 2243 S(const S &) = default; #2 2244 S(S &&) = delete; #3 2245 }; 2246cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3. 2247</pre></td></tr> 2248 2249 2250<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> 2251<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. 2252 2253Given 2254 class A { 2255 public: 2256 virtual void x(); 2257 }; 2258 matches A::x 2259</pre></td></tr> 2260 2261 2262<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> 2263<tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual". 2264 2265Given 2266 class A { 2267 public: 2268 virtual void x(); 2269 }; 2270 class B : public A { 2271 public: 2272 void x(); 2273 }; 2274 matches A::x but not B::x 2275</pre></td></tr> 2276 2277 2278<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> 2279<tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions. 2280 2281Given: 2282 MyClass *p1 = new MyClass[10]; 2283cxxNewExpr(isArray()) 2284 matches the expression 'new MyClass[10]'. 2285</pre></td></tr> 2286 2287 2288<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> 2289<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. 2290 2291Matches overloaded operator names specified in strings without the 2292"operator" prefix: e.g. "<<". 2293 2294Given: 2295 class A { int operator*(); }; 2296 const A &operator<<(const A &a, const A &b); 2297 A a; 2298 a << a; <-- This matches 2299 2300cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the 2301specified line and 2302cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) 2303matches the declaration of A. 2304 2305Usable 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>> 2306</pre></td></tr> 2307 2308 2309<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> 2310<tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined. 2311 2312Example matches x (matcher = cxxRecordDecl(hasDefinition())) 2313class x {}; 2314class y; 2315</pre></td></tr> 2316 2317 2318<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> 2319<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). 2320</pre></td></tr> 2321 2322 2323<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> 2324<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or 2325static member variable template instantiations. 2326 2327Given 2328 template<typename T> void A(T t) { } 2329 template<> void A(int N) { } 2330functionDecl(isExplicitTemplateSpecialization()) 2331 matches the specialization A<int>(). 2332 2333Usable 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>> 2334</pre></td></tr> 2335 2336 2337<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> 2338<tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. 2339 2340Given: 2341 class A final {}; 2342 2343 struct B { 2344 virtual void f(); 2345 }; 2346 2347 struct C : B { 2348 void f() final; 2349 }; 2350matches A and C::f, but not B, C, or B::f 2351</pre></td></tr> 2352 2353 2354<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> 2355<tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions. 2356 2357Given: 2358 auto x = []{}; 2359 2360cxxRecordDecl(isLambda()) matches the implicit class declaration of 2361decltype(x) 2362</pre></td></tr> 2363 2364 2365<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> 2366<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for 2367isSameOrDerivedFrom(hasName(...)). 2368</pre></td></tr> 2369 2370 2371<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> 2372<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static 2373member variable template instantiations. 2374 2375Given 2376 template <typename T> class X {}; class A {}; X<A> x; 2377or 2378 template <typename T> class X {}; class A {}; template class X<A>; 2379or 2380 template <typename T> class X {}; class A {}; extern template class X<A>; 2381cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2382 matches the template instantiation of X<A>. 2383 2384But given 2385 template <typename T> class X {}; class A {}; 2386 template <> class X<A> {}; X<A> x; 2387cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2388 does not match, as X<A> is an explicit template specialization. 2389 2390Usable 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>> 2391</pre></td></tr> 2392 2393 2394<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> 2395<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has 2396a specific number of arguments (including absent default arguments). 2397 2398Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 2399 void f(int x, int y); 2400 f(0, 0); 2401</pre></td></tr> 2402 2403 2404<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> 2405<tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind. 2406 2407Example: matches the implicit cast around 0 2408(matcher = castExpr(hasCastKind(CK_NullToPointer))) 2409 int *p = 0; 2410</pre></td></tr> 2411 2412 2413<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> 2414<tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr> 2415 2416 2417<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals3')"><a name="equals3Anchor">equals</a></td><td>const ValueT Value</td></tr> 2418<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT. 2419 2420Given 2421 f('false, 3.14, 42); 2422characterLiteral(equals(0)) 2423 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 2424 match false 2425floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 2426 match 3.14 2427integerLiteral(equals(42)) 2428 matches 42 2429 2430Note that you cannot directly match a negative numeric literal because the 2431minus sign is not part of the literal: It is a unary operator whose operand 2432is the positive numeric literal. Instead, you must use a unaryOperator() 2433matcher to match the minus sign: 2434 2435unaryOperator(hasOperatorName("-"), 2436 hasUnaryOperand(integerLiteral(equals(13)))) 2437 2438Usable 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>>, 2439 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>> 2440</pre></td></tr> 2441 2442 2443<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> 2444<tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr> 2445 2446 2447<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> 2448<tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr> 2449 2450 2451<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> 2452<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. 2453 2454Given 2455 template<typename T> struct C {}; 2456 C<int> c; 2457classTemplateSpecializationDecl(templateArgumentCountIs(1)) 2458 matches C<int>. 2459</pre></td></tr> 2460 2461 2462<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> 2463<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of 2464child statements. 2465 2466Example: Given 2467 { for (;;) {} } 2468compoundStmt(statementCountIs(0))) 2469 matches '{}' 2470 but does not match the outer compound statement. 2471</pre></td></tr> 2472 2473 2474<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> 2475<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size. 2476 2477Given 2478 int a[42]; 2479 int b[2 * 21]; 2480 int c[41], d[43]; 2481 char *s = "abcd"; 2482 wchar_t *ws = L"abcd"; 2483 char *w = "a"; 2484constantArrayType(hasSize(42)) 2485 matches "int a[42]" and "int b[2 * 21]" 2486stringLiteral(hasSize(4)) 2487 matches "abcd", L"abcd" 2488</pre></td></tr> 2489 2490 2491<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> 2492<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of 2493declarations. 2494 2495Example: Given 2496 int a, b; 2497 int c; 2498 int d = 2, e; 2499declCountIs(2) 2500 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. 2501</pre></td></tr> 2502 2503 2504<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> 2505<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. 2506 2507Matches a node if it equals the node previously bound to ID. 2508 2509Given 2510 class X { int a; int b; }; 2511cxxRecordDecl( 2512 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2513 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2514 matches the class X, as a and b have the same type. 2515 2516Note that when multiple matches are involved via forEach* matchers, 2517equalsBoundNodes acts as a filter. 2518For example: 2519compoundStmt( 2520 forEachDescendant(varDecl().bind("d")), 2521 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2522will trigger a match for each combination of variable declaration 2523and reference to that variable declaration within a compound statement. 2524</pre></td></tr> 2525 2526 2527<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> 2528<tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node. 2529 2530Decl has pointer identity in the AST. 2531</pre></td></tr> 2532 2533 2534<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> 2535<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. 2536 2537Given 2538 __attribute__((device)) void f() { ... } 2539decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of 2540f. If the matcher is use from clang-query, attr::Kind parameter should be 2541passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). 2542</pre></td></tr> 2543 2544 2545<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> 2546<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is 2547partially matching a given regex. 2548 2549Example matches Y but not X 2550 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 2551 #include "ASTMatcher.h" 2552 class X {}; 2553ASTMatcher.h: 2554 class Y {}; 2555 2556Usable 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>> 2557</pre></td></tr> 2558 2559 2560<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> 2561<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. 2562 2563Example matches X but not Y 2564 (matcher = cxxRecordDecl(isExpansionInMainFile()) 2565 #include <Y.h> 2566 class X {}; 2567Y.h: 2568 class Y {}; 2569 2570Usable 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>> 2571</pre></td></tr> 2572 2573 2574<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> 2575<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. 2576 2577Example matches Y but not X 2578 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 2579 #include <SystemHeader.h> 2580 class X {}; 2581SystemHeader.h: 2582 class Y {}; 2583 2584Usable 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>> 2585</pre></td></tr> 2586 2587 2588<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> 2589<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added 2590by the compiler (eg. implicit defaultcopy constructors). 2591</pre></td></tr> 2592 2593 2594<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> 2595<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. 2596 2597Given 2598 class C { 2599 public: int a; 2600 protected: int b; 2601 private: int c; 2602 }; 2603fieldDecl(isPrivate()) 2604 matches 'int c;' 2605</pre></td></tr> 2606 2607 2608<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> 2609<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. 2610 2611Given 2612 class C { 2613 public: int a; 2614 protected: int b; 2615 private: int c; 2616 }; 2617fieldDecl(isProtected()) 2618 matches 'int b;' 2619</pre></td></tr> 2620 2621 2622<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> 2623<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. 2624 2625Given 2626 class C { 2627 public: int a; 2628 protected: int b; 2629 private: int c; 2630 }; 2631fieldDecl(isPublic()) 2632 matches 'int a;' 2633</pre></td></tr> 2634 2635 2636<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> 2637<tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain 2638a specific number of designators. 2639 2640Example: Given 2641 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; 2642 point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }; 2643designatorCountIs(2) 2644 matches '{ [2].y = 1.0, [0].x = 1.0 }', 2645 but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'. 2646</pre></td></tr> 2647 2648 2649<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>></td><td class="name" onclick="toggle('isScoped0')"><a name="isScoped0Anchor">isScoped</a></td><td></td></tr> 2650<tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration. 2651 2652Example matches Y (matcher = enumDecl(isScoped())) 2653enum X {}; 2654enum class Y {}; 2655</pre></td></tr> 2656 2657 2658<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> 2659<tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified 2660bit width. 2661 2662Given 2663 class C { 2664 int a : 2; 2665 int b : 4; 2666 int c : 2; 2667 }; 2668fieldDecl(hasBitWidth(2)) 2669 matches 'int a;' and 'int c;' but not 'int b;'. 2670</pre></td></tr> 2671 2672 2673<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> 2674<tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields. 2675 2676Given 2677 class C { 2678 int a : 2; 2679 int b; 2680 }; 2681fieldDecl(isBitField()) 2682 matches 'int a;' but not 'int b;'. 2683</pre></td></tr> 2684 2685 2686<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>></td><td class="name" onclick="toggle('equals1')"><a name="equals1Anchor">equals</a></td><td>const ValueT Value</td></tr> 2687<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT. 2688 2689Given 2690 f('false, 3.14, 42); 2691characterLiteral(equals(0)) 2692 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 2693 match false 2694floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 2695 match 3.14 2696integerLiteral(equals(42)) 2697 matches 42 2698 2699Note that you cannot directly match a negative numeric literal because the 2700minus sign is not part of the literal: It is a unary operator whose operand 2701is the positive numeric literal. Instead, you must use a unaryOperator() 2702matcher to match the minus sign: 2703 2704unaryOperator(hasOperatorName("-"), 2705 hasUnaryOperand(integerLiteral(equals(13)))) 2706 2707Usable 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>>, 2708 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>> 2709</pre></td></tr> 2710 2711 2712<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> 2713<tr><td colspan="4" class="doc" id="equals12"><pre></pre></td></tr> 2714 2715 2716<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> 2717<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification. 2718 2719Given: 2720 void f(); 2721 void g() noexcept; 2722 void h() noexcept(true); 2723 void i() noexcept(false); 2724 void j() throw(); 2725 void k() throw(int); 2726 void l() throw(...); 2727functionDecl(hasDynamicExceptionSpec()) and 2728 functionProtoType(hasDynamicExceptionSpec()) 2729 match the declarations of j, k, and l, but not f, g, h, or i. 2730</pre></td></tr> 2731 2732 2733<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> 2734<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. 2735 2736Matches overloaded operator names specified in strings without the 2737"operator" prefix: e.g. "<<". 2738 2739Given: 2740 class A { int operator*(); }; 2741 const A &operator<<(const A &a, const A &b); 2742 A a; 2743 a << a; <-- This matches 2744 2745cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the 2746specified line and 2747cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) 2748matches the declaration of A. 2749 2750Usable 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>> 2751</pre></td></tr> 2752 2753 2754<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasTrailingReturn0')"><a name="hasTrailingReturn0Anchor">hasTrailingReturn</a></td><td></td></tr> 2755<tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type. 2756 2757Example matches Y (matcher = functionDecl(hasTrailingReturn())) 2758int X() {} 2759auto Y() -> int {} 2760</pre></td></tr> 2761 2762 2763<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> 2764<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations. 2765 2766Given: 2767 constexpr int foo = 42; 2768 constexpr int bar(); 2769varDecl(isConstexpr()) 2770 matches the declaration of foo. 2771functionDecl(isConstexpr()) 2772 matches the declaration of bar. 2773</pre></td></tr> 2774 2775 2776<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> 2777<tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations. 2778 2779Given: 2780 class A { ~A(); }; 2781 class B { ~B() = default; }; 2782functionDecl(isDefaulted()) 2783 matches the declaration of ~B, but not ~A. 2784</pre></td></tr> 2785 2786 2787<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> 2788<tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached. 2789 2790Example matches A, va, fa 2791 class A {}; 2792 class B; Doesn't match, as it has no body. 2793 int va; 2794 extern int vb; Doesn't match, as it doesn't define the variable. 2795 void fa() {} 2796 void fb(); Doesn't match, as it has no body. 2797 @interface X 2798 - (void)ma; Doesn't match, interface is declaration. 2799 @end 2800 @implementation X 2801 - (void)ma {} 2802 @end 2803 2804Usable 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>>, 2805 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 2806</pre></td></tr> 2807 2808 2809<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> 2810<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. 2811 2812Given: 2813 void Func(); 2814 void DeletedFunc() = delete; 2815functionDecl(isDeleted()) 2816 matches the declaration of DeletedFunc, but not Func. 2817</pre></td></tr> 2818 2819 2820<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> 2821<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or 2822static member variable template instantiations. 2823 2824Given 2825 template<typename T> void A(T t) { } 2826 template<> void A(int N) { } 2827functionDecl(isExplicitTemplateSpecialization()) 2828 matches the specialization A<int>(). 2829 2830Usable 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>> 2831</pre></td></tr> 2832 2833 2834<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> 2835<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations. 2836 2837Given: 2838 extern "C" void f() {} 2839 extern "C" { void g() {} } 2840 void h() {} 2841 extern "C" int x = 1; 2842 extern "C" int y = 2; 2843 int z = 3; 2844functionDecl(isExternC()) 2845 matches the declaration of f and g, but not the declaration of h. 2846varDecl(isExternC()) 2847 matches the declaration of x and y, but not the declaration of z. 2848</pre></td></tr> 2849 2850 2851<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> 2852<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with 2853the inline keyword. 2854 2855Given 2856 inline void f(); 2857 void g(); 2858 namespace n { 2859 inline namespace m {} 2860 } 2861functionDecl(isInline()) will match ::f(). 2862namespaceDecl(isInline()) will match n::m. 2863</pre></td></tr> 2864 2865 2866<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isNoReturn0')"><a name="isNoReturn0Anchor">isNoReturn</a></td><td></td></tr> 2867<tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute. 2868 2869Given 2870 void nope(); 2871 [[noreturn]] void a(); 2872 __attribute__((noreturn)) void b(); 2873 struct c { [[noreturn]] c(); }; 2874functionDecl(isNoReturn()) 2875 matches all of those except 2876 void nope(); 2877</pre></td></tr> 2878 2879 2880<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> 2881<tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification. 2882 2883Given: 2884 void f(); 2885 void g() noexcept; 2886 void h() throw(); 2887 void i() throw(int); 2888 void j() noexcept(false); 2889functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) 2890 match the declarations of g, and h, but not f, i or j. 2891</pre></td></tr> 2892 2893 2894<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isStaticStorageClass0')"><a name="isStaticStorageClass0Anchor">isStaticStorageClass</a></td><td></td></tr> 2895<tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variablefunction declarations that have "static" storage 2896class specifier ("static" keyword) written in the source. 2897 2898Given: 2899 static void f() {} 2900 static int i = 0; 2901 extern int j; 2902 int k; 2903functionDecl(isStaticStorageClass()) 2904 matches the function declaration f. 2905varDecl(isStaticStorageClass()) 2906 matches the variable declaration i. 2907</pre></td></tr> 2908 2909 2910<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> 2911<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 2912member variable template instantiations. 2913 2914Given 2915 template <typename T> class X {}; class A {}; X<A> x; 2916or 2917 template <typename T> class X {}; class A {}; template class X<A>; 2918or 2919 template <typename T> class X {}; class A {}; extern template class X<A>; 2920cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2921 matches the template instantiation of X<A>. 2922 2923But given 2924 template <typename T> class X {}; class A {}; 2925 template <> class X<A> {}; X<A> x; 2926cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2927 does not match, as X<A> is an explicit template specialization. 2928 2929Usable 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>> 2930</pre></td></tr> 2931 2932 2933<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> 2934<tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. 2935 2936Example matches f, but not g or h. The function i will not match, even when 2937compiled in C mode. 2938 void f(...); 2939 void g(int); 2940 template <typename... Ts> void h(Ts...); 2941 void i(); 2942</pre></td></tr> 2943 2944 2945<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> 2946<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a 2947specific parameter count. 2948 2949Given 2950 void f(int i) {} 2951 void g(int i, int j) {} 2952 void h(int i, int j); 2953 void j(int i); 2954 void k(int x, int y, int z, ...); 2955functionDecl(parameterCountIs(2)) 2956 matches g and h 2957functionProtoType(parameterCountIs(2)) 2958 matches g and h 2959functionProtoType(parameterCountIs(3)) 2960 matches k 2961</pre></td></tr> 2962 2963 2964<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> 2965<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification. 2966 2967Given: 2968 void f(); 2969 void g() noexcept; 2970 void h() noexcept(true); 2971 void i() noexcept(false); 2972 void j() throw(); 2973 void k() throw(int); 2974 void l() throw(...); 2975functionDecl(hasDynamicExceptionSpec()) and 2976 functionProtoType(hasDynamicExceptionSpec()) 2977 match the declarations of j, k, and l, but not f, g, h, or i. 2978</pre></td></tr> 2979 2980 2981<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> 2982<tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification. 2983 2984Given: 2985 void f(); 2986 void g() noexcept; 2987 void h() throw(); 2988 void i() throw(int); 2989 void j() noexcept(false); 2990functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) 2991 match the declarations of g, and h, but not f, i or j. 2992</pre></td></tr> 2993 2994 2995<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> 2996<tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a 2997specific parameter count. 2998 2999Given 3000 void f(int i) {} 3001 void g(int i, int j) {} 3002 void h(int i, int j); 3003 void j(int i); 3004 void k(int x, int y, int z, ...); 3005functionDecl(parameterCountIs(2)) 3006 matches g and h 3007functionProtoType(parameterCountIs(2)) 3008 matches g and h 3009functionProtoType(parameterCountIs(3)) 3010 matches k 3011</pre></td></tr> 3012 3013 3014<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> 3015<tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr> 3016 3017 3018<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals0')"><a name="equals0Anchor">equals</a></td><td>const ValueT Value</td></tr> 3019<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT. 3020 3021Given 3022 f('false, 3.14, 42); 3023characterLiteral(equals(0)) 3024 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 3025 match false 3026floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 3027 match 3.14 3028integerLiteral(equals(42)) 3029 matches 42 3030 3031Note that you cannot directly match a negative numeric literal because the 3032minus sign is not part of the literal: It is a unary operator whose operand 3033is the positive numeric literal. Instead, you must use a unaryOperator() 3034matcher to match the minus sign: 3035 3036unaryOperator(hasOperatorName("-"), 3037 hasUnaryOperand(integerLiteral(equals(13)))) 3038 3039Usable 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>>, 3040 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>> 3041</pre></td></tr> 3042 3043 3044<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> 3045<tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr> 3046 3047 3048<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> 3049<tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr> 3050 3051 3052<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> 3053<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 3054to '.'. 3055 3056Member calls on the implicit this pointer match as called with '->'. 3057 3058Given 3059 class Y { 3060 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 3061 int a; 3062 static int b; 3063 }; 3064memberExpr(isArrow()) 3065 matches this->x, x, y.x, a, this->b 3066</pre></td></tr> 3067 3068 3069<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> 3070<tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage. 3071 3072Example matches only z (matcher = varDecl(hasExternalFormalLinkage())) 3073void f() { 3074 int x; 3075 static int y; 3076} 3077int z; 3078 3079Example matches f() because it has external formal linkage despite being 3080unique to the translation unit as though it has internal likage 3081(matcher = functionDecl(hasExternalFormalLinkage())) 3082 3083namespace { 3084void f() {} 3085} 3086</pre></td></tr> 3087 3088 3089<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('hasName0')"><a name="hasName0Anchor">hasName</a></td><td>const std::string Name</td></tr> 3090<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 3091 3092Supports specifying enclosing namespaces or classes by prefixing the name 3093with '<enclosing>::'. 3094Does not match typedefs of an underlying type with the given name. 3095 3096Example matches X (Name == "X") 3097 class X; 3098 3099Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 3100 namespace a { namespace b { class X; } } 3101</pre></td></tr> 3102 3103 3104<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> 3105<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain 3106a substring matched by the given RegExp. 3107 3108Supports specifying enclosing namespaces or classes by 3109prefixing the name with '<enclosing>::'. Does not match typedefs 3110of an underlying type with the given name. 3111 3112Example matches X (regexp == "::X") 3113 class X; 3114 3115Example matches X (regexp is one of "::X", "^foo::.*X", among others) 3116 namespace foo { namespace bar { class X; } } 3117</pre></td></tr> 3118 3119 3120<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> 3121<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. 3122 3123Given 3124 namespace n { 3125 namespace {} #1 3126 } 3127namespaceDecl(isAnonymous()) will match #1 but not ::n. 3128</pre></td></tr> 3129 3130 3131<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> 3132<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with 3133the inline keyword. 3134 3135Given 3136 inline void f(); 3137 void g(); 3138 namespace n { 3139 inline namespace m {} 3140 } 3141functionDecl(isInline()) will match ::f(). 3142namespaceDecl(isInline()) will match n::m. 3143</pre></td></tr> 3144 3145 3146<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> 3147<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has 3148a specific number of arguments (including absent default arguments). 3149 3150Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 3151 void f(int x, int y); 3152 f(0, 0); 3153</pre></td></tr> 3154 3155 3156<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> 3157<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector 3158 3159objCMessageExpr(hasKeywordSelector()) matches the generated setFrame 3160message expression in 3161 3162 UIWebView *webView = ...; 3163 CGRect bodyFrame = webView.frame; 3164 bodyFrame.size.height = self.bodyContentHeight; 3165 webView.frame = bodyFrame; 3166 ^---- matches here 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('hasNullSelector0')"><a name="hasNullSelector0Anchor">hasNullSelector</a></td><td></td></tr> 3171<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector 3172 3173Matches only when the selector of the objCMessageExpr is NULL. This may 3174represent an error condition in the tree! 3175</pre></td></tr> 3176 3177 3178<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> 3179<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() 3180 3181 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); 3182 matches the outer message expr in the code below, but NOT the message 3183 invocation for self.bodyView. 3184 [self.bodyView loadHTMLString:html baseURL:NULL]; 3185</pre></td></tr> 3186 3187 3188<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> 3189<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector 3190 3191 matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); 3192 matches self.bodyView in the code below, but NOT the outer message 3193 invocation of "loadHTMLString:baseURL:". 3194 [self.bodyView loadHTMLString:html baseURL:NULL]; 3195</pre></td></tr> 3196 3197 3198<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> 3199<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains 3200a substring matched by the given RegExp. 3201 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message 3202 invocation for self.bodyView. 3203 [self.bodyView loadHTMLString:html baseURL:NULL]; 3204</pre></td></tr> 3205 3206 3207<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> 3208<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments 3209 3210 matcher = objCMessageExpr(numSelectorArgs(0)); 3211 matches self.bodyView in the code below 3212 3213 matcher = objCMessageExpr(numSelectorArgs(2)); 3214 matches the invocation of "loadHTMLString:baseURL:" but not that 3215 of self.bodyView 3216 [self.bodyView loadHTMLString:html baseURL:NULL]; 3217</pre></td></tr> 3218 3219 3220<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> 3221<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. 3222 3223Example matches A, va, fa 3224 class A {}; 3225 class B; Doesn't match, as it has no body. 3226 int va; 3227 extern int vb; Doesn't match, as it doesn't define the variable. 3228 void fa() {} 3229 void fb(); Doesn't match, as it has no body. 3230 @interface X 3231 - (void)ma; Doesn't match, interface is declaration. 3232 @end 3233 @implementation X 3234 - (void)ma {} 3235 @end 3236 3237Usable 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>>, 3238 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 3239</pre></td></tr> 3240 3241 3242<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> 3243<tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments. 3244 3245Example matches y (matcher = parmVarDecl(hasDefaultArgument())) 3246void x(int val) {} 3247void y(int val = 0) {} 3248</pre></td></tr> 3249 3250 3251<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> 3252<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 3253 3254Given 3255 class Y { public: void x(); }; 3256 void z() { Y* y; y->x(); } 3257cxxMemberCallExpr(on(hasType(asString("class Y *")))) 3258 matches y->x() 3259</pre></td></tr> 3260 3261 3262<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> 3263<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. 3264 3265Matches a node if it equals the node previously bound to ID. 3266 3267Given 3268 class X { int a; int b; }; 3269cxxRecordDecl( 3270 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3271 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3272 matches the class X, as a and b have the same type. 3273 3274Note that when multiple matches are involved via forEach* matchers, 3275equalsBoundNodes acts as a filter. 3276For example: 3277compoundStmt( 3278 forEachDescendant(varDecl().bind("d")), 3279 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3280will trigger a match for each combination of variable declaration 3281and reference to that variable declaration within a compound statement. 3282</pre></td></tr> 3283 3284 3285<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> 3286<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to 3287the node, not hidden within a typedef. 3288 3289Given 3290 typedef const int const_int; 3291 const_int i; 3292 int *const j; 3293 int *volatile k; 3294 int m; 3295varDecl(hasType(hasLocalQualifiers())) matches only j and k. 3296i is const-qualified but the qualifier is not local. 3297</pre></td></tr> 3298 3299 3300<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> 3301<tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type. 3302 3303Given 3304 void a(char); 3305 void b(wchar_t); 3306 void c(double); 3307functionDecl(hasAnyParameter(hasType(isAnyCharacter()))) 3308matches "a(char)", "b(wchar_t)", but not "c(double)". 3309</pre></td></tr> 3310 3311 3312<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> 3313<tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes 3314the Objective-C object pointer type, which is different despite being 3315syntactically similar. 3316 3317Given 3318 int *i = nullptr; 3319 3320 @interface Foo 3321 @end 3322 Foo *f; 3323 3324 int j; 3325varDecl(hasType(isAnyPointer())) 3326 matches "int *i" and "Foo *f", but not "int j". 3327</pre></td></tr> 3328 3329 3330<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> 3331<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 3332include "top-level" const. 3333 3334Given 3335 void a(int); 3336 void b(int const); 3337 void c(const int); 3338 void d(const int*); 3339 void e(int const) {}; 3340functionDecl(hasAnyParameter(hasType(isConstQualified()))) 3341 matches "void b(int const)", "void c(const int)" and 3342 "void e(int const) {}". It does not match d as there 3343 is no top-level const on the parameter type "const int *". 3344</pre></td></tr> 3345 3346 3347<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> 3348<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 3349 3350Given 3351 void a(int); 3352 void b(long); 3353 void c(double); 3354functionDecl(hasAnyParameter(hasType(isInteger()))) 3355matches "a(int)", "b(long)", but not "c(double)". 3356</pre></td></tr> 3357 3358 3359<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> 3360<tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type. 3361 3362Given 3363 void a(int); 3364 void b(unsigned long); 3365 void c(double); 3366functionDecl(hasAnyParameter(hasType(isSignedInteger()))) 3367matches "a(int)", but not "b(unsigned long)" and "c(double)". 3368</pre></td></tr> 3369 3370 3371<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isUnsignedInteger0')"><a name="isUnsignedInteger0Anchor">isUnsignedInteger</a></td><td></td></tr> 3372<tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type. 3373 3374Given 3375 void a(int); 3376 void b(unsigned long); 3377 void c(double); 3378functionDecl(hasAnyParameter(hasType(isUnsignedInteger()))) 3379matches "b(unsigned long)", but not "a(int)" and "c(double)". 3380</pre></td></tr> 3381 3382 3383<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> 3384<tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that 3385include "top-level" volatile. 3386 3387Given 3388 void a(int); 3389 void b(int volatile); 3390 void c(volatile int); 3391 void d(volatile int*); 3392 void e(int volatile) {}; 3393functionDecl(hasAnyParameter(hasType(isVolatileQualified()))) 3394 matches "void b(int volatile)", "void c(volatile int)" and 3395 "void e(int volatile) {}". It does not match d as there 3396 is no top-level volatile on the parameter type "volatile int *". 3397</pre></td></tr> 3398 3399 3400<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> 3401<tr><td colspan="4" class="doc" id="isClass0"><pre>Matches RecordDecl object that are spelled with "class." 3402 3403Example matches C, but not S or U. 3404 struct S {}; 3405 class C {}; 3406 union U {}; 3407</pre></td></tr> 3408 3409 3410<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> 3411<tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches RecordDecl object that are spelled with "struct." 3412 3413Example matches S, but not C or U. 3414 struct S {}; 3415 class C {}; 3416 union U {}; 3417</pre></td></tr> 3418 3419 3420<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> 3421<tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches RecordDecl object that are spelled with "union." 3422 3423Example matches U, but not C or S. 3424 struct S {}; 3425 class C {}; 3426 union U {}; 3427</pre></td></tr> 3428 3429 3430<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> 3431<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. 3432 3433Matches a node if it equals the node previously bound to ID. 3434 3435Given 3436 class X { int a; int b; }; 3437cxxRecordDecl( 3438 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3439 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3440 matches the class X, as a and b have the same type. 3441 3442Note that when multiple matches are involved via forEach* matchers, 3443equalsBoundNodes acts as a filter. 3444For example: 3445compoundStmt( 3446 forEachDescendant(varDecl().bind("d")), 3447 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3448will trigger a match for each combination of variable declaration 3449and reference to that variable declaration within a compound statement. 3450</pre></td></tr> 3451 3452 3453<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> 3454<tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. 3455 3456Stmt has pointer identity in the AST. 3457</pre></td></tr> 3458 3459 3460<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> 3461<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is 3462partially matching a given regex. 3463 3464Example matches Y but not X 3465 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 3466 #include "ASTMatcher.h" 3467 class X {}; 3468ASTMatcher.h: 3469 class Y {}; 3470 3471Usable 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>> 3472</pre></td></tr> 3473 3474 3475<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> 3476<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. 3477 3478Example matches X but not Y 3479 (matcher = cxxRecordDecl(isExpansionInMainFile()) 3480 #include <Y.h> 3481 class X {}; 3482Y.h: 3483 class Y {}; 3484 3485Usable 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>> 3486</pre></td></tr> 3487 3488 3489<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> 3490<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. 3491 3492Example matches Y but not X 3493 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 3494 #include <SystemHeader.h> 3495 class X {}; 3496SystemHeader.h: 3497 class Y {}; 3498 3499Usable 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>> 3500</pre></td></tr> 3501 3502 3503<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> 3504<tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size. 3505 3506Given 3507 int a[42]; 3508 int b[2 * 21]; 3509 int c[41], d[43]; 3510 char *s = "abcd"; 3511 wchar_t *ws = L"abcd"; 3512 char *w = "a"; 3513constantArrayType(hasSize(42)) 3514 matches "int a[42]" and "int b[2 * 21]" 3515stringLiteral(hasSize(4)) 3516 matches "abcd", L"abcd" 3517</pre></td></tr> 3518 3519 3520<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> 3521<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 3522 3523Example matches A, va, fa 3524 class A {}; 3525 class B; Doesn't match, as it has no body. 3526 int va; 3527 extern int vb; Doesn't match, as it doesn't define the variable. 3528 void fa() {} 3529 void fb(); Doesn't match, as it has no body. 3530 @interface X 3531 - (void)ma; Doesn't match, interface is declaration. 3532 @end 3533 @implementation X 3534 - (void)ma {} 3535 @end 3536 3537Usable 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>>, 3538 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 3539</pre></td></tr> 3540 3541 3542<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> 3543<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. 3544 3545Note that 'Value' is a string as the template argument's value is 3546an arbitrary precision integer. 'Value' must be euqal to the canonical 3547representation of that integral value in base 10. 3548 3549Given 3550 template<int T> struct C {}; 3551 C<42> c; 3552classTemplateSpecializationDecl( 3553 hasAnyTemplateArgument(equalsIntegralValue("42"))) 3554 matches the implicit instantiation of C in C<42>. 3555</pre></td></tr> 3556 3557 3558<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> 3559<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. 3560 3561Given 3562 template<int T> struct C {}; 3563 C<42> c; 3564classTemplateSpecializationDecl( 3565 hasAnyTemplateArgument(isIntegral())) 3566 matches the implicit instantiation of C in C<42> 3567 with isIntegral() matching 42. 3568</pre></td></tr> 3569 3570 3571<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> 3572<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. 3573 3574Given 3575 template<typename T> struct C {}; 3576 C<int> c; 3577classTemplateSpecializationDecl(templateArgumentCountIs(1)) 3578 matches C<int>. 3579</pre></td></tr> 3580 3581 3582<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> 3583<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is 3584partially matching a given regex. 3585 3586Example matches Y but not X 3587 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 3588 #include "ASTMatcher.h" 3589 class X {}; 3590ASTMatcher.h: 3591 class Y {}; 3592 3593Usable 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>> 3594</pre></td></tr> 3595 3596 3597<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> 3598<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. 3599 3600Example matches X but not Y 3601 (matcher = cxxRecordDecl(isExpansionInMainFile()) 3602 #include <Y.h> 3603 class X {}; 3604Y.h: 3605 class Y {}; 3606 3607Usable 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>> 3608</pre></td></tr> 3609 3610 3611<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> 3612<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. 3613 3614Example matches Y but not X 3615 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 3616 #include <SystemHeader.h> 3617 class X {}; 3618SystemHeader.h: 3619 class Y {}; 3620 3621Usable 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>> 3622</pre></td></tr> 3623 3624 3625<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> 3626<tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool. 3627 3628Given 3629 struct S { bool func(); }; 3630functionDecl(returns(booleanType())) 3631 matches "bool func();" 3632</pre></td></tr> 3633 3634 3635<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> 3636<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. 3637 3638Matches a node if it equals the node previously bound to ID. 3639 3640Given 3641 class X { int a; int b; }; 3642cxxRecordDecl( 3643 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3644 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3645 matches the class X, as a and b have the same type. 3646 3647Note that when multiple matches are involved via forEach* matchers, 3648equalsBoundNodes acts as a filter. 3649For example: 3650compoundStmt( 3651 forEachDescendant(varDecl().bind("d")), 3652 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3653will trigger a match for each combination of variable declaration 3654and reference to that variable declaration within a compound statement. 3655</pre></td></tr> 3656 3657 3658<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> 3659<tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node. 3660 3661Type has pointer identity in the AST. 3662</pre></td></tr> 3663 3664 3665<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> 3666<tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double). 3667 3668Given 3669 int i; 3670 float f; 3671realFloatingPointType() 3672 matches "float f" but not "int i" 3673</pre></td></tr> 3674 3675 3676<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> 3677<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. 3678 3679Given 3680 struct S { void func(); }; 3681functionDecl(returns(voidType())) 3682 matches "void func();" 3683</pre></td></tr> 3684 3685 3686<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> 3687<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 3688 3689Given 3690 int x; 3691 int s = sizeof(x) + alignof(x) 3692unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 3693 matches sizeof(x) 3694</pre></td></tr> 3695 3696 3697<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> 3698<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 3699unary). 3700 3701Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 3702 !(a || b) 3703</pre></td></tr> 3704 3705 3706<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> 3707<tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration. 3708 3709Example matches x, but not y, z, or a. 3710(matcher = varDecl(hasAutomaticStorageDuration()) 3711void f() { 3712 int x; 3713 static int y; 3714 thread_local int z; 3715} 3716int a; 3717</pre></td></tr> 3718 3719 3720<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> 3721<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. 3722 3723Example matches y and z (matcher = varDecl(hasGlobalStorage()) 3724void f() { 3725 int x; 3726 static int y; 3727} 3728int z; 3729</pre></td></tr> 3730 3731 3732<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> 3733<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a 3734non-static local variable. 3735 3736Example matches x (matcher = varDecl(hasLocalStorage()) 3737void f() { 3738 int x; 3739 static int y; 3740} 3741int z; 3742</pre></td></tr> 3743 3744 3745<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> 3746<tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration. 3747It includes the variable declared at namespace scope and those declared 3748with "static" and "extern" storage class specifiers. 3749 3750void f() { 3751 int x; 3752 static int y; 3753 thread_local int z; 3754} 3755int a; 3756static int b; 3757extern int c; 3758varDecl(hasStaticStorageDuration()) 3759 matches the function declaration y, a, b and c. 3760</pre></td></tr> 3761 3762 3763<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> 3764<tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration. 3765 3766Example matches z, but not x, z, or a. 3767(matcher = varDecl(hasThreadStorageDuration()) 3768void f() { 3769 int x; 3770 static int y; 3771 thread_local int z; 3772} 3773int a; 3774</pre></td></tr> 3775 3776 3777<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> 3778<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations. 3779 3780Given: 3781 constexpr int foo = 42; 3782 constexpr int bar(); 3783varDecl(isConstexpr()) 3784 matches the declaration of foo. 3785functionDecl(isConstexpr()) 3786 matches the declaration of bar. 3787</pre></td></tr> 3788 3789 3790<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> 3791<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 3792 3793Example matches A, va, fa 3794 class A {}; 3795 class B; Doesn't match, as it has no body. 3796 int va; 3797 extern int vb; Doesn't match, as it doesn't define the variable. 3798 void fa() {} 3799 void fb(); Doesn't match, as it has no body. 3800 @interface X 3801 - (void)ma; Doesn't match, interface is declaration. 3802 @end 3803 @implementation X 3804 - (void)ma {} 3805 @end 3806 3807Usable 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>>, 3808 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 3809</pre></td></tr> 3810 3811 3812<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isExceptionVariable0')"><a name="isExceptionVariable0Anchor">isExceptionVariable</a></td><td></td></tr> 3813<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from 3814a C++ catch block, or an Objective-C statement. 3815 3816Example matches x (matcher = varDecl(isExceptionVariable()) 3817void f(int y) { 3818 try { 3819 } catch (int x) { 3820 } 3821} 3822</pre></td></tr> 3823 3824 3825<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> 3826<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 3827static member variable template instantiations. 3828 3829Given 3830 template<typename T> void A(T t) { } 3831 template<> void A(int N) { } 3832functionDecl(isExplicitTemplateSpecialization()) 3833 matches the specialization A<int>(). 3834 3835Usable 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>> 3836</pre></td></tr> 3837 3838 3839<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> 3840<tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations. 3841 3842Given: 3843 extern "C" void f() {} 3844 extern "C" { void g() {} } 3845 void h() {} 3846 extern "C" int x = 1; 3847 extern "C" int y = 2; 3848 int z = 3; 3849functionDecl(isExternC()) 3850 matches the declaration of f and g, but not the declaration of h. 3851varDecl(isExternC()) 3852 matches the declaration of x and y, but not the declaration of z. 3853</pre></td></tr> 3854 3855 3856<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> 3857<tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variablefunction declarations that have "static" storage 3858class specifier ("static" keyword) written in the source. 3859 3860Given: 3861 static void f() {} 3862 static int i = 0; 3863 extern int j; 3864 int k; 3865functionDecl(isStaticStorageClass()) 3866 matches the function declaration f. 3867varDecl(isStaticStorageClass()) 3868 matches the variable declaration i. 3869</pre></td></tr> 3870 3871 3872<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> 3873<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 3874member variable template instantiations. 3875 3876Given 3877 template <typename T> class X {}; class A {}; X<A> x; 3878or 3879 template <typename T> class X {}; class A {}; template class X<A>; 3880or 3881 template <typename T> class X {}; class A {}; extern template class X<A>; 3882cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 3883 matches the template instantiation of X<A>. 3884 3885But given 3886 template <typename T> class X {}; class A {}; 3887 template <> class X<A> {}; X<A> x; 3888cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 3889 does not match, as X<A> is an explicit template specialization. 3890 3891Usable 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>> 3892</pre></td></tr> 3893 3894 3895<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> 3896<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside 3897template instantiations. 3898 3899Given 3900 template<typename T> void A(T t) { T i; } 3901 A(0); 3902 A(0U); 3903functionDecl(isInstantiated()) 3904 matches 'A(int) {...};' and 'A(unsigned) {...}'. 3905</pre></td></tr> 3906 3907 3908<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> 3909<tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as 3910GNU's __null, C++11's nullptr, or C's NULL macro. 3911 3912Given: 3913 void *v1 = NULL; 3914 void *v2 = nullptr; 3915 void *v3 = __null; GNU extension 3916 char *cp = (char *)0; 3917 int *ip = 0; 3918 int i = 0; 3919expr(nullPointerConstant()) 3920 matches the initializer for v1, v2, v3, cp, and ip. Does not match the 3921 initializer for i. 3922</pre></td></tr> 3923 3924 3925<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> 3926<tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names. 3927 3928This matcher is only provided as a performance optimization of hasName. 3929 hasAnyName(a, b, c) 3930 is equivalent to, but faster than 3931 anyOf(hasName(a), hasName(b), hasName(c)) 3932</pre></td></tr> 3933 3934 3935<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> 3936<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. 3937 3938Given 3939 int j; 3940 template<typename T> void A(T t) { T i; j += 42;} 3941 A(0); 3942 A(0U); 3943declStmt(isInTemplateInstantiation()) 3944 matches 'int i;' and 'unsigned i'. 3945unless(stmt(isInTemplateInstantiation())) 3946 will NOT match j += 42; as it's shared between the template definition and 3947 instantiation. 3948</pre></td></tr> 3949 3950<!--END_NARROWING_MATCHERS --> 3951</table> 3952 3953<!-- ======================================================================= --> 3954<h2 id="traversal-matchers">AST Traversal Matchers</h2> 3955<!-- ======================================================================= --> 3956 3957<p>Traversal matchers specify the relationship to other nodes that are 3958reachable from the current node.</p> 3959 3960<p>Note that there are special traversal matchers (has, hasDescendant, forEach and 3961forEachDescendant) which work on all nodes and allow users to write more generic 3962match expressions.</p> 3963 3964<table> 3965<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 3966<!-- START_TRAVERSAL_MATCHERS --> 3967 3968<tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 3969<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. 3970 3971Unlike anyOf, eachOf will generate a match result for each 3972matching submatcher. 3973 3974For example, in: 3975 class A { int a; int b; }; 3976The matcher: 3977 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), 3978 has(fieldDecl(hasName("b")).bind("v")))) 3979will generate two results binding "v", the first of which binds 3980the field declaration of a, the second the field declaration of 3981b. 3982 3983Usable as: Any Matcher 3984</pre></td></tr> 3985 3986 3987<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> 3988<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 3989provided matcher. 3990 3991Example matches X, A, A::X, B, B::C, B::C::X 3992 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) 3993 class X {}; 3994 class A { class X {}; }; Matches A, because A::X is a class of name 3995 X inside A. 3996 class B { class C { class X {}; }; }; 3997 3998DescendantT must be an AST base type. 3999 4000As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 4001each result that matches instead of only on the first one. 4002 4003Note: Recursively combined ForEachDescendant can cause many matches: 4004 cxxRecordDecl(forEachDescendant(cxxRecordDecl( 4005 forEachDescendant(cxxRecordDecl()) 4006 ))) 4007will match 10 times (plus injected class name matches) on: 4008 class A { class B { class C { class D { class E {}; }; }; }; }; 4009 4010Usable as: Any Matcher 4011</pre></td></tr> 4012 4013 4014<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> 4015<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 4016provided matcher. 4017 4018Example matches X, Y, Y::X, Z::Y, Z::Y::X 4019 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) 4020 class X {}; 4021 class Y { class X {}; }; Matches Y, because Y::X is a class of name X 4022 inside Y. 4023 class Z { class Y { class X {}; }; }; Does not match Z. 4024 4025ChildT must be an AST base type. 4026 4027As opposed to 'has', 'forEach' will cause a match for each result that 4028matches instead of only on the first one. 4029 4030Usable as: Any Matcher 4031</pre></td></tr> 4032 4033 4034<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> 4035<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 4036matcher. 4037 4038Given 4039void f() { if (true) { int x = 42; } } 4040void g() { for (;;) { int x = 43; } } 4041expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 4042 4043Usable as: Any Matcher 4044</pre></td></tr> 4045 4046 4047<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> 4048<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 4049provided matcher. 4050 4051Example matches X, Y, Z 4052 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) 4053 class X {}; Matches X, because X::X is a class of name X inside X. 4054 class Y { class X {}; }; 4055 class Z { class Y { class X {}; }; }; 4056 4057DescendantT must be an AST base type. 4058 4059Usable as: Any Matcher 4060</pre></td></tr> 4061 4062 4063<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> 4064<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 4065provided matcher. 4066 4067Example matches X, Y 4068 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) 4069 class X {}; Matches X, because X::X is a class of name X inside X. 4070 class Y { class X {}; }; 4071 class Z { class Y { class X {}; }; }; Does not match Z. 4072 4073ChildT must be an AST base type. 4074 4075Usable as: Any Matcher 4076Note that has is direct matcher, so it also matches things like implicit 4077casts and paren casts. If you are matching with expr then you should 4078probably consider using ignoringParenImpCasts like: 4079has(ignoringParenImpCasts(expr())). 4080</pre></td></tr> 4081 4082 4083<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> 4084<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 4085matcher. 4086 4087Given 4088void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 4089compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 4090 4091Usable as: Any Matcher 4092</pre></td></tr> 4093 4094 4095<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> 4096<tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop, 4097switch statement or conditional operator. 4098 4099Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 4100 if (true) {} 4101</pre></td></tr> 4102 4103 4104<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> 4105<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator 4106(binary or ternary). 4107 4108Example matches b 4109 condition ? a : b 4110 condition ?: b 4111</pre></td></tr> 4112 4113 4114<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> 4115<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 4116 4117Example 1 (conditional ternary operator): matches a 4118 condition ? a : b 4119 4120Example 2 (conditional binary operator): matches opaqueValueExpr(condition) 4121 condition ?: b 4122</pre></td></tr> 4123 4124 4125<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>></td><td class="name" onclick="toggle('hasDeclaration15')"><a name="hasDeclaration15Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4126<tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node 4127matches the given matcher. 4128 4129The associated declaration is: 4130- for type nodes, the declaration of the underlying type 4131- for CallExpr, the declaration of the callee 4132- for MemberExpr, the declaration of the referenced member 4133- for CXXConstructExpr, the declaration of the constructor 4134- for CXXNewExpr, the declaration of the operator new 4135 4136For type nodes, hasDeclaration will generally match the declaration of the 4137sugared type. Given 4138 class X {}; 4139 typedef X Y; 4140 Y y; 4141in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4142typedefDecl. A common use case is to match the underlying, desugared type. 4143This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4144 varDecl(hasType(hasUnqualifiedDesugaredType( 4145 recordType(hasDeclaration(decl()))))) 4146In this matcher, the decl will match the CXXRecordDecl of class X. 4147 4148Usable 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>>, 4149 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>>, 4150 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>>, 4151 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>>, 4152 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>>, 4153 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>>, 4154 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4155</pre></td></tr> 4156 4157 4158<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> 4159<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 4160 4161Given 4162 int i[5]; 4163 void f() { i[1] = 42; } 4164arraySubscriptExpression(hasBase(implicitCastExpr( 4165 hasSourceExpression(declRefExpr())))) 4166 matches i[1] with the declRefExpr() matching i 4167</pre></td></tr> 4168 4169 4170<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> 4171<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 4172 4173Given 4174 int i[5]; 4175 void f() { i[1] = 42; } 4176arraySubscriptExpression(hasIndex(integerLiteral())) 4177 matches i[1] with the integerLiteral() matching 1 4178</pre></td></tr> 4179 4180 4181<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> 4182<tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions. 4183 4184Example matches a (matcher = binaryOperator(hasLHS())) 4185 a || b 4186</pre></td></tr> 4187 4188 4189<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> 4190<tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions. 4191 4192Example matches b (matcher = binaryOperator(hasRHS())) 4193 a || b 4194</pre></td></tr> 4195 4196 4197<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> 4198<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element 4199type. 4200 4201Given 4202 struct A {}; 4203 A a[7]; 4204 int b[7]; 4205arrayType(hasElementType(builtinType())) 4206 matches "int b[7]" 4207 4208Usable 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>> 4209</pre></td></tr> 4210 4211 4212<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> 4213<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element 4214type. 4215 4216Given 4217 struct A {}; 4218 A a[7]; 4219 int b[7]; 4220arrayType(hasElementType(builtinType())) 4221 matches "int b[7]" 4222 4223Usable 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>> 4224</pre></td></tr> 4225 4226 4227<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> 4228<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. 4229 4230Given 4231 _Atomic(int) i; 4232 _Atomic(float) f; 4233atomicType(hasValueType(isInteger())) 4234 matches "_Atomic(int) i" 4235 4236Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 4237</pre></td></tr> 4238 4239 4240<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> 4241<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. 4242 4243Given 4244 _Atomic(int) i; 4245 _Atomic(float) f; 4246atomicType(hasValueType(isInteger())) 4247 matches "_Atomic(int) i" 4248 4249Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 4250</pre></td></tr> 4251 4252 4253<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> 4254<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. 4255 4256Note: There is no TypeLoc for the deduced type and thus no 4257getDeducedLoc() matcher. 4258 4259Given 4260 auto a = 1; 4261 auto b = 2.0; 4262autoType(hasDeducedType(isInteger())) 4263 matches "auto a" 4264 4265Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> 4266</pre></td></tr> 4267 4268 4269<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('hasEitherOperand0')"><a name="hasEitherOperand0Anchor">hasEitherOperand</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 4270<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 4271binary operator matches. 4272</pre></td></tr> 4273 4274 4275<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> 4276<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 4277 4278Example matches a (matcher = binaryOperator(hasLHS())) 4279 a || b 4280</pre></td></tr> 4281 4282 4283<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> 4284<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 4285 4286Example matches b (matcher = binaryOperator(hasRHS())) 4287 a || b 4288</pre></td></tr> 4289 4290 4291<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> 4292<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the 4293pointee matches a given matcher. 4294 4295Given 4296 int *a; 4297 int const *b; 4298 float const *f; 4299pointerType(pointee(isConstQualified(), isInteger())) 4300 matches "int const *b" 4301 4302Usable 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>>, 4303 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>> 4304</pre></td></tr> 4305 4306 4307<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> 4308<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the 4309pointee matches a given matcher. 4310 4311Given 4312 int *a; 4313 int const *b; 4314 float const *f; 4315pointerType(pointee(isConstQualified(), isInteger())) 4316 matches "int const *b" 4317 4318Usable 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>>, 4319 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>> 4320</pre></td></tr> 4321 4322 4323<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> 4324<tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl. 4325 4326Given 4327 void f(int i); 4328 int y; 4329 f(y); 4330callExpr( 4331 forEachArgumentWithParam( 4332 declRefExpr(to(varDecl(hasName("y")))), 4333 parmVarDecl(hasType(isInteger())) 4334)) 4335 matches f(y); 4336with declRefExpr(...) 4337 matching int y 4338and parmVarDecl(...) 4339 matching int i 4340</pre></td></tr> 4341 4342 4343<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> 4344<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call 4345expression. 4346 4347Given 4348 void x(int, int, int) { int y; x(1, y, 42); } 4349callExpr(hasAnyArgument(declRefExpr())) 4350 matches x(1, y, 42) 4351with hasAnyArgument(...) 4352 matching y 4353</pre></td></tr> 4354 4355 4356<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> 4357<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor 4358call expression. 4359 4360Example matches y in x(y) 4361 (matcher = callExpr(hasArgument(0, declRefExpr()))) 4362 void x(int) { int y; x(y); } 4363</pre></td></tr> 4364 4365 4366<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasDeclaration13')"><a name="hasDeclaration13Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4367<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node 4368matches the given matcher. 4369 4370The associated declaration is: 4371- for type nodes, the declaration of the underlying type 4372- for CallExpr, the declaration of the callee 4373- for MemberExpr, the declaration of the referenced member 4374- for CXXConstructExpr, the declaration of the constructor 4375- for CXXNewExpr, the declaration of the operator new 4376 4377For type nodes, hasDeclaration will generally match the declaration of the 4378sugared type. Given 4379 class X {}; 4380 typedef X Y; 4381 Y y; 4382in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4383typedefDecl. A common use case is to match the underlying, desugared type. 4384This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4385 varDecl(hasType(hasUnqualifiedDesugaredType( 4386 recordType(hasDeclaration(decl()))))) 4387In this matcher, the decl will match the CXXRecordDecl of class X. 4388 4389Usable 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>>, 4390 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>>, 4391 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>>, 4392 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>>, 4393 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>>, 4394 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>>, 4395 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4396</pre></td></tr> 4397 4398 4399<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> 4400<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. 4401 4402Given 4403 class A { A() : i(42), j(42) {} int i; int j; }; 4404cxxConstructorDecl(forEachConstructorInitializer( 4405 forField(decl().bind("x")) 4406)) 4407 will trigger two matches, binding for 'i' and 'j' respectively. 4408</pre></td></tr> 4409 4410 4411<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> 4412<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 4413 4414Given 4415 struct Foo { 4416 Foo() : foo_(1) { } 4417 int foo_; 4418 }; 4419cxxRecordDecl(has(cxxConstructorDecl( 4420 hasAnyConstructorInitializer(anything()) 4421))) 4422 record matches Foo, hasAnyConstructorInitializer matches foo_(1) 4423</pre></td></tr> 4424 4425 4426<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> 4427<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 4428 4429Given 4430 struct Foo { 4431 Foo() : foo_(1) { } 4432 int foo_; 4433 }; 4434cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 4435 forField(hasName("foo_")))))) 4436 matches Foo 4437with forField matching foo_ 4438</pre></td></tr> 4439 4440 4441<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> 4442<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 4443 4444Given 4445 struct Foo { 4446 Foo() : foo_(1) { } 4447 int foo_; 4448 }; 4449cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 4450 withInitializer(integerLiteral(equals(1))))))) 4451 matches Foo 4452with withInitializer matching (1) 4453</pre></td></tr> 4454 4455 4456<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> 4457<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'do while' statement or a function 4458definition that has a given body. 4459 4460Given 4461 for (;;) {} 4462hasBody(compoundStmt()) 4463 matches 'for (;;) {}' 4464with compoundStmt() 4465 matching '{}' 4466</pre></td></tr> 4467 4468 4469<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> 4470<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. 4471 4472Example: 4473 forStmt(hasLoopVariable(anything())) 4474matches 'int x' in 4475 for (int x : a) { } 4476</pre></td></tr> 4477 4478 4479<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> 4480<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. 4481 4482Example: 4483 forStmt(hasRangeInit(anything())) 4484matches 'a' in 4485 for (int x : a) { } 4486</pre></td></tr> 4487 4488 4489<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> 4490<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> 4491 4492 4493<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> 4494<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. 4495 4496Example matches y.x() 4497 (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))) 4498 class Y { public: void x(); }; 4499 void z() { Y y; y.x(); } 4500 4501FIXME: Overload to allow directly matching types? 4502</pre></td></tr> 4503 4504 4505<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> 4506<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 4507</pre></td></tr> 4508 4509 4510<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> 4511<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified 4512matcher, or is a pointer to a type that matches the InnerMatcher. 4513</pre></td></tr> 4514 4515 4516<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> 4517<tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overriden by the given method. This matcher may 4518produce multiple matches. 4519 4520Given 4521 class A { virtual void f(); }; 4522 class B : public A { void f(); }; 4523 class C : public B { void f(); }; 4524cxxMethodDecl(ofClass(hasName("C")), 4525 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") 4526 matches once, with "b" binding "A::f" and "d" binding "C::f" (Note 4527 that B::f is not overridden by C::f). 4528 4529The check can produce multiple matches in case of multiple inheritance, e.g. 4530 class A1 { virtual void f(); }; 4531 class A2 { virtual void f(); }; 4532 class C : public A1, public A2 { void f(); }; 4533cxxMethodDecl(ofClass(hasName("C")), 4534 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") 4535 matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and 4536 once with "b" binding "A2::f" and "d" binding "C::f". 4537</pre></td></tr> 4538 4539 4540<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> 4541<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 4542belongs to. 4543 4544FIXME: Generalize this for other kinds of declarations. 4545FIXME: What other kind of declarations would we need to generalize 4546this to? 4547 4548Example matches A() in the last line 4549 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( 4550 ofClass(hasName("A")))))) 4551 class A { 4552 public: 4553 A(); 4554 }; 4555 A a = A(); 4556</pre></td></tr> 4557 4558 4559<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> 4560<tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size. 4561 4562Given: 4563 MyClass *p1 = new MyClass[10]; 4564cxxNewExpr(hasArraySize(intgerLiteral(equals(10)))) 4565 matches the expression 'new MyClass[10]'. 4566</pre></td></tr> 4567 4568 4569<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('hasDeclaration12')"><a name="hasDeclaration12Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4570<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node 4571matches the given matcher. 4572 4573The associated declaration is: 4574- for type nodes, the declaration of the underlying type 4575- for CallExpr, the declaration of the callee 4576- for MemberExpr, the declaration of the referenced member 4577- for CXXConstructExpr, the declaration of the constructor 4578- for CXXNewExpr, the declaration of the operator new 4579 4580For type nodes, hasDeclaration will generally match the declaration of the 4581sugared type. Given 4582 class X {}; 4583 typedef X Y; 4584 Y y; 4585in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4586typedefDecl. A common use case is to match the underlying, desugared type. 4587This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4588 varDecl(hasType(hasUnqualifiedDesugaredType( 4589 recordType(hasDeclaration(decl()))))) 4590In this matcher, the decl will match the CXXRecordDecl of class X. 4591 4592Usable 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>>, 4593 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>>, 4594 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>>, 4595 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>>, 4596 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>>, 4597 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>>, 4598 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4599</pre></td></tr> 4600 4601 4602<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> 4603<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. 4604 4605Given: 4606 class A { void func(); }; 4607 class B { void member(); }; 4608 4609cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of 4610A but not B. 4611</pre></td></tr> 4612 4613 4614<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> 4615<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from 4616a class matching Base. 4617 4618Note that a class is not considered to be derived from itself. 4619 4620Example matches Y, Z, C (Base == hasName("X")) 4621 class X; 4622 class Y : public X {}; directly derived 4623 class Z : public Y {}; indirectly derived 4624 typedef X A; 4625 typedef A B; 4626 class C : public B {}; derived from a typedef of X 4627 4628In the following example, Bar matches isDerivedFrom(hasName("X")): 4629 class Foo; 4630 typedef Foo X; 4631 class Bar : public Foo {}; derived from a type that X is a typedef of 4632</pre></td></tr> 4633 4634 4635<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> 4636<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 4637match Base. 4638</pre></td></tr> 4639 4640 4641<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> 4642<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the 4643given matcher. 4644 4645Example matches y.x() (matcher = callExpr(callee( 4646 cxxMethodDecl(hasName("x"))))) 4647 class Y { public: void x(); }; 4648 void z() { Y y; y.x(); } 4649</pre></td></tr> 4650 4651 4652<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> 4653<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. 4654 4655Given 4656 class Y { void x() { this->x(); x(); Y y; y.x(); } }; 4657 void f() { f(); } 4658callExpr(callee(expr())) 4659 matches this->x(), x(), y.x(), f() 4660with callee(...) 4661 matching this->x, x, y.x, f respectively 4662 4663Note: Callee cannot take the more general internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> 4664because this introduces ambiguous overloads with calls to Callee taking a 4665internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely 4666implemented in terms of implicit casts. 4667</pre></td></tr> 4668 4669 4670<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> 4671<tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl. 4672 4673Given 4674 void f(int i); 4675 int y; 4676 f(y); 4677callExpr( 4678 forEachArgumentWithParam( 4679 declRefExpr(to(varDecl(hasName("y")))), 4680 parmVarDecl(hasType(isInteger())) 4681)) 4682 matches f(y); 4683with declRefExpr(...) 4684 matching int y 4685and parmVarDecl(...) 4686 matching int i 4687</pre></td></tr> 4688 4689 4690<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> 4691<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 4692expression. 4693 4694Given 4695 void x(int, int, int) { int y; x(1, y, 42); } 4696callExpr(hasAnyArgument(declRefExpr())) 4697 matches x(1, y, 42) 4698with hasAnyArgument(...) 4699 matching y 4700</pre></td></tr> 4701 4702 4703<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> 4704<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 4705call expression. 4706 4707Example matches y in x(y) 4708 (matcher = callExpr(hasArgument(0, declRefExpr()))) 4709 void x(int) { int y; x(y); } 4710</pre></td></tr> 4711 4712 4713<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasDeclaration14')"><a name="hasDeclaration14Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4714<tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node 4715matches the given matcher. 4716 4717The associated declaration is: 4718- for type nodes, the declaration of the underlying type 4719- for CallExpr, the declaration of the callee 4720- for MemberExpr, the declaration of the referenced member 4721- for CXXConstructExpr, the declaration of the constructor 4722- for CXXNewExpr, the declaration of the operator new 4723 4724For type nodes, hasDeclaration will generally match the declaration of the 4725sugared type. Given 4726 class X {}; 4727 typedef X Y; 4728 Y y; 4729in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4730typedefDecl. A common use case is to match the underlying, desugared type. 4731This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4732 varDecl(hasType(hasUnqualifiedDesugaredType( 4733 recordType(hasDeclaration(decl()))))) 4734In this matcher, the decl will match the CXXRecordDecl of class X. 4735 4736Usable 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>>, 4737 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>>, 4738 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>>, 4739 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>>, 4740 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>>, 4741 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>>, 4742 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4743</pre></td></tr> 4744 4745 4746<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> 4747<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range 4748extension, matches the constant given in the statement. 4749 4750Given 4751 switch (1) { case 1: case 1+1: case 3 ... 4: ; } 4752caseStmt(hasCaseConstant(integerLiteral())) 4753 matches "case 1:" 4754</pre></td></tr> 4755 4756 4757<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> 4758<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression 4759or opaque value's source expression matches the given matcher. 4760 4761Example 1: matches "a string" 4762(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) 4763class URL { URL(string); }; 4764URL url = "a string"; 4765 4766Example 2: matches 'b' (matcher = 4767opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) 4768int a = b ?: 1; 4769</pre></td></tr> 4770 4771 4772<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> 4773<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and 4774functionDecl that have at least one TemplateArgument matching the given 4775InnerMatcher. 4776 4777Given 4778 template<typename T> class A {}; 4779 template<> class A<double> {}; 4780 A<int> a; 4781 4782 template<typename T> f() {}; 4783 void func() { f<int>(); }; 4784 4785classTemplateSpecializationDecl(hasAnyTemplateArgument( 4786 refersToType(asString("int")))) 4787 matches the specialization A<int> 4788 4789functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 4790 matches the specialization f<int> 4791</pre></td></tr> 4792 4793 4794<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> 4795<tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration. 4796 4797Given 4798 tempalate<typename T> class A {}; 4799 typedef A<int> B; 4800classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl())) 4801 matches 'B' with classTemplateDecl() matching the class template 4802 declaration of 'A'. 4803</pre></td></tr> 4804 4805 4806<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> 4807<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and 4808functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 4809 4810Given 4811 template<typename T, typename U> class A {}; 4812 A<bool, int> b; 4813 A<int, bool> c; 4814 4815 template<typename T> void f() {} 4816 void func() { f<int>(); }; 4817classTemplateSpecializationDecl(hasTemplateArgument( 4818 1, refersToType(asString("int")))) 4819 matches the specialization A<bool, int> 4820 4821functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 4822 matches the specialization f<int> 4823</pre></td></tr> 4824 4825 4826<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> 4827<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element 4828type. 4829 4830Given 4831 struct A {}; 4832 A a[7]; 4833 int b[7]; 4834arrayType(hasElementType(builtinType())) 4835 matches "int b[7]" 4836 4837Usable 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>> 4838</pre></td></tr> 4839 4840 4841<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> 4842<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element 4843type. 4844 4845Given 4846 struct A {}; 4847 A a[7]; 4848 int b[7]; 4849arrayType(hasElementType(builtinType())) 4850 matches "int b[7]" 4851 4852Usable 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>> 4853</pre></td></tr> 4854 4855 4856<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> 4857<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 4858a given matcher. Also matches StmtExprs that have CompoundStmt as children. 4859 4860Given 4861 { {}; 1+2; } 4862hasAnySubstatement(compoundStmt()) 4863 matches '{ {}; 1+2; }' 4864with compoundStmt() 4865 matching '{}' 4866</pre></td></tr> 4867 4868 4869<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> 4870<tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whos decayed type matches InnerMatcher 4871</pre></td></tr> 4872 4873 4874<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('hasDeclaration11')"><a name="hasDeclaration11Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4875<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node 4876matches the given matcher. 4877 4878The associated declaration is: 4879- for type nodes, the declaration of the underlying type 4880- for CallExpr, the declaration of the callee 4881- for MemberExpr, the declaration of the referenced member 4882- for CXXConstructExpr, the declaration of the constructor 4883- for CXXNewExpr, the declaration of the operator new 4884 4885For type nodes, hasDeclaration will generally match the declaration of the 4886sugared type. Given 4887 class X {}; 4888 typedef X Y; 4889 Y y; 4890in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4891typedefDecl. A common use case is to match the underlying, desugared type. 4892This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4893 varDecl(hasType(hasUnqualifiedDesugaredType( 4894 recordType(hasDeclaration(decl()))))) 4895In this matcher, the decl will match the CXXRecordDecl of class X. 4896 4897Usable 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>>, 4898 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>>, 4899 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>>, 4900 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>>, 4901 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>>, 4902 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>>, 4903 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4904</pre></td></tr> 4905 4906 4907<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> 4908<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a 4909specific using shadow declaration. 4910 4911Given 4912 namespace a { void f() {} } 4913 using a::f; 4914 void g() { 4915 f(); Matches this .. 4916 a::f(); .. but not this. 4917 } 4918declRefExpr(throughUsingDecl(anything())) 4919 matches f() 4920</pre></td></tr> 4921 4922 4923<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> 4924<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 4925specified matcher. 4926 4927Example matches x in if(x) 4928 (matcher = declRefExpr(to(varDecl(hasName("x"))))) 4929 bool x; 4930 if (x) {} 4931</pre></td></tr> 4932 4933 4934<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> 4935<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 4936 4937Note that this does not work for global declarations because the AST 4938breaks up multiple-declaration DeclStmt's into multiple single-declaration 4939DeclStmt's. 4940Example: Given non-global declarations 4941 int a, b = 0; 4942 int c; 4943 int d = 2, e; 4944declStmt(containsDeclaration( 4945 0, varDecl(hasInitializer(anything())))) 4946 matches only 'int d = 2, e;', and 4947declStmt(containsDeclaration(1, varDecl())) 4948 matches 'int a, b = 0' as well as 'int d = 2, e;' 4949 but 'int c;' is not matched. 4950</pre></td></tr> 4951 4952 4953<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> 4954<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 4955 4956Given 4957 int a, b; 4958 int c; 4959declStmt(hasSingleDecl(anything())) 4960 matches 'int c;' but not 'int a, b;'. 4961</pre></td></tr> 4962 4963 4964<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> 4965<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches 4966the inner matcher. 4967 4968Given 4969 int x; 4970declaratorDecl(hasTypeLoc(loc(asString("int")))) 4971 matches int x 4972</pre></td></tr> 4973 4974 4975<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> 4976<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a 4977Decl, matches InnerMatcher. 4978 4979Given 4980 namespace N { 4981 namespace M { 4982 class D {}; 4983 } 4984 } 4985 4986cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the 4987declaration of class D. 4988</pre></td></tr> 4989 4990 4991<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> 4992<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'do while' statement or a function 4993definition that has a given body. 4994 4995Given 4996 for (;;) {} 4997hasBody(compoundStmt()) 4998 matches 'for (;;) {}' 4999with compoundStmt() 5000 matching '{}' 5001</pre></td></tr> 5002 5003 5004<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> 5005<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 5006switch statement or conditional operator. 5007 5008Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5009 if (true) {} 5010</pre></td></tr> 5011 5012 5013<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> 5014<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, 5015matches InnerMatcher if the qualifier exists. 5016 5017Given 5018 namespace N { 5019 namespace M { 5020 class D {}; 5021 } 5022 } 5023 N::M::D d; 5024 5025elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) 5026matches the type of the variable declaration of d. 5027</pre></td></tr> 5028 5029 5030<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> 5031<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. 5032 5033Given 5034 namespace N { 5035 namespace M { 5036 class D {}; 5037 } 5038 } 5039 N::M::D d; 5040 5041elaboratedType(namesType(recordType( 5042hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable 5043declaration of d. 5044</pre></td></tr> 5045 5046 5047<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>></td><td class="name" onclick="toggle('hasDeclaration10')"><a name="hasDeclaration10Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5048<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node 5049matches the given matcher. 5050 5051The associated declaration is: 5052- for type nodes, the declaration of the underlying type 5053- for CallExpr, the declaration of the callee 5054- for MemberExpr, the declaration of the referenced member 5055- for CXXConstructExpr, the declaration of the constructor 5056- for CXXNewExpr, the declaration of the operator new 5057 5058For type nodes, hasDeclaration will generally match the declaration of the 5059sugared type. Given 5060 class X {}; 5061 typedef X Y; 5062 Y y; 5063in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5064typedefDecl. A common use case is to match the underlying, desugared type. 5065This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5066 varDecl(hasType(hasUnqualifiedDesugaredType( 5067 recordType(hasDeclaration(decl()))))) 5068In this matcher, the decl will match the CXXRecordDecl of class X. 5069 5070Usable 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>>, 5071 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>>, 5072 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>>, 5073 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>>, 5074 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>>, 5075 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>>, 5076 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5077</pre></td></tr> 5078 5079 5080<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> 5081<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 5082 5083(Note: Clang's AST refers to other conversions as "casts" too, and calls 5084actual casts "explicit" casts.) 5085</pre></td></tr> 5086 5087 5088<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> 5089<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value 5090declaration's type. 5091 5092In case of a value declaration (for example a variable declaration), 5093this resolves one layer of indirection. For example, in the value 5094declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 5095X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 5096declaration of x. 5097 5098Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 5099 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 5100 class X {}; 5101 void y(X &x) { x; X z; } 5102 5103Usable 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>> 5104</pre></td></tr> 5105 5106 5107<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> 5108<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type 5109matcher. 5110 5111Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 5112 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 5113 and U (matcher = typedefDecl(hasType(asString("int"))) 5114 class X {}; 5115 void y(X &x) { x; X z; } 5116 typedef int U; 5117</pre></td></tr> 5118 5119 5120<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> 5121<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 5122are stripped off. 5123 5124Parentheses and explicit casts are not discarded. 5125Given 5126 int arr[5]; 5127 int a = 0; 5128 char b = 0; 5129 const int c = a; 5130 int *d = arr; 5131 long e = (long) 0l; 5132The matchers 5133 varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 5134 varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 5135would match the declarations for a, b, c, and d, but not e. 5136While 5137 varDecl(hasInitializer(integerLiteral())) 5138 varDecl(hasInitializer(declRefExpr())) 5139only match the declarations for b, c, and d. 5140</pre></td></tr> 5141 5142 5143<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> 5144<tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST 5145nodes are stripped off. 5146 5147Parentheses and explicit casts are not discarded. 5148Given 5149 class C {}; 5150 C a = C(); 5151 C b; 5152 C c = b; 5153The matchers 5154 varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr()))) 5155would match the declarations for a, b, and c. 5156While 5157 varDecl(hasInitializer(cxxConstructExpr())) 5158only match the declarations for b and c. 5159</pre></td></tr> 5160 5161 5162<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> 5163<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 5164casts are stripped off. 5165 5166Implicit and non-C Style casts are also discarded. 5167Given 5168 int a = 0; 5169 char b = (0); 5170 void* c = reinterpret_cast<char*>(0); 5171 char d = char(0); 5172The matcher 5173 varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 5174would match the declarations for a, b, c, and d. 5175while 5176 varDecl(hasInitializer(integerLiteral())) 5177only match the declaration for a. 5178</pre></td></tr> 5179 5180 5181<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> 5182<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 5183parentheses are stripped off. 5184 5185Explicit casts are not discarded. 5186Given 5187 int arr[5]; 5188 int a = 0; 5189 char b = (0); 5190 const int c = a; 5191 int *d = (arr); 5192 long e = ((long) 0l); 5193The matchers 5194 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 5195 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 5196would match the declarations for a, b, c, and d, but not e. 5197while 5198 varDecl(hasInitializer(integerLiteral())) 5199 varDecl(hasInitializer(declRefExpr())) 5200would only match the declaration for a. 5201</pre></td></tr> 5202 5203 5204<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> 5205<tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer. 5206 5207Given 5208 class C { 5209 int a = 2; 5210 int b = 3; 5211 int c; 5212 }; 5213fieldDecl(hasInClassInitializer(integerLiteral(equals(2)))) 5214 matches 'int a;' but not 'int b;'. 5215fieldDecl(hasInClassInitializer(anything())) 5216 matches 'int a;' and 'int b;' but not 'int c;'. 5217</pre></td></tr> 5218 5219 5220<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> 5221<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'do while' statement or a function 5222definition that has a given body. 5223 5224Given 5225 for (;;) {} 5226hasBody(compoundStmt()) 5227 matches 'for (;;) {}' 5228with compoundStmt() 5229 matching '{}' 5230</pre></td></tr> 5231 5232 5233<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> 5234<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 5235switch statement or conditional operator. 5236 5237Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5238 if (true) {} 5239</pre></td></tr> 5240 5241 5242<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> 5243<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 5244 5245Example: 5246 forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 5247matches '++x' in 5248 for (x; x < N; ++x) { } 5249</pre></td></tr> 5250 5251 5252<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> 5253<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 5254 5255Example: 5256 forStmt(hasLoopInit(declStmt())) 5257matches 'int x = 0' in 5258 for (int x = 0; x < N; ++x) { } 5259</pre></td></tr> 5260 5261 5262<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> 5263<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. 5264 5265Does not match the 'this' parameter of a method. 5266 5267Given 5268 class X { void f(int x, int y, int z) {} }; 5269cxxMethodDecl(hasAnyParameter(hasName("y"))) 5270 matches f(int x, int y, int z) {} 5271with hasAnyParameter(...) 5272 matching int y 5273</pre></td></tr> 5274 5275 5276<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> 5277<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and 5278functionDecl that have at least one TemplateArgument matching the given 5279InnerMatcher. 5280 5281Given 5282 template<typename T> class A {}; 5283 template<> class A<double> {}; 5284 A<int> a; 5285 5286 template<typename T> f() {}; 5287 void func() { f<int>(); }; 5288 5289classTemplateSpecializationDecl(hasAnyTemplateArgument( 5290 refersToType(asString("int")))) 5291 matches the specialization A<int> 5292 5293functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 5294 matches the specialization f<int> 5295</pre></td></tr> 5296 5297 5298<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> 5299<tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'do while' statement or a function 5300definition that has a given body. 5301 5302Given 5303 for (;;) {} 5304hasBody(compoundStmt()) 5305 matches 'for (;;) {}' 5306with compoundStmt() 5307 matching '{}' 5308</pre></td></tr> 5309 5310 5311<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> 5312<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. 5313 5314Given 5315 class X { void f(int x) {} }; 5316cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 5317 matches f(int x) {} 5318with hasParameter(...) 5319 matching int x 5320</pre></td></tr> 5321 5322 5323<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> 5324<tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and 5325functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 5326 5327Given 5328 template<typename T, typename U> class A {}; 5329 A<bool, int> b; 5330 A<int, bool> c; 5331 5332 template<typename T> void f() {} 5333 void func() { f<int>(); }; 5334classTemplateSpecializationDecl(hasTemplateArgument( 5335 1, refersToType(asString("int")))) 5336 matches the specialization A<bool, int> 5337 5338functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 5339 matches the specialization f<int> 5340</pre></td></tr> 5341 5342 5343<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> 5344<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 5345 5346Given: 5347 class X { int f() { return 1; } }; 5348cxxMethodDecl(returns(asString("int"))) 5349 matches int f() { return 1; } 5350</pre></td></tr> 5351 5352 5353<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> 5354<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 5355switch statement or conditional operator. 5356 5357Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5358 if (true) {} 5359</pre></td></tr> 5360 5361 5362<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> 5363<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 5364 5365Given 5366 if (A* a = GetAPointer()) {} 5367hasConditionVariableStatement(...) 5368 matches 'A* a = GetAPointer()'. 5369</pre></td></tr> 5370 5371 5372<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> 5373<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. 5374 5375Examples matches the if statement 5376 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) 5377 if (false) false; else true; 5378</pre></td></tr> 5379 5380 5381<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> 5382<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. 5383 5384Examples matches the if statement 5385 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) 5386 if (false) true; else false; 5387</pre></td></tr> 5388 5389 5390<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> 5391<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 5392matcher. 5393 5394FIXME: Unit test this matcher 5395</pre></td></tr> 5396 5397 5398<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> 5399<tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions 5400(if expression have it). 5401</pre></td></tr> 5402 5403 5404<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>></td><td class="name" onclick="toggle('hasDeclaration9')"><a name="hasDeclaration9Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5405<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node 5406matches the given matcher. 5407 5408The associated declaration is: 5409- for type nodes, the declaration of the underlying type 5410- for CallExpr, the declaration of the callee 5411- for MemberExpr, the declaration of the referenced member 5412- for CXXConstructExpr, the declaration of the constructor 5413- for CXXNewExpr, the declaration of the operator new 5414 5415For type nodes, hasDeclaration will generally match the declaration of the 5416sugared type. Given 5417 class X {}; 5418 typedef X Y; 5419 Y y; 5420in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5421typedefDecl. A common use case is to match the underlying, desugared type. 5422This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5423 varDecl(hasType(hasUnqualifiedDesugaredType( 5424 recordType(hasDeclaration(decl()))))) 5425In this matcher, the decl will match the CXXRecordDecl of class X. 5426 5427Usable 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>>, 5428 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>>, 5429 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>>, 5430 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>>, 5431 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>>, 5432 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>>, 5433 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5434</pre></td></tr> 5435 5436 5437<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>></td><td class="name" onclick="toggle('hasDeclaration8')"><a name="hasDeclaration8Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5438<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node 5439matches the given matcher. 5440 5441The associated declaration is: 5442- for type nodes, the declaration of the underlying type 5443- for CallExpr, the declaration of the callee 5444- for MemberExpr, the declaration of the referenced member 5445- for CXXConstructExpr, the declaration of the constructor 5446- for CXXNewExpr, the declaration of the operator new 5447 5448For type nodes, hasDeclaration will generally match the declaration of the 5449sugared type. Given 5450 class X {}; 5451 typedef X Y; 5452 Y y; 5453in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5454typedefDecl. A common use case is to match the underlying, desugared type. 5455This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5456 varDecl(hasType(hasUnqualifiedDesugaredType( 5457 recordType(hasDeclaration(decl()))))) 5458In this matcher, the decl will match the CXXRecordDecl of class X. 5459 5460Usable 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>>, 5461 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>>, 5462 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>>, 5463 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>>, 5464 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>>, 5465 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>>, 5466 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5467</pre></td></tr> 5468 5469 5470<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('hasDeclaration7')"><a name="hasDeclaration7Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5471<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node 5472matches the given matcher. 5473 5474The associated declaration is: 5475- for type nodes, the declaration of the underlying type 5476- for CallExpr, the declaration of the callee 5477- for MemberExpr, the declaration of the referenced member 5478- for CXXConstructExpr, the declaration of the constructor 5479- for CXXNewExpr, the declaration of the operator new 5480 5481For type nodes, hasDeclaration will generally match the declaration of the 5482sugared type. Given 5483 class X {}; 5484 typedef X Y; 5485 Y y; 5486in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5487typedefDecl. A common use case is to match the underlying, desugared type. 5488This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5489 varDecl(hasType(hasUnqualifiedDesugaredType( 5490 recordType(hasDeclaration(decl()))))) 5491In this matcher, the decl will match the CXXRecordDecl of class X. 5492 5493Usable 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>>, 5494 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>>, 5495 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>>, 5496 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>>, 5497 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>>, 5498 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>>, 5499 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5500</pre></td></tr> 5501 5502 5503<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> 5504<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is 5505matched by a given matcher. 5506 5507Given 5508 struct X { int m; }; 5509 void f(X x) { x.m; m; } 5510memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))))) 5511 matches "x.m" and "m" 5512with hasObjectExpression(...) 5513 matching "x" and the implicit object expression of "m" which has type X*. 5514</pre></td></tr> 5515 5516 5517<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> 5518<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 5519given matcher. 5520 5521Given 5522 struct { int first, second; } first, second; 5523 int i(second.first); 5524 int j(first.second); 5525memberExpr(member(hasName("first"))) 5526 matches second.first 5527 but not first.second (because the member name there is "second"). 5528</pre></td></tr> 5529 5530 5531<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> 5532<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the 5533pointee matches a given matcher. 5534 5535Given 5536 int *a; 5537 int const *b; 5538 float const *f; 5539pointerType(pointee(isConstQualified(), isInteger())) 5540 matches "int const *b" 5541 5542Usable 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>>, 5543 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>> 5544</pre></td></tr> 5545 5546 5547<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> 5548<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the 5549pointee matches a given matcher. 5550 5551Given 5552 int *a; 5553 int const *b; 5554 float const *f; 5555pointerType(pointee(isConstQualified(), isInteger())) 5556 matches "int const *b" 5557 5558Usable 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>>, 5559 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>> 5560</pre></td></tr> 5561 5562 5563<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> 5564<tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given 5565matcher. 5566 5567Given 5568 namespace N { template<class T> void f(T t); } 5569 template <class T> void g() { using N::f; f(T()); } 5570unresolvedLookupExpr(hasAnyDeclaration( 5571 namedDecl(hasUnderlyingDecl(hasName("::N::f"))))) 5572 matches the use of f in g() . 5573</pre></td></tr> 5574 5575 5576<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> 5577<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 5578 5579Given 5580 struct A { struct B { struct C {}; }; }; 5581 A::B::C c; 5582nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 5583 matches "A::" 5584</pre></td></tr> 5585 5586 5587<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> 5588<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 5589given TypeLoc. 5590 5591Given 5592 struct A { struct B { struct C {}; }; }; 5593 A::B::C c; 5594nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 5595 hasDeclaration(cxxRecordDecl(hasName("A"))))))) 5596 matches "A::" 5597</pre></td></tr> 5598 5599 5600<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> 5601<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 5602 5603Given 5604 struct A { struct B { struct C {}; }; }; 5605 A::B::C c; 5606nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 5607 matches "A::" 5608</pre></td></tr> 5609 5610 5611<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> 5612<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 5613given namespace matcher. 5614 5615Given 5616 namespace ns { struct A {}; } 5617 ns::A a; 5618nestedNameSpecifier(specifiesNamespace(hasName("ns"))) 5619 matches "ns::" 5620</pre></td></tr> 5621 5622 5623<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> 5624<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 5625given QualType matcher without qualifiers. 5626 5627Given 5628 struct A { struct B { struct C {}; }; }; 5629 A::B::C c; 5630nestedNameSpecifier(specifiesType( 5631 hasDeclaration(cxxRecordDecl(hasName("A"))) 5632)) 5633 matches "A::" 5634</pre></td></tr> 5635 5636 5637<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> 5638<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor 5639call expression. 5640 5641Example matches y in x(y) 5642 (matcher = callExpr(hasArgument(0, declRefExpr()))) 5643 void x(int) { int y; x(y); } 5644</pre></td></tr> 5645 5646 5647<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> 5648<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. 5649 5650Example 5651matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *"))); 5652matches the [webView ...] message invocation. 5653 NSString *webViewJavaScript = ... 5654 UIWebView *webView = ... 5655 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; 5656</pre></td></tr> 5657 5658 5659<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> 5660<tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression 5661or opaque value's source expression matches the given matcher. 5662 5663Example 1: matches "a string" 5664(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) 5665class URL { URL(string); }; 5666URL url = "a string"; 5667 5668Example 2: matches 'b' (matcher = 5669opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) 5670int a = b ?: 1; 5671</pre></td></tr> 5672 5673 5674<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> 5675<tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of 5676overloads matches the given matcher. 5677 5678Given 5679 template <typename T> void foo(T); 5680 template <typename T> void bar(T); 5681 template <typename T> void baz(T t) { 5682 foo(t); 5683 bar(t); 5684 } 5685unresolvedLookupExpr(hasAnyDeclaration( 5686 functionTemplateDecl(hasName("foo")))) 5687 matches foo in foo(t); but not bar in bar(t); 5688</pre></td></tr> 5689 5690 5691<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> 5692<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. 5693 5694Given 5695 int (*ptr_to_array)[4]; 5696 int (*ptr_to_func)(int); 5697 5698varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches 5699ptr_to_func but not ptr_to_array. 5700 5701Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> 5702</pre></td></tr> 5703 5704 5705<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> 5706<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the 5707pointee matches a given matcher. 5708 5709Given 5710 int *a; 5711 int const *b; 5712 float const *f; 5713pointerType(pointee(isConstQualified(), isInteger())) 5714 matches "int const *b" 5715 5716Usable 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>>, 5717 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>> 5718</pre></td></tr> 5719 5720 5721<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> 5722<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the 5723pointee matches a given matcher. 5724 5725Given 5726 int *a; 5727 int const *b; 5728 float const *f; 5729pointerType(pointee(isConstQualified(), isInteger())) 5730 matches "int const *b" 5731 5732Usable 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>>, 5733 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>> 5734</pre></td></tr> 5735 5736 5737<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> 5738<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. 5739 5740Given: 5741 typedef int &int_ref; 5742 int a; 5743 int_ref b = a; 5744 5745varDecl(hasType(qualType(referenceType()))))) will not match the 5746declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. 5747</pre></td></tr> 5748 5749 5750<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasDeclaration6')"><a name="hasDeclaration6Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5751<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node 5752matches the given matcher. 5753 5754The associated declaration is: 5755- for type nodes, the declaration of the underlying type 5756- for CallExpr, the declaration of the callee 5757- for MemberExpr, the declaration of the referenced member 5758- for CXXConstructExpr, the declaration of the constructor 5759- for CXXNewExpr, the declaration of the operator new 5760 5761For type nodes, hasDeclaration will generally match the declaration of the 5762sugared type. Given 5763 class X {}; 5764 typedef X Y; 5765 Y y; 5766in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5767typedefDecl. A common use case is to match the underlying, desugared type. 5768This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5769 varDecl(hasType(hasUnqualifiedDesugaredType( 5770 recordType(hasDeclaration(decl()))))) 5771In this matcher, the decl will match the CXXRecordDecl of class X. 5772 5773Usable 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>>, 5774 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>>, 5775 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>>, 5776 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>>, 5777 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>>, 5778 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>>, 5779 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5780</pre></td></tr> 5781 5782 5783<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> 5784<tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped. 5785 5786Given 5787 void (*fp)(void); 5788The matcher 5789 varDecl(hasType(pointerType(pointee(ignoringParens(functionType()))))) 5790would match the declaration for fp. 5791</pre></td></tr> 5792 5793 5794<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> 5795<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 5796</pre></td></tr> 5797 5798 5799<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> 5800<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type 5801matches the specified matcher. 5802 5803Example matches y->x() 5804 (matcher = cxxMemberCallExpr(on(hasType(pointsTo 5805 cxxRecordDecl(hasName("Y"))))))) 5806 class Y { public: void x(); }; 5807 void z() { Y *y; y->x(); } 5808</pre></td></tr> 5809 5810 5811<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> 5812<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 5813</pre></td></tr> 5814 5815 5816<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> 5817<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced 5818type matches the specified matcher. 5819 5820Example matches X &x and const X &y 5821 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) 5822 class X { 5823 void a(X b) { 5824 X &x = b; 5825 const X &y = b; 5826 } 5827 }; 5828</pre></td></tr> 5829 5830 5831<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>></td><td class="name" onclick="toggle('hasDeclaration5')"><a name="hasDeclaration5Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5832<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node 5833matches the given matcher. 5834 5835The associated declaration is: 5836- for type nodes, the declaration of the underlying type 5837- for CallExpr, the declaration of the callee 5838- for MemberExpr, the declaration of the referenced member 5839- for CXXConstructExpr, the declaration of the constructor 5840- for CXXNewExpr, the declaration of the operator new 5841 5842For type nodes, hasDeclaration will generally match the declaration of the 5843sugared type. Given 5844 class X {}; 5845 typedef X Y; 5846 Y y; 5847in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5848typedefDecl. A common use case is to match the underlying, desugared type. 5849This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5850 varDecl(hasType(hasUnqualifiedDesugaredType( 5851 recordType(hasDeclaration(decl()))))) 5852In this matcher, the decl will match the CXXRecordDecl of class X. 5853 5854Usable 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>>, 5855 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>>, 5856 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>>, 5857 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>>, 5858 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>>, 5859 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>>, 5860 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5861</pre></td></tr> 5862 5863 5864<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> 5865<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the 5866pointee matches a given matcher. 5867 5868Given 5869 int *a; 5870 int const *b; 5871 float const *f; 5872pointerType(pointee(isConstQualified(), isInteger())) 5873 matches "int const *b" 5874 5875Usable 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>>, 5876 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>> 5877</pre></td></tr> 5878 5879 5880<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> 5881<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the 5882pointee matches a given matcher. 5883 5884Given 5885 int *a; 5886 int const *b; 5887 float const *f; 5888pointerType(pointee(isConstQualified(), isInteger())) 5889 matches "int const *b" 5890 5891Usable 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>>, 5892 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>> 5893</pre></td></tr> 5894 5895 5896<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> 5897<tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement 5898 5899Given 5900 return a + b; 5901hasReturnValue(binaryOperator()) 5902 matches 'return a + b' 5903with binaryOperator() 5904 matching 'a + b' 5905</pre></td></tr> 5906 5907 5908<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> 5909<tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches 5910a given matcher. Also matches StmtExprs that have CompoundStmt as children. 5911 5912Given 5913 { {}; 1+2; } 5914hasAnySubstatement(compoundStmt()) 5915 matches '{ {}; 1+2; }' 5916with compoundStmt() 5917 matching '{}' 5918</pre></td></tr> 5919 5920 5921<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('alignOfExpr0')"><a name="alignOfExpr0Anchor">alignOfExpr</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr> 5922<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 5923alignof. 5924</pre></td></tr> 5925 5926 5927<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> 5928<tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to 5929 5930Given: 5931F& operator=(const F& o) { 5932 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); 5933 return *this; 5934} 5935returnStmt(forFunction(hasName("operator="))) 5936 matches 'return *this' 5937 but does match 'return > 0' 5938</pre></td></tr> 5939 5940 5941<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('sizeOfExpr0')"><a name="sizeOfExpr0Anchor">sizeOfExpr</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr> 5942<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 5943sizeof. 5944</pre></td></tr> 5945 5946 5947<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> 5948<tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement 5949type that matches the provided matcher. 5950 5951Given 5952 template <typename T> 5953 double F(T t); 5954 int i; 5955 double j = F(i); 5956 5957substTemplateTypeParmType(hasReplacementType(type())) matches int 5958</pre></td></tr> 5959 5960 5961<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> 5962<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch 5963statement. This matcher may produce multiple matches. 5964 5965Given 5966 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } 5967switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") 5968 matches four times, with "c" binding each of "case 1:", "case 2:", 5969"case 3:" and "case 4:", and "s" respectively binding "switch (1)", 5970"switch (1)", "switch (2)" and "switch (2)". 5971</pre></td></tr> 5972 5973 5974<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> 5975<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 5976switch statement or conditional operator. 5977 5978Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5979 if (true) {} 5980</pre></td></tr> 5981 5982 5983<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>></td><td class="name" onclick="toggle('hasDeclaration4')"><a name="hasDeclaration4Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5984<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node 5985matches the given matcher. 5986 5987The associated declaration is: 5988- for type nodes, the declaration of the underlying type 5989- for CallExpr, the declaration of the callee 5990- for MemberExpr, the declaration of the referenced member 5991- for CXXConstructExpr, the declaration of the constructor 5992- for CXXNewExpr, the declaration of the operator new 5993 5994For type nodes, hasDeclaration will generally match the declaration of the 5995sugared type. Given 5996 class X {}; 5997 typedef X Y; 5998 Y y; 5999in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6000typedefDecl. A common use case is to match the underlying, desugared type. 6001This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6002 varDecl(hasType(hasUnqualifiedDesugaredType( 6003 recordType(hasDeclaration(decl()))))) 6004In this matcher, the decl will match the CXXRecordDecl of class X. 6005 6006Usable 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>>, 6007 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>>, 6008 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>>, 6009 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>>, 6010 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>>, 6011 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>>, 6012 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6013</pre></td></tr> 6014 6015 6016<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> 6017<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. 6018 6019Given 6020 struct B { int next; }; 6021 template<int(B::*next_ptr)> struct A {}; 6022 A<&B::next> a; 6023templateSpecializationType(hasAnyTemplateArgument( 6024 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) 6025 matches the specialization A<&B::next> with fieldDecl(...) matching 6026 B::next 6027</pre></td></tr> 6028 6029 6030<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> 6031<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain 6032declaration. 6033 6034Given 6035 struct B { int next; }; 6036 template<int(B::*next_ptr)> struct A {}; 6037 A<&B::next> a; 6038classTemplateSpecializationDecl(hasAnyTemplateArgument( 6039 refersToDeclaration(fieldDecl(hasName("next"))))) 6040 matches the specialization A<&B::next> with fieldDecl(...) matching 6041 B::next 6042</pre></td></tr> 6043 6044 6045<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> 6046<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type. 6047 6048Given 6049 template<int T> struct C {}; 6050 C<42> c; 6051classTemplateSpecializationDecl( 6052 hasAnyTemplateArgument(refersToIntegralType(asString("int")))) 6053 matches the implicit instantiation of C in C<42>. 6054</pre></td></tr> 6055 6056 6057<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> 6058<tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template. 6059 6060Given 6061 template<template <typename> class S> class X {}; 6062 template<typename T> class Y {};" 6063 X<Y> xi; 6064classTemplateSpecializationDecl(hasAnyTemplateArgument( 6065 refersToTemplate(templateName()))) 6066 matches the specialization X<Y> 6067</pre></td></tr> 6068 6069 6070<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> 6071<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 6072 6073Given 6074 struct X {}; 6075 template<typename T> struct A {}; 6076 A<X> a; 6077classTemplateSpecializationDecl(hasAnyTemplateArgument( 6078 refersToType(class(hasName("X"))))) 6079 matches the specialization A<X> 6080</pre></td></tr> 6081 6082 6083<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> 6084<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and 6085functionDecl that have at least one TemplateArgument matching the given 6086InnerMatcher. 6087 6088Given 6089 template<typename T> class A {}; 6090 template<> class A<double> {}; 6091 A<int> a; 6092 6093 template<typename T> f() {}; 6094 void func() { f<int>(); }; 6095 6096classTemplateSpecializationDecl(hasAnyTemplateArgument( 6097 refersToType(asString("int")))) 6098 matches the specialization A<int> 6099 6100functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 6101 matches the specialization f<int> 6102</pre></td></tr> 6103 6104 6105<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasDeclaration3')"><a name="hasDeclaration3Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6106<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node 6107matches the given matcher. 6108 6109The associated declaration is: 6110- for type nodes, the declaration of the underlying type 6111- for CallExpr, the declaration of the callee 6112- for MemberExpr, the declaration of the referenced member 6113- for CXXConstructExpr, the declaration of the constructor 6114- for CXXNewExpr, the declaration of the operator new 6115 6116For type nodes, hasDeclaration will generally match the declaration of the 6117sugared type. Given 6118 class X {}; 6119 typedef X Y; 6120 Y y; 6121in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6122typedefDecl. A common use case is to match the underlying, desugared type. 6123This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6124 varDecl(hasType(hasUnqualifiedDesugaredType( 6125 recordType(hasDeclaration(decl()))))) 6126In this matcher, the decl will match the CXXRecordDecl of class X. 6127 6128Usable 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>>, 6129 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>>, 6130 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>>, 6131 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>>, 6132 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>>, 6133 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>>, 6134 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6135</pre></td></tr> 6136 6137 6138<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> 6139<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and 6140functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 6141 6142Given 6143 template<typename T, typename U> class A {}; 6144 A<bool, int> b; 6145 A<int, bool> c; 6146 6147 template<typename T> void f() {} 6148 void func() { f<int>(); }; 6149classTemplateSpecializationDecl(hasTemplateArgument( 6150 1, refersToType(asString("int")))) 6151 matches the specialization A<bool, int> 6152 6153functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 6154 matches the specialization f<int> 6155</pre></td></tr> 6156 6157 6158<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>></td><td class="name" onclick="toggle('hasDeclaration2')"><a name="hasDeclaration2Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6159<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node 6160matches the given matcher. 6161 6162The associated declaration is: 6163- for type nodes, the declaration of the underlying type 6164- for CallExpr, the declaration of the callee 6165- for MemberExpr, the declaration of the referenced member 6166- for CXXConstructExpr, the declaration of the constructor 6167- for CXXNewExpr, the declaration of the operator new 6168 6169For type nodes, hasDeclaration will generally match the declaration of the 6170sugared type. Given 6171 class X {}; 6172 typedef X Y; 6173 Y y; 6174in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6175typedefDecl. A common use case is to match the underlying, desugared type. 6176This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6177 varDecl(hasType(hasUnqualifiedDesugaredType( 6178 recordType(hasDeclaration(decl()))))) 6179In this matcher, the decl will match the CXXRecordDecl of class X. 6180 6181Usable 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>>, 6182 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>>, 6183 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>>, 6184 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>>, 6185 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>>, 6186 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>>, 6187 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6188</pre></td></tr> 6189 6190 6191<tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>const Matcher<T> Matcher</td></tr> 6192<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. 6193 6194Generates results for each match. 6195 6196For example, in: 6197 class A { class B {}; class C {}; }; 6198The matcher: 6199 cxxRecordDecl(hasName("::A"), 6200 findAll(cxxRecordDecl(isDefinition()).bind("m"))) 6201will generate results for A, B and C. 6202 6203Usable as: Any Matcher 6204</pre></td></tr> 6205 6206 6207<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> 6208<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type 6209matcher. 6210 6211Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6212 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6213 and U (matcher = typedefDecl(hasType(asString("int"))) 6214 class X {}; 6215 void y(X &x) { x; X z; } 6216 typedef int U; 6217</pre></td></tr> 6218 6219 6220<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>></td><td class="name" onclick="toggle('hasDeclaration1')"><a name="hasDeclaration1Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6221<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node 6222matches the given matcher. 6223 6224The associated declaration is: 6225- for type nodes, the declaration of the underlying type 6226- for CallExpr, the declaration of the callee 6227- for MemberExpr, the declaration of the referenced member 6228- for CXXConstructExpr, the declaration of the constructor 6229- for CXXNewExpr, the declaration of the operator new 6230 6231For type nodes, hasDeclaration will generally match the declaration of the 6232sugared type. Given 6233 class X {}; 6234 typedef X Y; 6235 Y y; 6236in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6237typedefDecl. A common use case is to match the underlying, desugared type. 6238This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6239 varDecl(hasType(hasUnqualifiedDesugaredType( 6240 recordType(hasDeclaration(decl()))))) 6241In this matcher, the decl will match the CXXRecordDecl of class X. 6242 6243Usable 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>>, 6244 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>>, 6245 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>>, 6246 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>>, 6247 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>>, 6248 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>>, 6249 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6250</pre></td></tr> 6251 6252 6253<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> 6254<tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared 6255type of the matched node. 6256 6257For example, in: 6258 class A {}; 6259 using B = A; 6260The matcher type(hasUnqualifeidDesugaredType(recordType())) matches 6261both B and A. 6262</pre></td></tr> 6263 6264 6265<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> 6266<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 6267 6268Given 6269 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 6270unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 6271 matches sizeof(a) and alignof(c) 6272</pre></td></tr> 6273 6274 6275<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> 6276<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 6277 6278Example matches true (matcher = hasUnaryOperand( 6279 cxxBoolLiteral(equals(true)))) 6280 !true 6281</pre></td></tr> 6282 6283 6284<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>></td><td class="name" onclick="toggle('hasDeclaration0')"><a name="hasDeclaration0Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6285<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node 6286matches the given matcher. 6287 6288The associated declaration is: 6289- for type nodes, the declaration of the underlying type 6290- for CallExpr, the declaration of the callee 6291- for MemberExpr, the declaration of the referenced member 6292- for CXXConstructExpr, the declaration of the constructor 6293- for CXXNewExpr, the declaration of the operator new 6294 6295For type nodes, hasDeclaration will generally match the declaration of the 6296sugared type. Given 6297 class X {}; 6298 typedef X Y; 6299 Y y; 6300in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6301typedefDecl. A common use case is to match the underlying, desugared type. 6302This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6303 varDecl(hasType(hasUnqualifiedDesugaredType( 6304 recordType(hasDeclaration(decl()))))) 6305In this matcher, the decl will match the CXXRecordDecl of class X. 6306 6307Usable 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>>, 6308 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>>, 6309 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>>, 6310 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>>, 6311 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>>, 6312 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>>, 6313 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6314</pre></td></tr> 6315 6316 6317<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> 6318<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 6319 6320Given 6321 namespace X { void b(); } 6322 using X::b; 6323usingDecl(hasAnyUsingShadowDecl(hasName("b")))) 6324 matches using X::b </pre></td></tr> 6325 6326 6327<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> 6328<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 6329matched by the given matcher. 6330 6331Given 6332 namespace X { int a; void b(); } 6333 using X::a; 6334 using X::b; 6335usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 6336 matches using X::b but not using X::a </pre></td></tr> 6337 6338 6339<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> 6340<tr><td colspan="4" class="doc" id="hasType4"><pre>Overloaded to match the declaration of the expression's or value 6341declaration's type. 6342 6343In case of a value declaration (for example a variable declaration), 6344this resolves one layer of indirection. For example, in the value 6345declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 6346X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 6347declaration of x. 6348 6349Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6350 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6351 class X {}; 6352 void y(X &x) { x; X z; } 6353 6354Usable 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>> 6355</pre></td></tr> 6356 6357 6358<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> 6359<tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type 6360matcher. 6361 6362Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6363 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6364 and U (matcher = typedefDecl(hasType(asString("int"))) 6365 class X {}; 6366 void y(X &x) { x; X z; } 6367 typedef int U; 6368</pre></td></tr> 6369 6370 6371<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> 6372<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 6373that matches the given matcher. 6374 6375Example matches x (matcher = varDecl(hasInitializer(callExpr()))) 6376 bool y() { return true; } 6377 bool x = y(); 6378</pre></td></tr> 6379 6380 6381<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> 6382<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 6383expression. 6384 6385Given 6386 void f(int b) { 6387 int a[b]; 6388 } 6389variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 6390 varDecl(hasName("b"))))))) 6391 matches "int a[b]" 6392</pre></td></tr> 6393 6394 6395<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> 6396<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'do while' statement or a function 6397definition that has a given body. 6398 6399Given 6400 for (;;) {} 6401hasBody(compoundStmt()) 6402 matches 'for (;;) {}' 6403with compoundStmt() 6404 matching '{}' 6405</pre></td></tr> 6406 6407 6408<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> 6409<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 6410switch statement or conditional operator. 6411 6412Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 6413 if (true) {} 6414</pre></td></tr> 6415 6416 6417<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> 6418<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner 6419NestedNameSpecifier-matcher matches. 6420</pre></td></tr> 6421 6422 6423<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> 6424<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner 6425QualType-matcher matches. 6426</pre></td></tr> 6427 6428<!--END_TRAVERSAL_MATCHERS --> 6429</table> 6430 6431</div> 6432</body> 6433</html> 6434 6435 6436