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