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 790hasDestinationType 791reinterpretCast 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 901hasDestinationType. 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('returnStmt0')"><a name="returnStmt0Anchor">returnStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>>...</td></tr> 1066<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. 1067 1068Given 1069 return 1; 1070returnStmt() 1071 matches 'return 1' 1072</pre></td></tr> 1073 1074 1075<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> 1076<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. 1077 1078Given 1079 { ++a; } 1080stmt() 1081 matches both the compound statement '{ ++a; }' and '++a'. 1082</pre></td></tr> 1083 1084 1085<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('stringLiteral0')"><a name="stringLiteral0Anchor">stringLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>>...</td></tr> 1086<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). 1087 1088Example matches "abcd", L"abcd" 1089 char *s = "abcd"; wchar_t *ws = L"abcd" 1090</pre></td></tr> 1091 1092 1093<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> 1094<tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. 1095 1096Given 1097 template <int N> 1098 struct A { static const int n = N; }; 1099 struct B : public A<42> {}; 1100substNonTypeTemplateParmExpr() 1101 matches "N" in the right-hand side of "static const int n = N;" 1102</pre></td></tr> 1103 1104 1105<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('switchCase0')"><a name="switchCase0Anchor">switchCase</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>>...</td></tr> 1106<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. 1107 1108Given 1109 switch(a) { case 42: break; default: break; } 1110switchCase() 1111 matches 'case 42: break;' and 'default: break;'. 1112</pre></td></tr> 1113 1114 1115<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('switchStmt0')"><a name="switchStmt0Anchor">switchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>>...</td></tr> 1116<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. 1117 1118Given 1119 switch(a) { case 42: break; default: break; } 1120switchStmt() 1121 matches 'switch(a)'. 1122</pre></td></tr> 1123 1124 1125<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> 1126<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) 1127 1128Given 1129 Foo x = bar; 1130 int y = sizeof(x) + alignof(x); 1131unaryExprOrTypeTraitExpr() 1132 matches sizeof(x) and alignof(x) 1133</pre></td></tr> 1134 1135 1136<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> 1137<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. 1138 1139Example matches !a 1140 !a || b 1141</pre></td></tr> 1142 1143 1144<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> 1145<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. 1146 1147Example match: "foo"_suffix 1148</pre></td></tr> 1149 1150 1151<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> 1152<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. 1153 1154Given 1155 while (true) {} 1156whileStmt() 1157 matches 'while (true) {}'. 1158</pre></td></tr> 1159 1160 1161<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> 1162<tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. 1163 1164Given 1165 template <typename T> struct C {}; 1166 C<int> c; 1167templateArgument() 1168 matches 'int' in C<int>. 1169</pre></td></tr> 1170 1171 1172<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> 1173<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. 1174</pre></td></tr> 1175 1176 1177<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('arrayType0')"><a name="arrayType0Anchor">arrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>...</td></tr> 1178<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. 1179 1180Given 1181 int a[] = { 2, 3 }; 1182 int b[4]; 1183 void f() { int c[a[0]]; } 1184arrayType() 1185 matches "int a[]", "int b[4]" and "int c[a[0]]"; 1186</pre></td></tr> 1187 1188 1189<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> 1190<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. 1191 1192Given 1193 _Atomic(int) i; 1194atomicType() 1195 matches "_Atomic(int) i" 1196</pre></td></tr> 1197 1198 1199<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('autoType0')"><a name="autoType0Anchor">autoType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>>...</td></tr> 1200<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. 1201 1202Given: 1203 auto n = 4; 1204 int v[] = { 2, 3 } 1205 for (auto i : v) { } 1206autoType() 1207 matches "auto n" and "auto i" 1208</pre></td></tr> 1209 1210 1211<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> 1212<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as 1213"void (^)(int)". 1214 1215The pointee is always required to be a FunctionType. 1216</pre></td></tr> 1217 1218 1219<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> 1220<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. 1221 1222Given 1223 struct A {}; 1224 A a; 1225 int b; 1226 float c; 1227 bool d; 1228builtinType() 1229 matches "int b", "float c" and "bool d" 1230</pre></td></tr> 1231 1232 1233<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> 1234<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. 1235 1236Given 1237 _Complex float f; 1238complexType() 1239 matches "_Complex float f" 1240</pre></td></tr> 1241 1242 1243<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> 1244<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. 1245 1246Given 1247 void() { 1248 int a[2]; 1249 int b[] = { 2, 3 }; 1250 int c[b[0]]; 1251 } 1252constantArrayType() 1253 matches "int a[2]" 1254</pre></td></tr> 1255 1256 1257<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('decayedType0')"><a name="decayedType0Anchor">decayedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>>...</td></tr> 1258<tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type 1259Example matches i[] in declaration of f. 1260 (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) 1261Example matches i[1]. 1262 (matcher = expr(hasType(decayedType(hasDecayedType(pointerType()))))) 1263 void f(int i[]) { 1264 i[1] = 0; 1265 } 1266</pre></td></tr> 1267 1268 1269<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> 1270<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. 1271 1272Given 1273 template<typename T, int Size> 1274 class array { 1275 T data[Size]; 1276 }; 1277dependentSizedArrayType 1278 matches "T data[Size]" 1279</pre></td></tr> 1280 1281 1282<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> 1283<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a 1284qualified name. 1285 1286Given 1287 namespace N { 1288 namespace M { 1289 class D {}; 1290 } 1291 } 1292 class C {}; 1293 1294 class C c; 1295 N::M::D d; 1296 1297elaboratedType() matches the type of the variable declarations of both 1298c and d. 1299</pre></td></tr> 1300 1301 1302<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> 1303<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. 1304 1305Given 1306 int (*f)(int); 1307 void g(); 1308functionType() 1309 matches "int (*f)(int)" and the type of "g". 1310</pre></td></tr> 1311 1312 1313<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> 1314<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. 1315 1316Given 1317 int a[] = { 2, 3 }; 1318 int b[42]; 1319 void f(int c[]) { int d[a[0]]; }; 1320incompleteArrayType() 1321 matches "int a[]" and "int c[]" 1322</pre></td></tr> 1323 1324 1325<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('injectedClassNameType0')"><a name="injectedClassNameType0Anchor">injectedClassNameType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>...</td></tr> 1326<tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types. 1327 1328Example matches S s, but not S<T> s. 1329 (matcher = parmVarDecl(hasType(injectedClassNameType()))) 1330 template <typename T> struct S { 1331 void f(S s); 1332 void g(S<T> s); 1333 }; 1334</pre></td></tr> 1335 1336 1337<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> 1338<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. 1339 1340Given: 1341 int *a; 1342 int &b = *a; 1343 int &&c = 1; 1344 auto &d = b; 1345 auto &&e = c; 1346 auto &&f = 2; 1347 int g = 5; 1348 1349lValueReferenceType() matches the types of b, d, and e. e is 1350matched since the type is deduced as int& by reference collapsing rules. 1351</pre></td></tr> 1352 1353 1354<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> 1355<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. 1356Given 1357 struct A { int i; } 1358 A::* ptr = A::i; 1359memberPointerType() 1360 matches "A::* ptr" 1361</pre></td></tr> 1362 1363 1364<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> 1365<tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from 1366a pointer type, despite being syntactically similar. 1367 1368Given 1369 int *a; 1370 1371 @interface Foo 1372 @end 1373 Foo *f; 1374pointerType() 1375 matches "Foo *f", but does not match "int *a". 1376</pre></td></tr> 1377 1378 1379<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> 1380<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. 1381 1382Given 1383 int (*ptr_to_array)[4]; 1384 int *array_of_ptrs[4]; 1385 1386varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not 1387array_of_ptrs. 1388</pre></td></tr> 1389 1390 1391<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> 1392<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer 1393types. 1394 1395Given 1396 int *a; 1397 int &b = *a; 1398 int c = 5; 1399 1400 @interface Foo 1401 @end 1402 Foo *f; 1403pointerType() 1404 matches "int *a", but does not match "Foo *f". 1405</pre></td></tr> 1406 1407 1408<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('rValueReferenceType0')"><a name="rValueReferenceType0Anchor">rValueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType</a>>...</td></tr> 1409<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. 1410 1411Given: 1412 int *a; 1413 int &b = *a; 1414 int &&c = 1; 1415 auto &d = b; 1416 auto &&e = c; 1417 auto &&f = 2; 1418 int g = 5; 1419 1420rValueReferenceType() matches the types of c and f. e is not 1421matched as it is deduced to int& by reference collapsing rules. 1422</pre></td></tr> 1423 1424 1425<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> 1426<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). 1427 1428Given 1429 class C {}; 1430 struct S {}; 1431 1432 C c; 1433 S s; 1434 1435recordType() matches the type of the variable declarations of both c 1436and s. 1437</pre></td></tr> 1438 1439 1440<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> 1441<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. 1442 1443Given 1444 int *a; 1445 int &b = *a; 1446 int &&c = 1; 1447 auto &d = b; 1448 auto &&e = c; 1449 auto &&f = 2; 1450 int g = 5; 1451 1452referenceType() matches the types of b, c, d, e, and f. 1453</pre></td></tr> 1454 1455 1456<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> 1457<tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a 1458template type parameter. 1459 1460Given 1461 template <typename T> 1462 void F(T t) { 1463 int i = 1 + t; 1464 } 1465 1466substTemplateTypeParmType() matches the type of 't' but not '1' 1467</pre></td></tr> 1468 1469 1470<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> 1471<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. 1472 1473Given 1474 template <typename T> 1475 class C { }; 1476 1477 template class C<int>; A 1478 C<char> var; B 1479 1480templateSpecializationType() matches the type of the explicit 1481instantiation in A and the type of the variable declaration in B. 1482</pre></td></tr> 1483 1484 1485<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> 1486<tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types. 1487 1488Example matches T, but not int. 1489 (matcher = templateTypeParmType()) 1490 template <typename T> void f(int i); 1491</pre></td></tr> 1492 1493 1494<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> 1495<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. 1496</pre></td></tr> 1497 1498 1499<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> 1500<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. 1501 1502Given 1503 typedef int X; 1504typedefType() 1505 matches "typedef int X" 1506</pre></td></tr> 1507 1508 1509<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> 1510<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. 1511 1512Given: 1513 typedef __underlying_type(T) type; 1514unaryTransformType() 1515 matches "__underlying_type(T)" 1516</pre></td></tr> 1517 1518 1519<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> 1520<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an 1521integer-constant-expression. 1522 1523Given 1524 void f() { 1525 int a[] = { 2, 3 } 1526 int b[42]; 1527 int c[a[0]]; 1528 } 1529variableArrayType() 1530 matches "int c[a[0]]" 1531</pre></td></tr> 1532 1533<!--END_DECL_MATCHERS --> 1534</table> 1535 1536<!-- ======================================================================= --> 1537<h2 id="narrowing-matchers">Narrowing Matchers</h2> 1538<!-- ======================================================================= --> 1539 1540<p>Narrowing matchers match certain attributes on the current node, thus 1541narrowing down the set of nodes of the current type to match on.</p> 1542 1543<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) 1544which allow users to create more powerful match expressions.</p> 1545 1546<table> 1547<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 1548<!-- START_NARROWING_MATCHERS --> 1549 1550<tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 1551<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. 1552 1553Usable as: Any Matcher 1554</pre></td></tr> 1555 1556 1557<tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 1558<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. 1559 1560Usable as: Any Matcher 1561</pre></td></tr> 1562 1563 1564<tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> 1565<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. 1566 1567Useful when another matcher requires a child matcher, but there's no 1568additional constraint. This will often be used with an explicit conversion 1569to an internal::Matcher<> type such as TypeMatcher. 1570 1571Example: DeclarationMatcher(anything()) matches all declarations, e.g., 1572"int* p" and "void f()" in 1573 int* p; 1574 void f(); 1575 1576Usable as: Any Matcher 1577</pre></td></tr> 1578 1579 1580<tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> 1581<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. 1582 1583Example matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) 1584 class X {}; 1585 class Y {}; 1586 1587Usable as: Any Matcher 1588</pre></td></tr> 1589 1590 1591<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> 1592<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or 1593unary). 1594 1595Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 1596 !(a || b) 1597</pre></td></tr> 1598 1599 1600<tr><td>Matcher<CXXBoolLiteral></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr> 1601<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value. 1602 1603Example matches true (matcher = cxxBoolLiteral(equals(true))) 1604 true 1605 1606Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1607 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>> 1608</pre></td></tr> 1609 1610 1611<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> 1612<tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. 1613 1614Given 1615 try { 1616 ... 1617 } catch (int) { 1618 ... 1619 } catch (...) { 1620 ... 1621 } 1622endcode 1623cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). 1624</pre></td></tr> 1625 1626 1627<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> 1628<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has 1629a specific number of arguments (including absent default arguments). 1630 1631Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 1632 void f(int x, int y); 1633 f(0, 0); 1634</pre></td></tr> 1635 1636 1637<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> 1638<tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. 1639</pre></td></tr> 1640 1641 1642<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> 1643<tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. 1644 1645Given 1646 struct S { 1647 S(); #1 1648 S(const S &); #2 1649 S(S &&); #3 1650 }; 1651cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. 1652</pre></td></tr> 1653 1654 1655<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> 1656<tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. 1657 1658Given 1659 struct S { 1660 S(); #1 1661 S(const S &); #2 1662 S(S &&); #3 1663 }; 1664cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. 1665</pre></td></tr> 1666 1667 1668<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> 1669<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with 1670the explicit keyword. 1671 1672Given 1673 struct S { 1674 S(int); #1 1675 explicit S(double); #2 1676 operator int(); #3 1677 explicit operator bool(); #4 1678 }; 1679cxxConstructorDecl(isExplicit()) will match #2, but not #1. 1680cxxConversionDecl(isExplicit()) will match #4, but not #3. 1681</pre></td></tr> 1682 1683 1684<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> 1685<tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. 1686 1687Given 1688 struct S { 1689 S(); #1 1690 S(const S &); #2 1691 S(S &&); #3 1692 }; 1693cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. 1694</pre></td></tr> 1695 1696 1697<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> 1698<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with 1699the explicit keyword. 1700 1701Given 1702 struct S { 1703 S(int); #1 1704 explicit S(double); #2 1705 operator int(); #3 1706 explicit operator bool(); #4 1707 }; 1708cxxConstructorDecl(isExplicit()) will match #2, but not #1. 1709cxxConversionDecl(isExplicit()) will match #4, but not #3. 1710</pre></td></tr> 1711 1712 1713<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> 1714<tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as 1715opposed to a member. 1716 1717Given 1718 struct B {}; 1719 struct D : B { 1720 int I; 1721 D(int i) : I(i) {} 1722 }; 1723 struct E : B { 1724 E() : B() {} 1725 }; 1726cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) 1727 will match E(), but not match D(int). 1728</pre></td></tr> 1729 1730 1731<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> 1732<tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as 1733opposed to a base. 1734 1735Given 1736 struct B {}; 1737 struct D : B { 1738 int I; 1739 D(int i) : I(i) {} 1740 }; 1741 struct E : B { 1742 E() : B() {} 1743 }; 1744cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) 1745 will match D(int), but not match E(). 1746</pre></td></tr> 1747 1748 1749<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> 1750<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in 1751code (as opposed to implicitly added by the compiler). 1752 1753Given 1754 struct Foo { 1755 Foo() { } 1756 Foo(int) : foo_("A") { } 1757 string foo_; 1758 }; 1759cxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) 1760 will match Foo(int), but not Foo() 1761</pre></td></tr> 1762 1763 1764<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> 1765<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. 1766 1767Given 1768struct A { 1769 void foo() const; 1770 void bar(); 1771}; 1772 1773cxxMethodDecl(isConst()) matches A::foo() but not A::bar() 1774</pre></td></tr> 1775 1776 1777<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> 1778<tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. 1779 1780Given: 1781 class A final {}; 1782 1783 struct B { 1784 virtual void f(); 1785 }; 1786 1787 struct C : B { 1788 void f() final; 1789 }; 1790matches A and C::f, but not B, C, or B::f 1791</pre></td></tr> 1792 1793 1794<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> 1795<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. 1796 1797Given 1798 class A { 1799 public: 1800 virtual void x(); 1801 }; 1802 class B : public A { 1803 public: 1804 virtual void x(); 1805 }; 1806 matches B::x 1807</pre></td></tr> 1808 1809 1810<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> 1811<tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. 1812 1813Given 1814 class A { 1815 public: 1816 virtual void x() = 0; 1817 }; 1818 matches A::x 1819</pre></td></tr> 1820 1821 1822<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> 1823<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. 1824 1825Given 1826 class A { 1827 public: 1828 virtual void x(); 1829 }; 1830 matches A::x 1831</pre></td></tr> 1832 1833 1834<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> 1835<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. 1836 1837Matches overloaded operator names specified in strings without the 1838"operator" prefix: e.g. "<<". 1839 1840Given: 1841 class A { int operator*(); }; 1842 const A &operator<<(const A &a, const A &b); 1843 A a; 1844 a << a; <-- This matches 1845 1846cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the 1847specified line and 1848cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) 1849matches the declaration of A. 1850 1851Usable 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>> 1852</pre></td></tr> 1853 1854 1855<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> 1856<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). 1857</pre></td></tr> 1858 1859 1860<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> 1861<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or 1862static member variable template instantiations. 1863 1864Given 1865 template<typename T> void A(T t) { } 1866 template<> void A(int N) { } 1867functionDecl(isExplicitTemplateSpecialization()) 1868 matches the specialization A<int>(). 1869 1870Usable 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>> 1871</pre></td></tr> 1872 1873 1874<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> 1875<tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. 1876 1877Given: 1878 class A final {}; 1879 1880 struct B { 1881 virtual void f(); 1882 }; 1883 1884 struct C : B { 1885 void f() final; 1886 }; 1887matches A and C::f, but not B, C, or B::f 1888</pre></td></tr> 1889 1890 1891<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> 1892<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for 1893isSameOrDerivedFrom(hasName(...)). 1894</pre></td></tr> 1895 1896 1897<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> 1898<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static 1899member variable template instantiations. 1900 1901Given 1902 template <typename T> class X {}; class A {}; X<A> x; 1903or 1904 template <typename T> class X {}; class A {}; template class X<A>; 1905cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 1906 matches the template instantiation of X<A>. 1907 1908But given 1909 template <typename T> class X {}; class A {}; 1910 template <> class X<A> {}; X<A> x; 1911cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 1912 does not match, as X<A> is an explicit template specialization. 1913 1914Usable 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>> 1915</pre></td></tr> 1916 1917 1918<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> 1919<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has 1920a specific number of arguments (including absent default arguments). 1921 1922Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 1923 void f(int x, int y); 1924 f(0, 0); 1925</pre></td></tr> 1926 1927 1928<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> 1929<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value. 1930 1931Example matches true (matcher = cxxBoolLiteral(equals(true))) 1932 true 1933 1934Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1935 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>> 1936</pre></td></tr> 1937 1938 1939<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> 1940<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. 1941 1942Given 1943 template<typename T> struct C {}; 1944 C<int> c; 1945classTemplateSpecializationDecl(templateArgumentCountIs(1)) 1946 matches C<int>. 1947</pre></td></tr> 1948 1949 1950<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> 1951<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of 1952child statements. 1953 1954Example: Given 1955 { for (;;) {} } 1956compoundStmt(statementCountIs(0))) 1957 matches '{}' 1958 but does not match the outer compound statement. 1959</pre></td></tr> 1960 1961 1962<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> 1963<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size. 1964 1965Given 1966 int a[42]; 1967 int b[2 * 21]; 1968 int c[41], d[43]; 1969constantArrayType(hasSize(42)) 1970 matches "int a[42]" and "int b[2 * 21]" 1971</pre></td></tr> 1972 1973 1974<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> 1975<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of 1976declarations. 1977 1978Example: Given 1979 int a, b; 1980 int c; 1981 int d = 2, e; 1982declCountIs(2) 1983 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. 1984</pre></td></tr> 1985 1986 1987<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('equalsBoundNode1')"><a name="equalsBoundNode1Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr> 1988<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. 1989 1990Matches a node if it equals the node previously bound to ID. 1991 1992Given 1993 class X { int a; int b; }; 1994cxxRecordDecl( 1995 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 1996 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 1997 matches the class X, as a and b have the same type. 1998 1999Note that when multiple matches are involved via forEach* matchers, 2000equalsBoundNodes acts as a filter. 2001For example: 2002compoundStmt( 2003 forEachDescendant(varDecl().bind("d")), 2004 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2005will trigger a match for each combination of variable declaration 2006and reference to that variable declaration within a compound statement. 2007</pre></td></tr> 2008 2009 2010<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> 2011<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. 2012 2013Given 2014 __attribute__((device)) void f() { ... } 2015decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of 2016f. If the matcher is use from clang-query, attr::Kind parameter should be 2017passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). 2018</pre></td></tr> 2019 2020 2021<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> 2022<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is 2023partially matching a given regex. 2024 2025Example matches Y but not X 2026 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 2027 #include "ASTMatcher.h" 2028 class X {}; 2029ASTMatcher.h: 2030 class Y {}; 2031 2032Usable 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>> 2033</pre></td></tr> 2034 2035 2036<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> 2037<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. 2038 2039Example matches X but not Y 2040 (matcher = cxxRecordDecl(isExpansionInMainFile()) 2041 #include <Y.h> 2042 class X {}; 2043Y.h: 2044 class Y {}; 2045 2046Usable 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>> 2047</pre></td></tr> 2048 2049 2050<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> 2051<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. 2052 2053Example matches Y but not X 2054 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 2055 #include <SystemHeader.h> 2056 class X {}; 2057SystemHeader.h: 2058 class Y {}; 2059 2060Usable 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>> 2061</pre></td></tr> 2062 2063 2064<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> 2065<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added 2066by the compiler (eg. implicit defaultcopy constructors). 2067</pre></td></tr> 2068 2069 2070<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> 2071<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. 2072 2073Given 2074 class C { 2075 public: int a; 2076 protected: int b; 2077 private: int c; 2078 }; 2079fieldDecl(isPrivate()) 2080 matches 'int c;' 2081</pre></td></tr> 2082 2083 2084<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> 2085<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. 2086 2087Given 2088 class C { 2089 public: int a; 2090 protected: int b; 2091 private: int c; 2092 }; 2093fieldDecl(isProtected()) 2094 matches 'int b;' 2095</pre></td></tr> 2096 2097 2098<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> 2099<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. 2100 2101Given 2102 class C { 2103 public: int a; 2104 protected: int b; 2105 private: int c; 2106 }; 2107fieldDecl(isPublic()) 2108 matches 'int a;' 2109</pre></td></tr> 2110 2111 2112<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> 2113<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. 2114 2115Example matches true (matcher = cxxBoolLiteral(equals(true))) 2116 true 2117 2118Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 2119 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>> 2120</pre></td></tr> 2121 2122 2123<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> 2124<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. 2125 2126Matches overloaded operator names specified in strings without the 2127"operator" prefix: e.g. "<<". 2128 2129Given: 2130 class A { int operator*(); }; 2131 const A &operator<<(const A &a, const A &b); 2132 A a; 2133 a << a; <-- This matches 2134 2135cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the 2136specified line and 2137cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) 2138matches the declaration of A. 2139 2140Usable 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>> 2141</pre></td></tr> 2142 2143 2144<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> 2145<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations. 2146 2147Given: 2148 constexpr int foo = 42; 2149 constexpr int bar(); 2150varDecl(isConstexpr()) 2151 matches the declaration of foo. 2152functionDecl(isConstexpr()) 2153 matches the declaration of bar. 2154</pre></td></tr> 2155 2156 2157<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> 2158<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. 2159 2160Example matches A, va, fa 2161 class A {}; 2162 class B; Doesn't match, as it has no body. 2163 int va; 2164 extern int vb; Doesn't match, as it doesn't define the variable. 2165 void fa() {} 2166 void fb(); Doesn't match, as it has no body. 2167 2168Usable 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>> 2169</pre></td></tr> 2170 2171 2172<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> 2173<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. 2174 2175Given: 2176 void Func(); 2177 void DeletedFunc() = delete; 2178functionDecl(isDeleted()) 2179 matches the declaration of DeletedFunc, but not Func. 2180</pre></td></tr> 2181 2182 2183<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> 2184<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or 2185static member variable template instantiations. 2186 2187Given 2188 template<typename T> void A(T t) { } 2189 template<> void A(int N) { } 2190functionDecl(isExplicitTemplateSpecialization()) 2191 matches the specialization A<int>(). 2192 2193Usable 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>> 2194</pre></td></tr> 2195 2196 2197<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> 2198<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. 2199 2200Given: 2201 extern "C" void f() {} 2202 extern "C" { void g() {} } 2203 void h() {} 2204functionDecl(isExternC()) 2205 matches the declaration of f and g, but not the declaration h 2206</pre></td></tr> 2207 2208 2209<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> 2210<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with 2211the inline keyword. 2212 2213Given 2214 inline void f(); 2215 void g(); 2216 namespace n { 2217 inline namespace m {} 2218 } 2219functionDecl(isInline()) will match ::f(). 2220namespaceDecl(isInline()) will match n::m. 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('isTemplateInstantiation0')"><a name="isTemplateInstantiation0Anchor">isTemplateInstantiation</a></td><td></td></tr> 2225<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 2226member variable template instantiations. 2227 2228Given 2229 template <typename T> class X {}; class A {}; X<A> x; 2230or 2231 template <typename T> class X {}; class A {}; template class X<A>; 2232cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2233 matches the template instantiation of X<A>. 2234 2235But given 2236 template <typename T> class X {}; class A {}; 2237 template <> class X<A> {}; X<A> x; 2238cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2239 does not match, as X<A> is an explicit template specialization. 2240 2241Usable 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>> 2242</pre></td></tr> 2243 2244 2245<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> 2246<tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. 2247 2248Example matches f, but not g or h. The function i will not match, even when 2249compiled in C mode. 2250 void f(...); 2251 void g(int); 2252 template <typename... Ts> void h(Ts...); 2253 void i(); 2254</pre></td></tr> 2255 2256 2257<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> 2258<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count. 2259 2260Given 2261 void f(int i) {} 2262 void g(int i, int j) {} 2263functionDecl(parameterCountIs(2)) 2264 matches g(int i, int j) {} 2265</pre></td></tr> 2266 2267 2268<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> 2269<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. 2270 2271Example matches true (matcher = cxxBoolLiteral(equals(true))) 2272 true 2273 2274Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 2275 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>> 2276</pre></td></tr> 2277 2278 2279<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> 2280<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 2281to '.'. 2282 2283Member calls on the implicit this pointer match as called with '->'. 2284 2285Given 2286 class Y { 2287 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 2288 int a; 2289 static int b; 2290 }; 2291memberExpr(isArrow()) 2292 matches this->x, x, y.x, a, this->b 2293</pre></td></tr> 2294 2295 2296<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> 2297<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 2298 2299Supports specifying enclosing namespaces or classes by prefixing the name 2300with '<enclosing>::'. 2301Does not match typedefs of an underlying type with the given name. 2302 2303Example matches X (Name == "X") 2304 class X; 2305 2306Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 2307 namespace a { namespace b { class X; } } 2308</pre></td></tr> 2309 2310 2311<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> 2312<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain 2313a substring matched by the given RegExp. 2314 2315Supports specifying enclosing namespaces or classes by 2316prefixing the name with '<enclosing>::'. Does not match typedefs 2317of an underlying type with the given name. 2318 2319Example matches X (regexp == "::X") 2320 class X; 2321 2322Example matches X (regexp is one of "::X", "^foo::.*X", among others) 2323 namespace foo { namespace bar { class X; } } 2324</pre></td></tr> 2325 2326 2327<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> 2328<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. 2329 2330Given 2331 namespace n { 2332 namespace {} #1 2333 } 2334namespaceDecl(isAnonymous()) will match #1 but not ::n. 2335</pre></td></tr> 2336 2337 2338<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> 2339<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with 2340the inline keyword. 2341 2342Given 2343 inline void f(); 2344 void g(); 2345 namespace n { 2346 inline namespace m {} 2347 } 2348functionDecl(isInline()) will match ::f(). 2349namespaceDecl(isInline()) will match n::m. 2350</pre></td></tr> 2351 2352 2353<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> 2354<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has 2355a specific number of arguments (including absent default arguments). 2356 2357Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 2358 void f(int x, int y); 2359 f(0, 0); 2360</pre></td></tr> 2361 2362 2363<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> 2364<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector 2365 2366objCMessageExpr(hasKeywordSelector()) matches the generated setFrame 2367message expression in 2368 2369 UIWebView *webView = ...; 2370 CGRect bodyFrame = webView.frame; 2371 bodyFrame.size.height = self.bodyContentHeight; 2372 webView.frame = bodyFrame; 2373 ^---- matches here 2374</pre></td></tr> 2375 2376 2377<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> 2378<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector 2379 2380Matches only when the selector of the objCMessageExpr is NULL. This may 2381represent an error condition in the tree! 2382</pre></td></tr> 2383 2384 2385<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> 2386<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() 2387 2388 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); 2389 matches the outer message expr in the code below, but NOT the message 2390 invocation for self.bodyView. 2391 [self.bodyView loadHTMLString:html baseURL:NULL]; 2392</pre></td></tr> 2393 2394 2395<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> 2396<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector 2397 2398 matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); 2399 matches self.bodyView in the code below, but NOT the outer message 2400 invocation of "loadHTMLString:baseURL:". 2401 [self.bodyView loadHTMLString:html baseURL:NULL]; 2402</pre></td></tr> 2403 2404 2405<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> 2406<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains 2407a substring matched by the given RegExp. 2408 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message 2409 invocation for self.bodyView. 2410 [self.bodyView loadHTMLString:html baseURL:NULL]; 2411</pre></td></tr> 2412 2413 2414<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> 2415<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments 2416 2417 matcher = objCMessageExpr(numSelectorArgs(0)); 2418 matches self.bodyView in the code below 2419 2420 matcher = objCMessageExpr(numSelectorArgs(2)); 2421 matches the invocation of "loadHTMLString:baseURL:" but not that 2422 of self.bodyView 2423 [self.bodyView loadHTMLString:html baseURL:NULL]; 2424</pre></td></tr> 2425 2426 2427<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> 2428<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 2429 2430Given 2431 class Y { public: void x(); }; 2432 void z() { Y* y; y->x(); } 2433cxxMemberCallExpr(on(hasType(asString("class Y *")))) 2434 matches y->x() 2435</pre></td></tr> 2436 2437 2438<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> 2439<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. 2440 2441Matches a node if it equals the node previously bound to ID. 2442 2443Given 2444 class X { int a; int b; }; 2445cxxRecordDecl( 2446 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2447 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2448 matches the class X, as a and b have the same type. 2449 2450Note that when multiple matches are involved via forEach* matchers, 2451equalsBoundNodes acts as a filter. 2452For example: 2453compoundStmt( 2454 forEachDescendant(varDecl().bind("d")), 2455 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2456will trigger a match for each combination of variable declaration 2457and reference to that variable declaration within a compound statement. 2458</pre></td></tr> 2459 2460 2461<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> 2462<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to 2463the node, not hidden within a typedef. 2464 2465Given 2466 typedef const int const_int; 2467 const_int i; 2468 int *const j; 2469 int *volatile k; 2470 int m; 2471varDecl(hasType(hasLocalQualifiers())) matches only j and k. 2472i is const-qualified but the qualifier is not local. 2473</pre></td></tr> 2474 2475 2476<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> 2477<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 2478include "top-level" const. 2479 2480Given 2481 void a(int); 2482 void b(int const); 2483 void c(const int); 2484 void d(const int*); 2485 void e(int const) {}; 2486functionDecl(hasAnyParameter(hasType(isConstQualified()))) 2487 matches "void b(int const)", "void c(const int)" and 2488 "void e(int const) {}". It does not match d as there 2489 is no top-level const on the parameter type "const int *". 2490</pre></td></tr> 2491 2492 2493<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> 2494<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 2495 2496Given 2497 void a(int); 2498 void b(long); 2499 void c(double); 2500functionDecl(hasAnyParameter(hasType(isInteger()))) 2501matches "a(int)", "b(long)", but not "c(double)". 2502</pre></td></tr> 2503 2504 2505<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> 2506<tr><td colspan="4" class="doc" id="isClass0"><pre>Matches RecordDecl object that are spelled with "class." 2507 2508Example matches C, but not S or U. 2509 struct S {}; 2510 class C {}; 2511 union U {}; 2512</pre></td></tr> 2513 2514 2515<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> 2516<tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches RecordDecl object that are spelled with "struct." 2517 2518Example matches S, but not C or U. 2519 struct S {}; 2520 class C {}; 2521 union U {}; 2522</pre></td></tr> 2523 2524 2525<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> 2526<tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches RecordDecl object that are spelled with "union." 2527 2528Example matches U, but not C or S. 2529 struct S {}; 2530 class C {}; 2531 union U {}; 2532</pre></td></tr> 2533 2534 2535<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> 2536<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. 2537 2538Matches a node if it equals the node previously bound to ID. 2539 2540Given 2541 class X { int a; int b; }; 2542cxxRecordDecl( 2543 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2544 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2545 matches the class X, as a and b have the same type. 2546 2547Note that when multiple matches are involved via forEach* matchers, 2548equalsBoundNodes acts as a filter. 2549For example: 2550compoundStmt( 2551 forEachDescendant(varDecl().bind("d")), 2552 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2553will trigger a match for each combination of variable declaration 2554and reference to that variable declaration within a compound statement. 2555</pre></td></tr> 2556 2557 2558<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> 2559<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is 2560partially matching a given regex. 2561 2562Example matches Y but not X 2563 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 2564 #include "ASTMatcher.h" 2565 class X {}; 2566ASTMatcher.h: 2567 class Y {}; 2568 2569Usable 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>> 2570</pre></td></tr> 2571 2572 2573<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> 2574<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. 2575 2576Example matches X but not Y 2577 (matcher = cxxRecordDecl(isExpansionInMainFile()) 2578 #include <Y.h> 2579 class X {}; 2580Y.h: 2581 class Y {}; 2582 2583Usable 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>> 2584</pre></td></tr> 2585 2586 2587<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> 2588<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. 2589 2590Example matches Y but not X 2591 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 2592 #include <SystemHeader.h> 2593 class X {}; 2594SystemHeader.h: 2595 class Y {}; 2596 2597Usable 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>> 2598</pre></td></tr> 2599 2600 2601<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> 2602<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 2603 2604Example matches A, va, fa 2605 class A {}; 2606 class B; Doesn't match, as it has no body. 2607 int va; 2608 extern int vb; Doesn't match, as it doesn't define the variable. 2609 void fa() {} 2610 void fb(); Doesn't match, as it has no body. 2611 2612Usable 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>> 2613</pre></td></tr> 2614 2615 2616<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> 2617<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. 2618 2619Note that 'Value' is a string as the template argument's value is 2620an arbitrary precision integer. 'Value' must be euqal to the canonical 2621representation of that integral value in base 10. 2622 2623Given 2624 template<int T> struct A {}; 2625 C<42> c; 2626classTemplateSpecializationDecl( 2627 hasAnyTemplateArgument(equalsIntegralValue("42"))) 2628 matches the implicit instantiation of C in C<42>. 2629</pre></td></tr> 2630 2631 2632<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> 2633<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. 2634 2635Given 2636 template<int T> struct A {}; 2637 C<42> c; 2638classTemplateSpecializationDecl( 2639 hasAnyTemplateArgument(isIntegral())) 2640 matches the implicit instantiation of C in C<42> 2641 with isIntegral() matching 42. 2642</pre></td></tr> 2643 2644 2645<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> 2646<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. 2647 2648Given 2649 template<typename T> struct C {}; 2650 C<int> c; 2651classTemplateSpecializationDecl(templateArgumentCountIs(1)) 2652 matches C<int>. 2653</pre></td></tr> 2654 2655 2656<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> 2657<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is 2658partially matching a given regex. 2659 2660Example matches Y but not X 2661 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 2662 #include "ASTMatcher.h" 2663 class X {}; 2664ASTMatcher.h: 2665 class Y {}; 2666 2667Usable 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>> 2668</pre></td></tr> 2669 2670 2671<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> 2672<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. 2673 2674Example matches X but not Y 2675 (matcher = cxxRecordDecl(isExpansionInMainFile()) 2676 #include <Y.h> 2677 class X {}; 2678Y.h: 2679 class Y {}; 2680 2681Usable 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>> 2682</pre></td></tr> 2683 2684 2685<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> 2686<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. 2687 2688Example matches Y but not X 2689 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 2690 #include <SystemHeader.h> 2691 class X {}; 2692SystemHeader.h: 2693 class Y {}; 2694 2695Usable 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>> 2696</pre></td></tr> 2697 2698 2699<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> 2700<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. 2701 2702Matches a node if it equals the node previously bound to ID. 2703 2704Given 2705 class X { int a; int b; }; 2706cxxRecordDecl( 2707 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2708 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2709 matches the class X, as a and b have the same type. 2710 2711Note that when multiple matches are involved via forEach* matchers, 2712equalsBoundNodes acts as a filter. 2713For example: 2714compoundStmt( 2715 forEachDescendant(varDecl().bind("d")), 2716 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2717will trigger a match for each combination of variable declaration 2718and reference to that variable declaration within a compound statement. 2719</pre></td></tr> 2720 2721 2722<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> 2723<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. 2724 2725Given 2726 struct S { void func(); }; 2727functionDecl(returns(voidType())) 2728 matches "void func();" 2729</pre></td></tr> 2730 2731 2732<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> 2733<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 2734 2735Given 2736 int x; 2737 int s = sizeof(x) + alignof(x) 2738unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 2739 matches sizeof(x) 2740</pre></td></tr> 2741 2742 2743<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> 2744<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 2745unary). 2746 2747Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 2748 !(a || b) 2749</pre></td></tr> 2750 2751 2752<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> 2753<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. 2754 2755Example matches y and z (matcher = varDecl(hasGlobalStorage()) 2756void f() { 2757 int x; 2758 static int y; 2759} 2760int z; 2761</pre></td></tr> 2762 2763 2764<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> 2765<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a 2766non-static local variable. 2767 2768Example matches x (matcher = varDecl(hasLocalStorage()) 2769void f() { 2770 int x; 2771 static int y; 2772} 2773int z; 2774</pre></td></tr> 2775 2776 2777<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> 2778<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations. 2779 2780Given: 2781 constexpr int foo = 42; 2782 constexpr int bar(); 2783varDecl(isConstexpr()) 2784 matches the declaration of foo. 2785functionDecl(isConstexpr()) 2786 matches the declaration of bar. 2787</pre></td></tr> 2788 2789 2790<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> 2791<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 2792 2793Example matches A, va, fa 2794 class A {}; 2795 class B; Doesn't match, as it has no body. 2796 int va; 2797 extern int vb; Doesn't match, as it doesn't define the variable. 2798 void fa() {} 2799 void fb(); Doesn't match, as it has no body. 2800 2801Usable 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>> 2802</pre></td></tr> 2803 2804 2805<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> 2806<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from 2807a C++ catch block, or an Objective-C statement. 2808 2809Example matches x (matcher = varDecl(isExceptionVariable()) 2810void f(int y) { 2811 try { 2812 } catch (int x) { 2813 } 2814} 2815</pre></td></tr> 2816 2817 2818<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> 2819<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 2820static member variable template instantiations. 2821 2822Given 2823 template<typename T> void A(T t) { } 2824 template<> void A(int N) { } 2825functionDecl(isExplicitTemplateSpecialization()) 2826 matches the specialization A<int>(). 2827 2828Usable 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>> 2829</pre></td></tr> 2830 2831 2832<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> 2833<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 2834member variable template instantiations. 2835 2836Given 2837 template <typename T> class X {}; class A {}; X<A> x; 2838or 2839 template <typename T> class X {}; class A {}; template class X<A>; 2840cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2841 matches the template instantiation of X<A>. 2842 2843But given 2844 template <typename T> class X {}; class A {}; 2845 template <> class X<A> {}; X<A> x; 2846cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2847 does not match, as X<A> is an explicit template specialization. 2848 2849Usable 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>> 2850</pre></td></tr> 2851 2852 2853<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> 2854<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside 2855template instantiations. 2856 2857Given 2858 template<typename T> void A(T t) { T i; } 2859 A(0); 2860 A(0U); 2861functionDecl(isInstantiated()) 2862 matches 'A(int) {...};' and 'A(unsigned) {...}'. 2863</pre></td></tr> 2864 2865 2866<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> 2867<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. 2868 2869Given 2870 int j; 2871 template<typename T> void A(T t) { T i; j += 42;} 2872 A(0); 2873 A(0U); 2874declStmt(isInTemplateInstantiation()) 2875 matches 'int i;' and 'unsigned i'. 2876unless(stmt(isInTemplateInstantiation())) 2877 will NOT match j += 42; as it's shared between the template definition and 2878 instantiation. 2879</pre></td></tr> 2880 2881<!--END_NARROWING_MATCHERS --> 2882</table> 2883 2884<!-- ======================================================================= --> 2885<h2 id="traversal-matchers">AST Traversal Matchers</h2> 2886<!-- ======================================================================= --> 2887 2888<p>Traversal matchers specify the relationship to other nodes that are 2889reachable from the current node.</p> 2890 2891<p>Note that there are special traversal matchers (has, hasDescendant, forEach and 2892forEachDescendant) which work on all nodes and allow users to write more generic 2893match expressions.</p> 2894 2895<table> 2896<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 2897<!-- START_TRAVERSAL_MATCHERS --> 2898 2899<tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 2900<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. 2901 2902Unlike anyOf, eachOf will generate a match result for each 2903matching submatcher. 2904 2905For example, in: 2906 class A { int a; int b; }; 2907The matcher: 2908 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), 2909 has(fieldDecl(hasName("b")).bind("v")))) 2910will generate two results binding "v", the first of which binds 2911the field declaration of a, the second the field declaration of 2912b. 2913 2914Usable as: Any Matcher 2915</pre></td></tr> 2916 2917 2918<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> 2919<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 2920provided matcher. 2921 2922Example matches X, A, B, C 2923 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) 2924 class X {}; Matches X, because X::X is a class of name X inside X. 2925 class A { class X {}; }; 2926 class B { class C { class X {}; }; }; 2927 2928DescendantT must be an AST base type. 2929 2930As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 2931each result that matches instead of only on the first one. 2932 2933Note: Recursively combined ForEachDescendant can cause many matches: 2934 cxxRecordDecl(forEachDescendant(cxxRecordDecl( 2935 forEachDescendant(cxxRecordDecl()) 2936 ))) 2937will match 10 times (plus injected class name matches) on: 2938 class A { class B { class C { class D { class E {}; }; }; }; }; 2939 2940Usable as: Any Matcher 2941</pre></td></tr> 2942 2943 2944<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> 2945<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 2946provided matcher. 2947 2948Example matches X, Y 2949 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) 2950 class X {}; Matches X, because X::X is a class of name X inside X. 2951 class Y { class X {}; }; 2952 class Z { class Y { class X {}; }; }; Does not match Z. 2953 2954ChildT must be an AST base type. 2955 2956As opposed to 'has', 'forEach' will cause a match for each result that 2957matches instead of only on the first one. 2958 2959Usable as: Any Matcher 2960</pre></td></tr> 2961 2962 2963<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> 2964<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 2965matcher. 2966 2967Given 2968void f() { if (true) { int x = 42; } } 2969void g() { for (;;) { int x = 43; } } 2970expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 2971 2972Usable as: Any Matcher 2973</pre></td></tr> 2974 2975 2976<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> 2977<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 2978provided matcher. 2979 2980Example matches X, Y, Z 2981 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) 2982 class X {}; Matches X, because X::X is a class of name X inside X. 2983 class Y { class X {}; }; 2984 class Z { class Y { class X {}; }; }; 2985 2986DescendantT must be an AST base type. 2987 2988Usable as: Any Matcher 2989</pre></td></tr> 2990 2991 2992<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> 2993<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 2994provided matcher. 2995 2996Example matches X, Y 2997 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) 2998 class X {}; Matches X, because X::X is a class of name X inside X. 2999 class Y { class X {}; }; 3000 class Z { class Y { class X {}; }; }; Does not match Z. 3001 3002ChildT must be an AST base type. 3003 3004Usable as: Any Matcher 3005</pre></td></tr> 3006 3007 3008<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> 3009<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 3010matcher. 3011 3012Given 3013void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 3014compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 3015 3016Usable as: Any Matcher 3017</pre></td></tr> 3018 3019 3020<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> 3021<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 3022 3023Given 3024 int i[5]; 3025 void f() { i[1] = 42; } 3026arraySubscriptExpression(hasBase(implicitCastExpr( 3027 hasSourceExpression(declRefExpr())))) 3028 matches i[1] with the declRefExpr() matching i 3029</pre></td></tr> 3030 3031 3032<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> 3033<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 3034 3035Given 3036 int i[5]; 3037 void f() { i[1] = 42; } 3038arraySubscriptExpression(hasIndex(integerLiteral())) 3039 matches i[1] with the integerLiteral() matching 1 3040</pre></td></tr> 3041 3042 3043<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> 3044<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element 3045type. 3046 3047Given 3048 struct A {}; 3049 A a[7]; 3050 int b[7]; 3051arrayType(hasElementType(builtinType())) 3052 matches "int b[7]" 3053 3054Usable 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>> 3055</pre></td></tr> 3056 3057 3058<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> 3059<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element 3060type. 3061 3062Given 3063 struct A {}; 3064 A a[7]; 3065 int b[7]; 3066arrayType(hasElementType(builtinType())) 3067 matches "int b[7]" 3068 3069Usable 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>> 3070</pre></td></tr> 3071 3072 3073<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> 3074<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. 3075 3076Given 3077 _Atomic(int) i; 3078 _Atomic(float) f; 3079atomicType(hasValueType(isInteger())) 3080 matches "_Atomic(int) i" 3081 3082Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 3083</pre></td></tr> 3084 3085 3086<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> 3087<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. 3088 3089Given 3090 _Atomic(int) i; 3091 _Atomic(float) f; 3092atomicType(hasValueType(isInteger())) 3093 matches "_Atomic(int) i" 3094 3095Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 3096</pre></td></tr> 3097 3098 3099<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> 3100<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. 3101 3102Note: There is no TypeLoc for the deduced type and thus no 3103getDeducedLoc() matcher. 3104 3105Given 3106 auto a = 1; 3107 auto b = 2.0; 3108autoType(hasDeducedType(isInteger())) 3109 matches "auto a" 3110 3111Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> 3112</pre></td></tr> 3113 3114 3115<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> 3116<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 3117binary operator matches. 3118</pre></td></tr> 3119 3120 3121<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> 3122<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 3123 3124Example matches a (matcher = binaryOperator(hasLHS())) 3125 a || b 3126</pre></td></tr> 3127 3128 3129<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> 3130<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 3131 3132Example matches b (matcher = binaryOperator(hasRHS())) 3133 a || b 3134</pre></td></tr> 3135 3136 3137<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> 3138<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the 3139pointee matches a given matcher. 3140 3141Given 3142 int *a; 3143 int const *b; 3144 float const *f; 3145pointerType(pointee(isConstQualified(), isInteger())) 3146 matches "int const *b" 3147 3148Usable 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>>, 3149 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>> 3150</pre></td></tr> 3151 3152 3153<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> 3154<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the 3155pointee matches a given matcher. 3156 3157Given 3158 int *a; 3159 int const *b; 3160 float const *f; 3161pointerType(pointee(isConstQualified(), isInteger())) 3162 matches "int const *b" 3163 3164Usable 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>>, 3165 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>> 3166</pre></td></tr> 3167 3168 3169<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> 3170<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call 3171expression. 3172 3173Given 3174 void x(int, int, int) { int y; x(1, y, 42); } 3175callExpr(hasAnyArgument(declRefExpr())) 3176 matches x(1, y, 42) 3177with hasAnyArgument(...) 3178 matching y 3179 3180FIXME: Currently this will ignore parentheses and implicit casts on 3181the argument before applying the inner matcher. We'll want to remove 3182this to allow for greater control by the user once ignoreImplicit() 3183has been implemented. 3184</pre></td></tr> 3185 3186 3187<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> 3188<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor 3189call expression. 3190 3191Example matches y in x(y) 3192 (matcher = callExpr(hasArgument(0, declRefExpr()))) 3193 void x(int) { int y; x(y); } 3194</pre></td></tr> 3195 3196 3197<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> 3198<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node 3199matches the given matcher. 3200 3201The associated declaration is: 3202- for type nodes, the declaration of the underlying type 3203- for CallExpr, the declaration of the callee 3204- for MemberExpr, the declaration of the referenced member 3205- for CXXConstructExpr, the declaration of the constructor 3206 3207Also usable as Matcher<T> for any T supporting the getDecl() member 3208function. e.g. various subtypes of clang::Type and various expressions. 3209 3210Usable 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>>, 3211 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>>, 3212 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>>, 3213 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>>, 3214 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>>, 3215 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>> 3216</pre></td></tr> 3217 3218 3219<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> 3220<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. 3221 3222Given 3223 class A { A() : i(42), j(42) {} int i; int j; }; 3224cxxConstructorDecl(forEachConstructorInitializer( 3225 forField(decl().bind("x")) 3226)) 3227 will trigger two matches, binding for 'i' and 'j' respectively. 3228</pre></td></tr> 3229 3230 3231<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> 3232<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 3233 3234Given 3235 struct Foo { 3236 Foo() : foo_(1) { } 3237 int foo_; 3238 }; 3239cxxRecordDecl(has(cxxConstructorDecl( 3240 hasAnyConstructorInitializer(anything()) 3241))) 3242 record matches Foo, hasAnyConstructorInitializer matches foo_(1) 3243</pre></td></tr> 3244 3245 3246<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> 3247<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 3248 3249Given 3250 struct Foo { 3251 Foo() : foo_(1) { } 3252 int foo_; 3253 }; 3254cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 3255 forField(hasName("foo_")))))) 3256 matches Foo 3257with forField matching foo_ 3258</pre></td></tr> 3259 3260 3261<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> 3262<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 3263 3264Given 3265 struct Foo { 3266 Foo() : foo_(1) { } 3267 int foo_; 3268 }; 3269cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 3270 withInitializer(integerLiteral(equals(1))))))) 3271 matches Foo 3272with withInitializer matching (1) 3273</pre></td></tr> 3274 3275 3276<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> 3277<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', or 'do while' statement that has 3278a given body. 3279 3280Given 3281 for (;;) {} 3282hasBody(compoundStmt()) 3283 matches 'for (;;) {}' 3284with compoundStmt() 3285 matching '{}' 3286</pre></td></tr> 3287 3288 3289<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> 3290<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. 3291 3292Example: 3293 forStmt(hasLoopVariable(anything())) 3294matches 'int x' in 3295 for (int x : a) { } 3296</pre></td></tr> 3297 3298 3299<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> 3300<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. 3301 3302Example: 3303 forStmt(hasRangeInit(anything())) 3304matches 'a' in 3305 for (int x : a) { } 3306</pre></td></tr> 3307 3308 3309<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> 3310<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> 3311 3312 3313<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> 3314<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. 3315 3316Example matches y.x() 3317 (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))) 3318 class Y { public: void x(); }; 3319 void z() { Y y; y.x(); }", 3320 3321FIXME: Overload to allow directly matching types? 3322</pre></td></tr> 3323 3324 3325<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> 3326<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 3327</pre></td></tr> 3328 3329 3330<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> 3331<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified 3332matcher, or is a pointer to a type that matches the InnerMatcher. 3333</pre></td></tr> 3334 3335 3336<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> 3337<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 3338belongs to. 3339 3340FIXME: Generalize this for other kinds of declarations. 3341FIXME: What other kind of declarations would we need to generalize 3342this to? 3343 3344Example matches A() in the last line 3345 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( 3346 ofClass(hasName("A")))))) 3347 class A { 3348 public: 3349 A(); 3350 }; 3351 A a = A(); 3352</pre></td></tr> 3353 3354 3355<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> 3356<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. 3357 3358Given: 3359 class A { void func(); }; 3360 class B { void member(); }; 3361 3362cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of 3363A but not B. 3364</pre></td></tr> 3365 3366 3367<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> 3368<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from 3369a class matching Base. 3370 3371Note that a class is not considered to be derived from itself. 3372 3373Example matches Y, Z, C (Base == hasName("X")) 3374 class X; 3375 class Y : public X {}; directly derived 3376 class Z : public Y {}; indirectly derived 3377 typedef X A; 3378 typedef A B; 3379 class C : public B {}; derived from a typedef of X 3380 3381In the following example, Bar matches isDerivedFrom(hasName("X")): 3382 class Foo; 3383 typedef Foo X; 3384 class Bar : public Foo {}; derived from a type that X is a typedef of 3385</pre></td></tr> 3386 3387 3388<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> 3389<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 3390match Base. 3391</pre></td></tr> 3392 3393 3394<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> 3395<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the 3396given matcher. 3397 3398Example matches y.x() (matcher = callExpr(callee( 3399 cxxMethodDecl(hasName("x"))))) 3400 class Y { public: void x(); }; 3401 void z() { Y y; y.x(); } 3402</pre></td></tr> 3403 3404 3405<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> 3406<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. 3407 3408Given 3409 class Y { void x() { this->x(); x(); Y y; y.x(); } }; 3410 void f() { f(); } 3411callExpr(callee(expr())) 3412 matches this->x(), x(), y.x(), f() 3413with callee(...) 3414 matching this->x, x, y.x, f respectively 3415 3416Note: Callee cannot take the more general internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> 3417because this introduces ambiguous overloads with calls to Callee taking a 3418internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely 3419implemented in terms of implicit casts. 3420</pre></td></tr> 3421 3422 3423<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> 3424<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 3425expression. 3426 3427Given 3428 void x(int, int, int) { int y; x(1, y, 42); } 3429callExpr(hasAnyArgument(declRefExpr())) 3430 matches x(1, y, 42) 3431with hasAnyArgument(...) 3432 matching y 3433 3434FIXME: Currently this will ignore parentheses and implicit casts on 3435the argument before applying the inner matcher. We'll want to remove 3436this to allow for greater control by the user once ignoreImplicit() 3437has been implemented. 3438</pre></td></tr> 3439 3440 3441<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> 3442<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 3443call expression. 3444 3445Example matches y in x(y) 3446 (matcher = callExpr(hasArgument(0, declRefExpr()))) 3447 void x(int) { int y; x(y); } 3448</pre></td></tr> 3449 3450 3451<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> 3452<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node 3453matches the given matcher. 3454 3455The associated declaration is: 3456- for type nodes, the declaration of the underlying type 3457- for CallExpr, the declaration of the callee 3458- for MemberExpr, the declaration of the referenced member 3459- for CXXConstructExpr, the declaration of the constructor 3460 3461Also usable as Matcher<T> for any T supporting the getDecl() member 3462function. e.g. various subtypes of clang::Type and various expressions. 3463 3464Usable 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>>, 3465 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>>, 3466 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>>, 3467 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>>, 3468 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>>, 3469 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>> 3470</pre></td></tr> 3471 3472 3473<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> 3474<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range 3475extension, matches the constant given in the statement. 3476 3477Given 3478 switch (1) { case 1: case 1+1: case 3 ... 4: ; } 3479caseStmt(hasCaseConstant(integerLiteral())) 3480 matches "case 1:" 3481</pre></td></tr> 3482 3483 3484<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> 3485<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher. 3486 3487Example: matches "a string" (matcher = 3488 hasSourceExpression(cxxConstructExpr())) 3489class URL { URL(string); }; 3490URL url = "a string"; 3491</pre></td></tr> 3492 3493 3494<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> 3495<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one 3496TemplateArgument matching the given InnerMatcher. 3497 3498Given 3499 template<typename T> class A {}; 3500 template<> class A<double> {}; 3501 A<int> a; 3502classTemplateSpecializationDecl(hasAnyTemplateArgument( 3503 refersToType(asString("int")))) 3504 matches the specialization A<int> 3505</pre></td></tr> 3506 3507 3508<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> 3509<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument 3510matches the given InnerMatcher. 3511 3512Given 3513 template<typename T, typename U> class A {}; 3514 A<bool, int> b; 3515 A<int, bool> c; 3516classTemplateSpecializationDecl(hasTemplateArgument( 3517 1, refersToType(asString("int")))) 3518 matches the specialization A<bool, int> 3519</pre></td></tr> 3520 3521 3522<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> 3523<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element 3524type. 3525 3526Given 3527 struct A {}; 3528 A a[7]; 3529 int b[7]; 3530arrayType(hasElementType(builtinType())) 3531 matches "int b[7]" 3532 3533Usable 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>> 3534</pre></td></tr> 3535 3536 3537<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> 3538<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element 3539type. 3540 3541Given 3542 struct A {}; 3543 A a[7]; 3544 int b[7]; 3545arrayType(hasElementType(builtinType())) 3546 matches "int b[7]" 3547 3548Usable 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>> 3549</pre></td></tr> 3550 3551 3552<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> 3553<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 3554a given matcher. 3555 3556Given 3557 { {}; 1+2; } 3558hasAnySubstatement(compoundStmt()) 3559 matches '{ {}; 1+2; }' 3560with compoundStmt() 3561 matching '{}' 3562</pre></td></tr> 3563 3564 3565<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> 3566<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 3567or conditional operator. 3568 3569Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 3570 if (true) {} 3571</pre></td></tr> 3572 3573 3574<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> 3575<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator. 3576 3577Example matches b 3578 condition ? a : b 3579</pre></td></tr> 3580 3581 3582<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> 3583<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 3584 3585Example matches a 3586 condition ? a : b 3587</pre></td></tr> 3588 3589 3590<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> 3591<tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whos decayed type matches InnerMatcher 3592</pre></td></tr> 3593 3594 3595<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> 3596<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node 3597matches the given matcher. 3598 3599The associated declaration is: 3600- for type nodes, the declaration of the underlying type 3601- for CallExpr, the declaration of the callee 3602- for MemberExpr, the declaration of the referenced member 3603- for CXXConstructExpr, the declaration of the constructor 3604 3605Also usable as Matcher<T> for any T supporting the getDecl() member 3606function. e.g. various subtypes of clang::Type and various expressions. 3607 3608Usable 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>>, 3609 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>>, 3610 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>>, 3611 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>>, 3612 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>>, 3613 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>> 3614</pre></td></tr> 3615 3616 3617<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> 3618<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a 3619specific using shadow declaration. 3620 3621Given 3622 namespace a { void f() {} } 3623 using a::f; 3624 void g() { 3625 f(); Matches this .. 3626 a::f(); .. but not this. 3627 } 3628declRefExpr(throughUsingDecl(anything())) 3629 matches f() 3630</pre></td></tr> 3631 3632 3633<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> 3634<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 3635specified matcher. 3636 3637Example matches x in if(x) 3638 (matcher = declRefExpr(to(varDecl(hasName("x"))))) 3639 bool x; 3640 if (x) {} 3641</pre></td></tr> 3642 3643 3644<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> 3645<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 3646 3647Note that this does not work for global declarations because the AST 3648breaks up multiple-declaration DeclStmt's into multiple single-declaration 3649DeclStmt's. 3650Example: Given non-global declarations 3651 int a, b = 0; 3652 int c; 3653 int d = 2, e; 3654declStmt(containsDeclaration( 3655 0, varDecl(hasInitializer(anything())))) 3656 matches only 'int d = 2, e;', and 3657declStmt(containsDeclaration(1, varDecl())) 3658 matches 'int a, b = 0' as well as 'int d = 2, e;' 3659 but 'int c;' is not matched. 3660</pre></td></tr> 3661 3662 3663<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> 3664<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 3665 3666Given 3667 int a, b; 3668 int c; 3669declStmt(hasSingleDecl(anything())) 3670 matches 'int c;' but not 'int a, b;'. 3671</pre></td></tr> 3672 3673 3674<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> 3675<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches 3676the inner matcher. 3677 3678Given 3679 int x; 3680declaratorDecl(hasTypeLoc(loc(asString("int")))) 3681 matches int x 3682</pre></td></tr> 3683 3684 3685<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> 3686<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a 3687Decl, matches InnerMatcher. 3688 3689Given 3690 namespace N { 3691 namespace M { 3692 class D {}; 3693 } 3694 } 3695 3696cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the 3697declaration of class D. 3698</pre></td></tr> 3699 3700 3701<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> 3702<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has 3703a given body. 3704 3705Given 3706 for (;;) {} 3707hasBody(compoundStmt()) 3708 matches 'for (;;) {}' 3709with compoundStmt() 3710 matching '{}' 3711</pre></td></tr> 3712 3713 3714<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> 3715<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 3716or conditional operator. 3717 3718Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 3719 if (true) {} 3720</pre></td></tr> 3721 3722 3723<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> 3724<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, 3725matches InnerMatcher if the qualifier exists. 3726 3727Given 3728 namespace N { 3729 namespace M { 3730 class D {}; 3731 } 3732 } 3733 N::M::D d; 3734 3735elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) 3736matches the type of the variable declaration of d. 3737</pre></td></tr> 3738 3739 3740<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> 3741<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. 3742 3743Given 3744 namespace N { 3745 namespace M { 3746 class D {}; 3747 } 3748 } 3749 N::M::D d; 3750 3751elaboratedType(namesType(recordType( 3752hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable 3753declaration of d. 3754</pre></td></tr> 3755 3756 3757<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> 3758<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node 3759matches the given matcher. 3760 3761The associated declaration is: 3762- for type nodes, the declaration of the underlying type 3763- for CallExpr, the declaration of the callee 3764- for MemberExpr, the declaration of the referenced member 3765- for CXXConstructExpr, the declaration of the constructor 3766 3767Also usable as Matcher<T> for any T supporting the getDecl() member 3768function. e.g. various subtypes of clang::Type and various expressions. 3769 3770Usable 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>>, 3771 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>>, 3772 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>>, 3773 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>>, 3774 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>>, 3775 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>> 3776</pre></td></tr> 3777 3778 3779<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> 3780<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 3781 3782(Note: Clang's AST refers to other conversions as "casts" too, and calls 3783actual casts "explicit" casts.) 3784</pre></td></tr> 3785 3786 3787<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('hasType2')"><a name="hasType2Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3788<tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value 3789declaration's type. 3790 3791In case of a value declaration (for example a variable declaration), 3792this resolves one layer of indirection. For example, in the value 3793declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 3794X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 3795declaration of x. 3796 3797Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 3798 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 3799 class X {}; 3800 void y(X &x) { x; X z; } 3801 3802Usable 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>> 3803</pre></td></tr> 3804 3805 3806<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> 3807<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type 3808matcher. 3809 3810Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 3811 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 3812 class X {}; 3813 void y(X &x) { x; X z; } 3814</pre></td></tr> 3815 3816 3817<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> 3818<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 3819are stripped off. 3820 3821Parentheses and explicit casts are not discarded. 3822Given 3823 int arr[5]; 3824 int a = 0; 3825 char b = 0; 3826 const int c = a; 3827 int *d = arr; 3828 long e = (long) 0l; 3829The matchers 3830 varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 3831 varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 3832would match the declarations for a, b, c, and d, but not e. 3833While 3834 varDecl(hasInitializer(integerLiteral())) 3835 varDecl(hasInitializer(declRefExpr())) 3836only match the declarations for b, c, and d. 3837</pre></td></tr> 3838 3839 3840<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> 3841<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 3842casts are stripped off. 3843 3844Implicit and non-C Style casts are also discarded. 3845Given 3846 int a = 0; 3847 char b = (0); 3848 void* c = reinterpret_cast<char*>(0); 3849 char d = char(0); 3850The matcher 3851 varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 3852would match the declarations for a, b, c, and d. 3853while 3854 varDecl(hasInitializer(integerLiteral())) 3855only match the declaration for a. 3856</pre></td></tr> 3857 3858 3859<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> 3860<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 3861parentheses are stripped off. 3862 3863Explicit casts are not discarded. 3864Given 3865 int arr[5]; 3866 int a = 0; 3867 char b = (0); 3868 const int c = a; 3869 int *d = (arr); 3870 long e = ((long) 0l); 3871The matchers 3872 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 3873 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 3874would match the declarations for a, b, c, and d, but not e. 3875while 3876 varDecl(hasInitializer(integerLiteral())) 3877 varDecl(hasInitializer(declRefExpr())) 3878would only match the declaration for a. 3879</pre></td></tr> 3880 3881 3882<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> 3883<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has 3884a given body. 3885 3886Given 3887 for (;;) {} 3888hasBody(compoundStmt()) 3889 matches 'for (;;) {}' 3890with compoundStmt() 3891 matching '{}' 3892</pre></td></tr> 3893 3894 3895<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> 3896<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 3897or conditional operator. 3898 3899Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 3900 if (true) {} 3901</pre></td></tr> 3902 3903 3904<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> 3905<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 3906 3907Example: 3908 forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 3909matches '++x' in 3910 for (x; x < N; ++x) { } 3911</pre></td></tr> 3912 3913 3914<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> 3915<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 3916 3917Example: 3918 forStmt(hasLoopInit(declStmt())) 3919matches 'int x = 0' in 3920 for (int x = 0; x < N; ++x) { } 3921</pre></td></tr> 3922 3923 3924<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> 3925<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. 3926 3927Does not match the 'this' parameter of a method. 3928 3929Given 3930 class X { void f(int x, int y, int z) {} }; 3931cxxMethodDecl(hasAnyParameter(hasName("y"))) 3932 matches f(int x, int y, int z) {} 3933with hasAnyParameter(...) 3934 matching int y 3935</pre></td></tr> 3936 3937 3938<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> 3939<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. 3940 3941Given 3942 class X { void f(int x) {} }; 3943cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 3944 matches f(int x) {} 3945with hasParameter(...) 3946 matching int x 3947</pre></td></tr> 3948 3949 3950<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> 3951<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 3952 3953Given: 3954 class X { int f() { return 1; } }; 3955cxxMethodDecl(returns(asString("int"))) 3956 matches int f() { return 1; } 3957</pre></td></tr> 3958 3959 3960<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> 3961<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 3962or conditional operator. 3963 3964Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 3965 if (true) {} 3966</pre></td></tr> 3967 3968 3969<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> 3970<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 3971 3972Given 3973 if (A* a = GetAPointer()) {} 3974hasConditionVariableStatement(...) 3975 matches 'A* a = GetAPointer()'. 3976</pre></td></tr> 3977 3978 3979<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> 3980<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. 3981 3982Examples matches the if statement 3983 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) 3984 if (false) false; else true; 3985</pre></td></tr> 3986 3987 3988<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> 3989<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. 3990 3991Examples matches the if statement 3992 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) 3993 if (false) true; else false; 3994</pre></td></tr> 3995 3996 3997<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> 3998<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 3999matcher. 4000 4001FIXME: Unit test this matcher 4002</pre></td></tr> 4003 4004 4005<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> 4006<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node 4007matches the given matcher. 4008 4009The associated declaration is: 4010- for type nodes, the declaration of the underlying type 4011- for CallExpr, the declaration of the callee 4012- for MemberExpr, the declaration of the referenced member 4013- for CXXConstructExpr, the declaration of the constructor 4014 4015Also usable as Matcher<T> for any T supporting the getDecl() member 4016function. e.g. various subtypes of clang::Type and various expressions. 4017 4018Usable 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>>, 4019 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>>, 4020 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>>, 4021 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>>, 4022 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>>, 4023 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>> 4024</pre></td></tr> 4025 4026 4027<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> 4028<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node 4029matches the given matcher. 4030 4031The associated declaration is: 4032- for type nodes, the declaration of the underlying type 4033- for CallExpr, the declaration of the callee 4034- for MemberExpr, the declaration of the referenced member 4035- for CXXConstructExpr, the declaration of the constructor 4036 4037Also usable as Matcher<T> for any T supporting the getDecl() member 4038function. e.g. various subtypes of clang::Type and various expressions. 4039 4040Usable 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>>, 4041 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>>, 4042 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>>, 4043 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>>, 4044 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>>, 4045 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>> 4046</pre></td></tr> 4047 4048 4049<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> 4050<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node 4051matches the given matcher. 4052 4053The associated declaration is: 4054- for type nodes, the declaration of the underlying type 4055- for CallExpr, the declaration of the callee 4056- for MemberExpr, the declaration of the referenced member 4057- for CXXConstructExpr, the declaration of the constructor 4058 4059Also usable as Matcher<T> for any T supporting the getDecl() member 4060function. e.g. various subtypes of clang::Type and various expressions. 4061 4062Usable 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>>, 4063 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>>, 4064 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>>, 4065 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>>, 4066 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>>, 4067 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>> 4068</pre></td></tr> 4069 4070 4071<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> 4072<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is 4073matched by a given matcher. 4074 4075Given 4076 struct X { int m; }; 4077 void f(X x) { x.m; m; } 4078memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))))) 4079 matches "x.m" and "m" 4080with hasObjectExpression(...) 4081 matching "x" and the implicit object expression of "m" which has type X*. 4082</pre></td></tr> 4083 4084 4085<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> 4086<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 4087given matcher. 4088 4089Given 4090 struct { int first, second; } first, second; 4091 int i(second.first); 4092 int j(first.second); 4093memberExpr(member(hasName("first"))) 4094 matches second.first 4095 but not first.second (because the member name there is "second"). 4096</pre></td></tr> 4097 4098 4099<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> 4100<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the 4101pointee matches a given matcher. 4102 4103Given 4104 int *a; 4105 int const *b; 4106 float const *f; 4107pointerType(pointee(isConstQualified(), isInteger())) 4108 matches "int const *b" 4109 4110Usable 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>>, 4111 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>> 4112</pre></td></tr> 4113 4114 4115<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> 4116<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the 4117pointee matches a given matcher. 4118 4119Given 4120 int *a; 4121 int const *b; 4122 float const *f; 4123pointerType(pointee(isConstQualified(), isInteger())) 4124 matches "int const *b" 4125 4126Usable 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>>, 4127 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>> 4128</pre></td></tr> 4129 4130 4131<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> 4132<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 4133 4134Given 4135 struct A { struct B { struct C {}; }; }; 4136 A::B::C c; 4137nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 4138 matches "A::" 4139</pre></td></tr> 4140 4141 4142<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> 4143<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 4144given TypeLoc. 4145 4146Given 4147 struct A { struct B { struct C {}; }; }; 4148 A::B::C c; 4149nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 4150 hasDeclaration(cxxRecordDecl(hasName("A"))))))) 4151 matches "A::" 4152</pre></td></tr> 4153 4154 4155<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> 4156<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 4157 4158Given 4159 struct A { struct B { struct C {}; }; }; 4160 A::B::C c; 4161nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 4162 matches "A::" 4163</pre></td></tr> 4164 4165 4166<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> 4167<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 4168given namespace matcher. 4169 4170Given 4171 namespace ns { struct A {}; } 4172 ns::A a; 4173nestedNameSpecifier(specifiesNamespace(hasName("ns"))) 4174 matches "ns::" 4175</pre></td></tr> 4176 4177 4178<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> 4179<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 4180given QualType matcher without qualifiers. 4181 4182Given 4183 struct A { struct B { struct C {}; }; }; 4184 A::B::C c; 4185nestedNameSpecifier(specifiesType( 4186 hasDeclaration(cxxRecordDecl(hasName("A"))) 4187)) 4188 matches "A::" 4189</pre></td></tr> 4190 4191 4192<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> 4193<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor 4194call expression. 4195 4196Example matches y in x(y) 4197 (matcher = callExpr(hasArgument(0, declRefExpr()))) 4198 void x(int) { int y; x(y); } 4199</pre></td></tr> 4200 4201 4202<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> 4203<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. 4204 4205Example 4206matcher = objCMessageExpr(hasRecieverType(asString("UIWebView *"))); 4207matches the [webView ...] message invocation. 4208 NSString *webViewJavaScript = ... 4209 UIWebView *webView = ... 4210 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; 4211</pre></td></tr> 4212 4213 4214<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> 4215<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. 4216 4217Given 4218 int (*ptr_to_array)[4]; 4219 int (*ptr_to_func)(int); 4220 4221varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches 4222ptr_to_func but not ptr_to_array. 4223 4224Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> 4225</pre></td></tr> 4226 4227 4228<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> 4229<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the 4230pointee matches a given matcher. 4231 4232Given 4233 int *a; 4234 int const *b; 4235 float const *f; 4236pointerType(pointee(isConstQualified(), isInteger())) 4237 matches "int const *b" 4238 4239Usable 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>>, 4240 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>> 4241</pre></td></tr> 4242 4243 4244<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> 4245<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the 4246pointee matches a given matcher. 4247 4248Given 4249 int *a; 4250 int const *b; 4251 float const *f; 4252pointerType(pointee(isConstQualified(), isInteger())) 4253 matches "int const *b" 4254 4255Usable 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>>, 4256 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>> 4257</pre></td></tr> 4258 4259 4260<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> 4261<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. 4262 4263Given: 4264 typedef int &int_ref; 4265 int a; 4266 int_ref b = a; 4267 4268varDecl(hasType(qualType(referenceType()))))) will not match the 4269declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. 4270</pre></td></tr> 4271 4272 4273<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> 4274<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node 4275matches the given matcher. 4276 4277The associated declaration is: 4278- for type nodes, the declaration of the underlying type 4279- for CallExpr, the declaration of the callee 4280- for MemberExpr, the declaration of the referenced member 4281- for CXXConstructExpr, the declaration of the constructor 4282 4283Also usable as Matcher<T> for any T supporting the getDecl() member 4284function. e.g. various subtypes of clang::Type and various expressions. 4285 4286Usable 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>>, 4287 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>>, 4288 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>>, 4289 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>>, 4290 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>>, 4291 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>> 4292</pre></td></tr> 4293 4294 4295<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> 4296<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 4297</pre></td></tr> 4298 4299 4300<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> 4301<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type 4302matches the specified matcher. 4303 4304Example matches y->x() 4305 (matcher = cxxMemberCallExpr(on(hasType(pointsTo 4306 cxxRecordDecl(hasName("Y"))))))) 4307 class Y { public: void x(); }; 4308 void z() { Y *y; y->x(); } 4309</pre></td></tr> 4310 4311 4312<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> 4313<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 4314</pre></td></tr> 4315 4316 4317<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> 4318<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced 4319type matches the specified matcher. 4320 4321Example matches X &x and const X &y 4322 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) 4323 class X { 4324 void a(X b) { 4325 X &x = b; 4326 const X &y = b; 4327 } 4328 }; 4329</pre></td></tr> 4330 4331 4332<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> 4333<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node 4334matches the given matcher. 4335 4336The associated declaration is: 4337- for type nodes, the declaration of the underlying type 4338- for CallExpr, the declaration of the callee 4339- for MemberExpr, the declaration of the referenced member 4340- for CXXConstructExpr, the declaration of the constructor 4341 4342Also usable as Matcher<T> for any T supporting the getDecl() member 4343function. e.g. various subtypes of clang::Type and various expressions. 4344 4345Usable 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>>, 4346 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>>, 4347 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>>, 4348 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>>, 4349 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>>, 4350 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>> 4351</pre></td></tr> 4352 4353 4354<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> 4355<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the 4356pointee matches a given matcher. 4357 4358Given 4359 int *a; 4360 int const *b; 4361 float const *f; 4362pointerType(pointee(isConstQualified(), isInteger())) 4363 matches "int const *b" 4364 4365Usable 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>>, 4366 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>> 4367</pre></td></tr> 4368 4369 4370<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> 4371<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the 4372pointee matches a given matcher. 4373 4374Given 4375 int *a; 4376 int const *b; 4377 float const *f; 4378pointerType(pointee(isConstQualified(), isInteger())) 4379 matches "int const *b" 4380 4381Usable 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>>, 4382 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>> 4383</pre></td></tr> 4384 4385 4386<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> 4387<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 4388alignof. 4389</pre></td></tr> 4390 4391 4392<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> 4393<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 4394sizeof. 4395</pre></td></tr> 4396 4397 4398<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> 4399<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch 4400statement. This matcher may produce multiple matches. 4401 4402Given 4403 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } 4404switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") 4405 matches four times, with "c" binding each of "case 1:", "case 2:", 4406"case 3:" and "case 4:", and "s" respectively binding "switch (1)", 4407"switch (1)", "switch (2)" and "switch (2)". 4408</pre></td></tr> 4409 4410 4411<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> 4412<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node 4413matches the given matcher. 4414 4415The associated declaration is: 4416- for type nodes, the declaration of the underlying type 4417- for CallExpr, the declaration of the callee 4418- for MemberExpr, the declaration of the referenced member 4419- for CXXConstructExpr, the declaration of the constructor 4420 4421Also usable as Matcher<T> for any T supporting the getDecl() member 4422function. e.g. various subtypes of clang::Type and various expressions. 4423 4424Usable 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>>, 4425 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>>, 4426 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>>, 4427 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>>, 4428 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>>, 4429 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>> 4430</pre></td></tr> 4431 4432 4433<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> 4434<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. 4435 4436Given 4437 template<typename T> struct A {}; 4438 struct B { B* next; }; 4439 A<&B::next> a; 4440templateSpecializationType(hasAnyTemplateArgument( 4441 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) 4442 matches the specialization A<&B::next> with fieldDecl(...) matching 4443 B::next 4444</pre></td></tr> 4445 4446 4447<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> 4448<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain 4449declaration. 4450 4451Given 4452 template<typename T> struct A {}; 4453 struct B { B* next; }; 4454 A<&B::next> a; 4455classTemplateSpecializationDecl(hasAnyTemplateArgument( 4456 refersToDeclaration(fieldDecl(hasName("next")))) 4457 matches the specialization A<&B::next> with fieldDecl(...) matching 4458 B::next 4459</pre></td></tr> 4460 4461 4462<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> 4463<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type. 4464 4465Given 4466 template<int T> struct A {}; 4467 C<42> c; 4468classTemplateSpecializationDecl( 4469 hasAnyTemplateArgument(refersToIntegralType(asString("int")))) 4470 matches the implicit instantiation of C in C<42>. 4471</pre></td></tr> 4472 4473 4474<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> 4475<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 4476 4477Given 4478 struct X {}; 4479 template<typename T> struct A {}; 4480 A<X> a; 4481classTemplateSpecializationDecl(hasAnyTemplateArgument( 4482 refersToType(class(hasName("X"))))) 4483 matches the specialization A<X> 4484</pre></td></tr> 4485 4486 4487<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> 4488<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations that have at least one 4489TemplateArgument matching the given InnerMatcher. 4490 4491Given 4492 template<typename T> class A {}; 4493 template<> class A<double> {}; 4494 A<int> a; 4495classTemplateSpecializationDecl(hasAnyTemplateArgument( 4496 refersToType(asString("int")))) 4497 matches the specialization A<int> 4498</pre></td></tr> 4499 4500 4501<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> 4502<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node 4503matches the given matcher. 4504 4505The associated declaration is: 4506- for type nodes, the declaration of the underlying type 4507- for CallExpr, the declaration of the callee 4508- for MemberExpr, the declaration of the referenced member 4509- for CXXConstructExpr, the declaration of the constructor 4510 4511Also usable as Matcher<T> for any T supporting the getDecl() member 4512function. e.g. various subtypes of clang::Type and various expressions. 4513 4514Usable 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>>, 4515 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>>, 4516 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>>, 4517 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>>, 4518 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>>, 4519 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>> 4520</pre></td></tr> 4521 4522 4523<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> 4524<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument 4525matches the given InnerMatcher. 4526 4527Given 4528 template<typename T, typename U> class A {}; 4529 A<bool, int> b; 4530 A<int, bool> c; 4531classTemplateSpecializationDecl(hasTemplateArgument( 4532 1, refersToType(asString("int")))) 4533 matches the specialization A<bool, int> 4534</pre></td></tr> 4535 4536 4537<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> 4538<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node 4539matches the given matcher. 4540 4541The associated declaration is: 4542- for type nodes, the declaration of the underlying type 4543- for CallExpr, the declaration of the callee 4544- for MemberExpr, the declaration of the referenced member 4545- for CXXConstructExpr, the declaration of the constructor 4546 4547Also usable as Matcher<T> for any T supporting the getDecl() member 4548function. e.g. various subtypes of clang::Type and various expressions. 4549 4550Usable 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>>, 4551 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>>, 4552 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>>, 4553 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>>, 4554 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>>, 4555 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>> 4556</pre></td></tr> 4557 4558 4559<tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<T> Matcher</td></tr> 4560<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. 4561 4562Generates results for each match. 4563 4564For example, in: 4565 class A { class B {}; class C {}; }; 4566The matcher: 4567 cxxRecordDecl(hasName("::A"), 4568 findAll(cxxRecordDecl(isDefinition()).bind("m"))) 4569will generate results for A, B and C. 4570 4571Usable as: Any Matcher 4572</pre></td></tr> 4573 4574 4575<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> 4576<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node 4577matches the given matcher. 4578 4579The associated declaration is: 4580- for type nodes, the declaration of the underlying type 4581- for CallExpr, the declaration of the callee 4582- for MemberExpr, the declaration of the referenced member 4583- for CXXConstructExpr, the declaration of the constructor 4584 4585Also usable as Matcher<T> for any T supporting the getDecl() member 4586function. e.g. various subtypes of clang::Type and various expressions. 4587 4588Usable 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>>, 4589 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>>, 4590 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>>, 4591 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>>, 4592 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>>, 4593 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>> 4594</pre></td></tr> 4595 4596 4597<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> 4598<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 4599 4600Given 4601 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 4602unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 4603 matches sizeof(a) and alignof(c) 4604</pre></td></tr> 4605 4606 4607<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> 4608<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 4609 4610Example matches true (matcher = hasUnaryOperand( 4611 cxxBoolLiteral(equals(true)))) 4612 !true 4613</pre></td></tr> 4614 4615 4616<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> 4617<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node 4618matches the given matcher. 4619 4620The associated declaration is: 4621- for type nodes, the declaration of the underlying type 4622- for CallExpr, the declaration of the callee 4623- for MemberExpr, the declaration of the referenced member 4624- for CXXConstructExpr, the declaration of the constructor 4625 4626Also usable as Matcher<T> for any T supporting the getDecl() member 4627function. e.g. various subtypes of clang::Type and various expressions. 4628 4629Usable 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>>, 4630 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>>, 4631 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>>, 4632 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>>, 4633 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>>, 4634 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>> 4635</pre></td></tr> 4636 4637 4638<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> 4639<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 4640 4641Given 4642 namespace X { void b(); } 4643 using X::b; 4644usingDecl(hasAnyUsingShadowDecl(hasName("b")))) 4645 matches using X::b </pre></td></tr> 4646 4647 4648<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> 4649<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 4650matched by the given matcher. 4651 4652Given 4653 namespace X { int a; void b(); } 4654 using X::a; 4655 using X::b; 4656usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 4657 matches using X::b but not using X::a </pre></td></tr> 4658 4659 4660<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType3')"><a name="hasType3Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4661<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value 4662declaration's type. 4663 4664In case of a value declaration (for example a variable declaration), 4665this resolves one layer of indirection. For example, in the value 4666declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 4667X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 4668declaration of x. 4669 4670Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 4671 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 4672 class X {}; 4673 void y(X &x) { x; X z; } 4674 4675Usable 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>> 4676</pre></td></tr> 4677 4678 4679<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType1')"><a name="hasType1Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 4680<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type 4681matcher. 4682 4683Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 4684 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 4685 class X {}; 4686 void y(X &x) { x; X z; } 4687</pre></td></tr> 4688 4689 4690<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> 4691<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 4692that matches the given matcher. 4693 4694Example matches x (matcher = varDecl(hasInitializer(callExpr()))) 4695 bool y() { return true; } 4696 bool x = y(); 4697</pre></td></tr> 4698 4699 4700<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> 4701<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 4702expression. 4703 4704Given 4705 void f(int b) { 4706 int a[b]; 4707 } 4708variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 4709 varDecl(hasName("b"))))))) 4710 matches "int a[b]" 4711</pre></td></tr> 4712 4713 4714<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> 4715<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has 4716a given body. 4717 4718Given 4719 for (;;) {} 4720hasBody(compoundStmt()) 4721 matches 'for (;;) {}' 4722with compoundStmt() 4723 matching '{}' 4724</pre></td></tr> 4725 4726 4727<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> 4728<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 4729or conditional operator. 4730 4731Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 4732 if (true) {} 4733</pre></td></tr> 4734 4735 4736<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> 4737<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner 4738NestedNameSpecifier-matcher matches. 4739</pre></td></tr> 4740 4741 4742<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> 4743<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner 4744QualType-matcher matches. 4745</pre></td></tr> 4746 4747<!--END_TRAVERSAL_MATCHERS --> 4748</table> 4749 4750</div> 4751</body> 4752</html> 4753 4754 4755