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