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