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