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('ctorInitializer0')"><a name="ctorInitializer0Anchor">ctorInitializer</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="ctorInitializer0"><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('constructorDecl0')"><a name="constructorDecl0Anchor">constructorDecl</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="constructorDecl0"><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('conversionDecl0')"><a name="conversionDecl0Anchor">conversionDecl</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="conversionDecl0"><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('decl0')"><a name="decl0Anchor">decl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>...</td></tr> 169<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. 170 171Examples matches X, C, and the friend declaration inside C; 172 void X(); 173 class C { 174 friend X; 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('declaratorDecl0')"><a name="declaratorDecl0Anchor">declaratorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>...</td></tr> 180<tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function 181and non-type template parameter declarations). 182 183Given 184 class X { int y; }; 185declaratorDecl() 186 matches int y. 187</pre></td></tr> 188 189 190<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('destructorDecl0')"><a name="destructorDecl0Anchor">destructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>>...</td></tr> 191<tr><td colspan="4" class="doc" id="destructorDecl0"><pre>Matches explicit C++ destructor declarations. 192 193Example matches Foo::~Foo() 194 class Foo { 195 public: 196 virtual ~Foo(); 197 }; 198</pre></td></tr> 199 200 201<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> 202<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. 203 204Example matches A, B, C 205 enum X { 206 A, B, C 207 }; 208</pre></td></tr> 209 210 211<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> 212<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. 213 214Example matches X 215 enum X { 216 A, B, C 217 }; 218</pre></td></tr> 219 220 221<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> 222<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. 223 224Given 225 class X { int m; }; 226fieldDecl() 227 matches 'm'. 228</pre></td></tr> 229 230 231<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> 232<tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations. 233 234Given 235 class X { friend void foo(); }; 236friendDecl() 237 matches 'friend void foo()'. 238</pre></td></tr> 239 240 241<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> 242<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. 243 244Example matches f 245 void f(); 246</pre></td></tr> 247 248 249<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> 250<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. 251 252Example matches f 253 template<class T> void f(T t) {} 254</pre></td></tr> 255 256 257<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> 258<tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification. 259 260Given 261 extern "C" {} 262linkageSpecDecl() 263 matches "extern "C" {}" 264</pre></td></tr> 265 266 267<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('methodDecl0')"><a name="methodDecl0Anchor">methodDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>>...</td></tr> 268<tr><td colspan="4" class="doc" id="methodDecl0"><pre>Matches method declarations. 269 270Example matches y 271 class X { void y(); }; 272</pre></td></tr> 273 274 275<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> 276<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. 277 278Example matches X, S, the anonymous union type, i, and U; 279 typedef int X; 280 struct S { 281 union { 282 int i; 283 } U; 284 }; 285</pre></td></tr> 286 287 288<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> 289<tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias. 290 291Given 292 namespace test {} 293 namespace alias = ::test; 294namespaceAliasDecl() 295 matches "namespace alias" but not "namespace test" 296</pre></td></tr> 297 298 299<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> 300<tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. 301 302Given 303 namespace {} 304 namespace test {} 305namespaceDecl() 306 matches "namespace {}" and "namespace test {}" 307</pre></td></tr> 308 309 310<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> 311<tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. 312 313Given 314 void f(int x); 315parmVarDecl() 316 matches int x. 317</pre></td></tr> 318 319 320<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_1CXXRecordDecl.html">CXXRecordDecl</a>>...</td></tr> 321<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches C++ class declarations. 322 323Example matches X, Z 324 class X; 325 template<class T> class Z {}; 326</pre></td></tr> 327 328 329<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> 330<tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration. 331 332Example: 333 staticAssertExpr() 334matches 335 static_assert(sizeof(S) == sizeof(int)) 336in 337 struct S { 338 int x; 339 }; 340 static_assert(sizeof(S) == sizeof(int)); 341</pre></td></tr> 342 343 344<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> 345<tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context. 346 347Given 348 int X; 349 namespace NS { 350 int Y; 351 } namespace NS 352decl(hasDeclContext(translationUnitDecl())) 353 matches "int X", but not "int Y". 354</pre></td></tr> 355 356 357<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> 358<tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations. 359 360Given 361 typedef int X; 362typedefDecl() 363 matches "typedef int X" 364</pre></td></tr> 365 366 367<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> 368<tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations. 369 370Given 371 template<typename X> 372 class C : private X { 373 using X::x; 374 }; 375unresolvedUsingValueDecl() 376 matches using X::x </pre></td></tr> 377 378 379<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> 380<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. 381 382Given 383 namespace X { int x; } 384 using X::x; 385usingDecl() 386 matches using X::x </pre></td></tr> 387 388 389<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> 390<tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations. 391 392Given 393 namespace X { int x; } 394 using namespace X; 395usingDirectiveDecl() 396 matches using namespace X </pre></td></tr> 397 398 399<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> 400<tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration. 401 402Example matches A, B, C and F 403 enum X { A, B, C }; 404 void F(); 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('varDecl0')"><a name="varDecl0Anchor">varDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>...</td></tr> 409<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. 410 411Note: this does not match declarations of member variables, which are 412"field" declarations in Clang parlance. 413 414Example matches a 415 int a; 416</pre></td></tr> 417 418 419<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> 420<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. 421</pre></td></tr> 422 423 424<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> 425<tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. 426 427Given 428 namespace ns { 429 struct A { static void f(); }; 430 void A::f() {} 431 void g() { A::f(); } 432 } 433 ns::A a; 434nestedNameSpecifier() 435 matches "ns::" and both "A::" 436</pre></td></tr> 437 438 439<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> 440<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. 441</pre></td></tr> 442 443 444<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> 445<tr><td colspan="4" class="doc" id="CUDAKernelCallExpr0"><pre>Matches CUDA kernel call expression. 446 447Example matches, 448 kernel<<<i,j>>>(); 449</pre></td></tr> 450 451 452<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> 453<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. 454 455Given 456 int i = a[1]; 457arraySubscriptExpr() 458 matches "a[1]" 459</pre></td></tr> 460 461 462<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> 463<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. 464 465 int i = 100; 466 __asm("mov al, 2"); 467asmStmt() 468 matches '__asm("mov al, 2")' 469</pre></td></tr> 470 471 472<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> 473<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. 474 475Example matches a || b 476 !(a || b) 477</pre></td></tr> 478 479 480<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('bindTemporaryExpr0')"><a name="bindTemporaryExpr0Anchor">bindTemporaryExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>>...</td></tr> 481<tr><td colspan="4" class="doc" id="bindTemporaryExpr0"><pre>Matches nodes where temporaries are created. 482 483Example matches FunctionTakesString(GetStringByValue()) 484 (matcher = bindTemporaryExpr()) 485 FunctionTakesString(GetStringByValue()); 486 FunctionTakesStringByPointer(GetStringPointer()); 487</pre></td></tr> 488 489 490<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('boolLiteral0')"><a name="boolLiteral0Anchor">boolLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>...</td></tr> 491<tr><td colspan="4" class="doc" id="boolLiteral0"><pre>Matches bool literals. 492 493Example matches true 494 true 495</pre></td></tr> 496 497 498<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> 499<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. 500 501Given 502 while (true) { break; } 503breakStmt() 504 matches 'break' 505</pre></td></tr> 506 507 508<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> 509<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. 510 511Example: Matches (int*) 2.2f in 512 int i = (int) 2.2f; 513</pre></td></tr> 514 515 516<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> 517<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. 518 519Example matches x.y() and y() 520 X x; 521 x.y(); 522 y(); 523</pre></td></tr> 524 525 526<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> 527<tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. 528 529Given 530 switch(a) { case 42: break; default: break; } 531caseStmt() 532 matches 'case 42: break;'. 533</pre></td></tr> 534 535 536<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> 537<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. 538 539Example: castExpr() matches each of the following: 540 (int) 3; 541 const_cast<Expr *>(SubExpr); 542 char c = 0; 543but does not match 544 int i = (0); 545 int k = 0; 546</pre></td></tr> 547 548 549<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('catchStmt0')"><a name="catchStmt0Anchor">catchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>>...</td></tr> 550<tr><td colspan="4" class="doc" id="catchStmt0"><pre>Matches catch statements. 551 552 try {} catch(int i) {} 553catchStmt() 554 matches 'catch(int i)' 555</pre></td></tr> 556 557 558<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> 559<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). 560 561Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), 562though. 563 564Example matches 'a', L'a' 565 char ch = 'a'; wchar_t chw = L'a'; 566</pre></td></tr> 567 568 569<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> 570<tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals 571 572Example match: {1}, (1, 2) 573 int array[4] = {1}; vector int myvec = (vector int)(1, 2); 574</pre></td></tr> 575 576 577<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> 578<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. 579 580Example matches '{}' and '{{}}'in 'for (;;) {{}}' 581 for (;;) {{}} 582</pre></td></tr> 583 584 585<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> 586<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. 587 588Example matches a ? b : c 589 (a ? b : c) + 42 590</pre></td></tr> 591 592 593<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('constCastExpr0')"><a name="constCastExpr0Anchor">constCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>>...</td></tr> 594<tr><td colspan="4" class="doc" id="constCastExpr0"><pre>Matches a const_cast expression. 595 596Example: Matches const_cast<int*>(&r) in 597 int n = 42; 598 const int &r(n); 599 int* p = const_cast<int*>(&r); 600</pre></td></tr> 601 602 603<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('constructExpr0')"><a name="constructExpr0Anchor">constructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>...</td></tr> 604<tr><td colspan="4" class="doc" id="constructExpr0"><pre>Matches constructor call expressions (including implicit ones). 605 606Example matches string(ptr, n) and ptr within arguments of f 607 (matcher = constructExpr()) 608 void f(const string &a, const string &b); 609 char *ptr; 610 int n; 611 f(string(ptr, n), ptr); 612</pre></td></tr> 613 614 615<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> 616<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. 617 618Given 619 while (true) { continue; } 620continueStmt() 621 matches 'continue' 622</pre></td></tr> 623 624 625<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> 626<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. 627 628Example matches x in if (x) 629 bool x; 630 if (x) {} 631</pre></td></tr> 632 633 634<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('declStmt0')"><a name="declStmt0Anchor">declStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>>...</td></tr> 635<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. 636 637Given 638 int a; 639declStmt() 640 matches 'int a'. 641</pre></td></tr> 642 643 644<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('defaultArgExpr0')"><a name="defaultArgExpr0Anchor">defaultArgExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>>...</td></tr> 645<tr><td colspan="4" class="doc" id="defaultArgExpr0"><pre>Matches the value of a default argument at the call site. 646 647Example matches the CXXDefaultArgExpr placeholder inserted for the 648 default value of the second parameter in the call expression f(42) 649 (matcher = defaultArgExpr()) 650 void f(int x, int y = 0); 651 f(42); 652</pre></td></tr> 653 654 655<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> 656<tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. 657 658Given 659 switch(a) { case 42: break; default: break; } 660defaultStmt() 661 matches 'default: break;'. 662</pre></td></tr> 663 664 665<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('deleteExpr0')"><a name="deleteExpr0Anchor">deleteExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>>...</td></tr> 666<tr><td colspan="4" class="doc" id="deleteExpr0"><pre>Matches delete expressions. 667 668Given 669 delete X; 670deleteExpr() 671 matches 'delete X'. 672</pre></td></tr> 673 674 675<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> 676<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. 677 678Given 679 do {} while (true); 680doStmt() 681 matches 'do {} while(true)' 682</pre></td></tr> 683 684 685<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('dynamicCastExpr0')"><a name="dynamicCastExpr0Anchor">dynamicCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>>...</td></tr> 686<tr><td colspan="4" class="doc" id="dynamicCastExpr0"><pre>Matches a dynamic_cast expression. 687 688Example: 689 dynamicCastExpr() 690matches 691 dynamic_cast<D*>(&b); 692in 693 struct B { virtual ~B() {} }; struct D : B {}; 694 B b; 695 D* p = dynamic_cast<D*>(&b); 696</pre></td></tr> 697 698 699<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> 700<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. 701 702Matches any cast expression written in user code, whether it be a 703C-style cast, a functional-style cast, or a keyword cast. 704 705Does not match implicit conversions. 706 707Note: the name "explicitCast" is chosen to match Clang's terminology, as 708Clang uses the term "cast" to apply to implicit conversions as well as to 709actual cast expressions. 710 711hasDestinationType. 712 713Example: matches all five of the casts in 714 int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) 715but does not match the implicit conversion in 716 long ell = 42; 717</pre></td></tr> 718 719 720<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> 721<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. 722 723Example matches x() 724 void f() { x(); } 725</pre></td></tr> 726 727 728<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> 729<tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end 730of the sub-expression's evaluation. 731 732Example matches std::string() 733 const std::string str = std::string(); 734</pre></td></tr> 735 736 737<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> 738<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g. 7391.0, 1.0f, 1.0L and 1e10. 740 741Does not match implicit conversions such as 742 float a = 10; 743</pre></td></tr> 744 745 746<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('forRangeStmt0')"><a name="forRangeStmt0Anchor">forRangeStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>>...</td></tr> 747<tr><td colspan="4" class="doc" id="forRangeStmt0"><pre>Matches range-based for statements. 748 749forRangeStmt() matches 'for (auto a : i)' 750 int i[] = {1, 2, 3}; for (auto a : i); 751 for(int j = 0; j < 5; ++j); 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('forStmt0')"><a name="forStmt0Anchor">forStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>>...</td></tr> 756<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. 757 758Example matches 'for (;;) {}' 759 for (;;) {} 760 int i[] = {1, 2, 3}; for (auto a : i); 761</pre></td></tr> 762 763 764<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('functionalCastExpr0')"><a name="functionalCastExpr0Anchor">functionalCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>...</td></tr> 765<tr><td colspan="4" class="doc" id="functionalCastExpr0"><pre>Matches functional cast expressions 766 767Example: Matches Foo(bar); 768 Foo f = bar; 769 Foo g = (Foo) bar; 770 Foo h = Foo(bar); 771</pre></td></tr> 772 773 774<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> 775<tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. 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('gotoStmt0')"><a name="gotoStmt0Anchor">gotoStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1GotoStmt.html">GotoStmt</a>>...</td></tr> 780<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. 781 782Given 783 goto FOO; 784 FOO: bar(); 785gotoStmt() 786 matches 'goto FOO' 787</pre></td></tr> 788 789 790<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> 791<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. 792 793Example matches 'if (x) {}' 794 if (x) {} 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('implicitCastExpr0')"><a name="implicitCastExpr0Anchor">implicitCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr</a>>...</td></tr> 799<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. 800 801This matches many different places, including function call return value 802eliding, as well as any type conversions. 803</pre></td></tr> 804 805 806<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('initListExpr0')"><a name="initListExpr0Anchor">initListExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>>...</td></tr> 807<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. 808 809Given 810 int a[] = { 1, 2 }; 811 struct B { int x, y; }; 812 B b = { 5, 6 }; 813initListExpr() 814 matches "{ 1, 2 }" and "{ 5, 6 }" 815</pre></td></tr> 816 817 818<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('integerLiteral0')"><a name="integerLiteral0Anchor">integerLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>...</td></tr> 819<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g. 8201, 1L, 0x1 and 1U. 821 822Does not match character-encoded integers such as L'a'. 823</pre></td></tr> 824 825 826<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> 827<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. 828 829Given 830 goto FOO; 831 FOO: bar(); 832labelStmt() 833 matches 'FOO:' 834</pre></td></tr> 835 836 837<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> 838<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. 839 840Example matches [&](){return 5;} 841 [&](){return 5;} 842</pre></td></tr> 843 844 845<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> 846<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. 847 848Example: Given 849 struct T {void func()}; 850 T f(); 851 void g(T); 852materializeTemporaryExpr() matches 'f()' in these statements 853 T u(f()); 854 g(f()); 855but does not match 856 f(); 857 f().func(); 858</pre></td></tr> 859 860 861<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('memberCallExpr0')"><a name="memberCallExpr0Anchor">memberCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>>...</td></tr> 862<tr><td colspan="4" class="doc" id="memberCallExpr0"><pre>Matches member call expressions. 863 864Example matches x.y() 865 X x; 866 x.y(); 867</pre></td></tr> 868 869 870<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('memberExpr0')"><a name="memberExpr0Anchor">memberExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>...</td></tr> 871<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. 872 873Given 874 class Y { 875 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 876 int a; static int b; 877 }; 878memberExpr() 879 matches this->x, x, y.x, a, this->b 880</pre></td></tr> 881 882 883<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('newExpr0')"><a name="newExpr0Anchor">newExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>...</td></tr> 884<tr><td colspan="4" class="doc" id="newExpr0"><pre>Matches new expressions. 885 886Given 887 new X; 888newExpr() 889 matches 'new X'. 890</pre></td></tr> 891 892 893<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('nullPtrLiteralExpr0')"><a name="nullPtrLiteralExpr0Anchor">nullPtrLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>>...</td></tr> 894<tr><td colspan="4" class="doc" id="nullPtrLiteralExpr0"><pre>Matches nullptr literal. 895</pre></td></tr> 896 897 898<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> 899<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. 900 901 foo();; 902nullStmt() 903 matches the second ';' 904</pre></td></tr> 905 906 907<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> 908<tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions. 909 910The innermost message send invokes the "alloc" class method on the 911NSString class, while the outermost message send invokes the 912"initWithString" instance method on the object returned from 913NSString's "alloc". This matcher should match both message sends. 914 [[NSString alloc] initWithString:@"Hello"] 915</pre></td></tr> 916 917 918<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('operatorCallExpr0')"><a name="operatorCallExpr0Anchor">operatorCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>...</td></tr> 919<tr><td colspan="4" class="doc" id="operatorCallExpr0"><pre>Matches overloaded operator calls. 920 921Note that if an operator isn't overloaded, it won't match. Instead, use 922binaryOperator matcher. 923Currently it does not match operators such as new delete. 924FIXME: figure out why these do not match? 925 926Example matches both operator<<((o << b), c) and operator<<(o, b) 927 (matcher = operatorCallExpr()) 928 ostream &operator<< (ostream &out, int i) { }; 929 ostream &o; int b = 1, c = 1; 930 o << b << c; 931</pre></td></tr> 932 933 934<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('reinterpretCastExpr0')"><a name="reinterpretCastExpr0Anchor">reinterpretCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>>...</td></tr> 935<tr><td colspan="4" class="doc" id="reinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. 936 937Either the source expression or the destination type can be matched 938using has(), but hasDestinationType() is more specific and can be 939more readable. 940 941Example matches reinterpret_cast<char*>(&p) in 942 void* p = reinterpret_cast<char*>(&p); 943</pre></td></tr> 944 945 946<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> 947<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. 948 949Given 950 return 1; 951returnStmt() 952 matches 'return 1' 953</pre></td></tr> 954 955 956<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('staticCastExpr0')"><a name="staticCastExpr0Anchor">staticCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>>...</td></tr> 957<tr><td colspan="4" class="doc" id="staticCastExpr0"><pre>Matches a C++ static_cast expression. 958 959hasDestinationType 960reinterpretCast 961 962Example: 963 staticCastExpr() 964matches 965 static_cast<long>(8) 966in 967 long eight(static_cast<long>(8)); 968</pre></td></tr> 969 970 971<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> 972<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. 973 974Given 975 { ++a; } 976stmt() 977 matches both the compound statement '{ ++a; }' and '++a'. 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('stringLiteral0')"><a name="stringLiteral0Anchor">stringLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>>...</td></tr> 982<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). 983 984Example matches "abcd", L"abcd" 985 char *s = "abcd"; wchar_t *ws = L"abcd" 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('substNonTypeTemplateParmExpr0')"><a name="substNonTypeTemplateParmExpr0Anchor">substNonTypeTemplateParmExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstNonTypeTemplateParmExpr.html">SubstNonTypeTemplateParmExpr</a>>...</td></tr> 990<tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. 991 992Given 993 template <int N> 994 struct A { static const int n = N; }; 995 struct B : public A<42> {}; 996substNonTypeTemplateParmExpr() 997 matches "N" in the right-hand side of "static const int n = N;" 998</pre></td></tr> 999 1000 1001<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> 1002<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. 1003 1004Given 1005 switch(a) { case 42: break; default: break; } 1006switchCase() 1007 matches 'case 42: break;' and 'default: break;'. 1008</pre></td></tr> 1009 1010 1011<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> 1012<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. 1013 1014Given 1015 switch(a) { case 42: break; default: break; } 1016switchStmt() 1017 matches 'switch(a)'. 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('temporaryObjectExpr0')"><a name="temporaryObjectExpr0Anchor">temporaryObjectExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>...</td></tr> 1022<tr><td colspan="4" class="doc" id="temporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments 1023 1024Example: Matches Foo(bar, bar) 1025 Foo h = Foo(bar, bar); 1026</pre></td></tr> 1027 1028 1029<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('thisExpr0')"><a name="thisExpr0Anchor">thisExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>>...</td></tr> 1030<tr><td colspan="4" class="doc" id="thisExpr0"><pre>Matches implicit and explicit this expressions. 1031 1032Example matches the implicit this expression in "return i". 1033 (matcher = thisExpr()) 1034struct foo { 1035 int i; 1036 int f() { return i; } 1037}; 1038</pre></td></tr> 1039 1040 1041<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('throwExpr0')"><a name="throwExpr0Anchor">throwExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>>...</td></tr> 1042<tr><td colspan="4" class="doc" id="throwExpr0"><pre>Matches throw expressions. 1043 1044 try { throw 5; } catch(int i) {} 1045throwExpr() 1046 matches 'throw 5' 1047</pre></td></tr> 1048 1049 1050<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('tryStmt0')"><a name="tryStmt0Anchor">tryStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>>...</td></tr> 1051<tr><td colspan="4" class="doc" id="tryStmt0"><pre>Matches try statements. 1052 1053 try {} catch(int i) {} 1054tryStmt() 1055 matches 'try {}' 1056</pre></td></tr> 1057 1058 1059<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> 1060<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) 1061 1062Given 1063 Foo x = bar; 1064 int y = sizeof(x) + alignof(x); 1065unaryExprOrTypeTraitExpr() 1066 matches sizeof(x) and alignof(x) 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('unaryOperator0')"><a name="unaryOperator0Anchor">unaryOperator</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>>...</td></tr> 1071<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. 1072 1073Example matches !a 1074 !a || b 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('unresolvedConstructExpr0')"><a name="unresolvedConstructExpr0Anchor">unresolvedConstructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>...</td></tr> 1079<tr><td colspan="4" class="doc" id="unresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. 1080 1081Example matches T(t) in return statement of f 1082 (matcher = unresolvedConstructExpr()) 1083 template <typename T> 1084 void f(const T& t) { return T(t); } 1085</pre></td></tr> 1086 1087 1088<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> 1089<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. 1090 1091Example match: "foo"_suffix 1092</pre></td></tr> 1093 1094 1095<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> 1096<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. 1097 1098Given 1099 while (true) {} 1100whileStmt() 1101 matches 'while (true) {}'. 1102</pre></td></tr> 1103 1104 1105<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> 1106<tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. 1107 1108Given 1109 template <typename T> struct C {}; 1110 C<int> c; 1111templateArgument() 1112 matches 'int' in C<int>. 1113</pre></td></tr> 1114 1115 1116<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> 1117<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. 1118</pre></td></tr> 1119 1120 1121<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> 1122<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. 1123 1124Given 1125 int a[] = { 2, 3 }; 1126 int b[4]; 1127 void f() { int c[a[0]]; } 1128arrayType() 1129 matches "int a[]", "int b[4]" and "int c[a[0]]"; 1130</pre></td></tr> 1131 1132 1133<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> 1134<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. 1135 1136Given 1137 _Atomic(int) i; 1138atomicType() 1139 matches "_Atomic(int) i" 1140</pre></td></tr> 1141 1142 1143<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> 1144<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. 1145 1146Given: 1147 auto n = 4; 1148 int v[] = { 2, 3 } 1149 for (auto i : v) { } 1150autoType() 1151 matches "auto n" and "auto i" 1152</pre></td></tr> 1153 1154 1155<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> 1156<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as 1157"void (^)(int)". 1158 1159The pointee is always required to be a FunctionType. 1160</pre></td></tr> 1161 1162 1163<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> 1164<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. 1165 1166Given 1167 struct A {}; 1168 A a; 1169 int b; 1170 float c; 1171 bool d; 1172builtinType() 1173 matches "int b", "float c" and "bool d" 1174</pre></td></tr> 1175 1176 1177<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> 1178<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. 1179 1180Given 1181 _Complex float f; 1182complexType() 1183 matches "_Complex float f" 1184</pre></td></tr> 1185 1186 1187<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> 1188<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. 1189 1190Given 1191 void() { 1192 int a[2]; 1193 int b[] = { 2, 3 }; 1194 int c[b[0]]; 1195 } 1196constantArrayType() 1197 matches "int a[2]" 1198</pre></td></tr> 1199 1200 1201<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> 1202<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. 1203 1204Given 1205 template<typename T, int Size> 1206 class array { 1207 T data[Size]; 1208 }; 1209dependentSizedArrayType 1210 matches "T data[Size]" 1211</pre></td></tr> 1212 1213 1214<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> 1215<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a 1216qualified name. 1217 1218Given 1219 namespace N { 1220 namespace M { 1221 class D {}; 1222 } 1223 } 1224 class C {}; 1225 1226 class C c; 1227 N::M::D d; 1228 1229elaboratedType() matches the type of the variable declarations of both 1230c and d. 1231</pre></td></tr> 1232 1233 1234<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> 1235<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. 1236 1237Given 1238 int (*f)(int); 1239 void g(); 1240functionType() 1241 matches "int (*f)(int)" and the type of "g". 1242</pre></td></tr> 1243 1244 1245<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> 1246<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. 1247 1248Given 1249 int a[] = { 2, 3 }; 1250 int b[42]; 1251 void f(int c[]) { int d[a[0]]; }; 1252incompleteArrayType() 1253 matches "int a[]" and "int c[]" 1254</pre></td></tr> 1255 1256 1257<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> 1258<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. 1259 1260Given: 1261 int *a; 1262 int &b = *a; 1263 int &&c = 1; 1264 auto &d = b; 1265 auto &&e = c; 1266 auto &&f = 2; 1267 int g = 5; 1268 1269lValueReferenceType() matches the types of b, d, and e. e is 1270matched since the type is deduced as int& by reference collapsing rules. 1271</pre></td></tr> 1272 1273 1274<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> 1275<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. 1276Given 1277 struct A { int i; } 1278 A::* ptr = A::i; 1279memberPointerType() 1280 matches "A::* ptr" 1281</pre></td></tr> 1282 1283 1284<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> 1285<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. 1286 1287Given 1288 int (*ptr_to_array)[4]; 1289 int *array_of_ptrs[4]; 1290 1291varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not 1292array_of_ptrs. 1293</pre></td></tr> 1294 1295 1296<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> 1297<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types. 1298 1299Given 1300 int *a; 1301 int &b = *a; 1302 int c = 5; 1303pointerType() 1304 matches "int *a" 1305</pre></td></tr> 1306 1307 1308<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> 1309<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. 1310 1311Given: 1312 int *a; 1313 int &b = *a; 1314 int &&c = 1; 1315 auto &d = b; 1316 auto &&e = c; 1317 auto &&f = 2; 1318 int g = 5; 1319 1320rValueReferenceType() matches the types of c and f. e is not 1321matched as it is deduced to int& by reference collapsing rules. 1322</pre></td></tr> 1323 1324 1325<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> 1326<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). 1327 1328Given 1329 class C {}; 1330 struct S {}; 1331 1332 C c; 1333 S s; 1334 1335recordType() matches the type of the variable declarations of both c 1336and s. 1337</pre></td></tr> 1338 1339 1340<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> 1341<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. 1342 1343Given 1344 int *a; 1345 int &b = *a; 1346 int &&c = 1; 1347 auto &d = b; 1348 auto &&e = c; 1349 auto &&f = 2; 1350 int g = 5; 1351 1352referenceType() matches the types of b, c, d, e, and f. 1353</pre></td></tr> 1354 1355 1356<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> 1357<tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a 1358template type parameter. 1359 1360Given 1361 template <typename T> 1362 void F(T t) { 1363 int i = 1 + t; 1364 } 1365 1366substTemplateTypeParmType() matches the type of 't' but not '1' 1367</pre></td></tr> 1368 1369 1370<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> 1371<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. 1372 1373Given 1374 template <typename T> 1375 class C { }; 1376 1377 template class C<int>; A 1378 C<char> var; B 1379 1380templateSpecializationType() matches the type of the explicit 1381instantiation in A and the type of the variable declaration in B. 1382</pre></td></tr> 1383 1384 1385<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> 1386<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. 1387</pre></td></tr> 1388 1389 1390<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('typedefType0')"><a name="typedefType0Anchor">typedefType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>...</td></tr> 1391<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. 1392 1393Given 1394 typedef int X; 1395typedefType() 1396 matches "typedef int X" 1397</pre></td></tr> 1398 1399 1400<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> 1401<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. 1402 1403Given: 1404 typedef __underlying_type(T) type; 1405unaryTransformType() 1406 matches "__underlying_type(T)" 1407</pre></td></tr> 1408 1409 1410<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> 1411<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an 1412integer-constant-expression. 1413 1414Given 1415 void f() { 1416 int a[] = { 2, 3 } 1417 int b[42]; 1418 int c[a[0]]; 1419 } 1420variableArrayType() 1421 matches "int c[a[0]]" 1422</pre></td></tr> 1423 1424<!--END_DECL_MATCHERS --> 1425</table> 1426 1427<!-- ======================================================================= --> 1428<h2 id="narrowing-matchers">Narrowing Matchers</h2> 1429<!-- ======================================================================= --> 1430 1431<p>Narrowing matchers match certain attributes on the current node, thus 1432narrowing down the set of nodes of the current type to match on.</p> 1433 1434<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) 1435which allow users to create more powerful match expressions.</p> 1436 1437<table> 1438<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 1439<!-- START_NARROWING_MATCHERS --> 1440 1441<tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 1442<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. 1443 1444Usable as: Any Matcher 1445</pre></td></tr> 1446 1447 1448<tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 1449<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. 1450 1451Usable as: Any Matcher 1452</pre></td></tr> 1453 1454 1455<tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> 1456<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. 1457 1458Useful when another matcher requires a child matcher, but there's no 1459additional constraint. This will often be used with an explicit conversion 1460to an internal::Matcher<> type such as TypeMatcher. 1461 1462Example: DeclarationMatcher(anything()) matches all declarations, e.g., 1463"int* p" and "void f()" in 1464 int* p; 1465 void f(); 1466 1467Usable as: Any Matcher 1468</pre></td></tr> 1469 1470 1471<tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> 1472<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. 1473 1474Example matches Y (matcher = recordDecl(unless(hasName("X")))) 1475 class X {}; 1476 class Y {}; 1477 1478Usable as: Any Matcher 1479</pre></td></tr> 1480 1481 1482<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> 1483<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or 1484unary). 1485 1486Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 1487 !(a || b) 1488</pre></td></tr> 1489 1490 1491<tr><td>Matcher<CXXBoolLiteral></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr> 1492<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value. 1493 1494Example matches true (matcher = boolLiteral(equals(true))) 1495 true 1496 1497Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1498 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>> 1499</pre></td></tr> 1500 1501 1502<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> 1503<tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. 1504 1505Given 1506 try { 1507 ... 1508 } catch (int) { 1509 ... 1510 } catch (...) { 1511 ... 1512 } 1513endcode 1514catchStmt(isCatchAll()) matches catch(...) but not catch(int). 1515</pre></td></tr> 1516 1517 1518<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> 1519<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has 1520a specific number of arguments (including absent default arguments). 1521 1522Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 1523 void f(int x, int y); 1524 f(0, 0); 1525</pre></td></tr> 1526 1527 1528<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> 1529<tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. 1530</pre></td></tr> 1531 1532 1533<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> 1534<tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. 1535 1536Given 1537 struct S { 1538 S(); #1 1539 S(const S &); #2 1540 S(S &&); #3 1541 }; 1542constructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. 1543</pre></td></tr> 1544 1545 1546<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> 1547<tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. 1548 1549Given 1550 struct S { 1551 S(); #1 1552 S(const S &); #2 1553 S(S &&); #3 1554 }; 1555constructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. 1556</pre></td></tr> 1557 1558 1559<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> 1560<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with 1561the explicit keyword. 1562 1563Given 1564 struct S { 1565 S(int); #1 1566 explicit S(double); #2 1567 operator int(); #3 1568 explicit operator bool(); #4 1569 }; 1570constructorDecl(isExplicit()) will match #2, but not #1. 1571conversionDecl(isExplicit()) will match #4, but not #3. 1572</pre></td></tr> 1573 1574 1575<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> 1576<tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. 1577 1578Given 1579 struct S { 1580 S(); #1 1581 S(const S &); #2 1582 S(S &&); #3 1583 }; 1584constructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. 1585</pre></td></tr> 1586 1587 1588<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> 1589<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with 1590the explicit keyword. 1591 1592Given 1593 struct S { 1594 S(int); #1 1595 explicit S(double); #2 1596 operator int(); #3 1597 explicit operator bool(); #4 1598 }; 1599constructorDecl(isExplicit()) will match #2, but not #1. 1600conversionDecl(isExplicit()) will match #4, but not #3. 1601</pre></td></tr> 1602 1603 1604<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> 1605<tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as 1606opposed to a member. 1607 1608Given 1609 struct B {}; 1610 struct D : B { 1611 int I; 1612 D(int i) : I(i) {} 1613 }; 1614 struct E : B { 1615 E() : B() {} 1616 }; 1617constructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) 1618 will match E(), but not match D(int). 1619</pre></td></tr> 1620 1621 1622<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> 1623<tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as 1624opposed to a base. 1625 1626Given 1627 struct B {}; 1628 struct D : B { 1629 int I; 1630 D(int i) : I(i) {} 1631 }; 1632 struct E : B { 1633 E() : B() {} 1634 }; 1635constructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) 1636 will match D(int), but not match E(). 1637</pre></td></tr> 1638 1639 1640<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> 1641<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in 1642code (as opposed to implicitly added by the compiler). 1643 1644Given 1645 struct Foo { 1646 Foo() { } 1647 Foo(int) : foo_("A") { } 1648 string foo_; 1649 }; 1650constructorDecl(hasAnyConstructorInitializer(isWritten())) 1651 will match Foo(int), but not Foo() 1652</pre></td></tr> 1653 1654 1655<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> 1656<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. 1657 1658Given 1659struct A { 1660 void foo() const; 1661 void bar(); 1662}; 1663 1664methodDecl(isConst()) matches A::foo() but not A::bar() 1665</pre></td></tr> 1666 1667 1668<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> 1669<tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. 1670 1671Given: 1672 class A final {}; 1673 1674 struct B { 1675 virtual void f(); 1676 }; 1677 1678 struct C : B { 1679 void f() final; 1680 }; 1681matches A and C::f, but not B, C, or B::f 1682</pre></td></tr> 1683 1684 1685<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> 1686<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. 1687 1688Given 1689 class A { 1690 public: 1691 virtual void x(); 1692 }; 1693 class B : public A { 1694 public: 1695 virtual void x(); 1696 }; 1697 matches B::x 1698</pre></td></tr> 1699 1700 1701<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> 1702<tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. 1703 1704Given 1705 class A { 1706 public: 1707 virtual void x() = 0; 1708 }; 1709 matches A::x 1710</pre></td></tr> 1711 1712 1713<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> 1714<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. 1715 1716Given 1717 class A { 1718 public: 1719 virtual void x(); 1720 }; 1721 matches A::x 1722</pre></td></tr> 1723 1724 1725<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> 1726<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. 1727 1728Matches overloaded operator names specified in strings without the 1729"operator" prefix: e.g. "<<". 1730 1731Given: 1732 class A { int operator*(); }; 1733 const A &operator<<(const A &a, const A &b); 1734 A a; 1735 a << a; <-- This matches 1736 1737operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified 1738line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches 1739the declaration of A. 1740 1741Usable 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>> 1742</pre></td></tr> 1743 1744 1745<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> 1746<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). 1747</pre></td></tr> 1748 1749 1750<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> 1751<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or 1752static member variable template instantiations. 1753 1754Given 1755 template<typename T> void A(T t) { } 1756 template<> void A(int N) { } 1757functionDecl(isExplicitTemplateSpecialization()) 1758 matches the specialization A<int>(). 1759 1760Usable 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>> 1761</pre></td></tr> 1762 1763 1764<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> 1765<tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. 1766 1767Given: 1768 class A final {}; 1769 1770 struct B { 1771 virtual void f(); 1772 }; 1773 1774 struct C : B { 1775 void f() final; 1776 }; 1777matches A and C::f, but not B, C, or B::f 1778</pre></td></tr> 1779 1780 1781<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> 1782<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for 1783isSameOrDerivedFrom(hasName(...)). 1784</pre></td></tr> 1785 1786 1787<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> 1788<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static 1789member variable template instantiations. 1790 1791Given 1792 template <typename T> class X {}; class A {}; X<A> x; 1793or 1794 template <typename T> class X {}; class A {}; template class X<A>; 1795recordDecl(hasName("::X"), isTemplateInstantiation()) 1796 matches the template instantiation of X<A>. 1797 1798But given 1799 template <typename T> class X {}; class A {}; 1800 template <> class X<A> {}; X<A> x; 1801recordDecl(hasName("::X"), isTemplateInstantiation()) 1802 does not match, as X<A> is an explicit template specialization. 1803 1804Usable 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>> 1805</pre></td></tr> 1806 1807 1808<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> 1809<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has 1810a specific number of arguments (including absent default arguments). 1811 1812Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 1813 void f(int x, int y); 1814 f(0, 0); 1815</pre></td></tr> 1816 1817 1818<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> 1819<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value. 1820 1821Example matches true (matcher = boolLiteral(equals(true))) 1822 true 1823 1824Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1825 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>> 1826</pre></td></tr> 1827 1828 1829<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> 1830<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. 1831 1832Given 1833 template<typename T> struct C {}; 1834 C<int> c; 1835classTemplateSpecializationDecl(templateArgumentCountIs(1)) 1836 matches C<int>. 1837</pre></td></tr> 1838 1839 1840<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> 1841<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of 1842child statements. 1843 1844Example: Given 1845 { for (;;) {} } 1846compoundStmt(statementCountIs(0))) 1847 matches '{}' 1848 but does not match the outer compound statement. 1849</pre></td></tr> 1850 1851 1852<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> 1853<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size. 1854 1855Given 1856 int a[42]; 1857 int b[2 * 21]; 1858 int c[41], d[43]; 1859constantArrayType(hasSize(42)) 1860 matches "int a[42]" and "int b[2 * 21]" 1861</pre></td></tr> 1862 1863 1864<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> 1865<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of 1866declarations. 1867 1868Example: Given 1869 int a, b; 1870 int c; 1871 int d = 2, e; 1872declCountIs(2) 1873 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. 1874</pre></td></tr> 1875 1876 1877<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> 1878<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. 1879 1880Matches a node if it equals the node previously bound to ID. 1881 1882Given 1883 class X { int a; int b; }; 1884recordDecl( 1885 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 1886 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 1887 matches the class X, as a and b have the same type. 1888 1889Note that when multiple matches are involved via forEach* matchers, 1890equalsBoundNodes acts as a filter. 1891For example: 1892compoundStmt( 1893 forEachDescendant(varDecl().bind("d")), 1894 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 1895will trigger a match for each combination of variable declaration 1896and reference to that variable declaration within a compound statement. 1897</pre></td></tr> 1898 1899 1900<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> 1901<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. 1902 1903Given 1904 __attribute__((device)) void f() { ... } 1905decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of 1906f. If the matcher is use from clang-query, attr::Kind parameter should be 1907passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). 1908</pre></td></tr> 1909 1910 1911<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> 1912<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is 1913partially matching a given regex. 1914 1915Example matches Y but not X 1916 (matcher = recordDecl(isExpansionInFileMatching("AST.*")) 1917 #include "ASTMatcher.h" 1918 class X {}; 1919ASTMatcher.h: 1920 class Y {}; 1921 1922Usable 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>> 1923</pre></td></tr> 1924 1925 1926<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> 1927<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. 1928 1929Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile()) 1930 #include <Y.h> 1931 class X {}; 1932Y.h: 1933 class Y {}; 1934 1935Usable 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>> 1936</pre></td></tr> 1937 1938 1939<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> 1940<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. 1941 1942Example matches Y but not X 1943 (matcher = recordDecl(isExpansionInSystemHeader()) 1944 #include <SystemHeader.h> 1945 class X {}; 1946SystemHeader.h: 1947 class Y {}; 1948 1949Usable 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>> 1950</pre></td></tr> 1951 1952 1953<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> 1954<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added 1955by the compiler (eg. implicit defaultcopy constructors). 1956</pre></td></tr> 1957 1958 1959<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> 1960<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. 1961 1962Given 1963 class C { 1964 public: int a; 1965 protected: int b; 1966 private: int c; 1967 }; 1968fieldDecl(isPrivate()) 1969 matches 'int c;' 1970</pre></td></tr> 1971 1972 1973<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> 1974<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. 1975 1976Given 1977 class C { 1978 public: int a; 1979 protected: int b; 1980 private: int c; 1981 }; 1982fieldDecl(isProtected()) 1983 matches 'int b;' 1984</pre></td></tr> 1985 1986 1987<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> 1988<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. 1989 1990Given 1991 class C { 1992 public: int a; 1993 protected: int b; 1994 private: int c; 1995 }; 1996fieldDecl(isPublic()) 1997 matches 'int a;' 1998</pre></td></tr> 1999 2000 2001<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> 2002<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. 2003 2004Example matches true (matcher = boolLiteral(equals(true))) 2005 true 2006 2007Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 2008 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>> 2009</pre></td></tr> 2010 2011 2012<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> 2013<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. 2014 2015Matches overloaded operator names specified in strings without the 2016"operator" prefix: e.g. "<<". 2017 2018Given: 2019 class A { int operator*(); }; 2020 const A &operator<<(const A &a, const A &b); 2021 A a; 2022 a << a; <-- This matches 2023 2024operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified 2025line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches 2026the declaration of A. 2027 2028Usable 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>> 2029</pre></td></tr> 2030 2031 2032<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> 2033<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations. 2034 2035Given: 2036 constexpr int foo = 42; 2037 constexpr int bar(); 2038varDecl(isConstexpr()) 2039 matches the declaration of foo. 2040functionDecl(isConstexpr()) 2041 matches the declaration of bar. 2042</pre></td></tr> 2043 2044 2045<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> 2046<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. 2047 2048Example matches A, va, fa 2049 class A {}; 2050 class B; Doesn't match, as it has no body. 2051 int va; 2052 extern int vb; Doesn't match, as it doesn't define the variable. 2053 void fa() {} 2054 void fb(); Doesn't match, as it has no body. 2055 2056Usable 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>> 2057</pre></td></tr> 2058 2059 2060<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> 2061<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. 2062 2063Given: 2064 void Func(); 2065 void DeletedFunc() = delete; 2066functionDecl(isDeleted()) 2067 matches the declaration of DeletedFunc, but not Func. 2068</pre></td></tr> 2069 2070 2071<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> 2072<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or 2073static member variable template instantiations. 2074 2075Given 2076 template<typename T> void A(T t) { } 2077 template<> void A(int N) { } 2078functionDecl(isExplicitTemplateSpecialization()) 2079 matches the specialization A<int>(). 2080 2081Usable 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>> 2082</pre></td></tr> 2083 2084 2085<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> 2086<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. 2087 2088Given: 2089 extern "C" void f() {} 2090 extern "C" { void g() {} } 2091 void h() {} 2092functionDecl(isExternC()) 2093 matches the declaration of f and g, but not the declaration h 2094</pre></td></tr> 2095 2096 2097<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> 2098<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with 2099the inline keyword. 2100 2101Given 2102 inline void f(); 2103 void g(); 2104 namespace n { 2105 inline namespace m {} 2106 } 2107functionDecl(isInline()) will match ::f(). 2108namespaceDecl(isInline()) will match n::m. 2109</pre></td></tr> 2110 2111 2112<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> 2113<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 2114member variable template instantiations. 2115 2116Given 2117 template <typename T> class X {}; class A {}; X<A> x; 2118or 2119 template <typename T> class X {}; class A {}; template class X<A>; 2120recordDecl(hasName("::X"), isTemplateInstantiation()) 2121 matches the template instantiation of X<A>. 2122 2123But given 2124 template <typename T> class X {}; class A {}; 2125 template <> class X<A> {}; X<A> x; 2126recordDecl(hasName("::X"), isTemplateInstantiation()) 2127 does not match, as X<A> is an explicit template specialization. 2128 2129Usable 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>> 2130</pre></td></tr> 2131 2132 2133<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> 2134<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count. 2135 2136Given 2137 void f(int i) {} 2138 void g(int i, int j) {} 2139functionDecl(parameterCountIs(2)) 2140 matches g(int i, int j) {} 2141</pre></td></tr> 2142 2143 2144<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> 2145<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. 2146 2147Example matches true (matcher = boolLiteral(equals(true))) 2148 true 2149 2150Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 2151 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>> 2152</pre></td></tr> 2153 2154 2155<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> 2156<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 2157to '.'. 2158 2159Member calls on the implicit this pointer match as called with '->'. 2160 2161Given 2162 class Y { 2163 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 2164 int a; 2165 static int b; 2166 }; 2167memberExpr(isArrow()) 2168 matches this->x, x, y.x, a, this->b 2169</pre></td></tr> 2170 2171 2172<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> 2173<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 2174 2175Supports specifying enclosing namespaces or classes by prefixing the name 2176with '<enclosing>::'. 2177Does not match typedefs of an underlying type with the given name. 2178 2179Example matches X (Name == "X") 2180 class X; 2181 2182Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 2183 namespace a { namespace b { class X; } } 2184</pre></td></tr> 2185 2186 2187<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> 2188<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain 2189a substring matched by the given RegExp. 2190 2191Supports specifying enclosing namespaces or classes by 2192prefixing the name with '<enclosing>::'. Does not match typedefs 2193of an underlying type with the given name. 2194 2195Example matches X (regexp == "::X") 2196 class X; 2197 2198Example matches X (regexp is one of "::X", "^foo::.*X", among others) 2199 namespace foo { namespace bar { class X; } } 2200</pre></td></tr> 2201 2202 2203<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> 2204<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. 2205 2206Given 2207 namespace n { 2208 namespace {} #1 2209 } 2210namespaceDecl(isAnonymous()) will match #1 but not ::n. 2211</pre></td></tr> 2212 2213 2214<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> 2215<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with 2216the inline keyword. 2217 2218Given 2219 inline void f(); 2220 void g(); 2221 namespace n { 2222 inline namespace m {} 2223 } 2224functionDecl(isInline()) will match ::f(). 2225namespaceDecl(isInline()) will match n::m. 2226</pre></td></tr> 2227 2228 2229<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> 2230<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has 2231a specific number of arguments (including absent default arguments). 2232 2233Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 2234 void f(int x, int y); 2235 f(0, 0); 2236</pre></td></tr> 2237 2238 2239<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> 2240<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre></pre></td></tr> 2241 2242 2243<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> 2244<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector 2245 2246Matches only when the selector of the objCMessageExpr is NULL. This may 2247represent an error condition in the tree! 2248</pre></td></tr> 2249 2250 2251<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> 2252<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() 2253 2254 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); 2255 matches the outer message expr in the code below, but NOT the message 2256 invocation for self.bodyView. 2257 [self.bodyView loadHTMLString:html baseURL:NULL]; 2258</pre></td></tr> 2259 2260 2261<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> 2262<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector 2263 2264 matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); 2265 matches self.bodyView in the code below, but NOT the outer message 2266 invocation of "loadHTMLString:baseURL:". 2267 [self.bodyView loadHTMLString:html baseURL:NULL]; 2268</pre></td></tr> 2269 2270 2271<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> 2272<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains 2273a substring matched by the given RegExp. 2274 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message 2275 invocation for self.bodyView. 2276 [self.bodyView loadHTMLString:html baseURL:NULL]; 2277</pre></td></tr> 2278 2279 2280<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> 2281<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments 2282 2283 matcher = objCMessageExpr(numSelectorArgs(1)); 2284 matches self.bodyView in the code below 2285 2286 matcher = objCMessageExpr(numSelectorArgs(2)); 2287 matches the invocation of "loadHTMLString:baseURL:" but not that 2288 of self.bodyView 2289 [self.bodyView loadHTMLString:html baseURL:NULL]; 2290</pre></td></tr> 2291 2292 2293<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> 2294<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 2295 2296Given 2297 class Y { public: void x(); }; 2298 void z() { Y* y; y->x(); } 2299memberCallExpr(on(hasType(asString("class Y *")))) 2300 matches y->x() 2301</pre></td></tr> 2302 2303 2304<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> 2305<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. 2306 2307Matches a node if it equals the node previously bound to ID. 2308 2309Given 2310 class X { int a; int b; }; 2311recordDecl( 2312 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2313 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2314 matches the class X, as a and b have the same type. 2315 2316Note that when multiple matches are involved via forEach* matchers, 2317equalsBoundNodes acts as a filter. 2318For example: 2319compoundStmt( 2320 forEachDescendant(varDecl().bind("d")), 2321 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2322will trigger a match for each combination of variable declaration 2323and reference to that variable declaration within a compound statement. 2324</pre></td></tr> 2325 2326 2327<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> 2328<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to 2329the node, not hidden within a typedef. 2330 2331Given 2332 typedef const int const_int; 2333 const_int i; 2334 int *const j; 2335 int *volatile k; 2336 int m; 2337varDecl(hasType(hasLocalQualifiers())) matches only j and k. 2338i is const-qualified but the qualifier is not local. 2339</pre></td></tr> 2340 2341 2342<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> 2343<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 2344include "top-level" const. 2345 2346Given 2347 void a(int); 2348 void b(int const); 2349 void c(const int); 2350 void d(const int*); 2351 void e(int const) {}; 2352functionDecl(hasAnyParameter(hasType(isConstQualified()))) 2353 matches "void b(int const)", "void c(const int)" and 2354 "void e(int const) {}". It does not match d as there 2355 is no top-level const on the parameter type "const int *". 2356</pre></td></tr> 2357 2358 2359<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> 2360<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 2361 2362Given 2363 void a(int); 2364 void b(long); 2365 void c(double); 2366functionDecl(hasAnyParameter(hasType(isInteger()))) 2367matches "a(int)", "b(long)", but not "c(double)". 2368</pre></td></tr> 2369 2370 2371<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> 2372<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. 2373 2374Matches a node if it equals the node previously bound to ID. 2375 2376Given 2377 class X { int a; int b; }; 2378recordDecl( 2379 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2380 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2381 matches the class X, as a and b have the same type. 2382 2383Note that when multiple matches are involved via forEach* matchers, 2384equalsBoundNodes acts as a filter. 2385For example: 2386compoundStmt( 2387 forEachDescendant(varDecl().bind("d")), 2388 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2389will trigger a match for each combination of variable declaration 2390and reference to that variable declaration within a compound statement. 2391</pre></td></tr> 2392 2393 2394<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> 2395<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is 2396partially matching a given regex. 2397 2398Example matches Y but not X 2399 (matcher = recordDecl(isExpansionInFileMatching("AST.*")) 2400 #include "ASTMatcher.h" 2401 class X {}; 2402ASTMatcher.h: 2403 class Y {}; 2404 2405Usable 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>> 2406</pre></td></tr> 2407 2408 2409<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> 2410<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. 2411 2412Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile()) 2413 #include <Y.h> 2414 class X {}; 2415Y.h: 2416 class Y {}; 2417 2418Usable 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>> 2419</pre></td></tr> 2420 2421 2422<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> 2423<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. 2424 2425Example matches Y but not X 2426 (matcher = recordDecl(isExpansionInSystemHeader()) 2427 #include <SystemHeader.h> 2428 class X {}; 2429SystemHeader.h: 2430 class Y {}; 2431 2432Usable 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>> 2433</pre></td></tr> 2434 2435 2436<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> 2437<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 2438 2439Example matches A, va, fa 2440 class A {}; 2441 class B; Doesn't match, as it has no body. 2442 int va; 2443 extern int vb; Doesn't match, as it doesn't define the variable. 2444 void fa() {} 2445 void fb(); Doesn't match, as it has no body. 2446 2447Usable 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>> 2448</pre></td></tr> 2449 2450 2451<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> 2452<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. 2453 2454Note that 'Value' is a string as the template argument's value is 2455an arbitrary precision integer. 'Value' must be euqal to the canonical 2456representation of that integral value in base 10. 2457 2458Given 2459 template<int T> struct A {}; 2460 C<42> c; 2461classTemplateSpecializationDecl( 2462 hasAnyTemplateArgument(equalsIntegralValue("42"))) 2463 matches the implicit instantiation of C in C<42>. 2464</pre></td></tr> 2465 2466 2467<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> 2468<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. 2469 2470Given 2471 template<int T> struct A {}; 2472 C<42> c; 2473classTemplateSpecializationDecl( 2474 hasAnyTemplateArgument(isIntegral())) 2475 matches the implicit instantiation of C in C<42> 2476 with isIntegral() matching 42. 2477</pre></td></tr> 2478 2479 2480<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> 2481<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. 2482 2483Given 2484 template<typename T> struct C {}; 2485 C<int> c; 2486classTemplateSpecializationDecl(templateArgumentCountIs(1)) 2487 matches C<int>. 2488</pre></td></tr> 2489 2490 2491<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> 2492<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is 2493partially matching a given regex. 2494 2495Example matches Y but not X 2496 (matcher = recordDecl(isExpansionInFileMatching("AST.*")) 2497 #include "ASTMatcher.h" 2498 class X {}; 2499ASTMatcher.h: 2500 class Y {}; 2501 2502Usable 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>> 2503</pre></td></tr> 2504 2505 2506<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> 2507<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. 2508 2509Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile()) 2510 #include <Y.h> 2511 class X {}; 2512Y.h: 2513 class Y {}; 2514 2515Usable 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>> 2516</pre></td></tr> 2517 2518 2519<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> 2520<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. 2521 2522Example matches Y but not X 2523 (matcher = recordDecl(isExpansionInSystemHeader()) 2524 #include <SystemHeader.h> 2525 class X {}; 2526SystemHeader.h: 2527 class Y {}; 2528 2529Usable 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>> 2530</pre></td></tr> 2531 2532 2533<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> 2534<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. 2535 2536Matches a node if it equals the node previously bound to ID. 2537 2538Given 2539 class X { int a; int b; }; 2540recordDecl( 2541 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2542 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2543 matches the class X, as a and b have the same type. 2544 2545Note that when multiple matches are involved via forEach* matchers, 2546equalsBoundNodes acts as a filter. 2547For example: 2548compoundStmt( 2549 forEachDescendant(varDecl().bind("d")), 2550 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2551will trigger a match for each combination of variable declaration 2552and reference to that variable declaration within a compound statement. 2553</pre></td></tr> 2554 2555 2556<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> 2557<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. 2558 2559Given 2560 struct S { void func(); }; 2561functionDecl(returns(voidType())) 2562 matches "void func();" 2563</pre></td></tr> 2564 2565 2566<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> 2567<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 2568 2569Given 2570 int x; 2571 int s = sizeof(x) + alignof(x) 2572unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 2573 matches sizeof(x) 2574</pre></td></tr> 2575 2576 2577<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> 2578<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 2579unary). 2580 2581Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 2582 !(a || b) 2583</pre></td></tr> 2584 2585 2586<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> 2587<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. 2588 2589Example matches y and z (matcher = varDecl(hasGlobalStorage()) 2590void f() { 2591 int x; 2592 static int y; 2593} 2594int z; 2595</pre></td></tr> 2596 2597 2598<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> 2599<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a 2600non-static local variable. 2601 2602Example matches x (matcher = varDecl(hasLocalStorage()) 2603void f() { 2604 int x; 2605 static int y; 2606} 2607int z; 2608</pre></td></tr> 2609 2610 2611<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> 2612<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations. 2613 2614Given: 2615 constexpr int foo = 42; 2616 constexpr int bar(); 2617varDecl(isConstexpr()) 2618 matches the declaration of foo. 2619functionDecl(isConstexpr()) 2620 matches the declaration of bar. 2621</pre></td></tr> 2622 2623 2624<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> 2625<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 2626 2627Example matches A, va, fa 2628 class A {}; 2629 class B; Doesn't match, as it has no body. 2630 int va; 2631 extern int vb; Doesn't match, as it doesn't define the variable. 2632 void fa() {} 2633 void fb(); Doesn't match, as it has no body. 2634 2635Usable 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>> 2636</pre></td></tr> 2637 2638 2639<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> 2640<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from 2641a C++ catch block, or an Objective-C statement. 2642 2643Example matches x (matcher = varDecl(isExceptionVariable()) 2644void f(int y) { 2645 try { 2646 } catch (int x) { 2647 } 2648} 2649</pre></td></tr> 2650 2651 2652<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> 2653<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 2654static member variable template instantiations. 2655 2656Given 2657 template<typename T> void A(T t) { } 2658 template<> void A(int N) { } 2659functionDecl(isExplicitTemplateSpecialization()) 2660 matches the specialization A<int>(). 2661 2662Usable 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>> 2663</pre></td></tr> 2664 2665 2666<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> 2667<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 2668member variable template instantiations. 2669 2670Given 2671 template <typename T> class X {}; class A {}; X<A> x; 2672or 2673 template <typename T> class X {}; class A {}; template class X<A>; 2674recordDecl(hasName("::X"), isTemplateInstantiation()) 2675 matches the template instantiation of X<A>. 2676 2677But given 2678 template <typename T> class X {}; class A {}; 2679 template <> class X<A> {}; X<A> x; 2680recordDecl(hasName("::X"), isTemplateInstantiation()) 2681 does not match, as X<A> is an explicit template specialization. 2682 2683Usable 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>> 2684</pre></td></tr> 2685 2686 2687<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> 2688<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside 2689template instantiations. 2690 2691Given 2692 template<typename T> void A(T t) { T i; } 2693 A(0); 2694 A(0U); 2695functionDecl(isInstantiated()) 2696 matches 'A(int) {...};' and 'A(unsigned) {...}'. 2697</pre></td></tr> 2698 2699 2700<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> 2701<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. 2702 2703Given 2704 int j; 2705 template<typename T> void A(T t) { T i; j += 42;} 2706 A(0); 2707 A(0U); 2708declStmt(isInTemplateInstantiation()) 2709 matches 'int i;' and 'unsigned i'. 2710unless(stmt(isInTemplateInstantiation())) 2711 will NOT match j += 42; as it's shared between the template definition and 2712 instantiation. 2713</pre></td></tr> 2714 2715<!--END_NARROWING_MATCHERS --> 2716</table> 2717 2718<!-- ======================================================================= --> 2719<h2 id="traversal-matchers">AST Traversal Matchers</h2> 2720<!-- ======================================================================= --> 2721 2722<p>Traversal matchers specify the relationship to other nodes that are 2723reachable from the current node.</p> 2724 2725<p>Note that there are special traversal matchers (has, hasDescendant, forEach and 2726forEachDescendant) which work on all nodes and allow users to write more generic 2727match expressions.</p> 2728 2729<table> 2730<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 2731<!-- START_TRAVERSAL_MATCHERS --> 2732 2733<tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 2734<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. 2735 2736Unlike anyOf, eachOf will generate a match result for each 2737matching submatcher. 2738 2739For example, in: 2740 class A { int a; int b; }; 2741The matcher: 2742 recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), 2743 has(fieldDecl(hasName("b")).bind("v")))) 2744will generate two results binding "v", the first of which binds 2745the field declaration of a, the second the field declaration of 2746b. 2747 2748Usable as: Any Matcher 2749</pre></td></tr> 2750 2751 2752<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> 2753<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 2754provided matcher. 2755 2756Example matches X, A, B, C 2757 (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X"))))) 2758 class X {}; Matches X, because X::X is a class of name X inside X. 2759 class A { class X {}; }; 2760 class B { class C { class X {}; }; }; 2761 2762DescendantT must be an AST base type. 2763 2764As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 2765each result that matches instead of only on the first one. 2766 2767Note: Recursively combined ForEachDescendant can cause many matches: 2768 recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl())))) 2769will match 10 times (plus injected class name matches) on: 2770 class A { class B { class C { class D { class E {}; }; }; }; }; 2771 2772Usable as: Any Matcher 2773</pre></td></tr> 2774 2775 2776<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> 2777<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 2778provided matcher. 2779 2780Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X"))) 2781 class X {}; Matches X, because X::X is a class of name X inside X. 2782 class Y { class X {}; }; 2783 class Z { class Y { class X {}; }; }; Does not match Z. 2784 2785ChildT must be an AST base type. 2786 2787As opposed to 'has', 'forEach' will cause a match for each result that 2788matches instead of only on the first one. 2789 2790Usable as: Any Matcher 2791</pre></td></tr> 2792 2793 2794<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> 2795<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 2796matcher. 2797 2798Given 2799void f() { if (true) { int x = 42; } } 2800void g() { for (;;) { int x = 43; } } 2801expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 2802 2803Usable as: Any Matcher 2804</pre></td></tr> 2805 2806 2807<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> 2808<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 2809provided matcher. 2810 2811Example matches X, Y, Z 2812 (matcher = recordDecl(hasDescendant(recordDecl(hasName("X"))))) 2813 class X {}; Matches X, because X::X is a class of name X inside X. 2814 class Y { class X {}; }; 2815 class Z { class Y { class X {}; }; }; 2816 2817DescendantT must be an AST base type. 2818 2819Usable as: Any Matcher 2820</pre></td></tr> 2821 2822 2823<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> 2824<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 2825provided matcher. 2826 2827Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X"))) 2828 class X {}; Matches X, because X::X is a class of name X inside X. 2829 class Y { class X {}; }; 2830 class Z { class Y { class X {}; }; }; Does not match Z. 2831 2832ChildT must be an AST base type. 2833 2834Usable as: Any Matcher 2835</pre></td></tr> 2836 2837 2838<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> 2839<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 2840matcher. 2841 2842Given 2843void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 2844compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 2845 2846Usable as: Any Matcher 2847</pre></td></tr> 2848 2849 2850<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> 2851<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 2852 2853Given 2854 int i[5]; 2855 void f() { i[1] = 42; } 2856arraySubscriptExpression(hasBase(implicitCastExpr( 2857 hasSourceExpression(declRefExpr())))) 2858 matches i[1] with the declRefExpr() matching i 2859</pre></td></tr> 2860 2861 2862<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> 2863<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 2864 2865Given 2866 int i[5]; 2867 void f() { i[1] = 42; } 2868arraySubscriptExpression(hasIndex(integerLiteral())) 2869 matches i[1] with the integerLiteral() matching 1 2870</pre></td></tr> 2871 2872 2873<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> 2874<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element 2875type. 2876 2877Given 2878 struct A {}; 2879 A a[7]; 2880 int b[7]; 2881arrayType(hasElementType(builtinType())) 2882 matches "int b[7]" 2883 2884Usable 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>> 2885</pre></td></tr> 2886 2887 2888<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> 2889<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element 2890type. 2891 2892Given 2893 struct A {}; 2894 A a[7]; 2895 int b[7]; 2896arrayType(hasElementType(builtinType())) 2897 matches "int b[7]" 2898 2899Usable 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>> 2900</pre></td></tr> 2901 2902 2903<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> 2904<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. 2905 2906Given 2907 _Atomic(int) i; 2908 _Atomic(float) f; 2909atomicType(hasValueType(isInteger())) 2910 matches "_Atomic(int) i" 2911 2912Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 2913</pre></td></tr> 2914 2915 2916<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> 2917<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. 2918 2919Given 2920 _Atomic(int) i; 2921 _Atomic(float) f; 2922atomicType(hasValueType(isInteger())) 2923 matches "_Atomic(int) i" 2924 2925Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 2926</pre></td></tr> 2927 2928 2929<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> 2930<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. 2931 2932Note: There is no TypeLoc for the deduced type and thus no 2933getDeducedLoc() matcher. 2934 2935Given 2936 auto a = 1; 2937 auto b = 2.0; 2938autoType(hasDeducedType(isInteger())) 2939 matches "auto a" 2940 2941Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> 2942</pre></td></tr> 2943 2944 2945<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> 2946<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 2947binary operator matches. 2948</pre></td></tr> 2949 2950 2951<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> 2952<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 2953 2954Example matches a (matcher = binaryOperator(hasLHS())) 2955 a || b 2956</pre></td></tr> 2957 2958 2959<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> 2960<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 2961 2962Example matches b (matcher = binaryOperator(hasRHS())) 2963 a || b 2964</pre></td></tr> 2965 2966 2967<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> 2968<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the 2969pointee matches a given matcher. 2970 2971Given 2972 int *a; 2973 int const *b; 2974 float const *f; 2975pointerType(pointee(isConstQualified(), isInteger())) 2976 matches "int const *b" 2977 2978Usable 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>>, 2979 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>> 2980</pre></td></tr> 2981 2982 2983<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> 2984<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the 2985pointee matches a given matcher. 2986 2987Given 2988 int *a; 2989 int const *b; 2990 float const *f; 2991pointerType(pointee(isConstQualified(), isInteger())) 2992 matches "int const *b" 2993 2994Usable 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>>, 2995 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>> 2996</pre></td></tr> 2997 2998 2999<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> 3000<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call 3001expression. 3002 3003Given 3004 void x(int, int, int) { int y; x(1, y, 42); } 3005callExpr(hasAnyArgument(declRefExpr())) 3006 matches x(1, y, 42) 3007with hasAnyArgument(...) 3008 matching y 3009 3010FIXME: Currently this will ignore parentheses and implicit casts on 3011the argument before applying the inner matcher. We'll want to remove 3012this to allow for greater control by the user once ignoreImplicit() 3013has been implemented. 3014</pre></td></tr> 3015 3016 3017<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> 3018<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor 3019call expression. 3020 3021Example matches y in x(y) 3022 (matcher = callExpr(hasArgument(0, declRefExpr()))) 3023 void x(int) { int y; x(y); } 3024</pre></td></tr> 3025 3026 3027<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</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> 3028<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node 3029matches the given matcher. 3030 3031The associated declaration is: 3032- for type nodes, the declaration of the underlying type 3033- for CallExpr, the declaration of the callee 3034- for MemberExpr, the declaration of the referenced member 3035- for CXXConstructExpr, the declaration of the constructor 3036 3037Also usable as Matcher<T> for any T supporting the getDecl() member 3038function. e.g. various subtypes of clang::Type and various expressions. 3039 3040Usable 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>>, 3041 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>>, 3042 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3043 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>>, 3044 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>>, 3045 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>> 3046</pre></td></tr> 3047 3048 3049<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> 3050<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. 3051 3052Given 3053 class A { A() : i(42), j(42) {} int i; int j; }; 3054constructorDecl(forEachConstructorInitializer(forField(decl().bind("x")))) 3055 will trigger two matches, binding for 'i' and 'j' respectively. 3056</pre></td></tr> 3057 3058 3059<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> 3060<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 3061 3062Given 3063 struct Foo { 3064 Foo() : foo_(1) { } 3065 int foo_; 3066 }; 3067recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything())))) 3068 record matches Foo, hasAnyConstructorInitializer matches foo_(1) 3069</pre></td></tr> 3070 3071 3072<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> 3073<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 3074 3075Given 3076 struct Foo { 3077 Foo() : foo_(1) { } 3078 int foo_; 3079 }; 3080recordDecl(has(constructorDecl(hasAnyConstructorInitializer( 3081 forField(hasName("foo_")))))) 3082 matches Foo 3083with forField matching foo_ 3084</pre></td></tr> 3085 3086 3087<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> 3088<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 3089 3090Given 3091 struct Foo { 3092 Foo() : foo_(1) { } 3093 int foo_; 3094 }; 3095recordDecl(has(constructorDecl(hasAnyConstructorInitializer( 3096 withInitializer(integerLiteral(equals(1))))))) 3097 matches Foo 3098with withInitializer matching (1) 3099</pre></td></tr> 3100 3101 3102<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> 3103<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', or 'do while' statement that has 3104a given body. 3105 3106Given 3107 for (;;) {} 3108hasBody(compoundStmt()) 3109 matches 'for (;;) {}' 3110with compoundStmt() 3111 matching '{}' 3112</pre></td></tr> 3113 3114 3115<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> 3116<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. 3117 3118Example: 3119 forStmt(hasLoopVariable(anything())) 3120matches 'int x' in 3121 for (int x : a) { } 3122</pre></td></tr> 3123 3124 3125<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> 3126<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. 3127 3128Example: 3129 forStmt(hasRangeInit(anything())) 3130matches 'a' in 3131 for (int x : a) { } 3132</pre></td></tr> 3133 3134 3135<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> 3136<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> 3137 3138 3139<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> 3140<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. 3141 3142Example matches y.x() 3143 (matcher = memberCallExpr(on(hasType(recordDecl(hasName("Y")))))) 3144 class Y { public: void x(); }; 3145 void z() { Y y; y.x(); }", 3146 3147FIXME: Overload to allow directly matching types? 3148</pre></td></tr> 3149 3150 3151<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> 3152<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 3153</pre></td></tr> 3154 3155 3156<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> 3157<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified 3158matcher, or is a pointer to a type that matches the InnerMatcher. 3159</pre></td></tr> 3160 3161 3162<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> 3163<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 3164belongs to. 3165 3166FIXME: Generalize this for other kinds of declarations. 3167FIXME: What other kind of declarations would we need to generalize 3168this to? 3169 3170Example matches A() in the last line 3171 (matcher = constructExpr(hasDeclaration(methodDecl( 3172 ofClass(hasName("A")))))) 3173 class A { 3174 public: 3175 A(); 3176 }; 3177 A a = A(); 3178</pre></td></tr> 3179 3180 3181<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> 3182<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. 3183 3184Given: 3185 class A { void func(); }; 3186 class B { void member(); }; 3187 3188recordDecl(hasMethod(hasName("func"))) matches the declaration of A 3189but not B. 3190</pre></td></tr> 3191 3192 3193<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> 3194<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from 3195a class matching Base. 3196 3197Note that a class is not considered to be derived from itself. 3198 3199Example matches Y, Z, C (Base == hasName("X")) 3200 class X; 3201 class Y : public X {}; directly derived 3202 class Z : public Y {}; indirectly derived 3203 typedef X A; 3204 typedef A B; 3205 class C : public B {}; derived from a typedef of X 3206 3207In the following example, Bar matches isDerivedFrom(hasName("X")): 3208 class Foo; 3209 typedef Foo X; 3210 class Bar : public Foo {}; derived from a type that X is a typedef of 3211</pre></td></tr> 3212 3213 3214<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> 3215<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 3216match Base. 3217</pre></td></tr> 3218 3219 3220<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> 3221<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the 3222given matcher. 3223 3224Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x"))))) 3225 class Y { public: void x(); }; 3226 void z() { Y y; y.x(); } 3227</pre></td></tr> 3228 3229 3230<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> 3231<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. 3232 3233Given 3234 class Y { void x() { this->x(); x(); Y y; y.x(); } }; 3235 void f() { f(); } 3236callExpr(callee(expr())) 3237 matches this->x(), x(), y.x(), f() 3238with callee(...) 3239 matching this->x, x, y.x, f respectively 3240 3241Note: Callee cannot take the more general internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> 3242because this introduces ambiguous overloads with calls to Callee taking a 3243internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely 3244implemented in terms of implicit casts. 3245</pre></td></tr> 3246 3247 3248<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> 3249<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 3250expression. 3251 3252Given 3253 void x(int, int, int) { int y; x(1, y, 42); } 3254callExpr(hasAnyArgument(declRefExpr())) 3255 matches x(1, y, 42) 3256with hasAnyArgument(...) 3257 matching y 3258 3259FIXME: Currently this will ignore parentheses and implicit casts on 3260the argument before applying the inner matcher. We'll want to remove 3261this to allow for greater control by the user once ignoreImplicit() 3262has been implemented. 3263</pre></td></tr> 3264 3265 3266<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> 3267<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 3268call expression. 3269 3270Example matches y in x(y) 3271 (matcher = callExpr(hasArgument(0, declRefExpr()))) 3272 void x(int) { int y; x(y); } 3273</pre></td></tr> 3274 3275 3276<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</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> 3277<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node 3278matches the given matcher. 3279 3280The associated declaration is: 3281- for type nodes, the declaration of the underlying type 3282- for CallExpr, the declaration of the callee 3283- for MemberExpr, the declaration of the referenced member 3284- for CXXConstructExpr, the declaration of the constructor 3285 3286Also usable as Matcher<T> for any T supporting the getDecl() member 3287function. e.g. various subtypes of clang::Type and various expressions. 3288 3289Usable 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>>, 3290 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>>, 3291 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3292 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>>, 3293 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>>, 3294 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>> 3295</pre></td></tr> 3296 3297 3298<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> 3299<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range 3300extension, matches the constant given in the statement. 3301 3302Given 3303 switch (1) { case 1: case 1+1: case 3 ... 4: ; } 3304caseStmt(hasCaseConstant(integerLiteral())) 3305 matches "case 1:" 3306</pre></td></tr> 3307 3308 3309<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> 3310<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher. 3311 3312Example: matches "a string" (matcher = 3313 hasSourceExpression(constructExpr())) 3314class URL { URL(string); }; 3315URL url = "a string"; 3316</pre></td></tr> 3317 3318 3319<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> 3320<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one 3321TemplateArgument matching the given InnerMatcher. 3322 3323Given 3324 template<typename T> class A {}; 3325 template<> class A<double> {}; 3326 A<int> a; 3327classTemplateSpecializationDecl(hasAnyTemplateArgument( 3328 refersToType(asString("int")))) 3329 matches the specialization A<int> 3330</pre></td></tr> 3331 3332 3333<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> 3334<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument 3335matches the given InnerMatcher. 3336 3337Given 3338 template<typename T, typename U> class A {}; 3339 A<bool, int> b; 3340 A<int, bool> c; 3341classTemplateSpecializationDecl(hasTemplateArgument( 3342 1, refersToType(asString("int")))) 3343 matches the specialization A<bool, int> 3344</pre></td></tr> 3345 3346 3347<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> 3348<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element 3349type. 3350 3351Given 3352 struct A {}; 3353 A a[7]; 3354 int b[7]; 3355arrayType(hasElementType(builtinType())) 3356 matches "int b[7]" 3357 3358Usable 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>> 3359</pre></td></tr> 3360 3361 3362<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> 3363<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element 3364type. 3365 3366Given 3367 struct A {}; 3368 A a[7]; 3369 int b[7]; 3370arrayType(hasElementType(builtinType())) 3371 matches "int b[7]" 3372 3373Usable 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>> 3374</pre></td></tr> 3375 3376 3377<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> 3378<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 3379a given matcher. 3380 3381Given 3382 { {}; 1+2; } 3383hasAnySubstatement(compoundStmt()) 3384 matches '{ {}; 1+2; }' 3385with compoundStmt() 3386 matching '{}' 3387</pre></td></tr> 3388 3389 3390<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</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> 3391<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 3392or conditional operator. 3393 3394Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3395 if (true) {} 3396</pre></td></tr> 3397 3398 3399<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</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> 3400<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator. 3401 3402Example matches b 3403 condition ? a : b 3404</pre></td></tr> 3405 3406 3407<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</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> 3408<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 3409 3410Example matches a 3411 condition ? a : b 3412</pre></td></tr> 3413 3414 3415<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('hasDeclaration11')"><a name="hasDeclaration11Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3416<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node 3417matches the given matcher. 3418 3419The associated declaration is: 3420- for type nodes, the declaration of the underlying type 3421- for CallExpr, the declaration of the callee 3422- for MemberExpr, the declaration of the referenced member 3423- for CXXConstructExpr, the declaration of the constructor 3424 3425Also usable as Matcher<T> for any T supporting the getDecl() member 3426function. e.g. various subtypes of clang::Type and various expressions. 3427 3428Usable 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>>, 3429 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>>, 3430 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3431 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>>, 3432 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>>, 3433 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>> 3434</pre></td></tr> 3435 3436 3437<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> 3438<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a 3439specific using shadow declaration. 3440 3441Given 3442 namespace a { void f() {} } 3443 using a::f; 3444 void g() { 3445 f(); Matches this .. 3446 a::f(); .. but not this. 3447 } 3448declRefExpr(throughUsingDecl(anything())) 3449 matches f() 3450</pre></td></tr> 3451 3452 3453<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> 3454<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 3455specified matcher. 3456 3457Example matches x in if(x) 3458 (matcher = declRefExpr(to(varDecl(hasName("x"))))) 3459 bool x; 3460 if (x) {} 3461</pre></td></tr> 3462 3463 3464<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> 3465<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 3466 3467Note that this does not work for global declarations because the AST 3468breaks up multiple-declaration DeclStmt's into multiple single-declaration 3469DeclStmt's. 3470Example: Given non-global declarations 3471 int a, b = 0; 3472 int c; 3473 int d = 2, e; 3474declStmt(containsDeclaration( 3475 0, varDecl(hasInitializer(anything())))) 3476 matches only 'int d = 2, e;', and 3477declStmt(containsDeclaration(1, varDecl())) 3478 matches 'int a, b = 0' as well as 'int d = 2, e;' 3479 but 'int c;' is not matched. 3480</pre></td></tr> 3481 3482 3483<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> 3484<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 3485 3486Given 3487 int a, b; 3488 int c; 3489declStmt(hasSingleDecl(anything())) 3490 matches 'int c;' but not 'int a, b;'. 3491</pre></td></tr> 3492 3493 3494<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> 3495<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches 3496the inner matcher. 3497 3498Given 3499 int x; 3500declaratorDecl(hasTypeLoc(loc(asString("int")))) 3501 matches int x 3502</pre></td></tr> 3503 3504 3505<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> 3506<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a 3507Decl, matches InnerMatcher. 3508 3509Given 3510 namespace N { 3511 namespace M { 3512 class D {}; 3513 } 3514 } 3515 3516recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the 3517declaration of class D. 3518</pre></td></tr> 3519 3520 3521<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> 3522<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has 3523a given body. 3524 3525Given 3526 for (;;) {} 3527hasBody(compoundStmt()) 3528 matches 'for (;;) {}' 3529with compoundStmt() 3530 matching '{}' 3531</pre></td></tr> 3532 3533 3534<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> 3535<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 3536or conditional operator. 3537 3538Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3539 if (true) {} 3540</pre></td></tr> 3541 3542 3543<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> 3544<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, 3545matches InnerMatcher if the qualifier exists. 3546 3547Given 3548 namespace N { 3549 namespace M { 3550 class D {}; 3551 } 3552 } 3553 N::M::D d; 3554 3555elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) 3556matches the type of the variable declaration of d. 3557</pre></td></tr> 3558 3559 3560<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> 3561<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. 3562 3563Given 3564 namespace N { 3565 namespace M { 3566 class D {}; 3567 } 3568 } 3569 N::M::D d; 3570 3571elaboratedType(namesType(recordType( 3572hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable 3573declaration of d. 3574</pre></td></tr> 3575 3576 3577<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>></td><td class="name" onclick="toggle('hasDeclaration10')"><a name="hasDeclaration10Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3578<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node 3579matches the given matcher. 3580 3581The associated declaration is: 3582- for type nodes, the declaration of the underlying type 3583- for CallExpr, the declaration of the callee 3584- for MemberExpr, the declaration of the referenced member 3585- for CXXConstructExpr, the declaration of the constructor 3586 3587Also usable as Matcher<T> for any T supporting the getDecl() member 3588function. e.g. various subtypes of clang::Type and various expressions. 3589 3590Usable 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>>, 3591 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>>, 3592 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3593 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>>, 3594 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>>, 3595 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>> 3596</pre></td></tr> 3597 3598 3599<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> 3600<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 3601 3602(Note: Clang's AST refers to other conversions as "casts" too, and calls 3603actual casts "explicit" casts.) 3604</pre></td></tr> 3605 3606 3607<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3608<tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value 3609declaration's type. 3610 3611In case of a value declaration (for example a variable declaration), 3612this resolves one layer of indirection. For example, in the value 3613declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, 3614while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration 3615of x." 3616 3617Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 3618 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 3619 class X {}; 3620 void y(X &x) { x; X z; } 3621 3622Usable 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>> 3623</pre></td></tr> 3624 3625 3626<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> 3627<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type 3628matcher. 3629 3630Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 3631 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 3632 class X {}; 3633 void y(X &x) { x; X z; } 3634</pre></td></tr> 3635 3636 3637<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> 3638<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 3639are stripped off. 3640 3641Parentheses and explicit casts are not discarded. 3642Given 3643 int arr[5]; 3644 int a = 0; 3645 char b = 0; 3646 const int c = a; 3647 int *d = arr; 3648 long e = (long) 0l; 3649The matchers 3650 varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 3651 varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 3652would match the declarations for a, b, c, and d, but not e. 3653While 3654 varDecl(hasInitializer(integerLiteral())) 3655 varDecl(hasInitializer(declRefExpr())) 3656only match the declarations for b, c, and d. 3657</pre></td></tr> 3658 3659 3660<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> 3661<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 3662casts are stripped off. 3663 3664Implicit and non-C Style casts are also discarded. 3665Given 3666 int a = 0; 3667 char b = (0); 3668 void* c = reinterpret_cast<char*>(0); 3669 char d = char(0); 3670The matcher 3671 varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 3672would match the declarations for a, b, c, and d. 3673while 3674 varDecl(hasInitializer(integerLiteral())) 3675only match the declaration for a. 3676</pre></td></tr> 3677 3678 3679<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> 3680<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 3681parentheses are stripped off. 3682 3683Explicit casts are not discarded. 3684Given 3685 int arr[5]; 3686 int a = 0; 3687 char b = (0); 3688 const int c = a; 3689 int *d = (arr); 3690 long e = ((long) 0l); 3691The matchers 3692 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 3693 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 3694would match the declarations for a, b, c, and d, but not e. 3695while 3696 varDecl(hasInitializer(integerLiteral())) 3697 varDecl(hasInitializer(declRefExpr())) 3698would only match the declaration for a. 3699</pre></td></tr> 3700 3701 3702<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> 3703<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has 3704a given body. 3705 3706Given 3707 for (;;) {} 3708hasBody(compoundStmt()) 3709 matches 'for (;;) {}' 3710with compoundStmt() 3711 matching '{}' 3712</pre></td></tr> 3713 3714 3715<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> 3716<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 3717or conditional operator. 3718 3719Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3720 if (true) {} 3721</pre></td></tr> 3722 3723 3724<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> 3725<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 3726 3727Example: 3728 forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 3729matches '++x' in 3730 for (x; x < N; ++x) { } 3731</pre></td></tr> 3732 3733 3734<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> 3735<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 3736 3737Example: 3738 forStmt(hasLoopInit(declStmt())) 3739matches 'int x = 0' in 3740 for (int x = 0; x < N; ++x) { } 3741</pre></td></tr> 3742 3743 3744<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> 3745<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. 3746 3747Does not match the 'this' parameter of a method. 3748 3749Given 3750 class X { void f(int x, int y, int z) {} }; 3751methodDecl(hasAnyParameter(hasName("y"))) 3752 matches f(int x, int y, int z) {} 3753with hasAnyParameter(...) 3754 matching int y 3755</pre></td></tr> 3756 3757 3758<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> 3759<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. 3760 3761Given 3762 class X { void f(int x) {} }; 3763methodDecl(hasParameter(0, hasType(varDecl()))) 3764 matches f(int x) {} 3765with hasParameter(...) 3766 matching int x 3767</pre></td></tr> 3768 3769 3770<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> 3771<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 3772 3773Given: 3774 class X { int f() { return 1; } }; 3775methodDecl(returns(asString("int"))) 3776 matches int f() { return 1; } 3777</pre></td></tr> 3778 3779 3780<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> 3781<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 3782or conditional operator. 3783 3784Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3785 if (true) {} 3786</pre></td></tr> 3787 3788 3789<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> 3790<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 3791 3792Given 3793 if (A* a = GetAPointer()) {} 3794hasConditionVariableStatement(...) 3795 matches 'A* a = GetAPointer()'. 3796</pre></td></tr> 3797 3798 3799<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> 3800<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. 3801 3802Examples matches the if statement 3803 (matcher = ifStmt(hasElse(boolLiteral(equals(true))))) 3804 if (false) false; else true; 3805</pre></td></tr> 3806 3807 3808<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> 3809<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. 3810 3811Examples matches the if statement 3812 (matcher = ifStmt(hasThen(boolLiteral(equals(true))))) 3813 if (false) true; else false; 3814</pre></td></tr> 3815 3816 3817<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> 3818<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 3819matcher. 3820 3821FIXME: Unit test this matcher 3822</pre></td></tr> 3823 3824 3825<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>></td><td class="name" onclick="toggle('hasDeclaration9')"><a name="hasDeclaration9Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3826<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node 3827matches the given matcher. 3828 3829The associated declaration is: 3830- for type nodes, the declaration of the underlying type 3831- for CallExpr, the declaration of the callee 3832- for MemberExpr, the declaration of the referenced member 3833- for CXXConstructExpr, the declaration of the constructor 3834 3835Also usable as Matcher<T> for any T supporting the getDecl() member 3836function. e.g. various subtypes of clang::Type and various expressions. 3837 3838Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, 3839 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>>, 3840 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3841 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>>, 3842 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>>, 3843 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>> 3844</pre></td></tr> 3845 3846 3847<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>></td><td class="name" onclick="toggle('hasDeclaration8')"><a name="hasDeclaration8Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3848<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node 3849matches the given matcher. 3850 3851The associated declaration is: 3852- for type nodes, the declaration of the underlying type 3853- for CallExpr, the declaration of the callee 3854- for MemberExpr, the declaration of the referenced member 3855- for CXXConstructExpr, the declaration of the constructor 3856 3857Also usable as Matcher<T> for any T supporting the getDecl() member 3858function. e.g. various subtypes of clang::Type and various expressions. 3859 3860Usable 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>>, 3861 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>>, 3862 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3863 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>>, 3864 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>>, 3865 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>> 3866</pre></td></tr> 3867 3868 3869<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> 3870<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node 3871matches the given matcher. 3872 3873The associated declaration is: 3874- for type nodes, the declaration of the underlying type 3875- for CallExpr, the declaration of the callee 3876- for MemberExpr, the declaration of the referenced member 3877- for CXXConstructExpr, the declaration of the constructor 3878 3879Also usable as Matcher<T> for any T supporting the getDecl() member 3880function. e.g. various subtypes of clang::Type and various expressions. 3881 3882Usable 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>>, 3883 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>>, 3884 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3885 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>>, 3886 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>>, 3887 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>> 3888</pre></td></tr> 3889 3890 3891<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> 3892<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is 3893matched by a given matcher. 3894 3895Given 3896 struct X { int m; }; 3897 void f(X x) { x.m; m; } 3898memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X"))))))) 3899 matches "x.m" and "m" 3900with hasObjectExpression(...) 3901 matching "x" and the implicit object expression of "m" which has type X*. 3902</pre></td></tr> 3903 3904 3905<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> 3906<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 3907given matcher. 3908 3909Given 3910 struct { int first, second; } first, second; 3911 int i(second.first); 3912 int j(first.second); 3913memberExpr(member(hasName("first"))) 3914 matches second.first 3915 but not first.second (because the member name there is "second"). 3916</pre></td></tr> 3917 3918 3919<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> 3920<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the 3921pointee matches a given matcher. 3922 3923Given 3924 int *a; 3925 int const *b; 3926 float const *f; 3927pointerType(pointee(isConstQualified(), isInteger())) 3928 matches "int const *b" 3929 3930Usable 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>>, 3931 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>> 3932</pre></td></tr> 3933 3934 3935<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> 3936<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the 3937pointee matches a given matcher. 3938 3939Given 3940 int *a; 3941 int const *b; 3942 float const *f; 3943pointerType(pointee(isConstQualified(), isInteger())) 3944 matches "int const *b" 3945 3946Usable 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>>, 3947 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>> 3948</pre></td></tr> 3949 3950 3951<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> 3952<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 3953 3954Given 3955 struct A { struct B { struct C {}; }; }; 3956 A::B::C c; 3957nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 3958 matches "A::" 3959</pre></td></tr> 3960 3961 3962<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> 3963<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 3964given TypeLoc. 3965 3966Given 3967 struct A { struct B { struct C {}; }; }; 3968 A::B::C c; 3969nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 3970 hasDeclaration(recordDecl(hasName("A"))))))) 3971 matches "A::" 3972</pre></td></tr> 3973 3974 3975<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> 3976<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 3977 3978Given 3979 struct A { struct B { struct C {}; }; }; 3980 A::B::C c; 3981nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 3982 matches "A::" 3983</pre></td></tr> 3984 3985 3986<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> 3987<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 3988given namespace matcher. 3989 3990Given 3991 namespace ns { struct A {}; } 3992 ns::A a; 3993nestedNameSpecifier(specifiesNamespace(hasName("ns"))) 3994 matches "ns::" 3995</pre></td></tr> 3996 3997 3998<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> 3999<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 4000given QualType matcher without qualifiers. 4001 4002Given 4003 struct A { struct B { struct C {}; }; }; 4004 A::B::C c; 4005nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A"))))) 4006 matches "A::" 4007</pre></td></tr> 4008 4009 4010<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> 4011<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor 4012call expression. 4013 4014Example matches y in x(y) 4015 (matcher = callExpr(hasArgument(0, declRefExpr()))) 4016 void x(int) { int y; x(y); } 4017</pre></td></tr> 4018 4019 4020<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> 4021<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. 4022 4023Example 4024matcher = objCMessageExpr(hasRecieverType(asString("UIWebView *"))); 4025matches the [webView ...] message invocation. 4026 NSString *webViewJavaScript = ... 4027 UIWebView *webView = ... 4028 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; 4029</pre></td></tr> 4030 4031 4032<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> 4033<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. 4034 4035Given 4036 int (*ptr_to_array)[4]; 4037 int (*ptr_to_func)(int); 4038 4039varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches 4040ptr_to_func but not ptr_to_array. 4041 4042Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> 4043</pre></td></tr> 4044 4045 4046<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> 4047<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the 4048pointee matches a given matcher. 4049 4050Given 4051 int *a; 4052 int const *b; 4053 float const *f; 4054pointerType(pointee(isConstQualified(), isInteger())) 4055 matches "int const *b" 4056 4057Usable 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>>, 4058 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>> 4059</pre></td></tr> 4060 4061 4062<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> 4063<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the 4064pointee matches a given matcher. 4065 4066Given 4067 int *a; 4068 int const *b; 4069 float const *f; 4070pointerType(pointee(isConstQualified(), isInteger())) 4071 matches "int const *b" 4072 4073Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 4074 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 4075</pre></td></tr> 4076 4077 4078<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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> 4079<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. 4080 4081Given: 4082 typedef int &int_ref; 4083 int a; 4084 int_ref b = a; 4085 4086varDecl(hasType(qualType(referenceType()))))) will not match the 4087declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. 4088</pre></td></tr> 4089 4090 4091<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> 4092<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node 4093matches the given matcher. 4094 4095The associated declaration is: 4096- for type nodes, the declaration of the underlying type 4097- for CallExpr, the declaration of the callee 4098- for MemberExpr, the declaration of the referenced member 4099- for CXXConstructExpr, the declaration of the constructor 4100 4101Also usable as Matcher<T> for any T supporting the getDecl() member 4102function. e.g. various subtypes of clang::Type and various expressions. 4103 4104Usable 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>>, 4105 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>>, 4106 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4107 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>>, 4108 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>>, 4109 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>> 4110</pre></td></tr> 4111 4112 4113<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> 4114<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 4115</pre></td></tr> 4116 4117 4118<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> 4119<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type 4120matches the specified matcher. 4121 4122Example matches y->x() 4123 (matcher = memberCallExpr(on(hasType(pointsTo 4124 recordDecl(hasName("Y"))))))) 4125 class Y { public: void x(); }; 4126 void z() { Y *y; y->x(); } 4127</pre></td></tr> 4128 4129 4130<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> 4131<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 4132</pre></td></tr> 4133 4134 4135<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> 4136<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced 4137type matches the specified matcher. 4138 4139Example matches X &x and const X &y 4140 (matcher = varDecl(hasType(references(recordDecl(hasName("X")))))) 4141 class X { 4142 void a(X b) { 4143 X &x = b; 4144 const X &y = b; 4145 } 4146 }; 4147</pre></td></tr> 4148 4149 4150<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> 4151<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node 4152matches the given matcher. 4153 4154The associated declaration is: 4155- for type nodes, the declaration of the underlying type 4156- for CallExpr, the declaration of the callee 4157- for MemberExpr, the declaration of the referenced member 4158- for CXXConstructExpr, the declaration of the constructor 4159 4160Also usable as Matcher<T> for any T supporting the getDecl() member 4161function. e.g. various subtypes of clang::Type and various expressions. 4162 4163Usable 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>>, 4164 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>>, 4165 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4166 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>>, 4167 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>>, 4168 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>> 4169</pre></td></tr> 4170 4171 4172<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> 4173<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the 4174pointee matches a given matcher. 4175 4176Given 4177 int *a; 4178 int const *b; 4179 float const *f; 4180pointerType(pointee(isConstQualified(), isInteger())) 4181 matches "int const *b" 4182 4183Usable 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>>, 4184 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>> 4185</pre></td></tr> 4186 4187 4188<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> 4189<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the 4190pointee matches a given matcher. 4191 4192Given 4193 int *a; 4194 int const *b; 4195 float const *f; 4196pointerType(pointee(isConstQualified(), isInteger())) 4197 matches "int const *b" 4198 4199Usable 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>>, 4200 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>> 4201</pre></td></tr> 4202 4203 4204<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> 4205<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 4206alignof. 4207</pre></td></tr> 4208 4209 4210<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> 4211<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 4212sizeof. 4213</pre></td></tr> 4214 4215 4216<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> 4217<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch 4218statement. This matcher may produce multiple matches. 4219 4220Given 4221 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } 4222switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") 4223 matches four times, with "c" binding each of "case 1:", "case 2:", 4224"case 3:" and "case 4:", and "s" respectively binding "switch (1)", 4225"switch (1)", "switch (2)" and "switch (2)". 4226</pre></td></tr> 4227 4228 4229<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> 4230<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node 4231matches the given matcher. 4232 4233The associated declaration is: 4234- for type nodes, the declaration of the underlying type 4235- for CallExpr, the declaration of the callee 4236- for MemberExpr, the declaration of the referenced member 4237- for CXXConstructExpr, the declaration of the constructor 4238 4239Also usable as Matcher<T> for any T supporting the getDecl() member 4240function. e.g. various subtypes of clang::Type and various expressions. 4241 4242Usable 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>>, 4243 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>>, 4244 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4245 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>>, 4246 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>>, 4247 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>> 4248</pre></td></tr> 4249 4250 4251<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> 4252<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. 4253 4254Given 4255 template<typename T> struct A {}; 4256 struct B { B* next; }; 4257 A<&B::next> a; 4258templateSpecializationType(hasAnyTemplateArgument( 4259 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) 4260 matches the specialization A<&B::next> with fieldDecl(...) matching 4261 B::next 4262</pre></td></tr> 4263 4264 4265<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> 4266<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain 4267declaration. 4268 4269Given 4270 template<typename T> struct A {}; 4271 struct B { B* next; }; 4272 A<&B::next> a; 4273classTemplateSpecializationDecl(hasAnyTemplateArgument( 4274 refersToDeclaration(fieldDecl(hasName("next")))) 4275 matches the specialization A<&B::next> with fieldDecl(...) matching 4276 B::next 4277</pre></td></tr> 4278 4279 4280<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> 4281<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type. 4282 4283Given 4284 template<int T> struct A {}; 4285 C<42> c; 4286classTemplateSpecializationDecl( 4287 hasAnyTemplateArgument(refersToIntegralType(asString("int")))) 4288 matches the implicit instantiation of C in C<42>. 4289</pre></td></tr> 4290 4291 4292<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> 4293<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 4294 4295Given 4296 struct X {}; 4297 template<typename T> struct A {}; 4298 A<X> a; 4299classTemplateSpecializationDecl(hasAnyTemplateArgument( 4300 refersToType(class(hasName("X"))))) 4301 matches the specialization A<X> 4302</pre></td></tr> 4303 4304 4305<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> 4306<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations that have at least one 4307TemplateArgument matching the given InnerMatcher. 4308 4309Given 4310 template<typename T> class A {}; 4311 template<> class A<double> {}; 4312 A<int> a; 4313classTemplateSpecializationDecl(hasAnyTemplateArgument( 4314 refersToType(asString("int")))) 4315 matches the specialization A<int> 4316</pre></td></tr> 4317 4318 4319<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> 4320<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node 4321matches the given matcher. 4322 4323The associated declaration is: 4324- for type nodes, the declaration of the underlying type 4325- for CallExpr, the declaration of the callee 4326- for MemberExpr, the declaration of the referenced member 4327- for CXXConstructExpr, the declaration of the constructor 4328 4329Also usable as Matcher<T> for any T supporting the getDecl() member 4330function. e.g. various subtypes of clang::Type and various expressions. 4331 4332Usable 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>>, 4333 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>>, 4334 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4335 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>>, 4336 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>>, 4337 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>> 4338</pre></td></tr> 4339 4340 4341<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> 4342<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument 4343matches the given InnerMatcher. 4344 4345Given 4346 template<typename T, typename U> class A {}; 4347 A<bool, int> b; 4348 A<int, bool> c; 4349classTemplateSpecializationDecl(hasTemplateArgument( 4350 1, refersToType(asString("int")))) 4351 matches the specialization A<bool, int> 4352</pre></td></tr> 4353 4354 4355<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> 4356<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node 4357matches the given matcher. 4358 4359The associated declaration is: 4360- for type nodes, the declaration of the underlying type 4361- for CallExpr, the declaration of the callee 4362- for MemberExpr, the declaration of the referenced member 4363- for CXXConstructExpr, the declaration of the constructor 4364 4365Also usable as Matcher<T> for any T supporting the getDecl() member 4366function. e.g. various subtypes of clang::Type and various expressions. 4367 4368Usable 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>>, 4369 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>>, 4370 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4371 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>>, 4372 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>>, 4373 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>> 4374</pre></td></tr> 4375 4376 4377<tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<T> Matcher</td></tr> 4378<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. 4379 4380Generates results for each match. 4381 4382For example, in: 4383 class A { class B {}; class C {}; }; 4384The matcher: 4385 recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m"))) 4386will generate results for A, B and C. 4387 4388Usable as: Any Matcher 4389</pre></td></tr> 4390 4391 4392<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> 4393<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node 4394matches the given matcher. 4395 4396The associated declaration is: 4397- for type nodes, the declaration of the underlying type 4398- for CallExpr, the declaration of the callee 4399- for MemberExpr, the declaration of the referenced member 4400- for CXXConstructExpr, the declaration of the constructor 4401 4402Also usable as Matcher<T> for any T supporting the getDecl() member 4403function. e.g. various subtypes of clang::Type and various expressions. 4404 4405Usable 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>>, 4406 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>>, 4407 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4408 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>>, 4409 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>>, 4410 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>> 4411</pre></td></tr> 4412 4413 4414<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> 4415<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 4416 4417Given 4418 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 4419unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 4420 matches sizeof(a) and alignof(c) 4421</pre></td></tr> 4422 4423 4424<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> 4425<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 4426 4427Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true)))) 4428 !true 4429</pre></td></tr> 4430 4431 4432<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> 4433<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node 4434matches the given matcher. 4435 4436The associated declaration is: 4437- for type nodes, the declaration of the underlying type 4438- for CallExpr, the declaration of the callee 4439- for MemberExpr, the declaration of the referenced member 4440- for CXXConstructExpr, the declaration of the constructor 4441 4442Also usable as Matcher<T> for any T supporting the getDecl() member 4443function. e.g. various subtypes of clang::Type and various expressions. 4444 4445Usable 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>>, 4446 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>>, 4447 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4448 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>>, 4449 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>>, 4450 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>> 4451</pre></td></tr> 4452 4453 4454<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> 4455<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 4456 4457Given 4458 namespace X { void b(); } 4459 using X::b; 4460usingDecl(hasAnyUsingShadowDecl(hasName("b")))) 4461 matches using X::b </pre></td></tr> 4462 4463 4464<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> 4465<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 4466matched by the given matcher. 4467 4468Given 4469 namespace X { int a; void b(); } 4470 using X::a; 4471 using X::b; 4472usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 4473 matches using X::b but not using X::a </pre></td></tr> 4474 4475 4476<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</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> 4477<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value 4478declaration's type. 4479 4480In case of a value declaration (for example a variable declaration), 4481this resolves one layer of indirection. For example, in the value 4482declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, 4483while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration 4484of x." 4485 4486Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 4487 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 4488 class X {}; 4489 void y(X &x) { x; X z; } 4490 4491Usable 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>> 4492</pre></td></tr> 4493 4494 4495<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</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> 4496<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type 4497matcher. 4498 4499Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 4500 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 4501 class X {}; 4502 void y(X &x) { x; X z; } 4503</pre></td></tr> 4504 4505 4506<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> 4507<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 4508that matches the given matcher. 4509 4510Example matches x (matcher = varDecl(hasInitializer(callExpr()))) 4511 bool y() { return true; } 4512 bool x = y(); 4513</pre></td></tr> 4514 4515 4516<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> 4517<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 4518expression. 4519 4520Given 4521 void f(int b) { 4522 int a[b]; 4523 } 4524variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 4525 varDecl(hasName("b"))))))) 4526 matches "int a[b]" 4527</pre></td></tr> 4528 4529 4530<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> 4531<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has 4532a 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_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> 4544<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 4545or conditional operator. 4546 4547Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 4548 if (true) {} 4549</pre></td></tr> 4550 4551 4552<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> 4553<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner 4554NestedNameSpecifier-matcher matches. 4555</pre></td></tr> 4556 4557 4558<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> 4559<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner 4560QualType-matcher matches. 4561</pre></td></tr> 4562 4563<!--END_TRAVERSAL_MATCHERS --> 4564</table> 4565 4566</div> 4567</body> 4568</html> 4569 4570 4571