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