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