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