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