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} 20span.mono { font-family: monospace; } 21 22.traverse_compare, .traverse_compare td, .traverse_compare th { 23 border: 1px solid black; 24 border-collapse: collapse; 25} 26</style> 27<script type="text/javascript"> 28function toggle(id) { 29 if (!id) return; 30 row = document.getElementById(id); 31 if (row.style.display != 'table-cell') 32 row.style.display = 'table-cell'; 33 else 34 row.style.display = 'none'; 35} 36</script> 37</head> 38<body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))"> 39 40<!--#include virtual="../menu.html.incl"--> 41 42<div id="content"> 43 44<h1>AST Matcher Reference</h1> 45 46<p>This document shows all currently implemented matchers. The matchers are grouped 47by category and node type they match. You can click on matcher names to show the 48matcher's source documentation.</p> 49 50<p>There are three different basic categories of matchers: 51<ul> 52<li><a href="#decl-matchers">Node Matchers:</a> Matchers that match a specific type of AST node.</li> 53<li><a href="#narrowing-matchers">Narrowing Matchers:</a> Matchers that match attributes on AST nodes.</li> 54<li><a href="#traversal-matchers">Traversal Matchers:</a> Matchers that allow traversal between AST nodes.</li> 55</ul> 56</p> 57 58<p>Within each category the matchers are ordered by node type they match on. 59Note that if a matcher can match multiple node types, it will appear 60multiple times. This means that by searching for Matcher<Stmt> you can 61find all matchers that can be used to match on Stmt nodes.</p> 62 63<p>The exception to that rule are matchers that can match on any node. Those 64are marked with a * and are listed in the beginning of each category.</p> 65 66<p>Note that the categorization of matchers is a great help when you combine 67them into matcher expressions. You will usually want to form matcher expressions 68that read like english sentences by alternating between node matchers and 69narrowing or traversal matchers, like this: 70<pre> 71recordDecl(hasDescendant( 72 ifStmt(hasTrueExpression( 73 expr(hasDescendant( 74 ifStmt())))))) 75</pre> 76</p> 77 78<!-- ======================================================================= --> 79<h2 id="traverse-mode">Traverse Mode</h2> 80<!-- ======================================================================= --> 81 82<p>The default mode of operation of AST Matchers visits all nodes in the AST, 83even if they are not spelled in the source. This is 84<span class="mono">AsIs</span> mode. This mode requires writing AST matchers 85that explicitly traverse or ignore implicit nodes, such as parentheses 86surrounding an expression or expressions with cleanups. These implicit 87nodes are not always obvious from the syntax of the source code, and so this 88mode requires careful consideration and testing to get the desired behavior 89from an AST matcher. 90</p> 91 92<p>In addition, because template instantiations are matched in the default mode, 93transformations can be accidentally made to template declarations. Finally, 94because implicit nodes are matched by default, transformations can be made on 95entirely incorrect places in the code.</p> 96 97<p>For these reasons, it is possible to ignore AST nodes which are not spelled 98in the source using the <span class="mono">IgnoreUnlessSpelledInSource</span> 99mode. This is likely to be far less error-prone for users who are not already 100very familiar with where implicit nodes appear in the AST. It is also likely 101to be less error-prone for experienced AST users, as difficult cases do not 102need to be encountered and matcher expressions adjusted for these cases.</p> 103 104<p>In clang-query, the mode can be changed with 105<pre> 106set traversal IgnoreUnlessSpelledInSource 107</pre> 108</p> 109This affects both matchers and AST dump output in results. 110 111<p>When using the C++ API such as in clang-tidy checks, the 112<span class="mono">traverse()</span> matcher is used to set the mode: 113<pre> 114Finder->addMatcher(traverse(TK_IgnoreUnlessSpelledInSource, 115 returnStmt(hasReturnValue(integerLiteral(equals(0)))) 116 ), this); 117</pre> 118</p> 119<p>The following table compares the <span class="mono">AsIs</span> mode with 120the <span class="mono">IgnoreUnlessSpelledInSource</span> mode:</p> 121 122<table class="traverse_compare"> 123<tr> 124<th></th> 125<th><span class="mono">AsIs</span></th> 126<th><span class="mono">IgnoreUnlessSpelledInSource</span></th> 127</tr> 128<tr> 129 <td>AST dump of <span class="mono">func1</span>: 130<pre> 131struct B { 132 B(int); 133}; 134 135B func1() { return 42; } 136</pre> 137 138 </td> 139 <td> 140C++98 dialect: 141<pre> 142FunctionDecl 143`-CompoundStmt 144 `-ReturnStmt 145 `-ExprWithCleanups 146 `-CXXConstructExpr 147 `-MaterializeTemporaryExpr 148 `-ImplicitCastExpr 149 `-ImplicitCastExpr 150 `-CXXConstructExpr 151 `-IntegerLiteral 'int' 42 152</pre> 153C++11, C++14 dialect: 154<pre> 155FunctionDecl 156`-CompoundStmt 157 `-ReturnStmt 158 `-ExprWithCleanups 159 `-CXXConstructExpr 160 `-MaterializeTemporaryExpr 161 `-ImplicitCastExpr 162 `-CXXConstructExpr 163 `-IntegerLiteral 'int' 42 164</pre> 165C++17, C++20 dialect: 166<pre> 167FunctionDecl 168`-CompoundStmt 169 `-ReturnStmt 170 `-ImplicitCastExpr 171 `-CXXConstructExpr 172 `-IntegerLiteral 'int' 42 173</pre> 174</td> 175 <td> 176All dialects: 177 <pre> 178FunctionDecl 179`-CompoundStmt 180 `-ReturnStmt 181 `-IntegerLiteral 'int' 42 182</pre></td> 183</tr> 184 185<tr> 186<td>Matcher for returned <span class="mono">42</span>: 187<pre> 188struct B { 189 B(int); 190}; 191 192B func1() { return 42; } 193</pre> 194 195 </td> 196 <td> 197All dialects: 198<pre> 199returnStmt(hasReturnValue( 200 ignoringImplicit( 201 ignoringElidableConstructorCall( 202 ignoringImplicit( 203 cxxConstructExpr(hasArgument(0, 204 ignoringImplicit( 205 integerLiteral().bind("returnVal") 206 ) 207 )) 208 ) 209 ) 210 ) 211 )) 212</pre></td> 213 <td> 214All dialects: 215<pre> 216returnStmt(hasReturnValue( 217 integerLiteral().bind("returnVal") 218)) 219</pre></td> 220</tr> 221<tr> 222<td>Match result for 223<pre>implicitCastExpr()</pre> 224given: 225<pre> 226struct B { 227 B(int); 228}; 229 230B func1() { return 42; } 231</pre> 232 233</td> 234<td> 235Match found.</td> 236 <td> 237No match.</td> 238</tr> 239<tr> 240 <td>Match result for: 241<pre> 242cxxConstructorDecl( 243 isCopyConstructor() 244 ).bind("prepend_explicit") 245</pre> 246given: 247<pre> 248struct Other {}; 249struct Copyable { 250 Other m_o; 251 Copyable(); 252}; 253</pre> 254</td> 255<td> 256Match found. Insertion produces incorrect output: 257<pre> 258struct Other {}; 259struct explicit Copyable { 260 Other m_o; 261 Copyable(); 262}; 263</pre> 264</td> 265<td> 266No match found. Incorrect replacement not possible. 267</td> 268</tr> 269<tr> 270 <td>Replacement of <span class="mono">begin()</span> 271 with <span class="mono">cbegin()</span>: 272<pre> 273cxxMemberCallExpr( 274 on(ConstContainerExpr), 275 callee(cxxMethodDecl(hasName("begin"))) 276 ).bind("replace_with_cbegin") 277</pre> 278given: 279<pre> 280void foo() { 281 const Container c; 282 c.begin(); 283 284 for (auto i : c) { 285 } 286} 287</pre> 288</td> 289<td> 2902 matches found. Replacement produces incorrect output: 291<pre> 292void foo() { 293 const Container c; 294 c.cbegin(); 295 296 for (auto i :.cbegin() c) { 297 } 298} 299</pre> 300</td> 301<td> 3021 match found. Replacement produces correct output: 303<pre> 304void foo() { 305 const Container c; 306 c.cbegin(); 307 308 for (auto i : c) { 309 } 310} 311</pre> 312</td> 313</tr> 314<tr> 315 <td>Replacement of <span class="mono">int</span> member 316 with <span class="mono">safe_int</span>: 317<pre> 318fieldDecl( 319 hasType(asString("int")) 320 ).bind("use_safe_int") 321</pre> 322given: 323<pre> 324struct S { 325 int m_i; 326}; 327 328template <typename T> struct TemplStruct { 329 TemplStruct() {} 330 ~TemplStruct() {} 331 332private: 333 T m_t; 334}; 335 336void instantiate() { TemplStruct<int> ti; } 337</pre> 338</td> 339<td> 3402 matches found. Replacement produces incorrect output: 341<pre> 342struct S { 343 safe_int m_i; 344}; 345 346template <typename T> struct TemplStruct { 347 TemplStruct() {} 348 ~TemplStruct() {} 349 350private: 351 safe_int m_t; 352}; 353 354void instantiate() { TemplStruct<int> ti; } 355</pre> 356</td> 357<td> 3581 match found. Replacement produces correct output: 359<pre> 360struct S { 361 safe_int m_i; 362}; 363 364template <typename T> struct TemplStruct { 365 TemplStruct() {} 366 ~TemplStruct() {} 367 368private: 369 T m_t; 370}; 371 372void instantiate() { TemplStruct<int> ti; } 373</pre> 374</td> 375</tr> 376<tr> 377 <td>Add prefix to member initializer 378<pre> 379cxxCtorInitializer( 380 forField(fieldDecl()) 381 ).bind("add_prefix") 382</pre> 383given: 384<pre> 385struct Simple {}; 386 387struct Record { 388 Record() : i(42) {} 389private: 390 int i; 391 Simple s; 392}; 393</pre> 394</td> 395<td> 3962 matches found. Replacement produces incorrect output: 397<pre> 398struct Simple {}; 399 400struct Record { 401 m_Record() : m_i(42) {} 402private: 403 int i; 404 Simple s; 405}; 406</pre> 407</td> 408<td> 4091 match found. Replacement produces correct output: 410<pre> 411struct Simple {}; 412 413struct Record { 414 Record() : m_i(42) {} 415private: 416 int i; 417 Simple s; 418}; 419</pre> 420</td> 421</tr> 422<tr> 423 <td>Ignored default arguments 424<pre> 425callExpr( 426 callee(functionDecl( 427 hasName("hasDefaultArg") 428 )), 429 argumentCountIs(1) 430 ).bind("add_prefix") 431</pre> 432given: 433<pre> 434void hasDefaultArg(int i, int j = 0) {} 435void callDefaultArg() { hasDefaultArg(42); } 436</pre> 437</td> 438<td> 439No match. 440</td> 441<td> 4421 match found. 443</td> 444</tr> 445<tr> 446 <td>Lambda fields 447<pre> 448fieldDecl( 449 hasType(asString("int")) 450 ).bind("make_safe") 451</pre> 452given: 453<pre> 454struct S { 455 int m_i; 456}; 457 458void func() { 459 int a = 0; 460 int c = 0; 461 462 auto l = [a, b = c](int d) { int e = d; }; 463 l(43); 464} 465</pre> 466</td> 467<td> 4682 matches found. Replacement produces incorrect output: 469<pre> 470struct S { 471 safe_int m_i; 472}; 473 474void func() { 475 int a = 0; 476 int c = 0; 477 478 auto l = [safe_a, safe_b = c](int d) { int e = d; }; 479 l(43); 480} 481</pre> 482</td> 483<td> 4841 match found. Replacement produces correct output: 485<pre> 486struct S { 487 safe_int m_i; 488}; 489 490void func() { 491 int a = 0; 492 int c = 0; 493 494 auto l = [a, b = c](int d) { int e = d; }; 495 l(43); 496} 497</pre> 498</td> 499 500</tr> 501 502 503 504 505 506<tr> 507 <td>Rewritten binary operators 508<pre> 509binaryOperator( 510 hasOperatorName("<"), 511 hasRHS(hasDescendant(integerLiteral(equals(0)))) 512 ) 513</pre> 514given: 515<pre> 516#include <compare> 517 518class HasSpaceship { 519public: 520 int x; 521 bool operator==(const HasSpaceship&) const = default; 522 std::strong_ordering operator<=>(const HasSpaceship&) const = default; 523}; 524 525bool isLess(const HasSpaceship& a, const HasSpaceship& b) { 526 return a < b; 527} 528</pre> 529</td> 530<td> 5311 match found. 532 533<pre> 534 return a < b; 535 ^~~~~ 536</pre> 537 538</td> 539<td> 540No match found. 541</td> 542</tr> 543</table> 544 545<!-- ======================================================================= --> 546<h2 id="decl-matchers">Node Matchers</h2> 547<!-- ======================================================================= --> 548 549<p>Node matchers are at the core of matcher expressions - they specify the type 550of node that is expected. Every match expression starts with a node matcher, 551which can then be further refined with a narrowing or traversal matcher. All 552traversal matchers take node matchers as their arguments.</p> 553 554<p>For convenience, all node matchers take an arbitrary number of arguments 555and implicitly act as allOf matchers.</p> 556 557<p>Node matchers are the only matchers that support the bind("id") call to 558bind the matched node to the given string, to be later retrieved from the 559match callback.</p> 560 561<p>It is important to remember that the arguments to node matchers are 562predicates on the same node, just with additional information about the type. 563This is often useful to make matcher expression more readable by inlining bind 564calls into redundant node matchers inside another node matcher: 565<pre> 566// This binds the CXXRecordDecl to "id", as the decl() matcher will stay on 567// the same node. 568recordDecl(decl().bind("id"), hasName("::MyClass")) 569</pre> 570</p> 571 572<table> 573<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 574<!-- START_DECL_MATCHERS --> 575 576<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>></td><td class="name" onclick="toggle('attr0')"><a name="attr0Anchor">attr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>>...</td></tr> 577<tr><td colspan="4" class="doc" id="attr0"><pre>Matches attributes. 578Attributes may be attached with a variety of different syntaxes (including 579keywords, C++11 attributes, GNU ``__attribute``` and MSVC `__declspec``, 580and ``#pragma``s). They may also be implicit. 581 582Given 583 struct [[nodiscard]] Foo{}; 584 void bar(int * __attribute__((nonnull)) ); 585 __declspec(noinline) void baz(); 586 587 #pragma omp declare simd 588 int min(); 589attr() 590 matches "nodiscard", "nonnull", "noinline", and the whole "#pragma" line. 591</pre></td></tr> 592 593 594<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>></td><td class="name" onclick="toggle('cxxBaseSpecifier0')"><a name="cxxBaseSpecifier0Anchor">cxxBaseSpecifier</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>...</td></tr> 595<tr><td colspan="4" class="doc" id="cxxBaseSpecifier0"><pre>Matches class bases. 596 597Examples matches public virtual B. 598 class B {}; 599 class C : public virtual B {}; 600</pre></td></tr> 601 602 603<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>...</td></tr> 604<tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers. 605 606Examples matches i(42). 607 class C { 608 C() : i(42) {} 609 int i; 610 }; 611</pre></td></tr> 612 613 614<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AccessSpecDecl.html">AccessSpecDecl</a>>...</td></tr> 615<tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations. 616 617Given 618 class C { 619 public: 620 int a; 621 }; 622accessSpecDecl() 623 matches 'public:' 624</pre></td></tr> 625 626 627<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('bindingDecl0')"><a name="bindingDecl0Anchor">bindingDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html">BindingDecl</a>>...</td></tr> 628<tr><td colspan="4" class="doc" id="bindingDecl0"><pre>Matches binding declarations 629Example matches foo and bar 630(matcher = bindingDecl() 631 632 auto [foo, bar] = std::make_pair{42, 42}; 633</pre></td></tr> 634 635 636<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('blockDecl0')"><a name="blockDecl0Anchor">blockDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>...</td></tr> 637<tr><td colspan="4" class="doc" id="blockDecl0"><pre>Matches block declarations. 638 639Example matches the declaration of the nameless block printing an input 640integer. 641 642 myFunc(^(int p) { 643 printf("%d", p); 644 }) 645</pre></td></tr> 646 647 648<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>>...</td></tr> 649<tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations. 650 651Example matches Z 652 template<class T> class Z {}; 653</pre></td></tr> 654 655 656<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('classTemplatePartialSpecializationDecl0')"><a name="classTemplatePartialSpecializationDecl0Anchor">classTemplatePartialSpecializationDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplatePartialSpecializationDecl.html">ClassTemplatePartialSpecializationDecl</a>>...</td></tr> 657<tr><td colspan="4" class="doc" id="classTemplatePartialSpecializationDecl0"><pre>Matches C++ class template partial specializations. 658 659Given 660 template<class T1, class T2, int I> 661 class A {}; 662 663 template<class T, int I> 664 class A<T, T*, I> {}; 665 666 template<> 667 class A<int, int, 1> {}; 668classTemplatePartialSpecializationDecl() 669 matches the specialization A<T,T*,I> but not A<int,int,1> 670</pre></td></tr> 671 672 673<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>...</td></tr> 674<tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations. 675 676Given 677 template<typename T> class A {}; 678 template<> class A<double> {}; 679 A<int> a; 680classTemplateSpecializationDecl() 681 matches the specializations A<int> and A<double> 682</pre></td></tr> 683 684 685<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>>...</td></tr> 686<tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations. 687 688Example matches Foo::Foo() and Foo::Foo(int) 689 class Foo { 690 public: 691 Foo(); 692 Foo(int); 693 int DoSomething(); 694 }; 695</pre></td></tr> 696 697 698<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>>...</td></tr> 699<tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations. 700 701Example matches the operator. 702 class X { operator int() const; }; 703</pre></td></tr> 704 705 706<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxDeductionGuideDecl0')"><a name="cxxDeductionGuideDecl0Anchor">cxxDeductionGuideDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDeductionGuideDecl.html">CXXDeductionGuideDecl</a>>...</td></tr> 707<tr><td colspan="4" class="doc" id="cxxDeductionGuideDecl0"><pre>Matches user-defined and implicitly generated deduction guide. 708 709Example matches the deduction guide. 710 template<typename T> 711 class X { X(int) }; 712 X(int) -> X<int>; 713</pre></td></tr> 714 715 716<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>>...</td></tr> 717<tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations. 718 719Example matches Foo::~Foo() 720 class Foo { 721 public: 722 virtual ~Foo(); 723 }; 724</pre></td></tr> 725 726 727<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>>...</td></tr> 728<tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations. 729 730Example matches y 731 class X { void y(); }; 732</pre></td></tr> 733 734 735<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>...</td></tr> 736<tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations. 737 738Example matches X, Z 739 class X; 740 template<class T> class Z {}; 741</pre></td></tr> 742 743 744<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>...</td></tr> 745<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. 746 747Examples matches X, C, and the friend declaration inside C; 748 void X(); 749 class C { 750 friend X; 751 }; 752</pre></td></tr> 753 754 755<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>...</td></tr> 756<tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function 757and non-type template parameter declarations). 758 759Given 760 class X { int y; }; 761declaratorDecl() 762 matches int y. 763</pre></td></tr> 764 765 766<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('decompositionDecl0')"><a name="decompositionDecl0Anchor">decompositionDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html">DecompositionDecl</a>>...</td></tr> 767<tr><td colspan="4" class="doc" id="decompositionDecl0"><pre>Matches decomposition-declarations. 768 769Examples matches the declaration node with foo and bar, but not 770number. 771(matcher = declStmt(has(decompositionDecl()))) 772 773 int number = 42; 774 auto [foo, bar] = std::make_pair{42, 42}; 775</pre></td></tr> 776 777 778<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html">EnumConstantDecl</a>>...</td></tr> 779<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. 780 781Example matches A, B, C 782 enum X { 783 A, B, C 784 }; 785</pre></td></tr> 786 787 788<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>>...</td></tr> 789<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. 790 791Example matches X 792 enum X { 793 A, B, C 794 }; 795</pre></td></tr> 796 797 798<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>>...</td></tr> 799<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. 800 801Given 802 class X { int m; }; 803fieldDecl() 804 matches 'm'. 805</pre></td></tr> 806 807 808<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>>...</td></tr> 809<tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations. 810 811Given 812 class X { friend void foo(); }; 813friendDecl() 814 matches 'friend void foo()'. 815</pre></td></tr> 816 817 818<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>...</td></tr> 819<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. 820 821Example matches f 822 void f(); 823</pre></td></tr> 824 825 826<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FunctionTemplateDecl.html">FunctionTemplateDecl</a>>...</td></tr> 827<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. 828 829Example matches f 830 template<class T> void f(T t) {} 831</pre></td></tr> 832 833 834<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('indirectFieldDecl0')"><a name="indirectFieldDecl0Anchor">indirectFieldDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IndirectFieldDecl.html">IndirectFieldDecl</a>>...</td></tr> 835<tr><td colspan="4" class="doc" id="indirectFieldDecl0"><pre>Matches indirect field declarations. 836 837Given 838 struct X { struct { int a; }; }; 839indirectFieldDecl() 840 matches 'a'. 841</pre></td></tr> 842 843 844<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('labelDecl0')"><a name="labelDecl0Anchor">labelDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelDecl.html">LabelDecl</a>>...</td></tr> 845<tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label. 846 847Given 848 goto FOO; 849 FOO: bar(); 850labelDecl() 851 matches 'FOO:' 852</pre></td></tr> 853 854 855<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1LinkageSpecDecl.html">LinkageSpecDecl</a>>...</td></tr> 856<tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification. 857 858Given 859 extern "C" {} 860linkageSpecDecl() 861 matches "extern "C" {}" 862</pre></td></tr> 863 864 865<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>>...</td></tr> 866<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. 867 868Example matches X, S, the anonymous union type, i, and U; 869 typedef int X; 870 struct S { 871 union { 872 int i; 873 } U; 874 }; 875</pre></td></tr> 876 877 878<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamespaceAliasDecl.html">NamespaceAliasDecl</a>>...</td></tr> 879<tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias. 880 881Given 882 namespace test {} 883 namespace alias = ::test; 884namespaceAliasDecl() 885 matches "namespace alias" but not "namespace test" 886</pre></td></tr> 887 888 889<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>>...</td></tr> 890<tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. 891 892Given 893 namespace {} 894 namespace test {} 895namespaceDecl() 896 matches "namespace {}" and "namespace test {}" 897</pre></td></tr> 898 899 900<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NonTypeTemplateParmDecl.html">NonTypeTemplateParmDecl</a>>...</td></tr> 901<tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations. 902 903Given 904 template <typename T, int N> struct C {}; 905nonTypeTemplateParmDecl() 906 matches 'N', but not 'T'. 907</pre></td></tr> 908 909 910<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcCategoryDecl0')"><a name="objcCategoryDecl0Anchor">objcCategoryDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryDecl.html">ObjCCategoryDecl</a>>...</td></tr> 911<tr><td colspan="4" class="doc" id="objcCategoryDecl0"><pre>Matches Objective-C category declarations. 912 913Example matches Foo (Additions) 914 @interface Foo (Additions) 915 @end 916</pre></td></tr> 917 918 919<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcCategoryImplDecl0')"><a name="objcCategoryImplDecl0Anchor">objcCategoryImplDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryImplDecl.html">ObjCCategoryImplDecl</a>>...</td></tr> 920<tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions. 921 922Example matches Foo (Additions) 923 @implementation Foo (Additions) 924 @end 925</pre></td></tr> 926 927 928<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcImplementationDecl0')"><a name="objcImplementationDecl0Anchor">objcImplementationDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html">ObjCImplementationDecl</a>>...</td></tr> 929<tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations. 930 931Example matches Foo 932 @implementation Foo 933 @end 934</pre></td></tr> 935 936 937<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>>...</td></tr> 938<tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations. 939 940Example matches Foo 941 @interface Foo 942 @end 943</pre></td></tr> 944 945 946<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcIvarDecl0')"><a name="objcIvarDecl0Anchor">objcIvarDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCIvarDecl.html">ObjCIvarDecl</a>>...</td></tr> 947<tr><td colspan="4" class="doc" id="objcIvarDecl0"><pre>Matches Objective-C instance variable declarations. 948 949Example matches _enabled 950 @implementation Foo { 951 BOOL _enabled; 952 } 953 @end 954</pre></td></tr> 955 956 957<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcMethodDecl0')"><a name="objcMethodDecl0Anchor">objcMethodDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>>...</td></tr> 958<tr><td colspan="4" class="doc" id="objcMethodDecl0"><pre>Matches Objective-C method declarations. 959 960Example matches both declaration and definition of -[Foo method] 961 @interface Foo 962 - (void)method; 963 @end 964 965 @implementation Foo 966 - (void)method {} 967 @end 968</pre></td></tr> 969 970 971<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcPropertyDecl0')"><a name="objcPropertyDecl0Anchor">objcPropertyDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>...</td></tr> 972<tr><td colspan="4" class="doc" id="objcPropertyDecl0"><pre>Matches Objective-C property declarations. 973 974Example matches enabled 975 @interface Foo 976 @property BOOL enabled; 977 @end 978</pre></td></tr> 979 980 981<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcProtocolDecl0')"><a name="objcProtocolDecl0Anchor">objcProtocolDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCProtocolDecl.html">ObjCProtocolDecl</a>>...</td></tr> 982<tr><td colspan="4" class="doc" id="objcProtocolDecl0"><pre>Matches Objective-C protocol declarations. 983 984Example matches FooDelegate 985 @protocol FooDelegate 986 @end 987</pre></td></tr> 988 989 990<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>>...</td></tr> 991<tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. 992 993Given 994 void f(int x); 995parmVarDecl() 996 matches int x. 997</pre></td></tr> 998 999 1000<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>>...</td></tr> 1001<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations. 1002 1003Example matches X, Z, U, and S 1004 class X; 1005 template<class T> class Z {}; 1006 struct S {}; 1007 union U {}; 1008</pre></td></tr> 1009 1010 1011<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1StaticAssertDecl.html">StaticAssertDecl</a>>...</td></tr> 1012<tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration. 1013 1014Example: 1015 staticAssertDecl() 1016matches 1017 static_assert(sizeof(S) == sizeof(int)) 1018in 1019 struct S { 1020 int x; 1021 }; 1022 static_assert(sizeof(S) == sizeof(int)); 1023</pre></td></tr> 1024 1025 1026<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('tagDecl0')"><a name="tagDecl0Anchor">tagDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>...</td></tr> 1027<tr><td colspan="4" class="doc" id="tagDecl0"><pre>Matches tag declarations. 1028 1029Example matches X, Z, U, S, E 1030 class X; 1031 template<class T> class Z {}; 1032 struct S {}; 1033 union U {}; 1034 enum E { 1035 A, B, C 1036 }; 1037</pre></td></tr> 1038 1039 1040<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('templateTemplateParmDecl0')"><a name="templateTemplateParmDecl0Anchor">templateTemplateParmDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTemplateParmDecl.html">TemplateTemplateParmDecl</a>>...</td></tr> 1041<tr><td colspan="4" class="doc" id="templateTemplateParmDecl0"><pre>Matches template template parameter declarations. 1042 1043Given 1044 template <template <typename> class Z, int N> struct C {}; 1045templateTypeParmDecl() 1046 matches 'Z', but not 'N'. 1047</pre></td></tr> 1048 1049 1050<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmDecl.html">TemplateTypeParmDecl</a>>...</td></tr> 1051<tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations. 1052 1053Given 1054 template <typename T, int N> struct C {}; 1055templateTypeParmDecl() 1056 matches 'T', but not 'N'. 1057</pre></td></tr> 1058 1059 1060<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TranslationUnitDecl.html">TranslationUnitDecl</a>>...</td></tr> 1061<tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context. 1062 1063Given 1064 int X; 1065 namespace NS { 1066 int Y; 1067 } // namespace NS 1068decl(hasDeclContext(translationUnitDecl())) 1069 matches "int X", but not "int Y". 1070</pre></td></tr> 1071 1072 1073<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typeAliasDecl0')"><a name="typeAliasDecl0Anchor">typeAliasDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeAliasDecl.html">TypeAliasDecl</a>>...</td></tr> 1074<tr><td colspan="4" class="doc" id="typeAliasDecl0"><pre>Matches type alias declarations. 1075 1076Given 1077 typedef int X; 1078 using Y = int; 1079typeAliasDecl() 1080 matches "using Y = int", but not "typedef int X" 1081</pre></td></tr> 1082 1083 1084<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typeAliasTemplateDecl0')"><a name="typeAliasTemplateDecl0Anchor">typeAliasTemplateDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeAliasTemplateDecl.html">TypeAliasTemplateDecl</a>>...</td></tr> 1085<tr><td colspan="4" class="doc" id="typeAliasTemplateDecl0"><pre>Matches type alias template declarations. 1086 1087typeAliasTemplateDecl() matches 1088 template <typename T> 1089 using Y = X<T>; 1090</pre></td></tr> 1091 1092 1093<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html">TypedefDecl</a>>...</td></tr> 1094<tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations. 1095 1096Given 1097 typedef int X; 1098 using Y = int; 1099typedefDecl() 1100 matches "typedef int X", but not "using Y = int" 1101</pre></td></tr> 1102 1103 1104<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typedefNameDecl0')"><a name="typedefNameDecl0Anchor">typedefNameDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>>...</td></tr> 1105<tr><td colspan="4" class="doc" id="typedefNameDecl0"><pre>Matches typedef name declarations. 1106 1107Given 1108 typedef int X; 1109 using Y = int; 1110typedefNameDecl() 1111 matches "typedef int X" and "using Y = int" 1112</pre></td></tr> 1113 1114 1115<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingTypenameDecl.html">UnresolvedUsingTypenameDecl</a>>...</td></tr> 1116<tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the 1117typename. 1118 1119Given 1120 template <typename T> 1121 struct Base { typedef T Foo; }; 1122 1123 template<typename T> 1124 struct S : private Base<T> { 1125 using typename Base<T>::Foo; 1126 }; 1127unresolvedUsingTypenameDecl() 1128 matches using Base<T>::Foo </pre></td></tr> 1129 1130 1131<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingValueDecl.html">UnresolvedUsingValueDecl</a>>...</td></tr> 1132<tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations. 1133 1134Given 1135 template<typename X> 1136 class C : private X { 1137 using X::x; 1138 }; 1139unresolvedUsingValueDecl() 1140 matches using X::x </pre></td></tr> 1141 1142 1143<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>>...</td></tr> 1144<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. 1145 1146Given 1147 namespace X { int x; } 1148 using X::x; 1149usingDecl() 1150 matches using X::x </pre></td></tr> 1151 1152 1153<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UsingDirectiveDecl.html">UsingDirectiveDecl</a>>...</td></tr> 1154<tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations. 1155 1156Given 1157 namespace X { int x; } 1158 using namespace X; 1159usingDirectiveDecl() 1160 matches using namespace X </pre></td></tr> 1161 1162 1163<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('usingEnumDecl0')"><a name="usingEnumDecl0Anchor">usingEnumDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingEnumDecl.html">UsingEnumDecl</a>>...</td></tr> 1164<tr><td colspan="4" class="doc" id="usingEnumDecl0"><pre>Matches using-enum declarations. 1165 1166Given 1167 namespace X { enum x {...}; } 1168 using enum X::x; 1169usingEnumDecl() 1170 matches using enum X::x </pre></td></tr> 1171 1172 1173<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>...</td></tr> 1174<tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration. 1175 1176Example matches A, B, C and F 1177 enum X { A, B, C }; 1178 void F(); 1179</pre></td></tr> 1180 1181 1182<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>...</td></tr> 1183<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. 1184 1185Note: this does not match declarations of member variables, which are 1186"field" declarations in Clang parlance. 1187 1188Example matches a 1189 int a; 1190</pre></td></tr> 1191 1192 1193<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>></td><td class="name" onclick="toggle('lambdaCapture0')"><a name="lambdaCapture0Anchor">lambdaCapture</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>>...</td></tr> 1194<tr><td colspan="4" class="doc" id="lambdaCapture0"><pre>Matches lambda captures. 1195 1196Given 1197 int main() { 1198 int x; 1199 auto f = [x](){}; 1200 auto g = [x = 1](){}; 1201 } 1202In the matcher `lambdaExpr(hasAnyCapture(lambdaCapture()))`, 1203`lambdaCapture()` matches `x` and `x=1`. 1204</pre></td></tr> 1205 1206 1207<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>>...</td></tr> 1208<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. 1209</pre></td></tr> 1210 1211 1212<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>>...</td></tr> 1213<tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. 1214 1215Given 1216 namespace ns { 1217 struct A { static void f(); }; 1218 void A::f() {} 1219 void g() { A::f(); } 1220 } 1221 ns::A a; 1222nestedNameSpecifier() 1223 matches "ns::" and both "A::" 1224</pre></td></tr> 1225 1226 1227<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPClause.html">OMPClause</a>></td><td class="name" onclick="toggle('ompDefaultClause0')"><a name="ompDefaultClause0Anchor">ompDefaultClause</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>>...</td></tr> 1228<tr><td colspan="4" class="doc" id="ompDefaultClause0"><pre>Matches OpenMP ``default`` clause. 1229 1230Given 1231 1232 #pragma omp parallel default(none) 1233 #pragma omp parallel default(shared) 1234 #pragma omp parallel default(private) 1235 #pragma omp parallel default(firstprivate) 1236 #pragma omp parallel 1237 1238``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, 1239`` default(private)`` and ``default(firstprivate)`` 1240</pre></td></tr> 1241 1242 1243<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>...</td></tr> 1244<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. 1245</pre></td></tr> 1246 1247 1248<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('addrLabelExpr0')"><a name="addrLabelExpr0Anchor">addrLabelExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>...</td></tr> 1249<tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension). 1250 1251Given 1252 FOO: bar(); 1253 void *ptr = &&FOO; 1254 goto *bar; 1255addrLabelExpr() 1256 matches '&&FOO' 1257</pre></td></tr> 1258 1259 1260<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>>...</td></tr> 1261<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. 1262 1263Given 1264 int i = a[1]; 1265arraySubscriptExpr() 1266 matches "a[1]" 1267</pre></td></tr> 1268 1269 1270<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AsmStmt.html">AsmStmt</a>>...</td></tr> 1271<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. 1272 1273 int i = 100; 1274 __asm("mov al, 2"); 1275asmStmt() 1276 matches '__asm("mov al, 2")' 1277</pre></td></tr> 1278 1279 1280<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('atomicExpr0')"><a name="atomicExpr0Anchor">atomicExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicExpr.html">AtomicExpr</a>>...</td></tr> 1281<tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins. 1282Example matches __atomic_load_n(ptr, 1) 1283 void foo() { int *ptr; __atomic_load_n(ptr, 1); } 1284</pre></td></tr> 1285 1286 1287<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('autoreleasePoolStmt0')"><a name="autoreleasePoolStmt0Anchor">autoreleasePoolStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCAutoreleasePoolStmt.html">ObjCAutoreleasePoolStmt</a>>...</td></tr> 1288<tr><td colspan="4" class="doc" id="autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement. 1289 1290Given 1291 @autoreleasepool { 1292 int x = 0; 1293 } 1294autoreleasePoolStmt(stmt()) matches the declaration of "x" 1295inside the autorelease pool. 1296</pre></td></tr> 1297 1298 1299<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('binaryConditionalOperator0')"><a name="binaryConditionalOperator0Anchor">binaryConditionalOperator</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryConditionalOperator.html">BinaryConditionalOperator</a>>...</td></tr> 1300<tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension). 1301 1302Example matches a ?: b 1303 (a ?: b) + 42; 1304</pre></td></tr> 1305 1306 1307<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>>...</td></tr> 1308<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. 1309 1310Example matches a || b 1311 !(a || b) 1312See also the binaryOperation() matcher for more-general matching. 1313</pre></td></tr> 1314 1315 1316<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('blockExpr0')"><a name="blockExpr0Anchor">blockExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockExpr.html">BlockExpr</a>>...</td></tr> 1317<tr><td colspan="4" class="doc" id="blockExpr0"><pre>Matches a reference to a block. 1318 1319Example: matches "^{}": 1320 void f() { ^{}(); } 1321</pre></td></tr> 1322 1323 1324<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BreakStmt.html">BreakStmt</a>>...</td></tr> 1325<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. 1326 1327Given 1328 while (true) { break; } 1329breakStmt() 1330 matches 'break' 1331</pre></td></tr> 1332 1333 1334<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CStyleCastExpr.html">CStyleCastExpr</a>>...</td></tr> 1335<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. 1336 1337Example: Matches (int) 2.2f in 1338 int i = (int) 2.2f; 1339</pre></td></tr> 1340 1341 1342<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>...</td></tr> 1343<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. 1344 1345Example matches x.y() and y() 1346 X x; 1347 x.y(); 1348 y(); 1349</pre></td></tr> 1350 1351 1352<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>>...</td></tr> 1353<tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. 1354 1355Given 1356 switch(a) { case 42: break; default: break; } 1357caseStmt() 1358 matches 'case 42:'. 1359</pre></td></tr> 1360 1361 1362<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>>...</td></tr> 1363<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. 1364 1365Example: castExpr() matches each of the following: 1366 (int) 3; 1367 const_cast<Expr *>(SubExpr); 1368 char c = 0; 1369but does not match 1370 int i = (0); 1371 int k = 0; 1372</pre></td></tr> 1373 1374 1375<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>...</td></tr> 1376<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). 1377 1378Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), 1379though. 1380 1381Example matches 'a', L'a' 1382 char ch = 'a'; 1383 wchar_t chw = L'a'; 1384</pre></td></tr> 1385 1386 1387<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('chooseExpr0')"><a name="chooseExpr0Anchor">chooseExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ChooseExpr.html">ChooseExpr</a>>...</td></tr> 1388<tr><td colspan="4" class="doc" id="chooseExpr0"><pre>Matches GNU __builtin_choose_expr. 1389</pre></td></tr> 1390 1391 1392<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('coawaitExpr0')"><a name="coawaitExpr0Anchor">coawaitExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CoawaitExpr.html">CoawaitExpr</a>>...</td></tr> 1393<tr><td colspan="4" class="doc" id="coawaitExpr0"><pre>Matches co_await expressions. 1394 1395Given 1396 co_await 1; 1397coawaitExpr() 1398 matches 'co_await 1' 1399</pre></td></tr> 1400 1401 1402<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>...</td></tr> 1403<tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals 1404 1405Example match: {1}, (1, 2) 1406 int array[4] = {1}; 1407 vector int myvec = (vector int)(1, 2); 1408</pre></td></tr> 1409 1410 1411<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>>...</td></tr> 1412<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. 1413 1414Example matches '{}' and '{{}}' in 'for (;;) {{}}' 1415 for (;;) {{}} 1416</pre></td></tr> 1417 1418 1419<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>>...</td></tr> 1420<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. 1421 1422Example matches a ? b : c 1423 (a ? b : c) + 42 1424</pre></td></tr> 1425 1426 1427<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('constantExpr0')"><a name="constantExpr0Anchor">constantExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ConstantExpr.html">ConstantExpr</a>>...</td></tr> 1428<tr><td colspan="4" class="doc" id="constantExpr0"><pre>Matches a constant expression wrapper. 1429 1430Example matches the constant in the case statement: 1431 (matcher = constantExpr()) 1432 switch (a) { 1433 case 37: break; 1434 } 1435</pre></td></tr> 1436 1437 1438<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ContinueStmt.html">ContinueStmt</a>>...</td></tr> 1439<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. 1440 1441Given 1442 while (true) { continue; } 1443continueStmt() 1444 matches 'continue' 1445</pre></td></tr> 1446 1447 1448<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('coreturnStmt0')"><a name="coreturnStmt0Anchor">coreturnStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CoreturnStmt.html">CoreturnStmt</a>>...</td></tr> 1449<tr><td colspan="4" class="doc" id="coreturnStmt0"><pre>Matches co_return statements. 1450 1451Given 1452 while (true) { co_return; } 1453coreturnStmt() 1454 matches 'co_return' 1455</pre></td></tr> 1456 1457 1458<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('coyieldExpr0')"><a name="coyieldExpr0Anchor">coyieldExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CoyieldExpr.html">CoyieldExpr</a>>...</td></tr> 1459<tr><td colspan="4" class="doc" id="coyieldExpr0"><pre>Matches co_yield expressions. 1460 1461Given 1462 co_yield 1; 1463coyieldExpr() 1464 matches 'co_yield 1' 1465</pre></td></tr> 1466 1467 1468<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr</a>>...</td></tr> 1469<tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression. 1470 1471Example matches, 1472 kernel<<<i,j>>>(); 1473</pre></td></tr> 1474 1475 1476<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>>...</td></tr> 1477<tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created. 1478 1479Example matches FunctionTakesString(GetStringByValue()) 1480 (matcher = cxxBindTemporaryExpr()) 1481 FunctionTakesString(GetStringByValue()); 1482 FunctionTakesStringByPointer(GetStringPointer()); 1483</pre></td></tr> 1484 1485 1486<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>...</td></tr> 1487<tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals. 1488 1489Example matches true 1490 true 1491</pre></td></tr> 1492 1493 1494<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>>...</td></tr> 1495<tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements. 1496 1497 try {} catch(int i) {} 1498cxxCatchStmt() 1499 matches 'catch(int i)' 1500</pre></td></tr> 1501 1502 1503<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>>...</td></tr> 1504<tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression. 1505 1506Example: Matches const_cast<int*>(&r) in 1507 int n = 42; 1508 const int &r(n); 1509 int* p = const_cast<int*>(&r); 1510</pre></td></tr> 1511 1512 1513<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>...</td></tr> 1514<tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones). 1515 1516Example matches string(ptr, n) and ptr within arguments of f 1517 (matcher = cxxConstructExpr()) 1518 void f(const string &a, const string &b); 1519 char *ptr; 1520 int n; 1521 f(string(ptr, n), ptr); 1522</pre></td></tr> 1523 1524 1525<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>>...</td></tr> 1526<tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site. 1527 1528Example matches the CXXDefaultArgExpr placeholder inserted for the 1529 default value of the second parameter in the call expression f(42) 1530 (matcher = cxxDefaultArgExpr()) 1531 void f(int x, int y = 0); 1532 f(42); 1533</pre></td></tr> 1534 1535 1536<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>>...</td></tr> 1537<tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions. 1538 1539Given 1540 delete X; 1541cxxDeleteExpr() 1542 matches 'delete X'. 1543</pre></td></tr> 1544 1545 1546<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDependentScopeMemberExpr0')"><a name="cxxDependentScopeMemberExpr0Anchor">cxxDependentScopeMemberExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>>...</td></tr> 1547<tr><td colspan="4" class="doc" id="cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be 1548resolved because the base expression or the member name was dependent. 1549 1550Given 1551 template <class T> void f() { T t; t.g(); } 1552cxxDependentScopeMemberExpr() 1553 matches t.g 1554</pre></td></tr> 1555 1556 1557<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>>...</td></tr> 1558<tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression. 1559 1560Example: 1561 cxxDynamicCastExpr() 1562matches 1563 dynamic_cast<D*>(&b); 1564in 1565 struct B { virtual ~B() {} }; struct D : B {}; 1566 B b; 1567 D* p = dynamic_cast<D*>(&b); 1568</pre></td></tr> 1569 1570 1571<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>>...</td></tr> 1572<tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements. 1573 1574cxxForRangeStmt() matches 'for (auto a : i)' 1575 int i[] = {1, 2, 3}; for (auto a : i); 1576 for(int j = 0; j < 5; ++j); 1577</pre></td></tr> 1578 1579 1580<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>...</td></tr> 1581<tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions 1582 1583Example: Matches Foo(bar); 1584 Foo f = bar; 1585 Foo g = (Foo) bar; 1586 Foo h = Foo(bar); 1587</pre></td></tr> 1588 1589 1590<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>>...</td></tr> 1591<tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions. 1592 1593Example matches x.y() 1594 X x; 1595 x.y(); 1596</pre></td></tr> 1597 1598 1599<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>...</td></tr> 1600<tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions. 1601 1602Given 1603 new X; 1604cxxNewExpr() 1605 matches 'new X'. 1606</pre></td></tr> 1607 1608 1609<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxNoexceptExpr0')"><a name="cxxNoexceptExpr0Anchor">cxxNoexceptExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNoexceptExpr.html">CXXNoexceptExpr</a>>...</td></tr> 1610<tr><td colspan="4" class="doc" id="cxxNoexceptExpr0"><pre>Matches noexcept expressions. 1611 1612Given 1613 bool a() noexcept; 1614 bool b() noexcept(true); 1615 bool c() noexcept(false); 1616 bool d() noexcept(noexcept(a())); 1617 bool e = noexcept(b()) || noexcept(c()); 1618cxxNoexceptExpr() 1619 matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`. 1620 doesn't match the noexcept specifier in the declarations a, b, c or d. 1621</pre></td></tr> 1622 1623 1624<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>>...</td></tr> 1625<tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal. 1626</pre></td></tr> 1627 1628 1629<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>...</td></tr> 1630<tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls. 1631 1632Note that if an operator isn't overloaded, it won't match. Instead, use 1633binaryOperator matcher. 1634Currently it does not match operators such as new delete. 1635FIXME: figure out why these do not match? 1636 1637Example matches both operator<<((o << b), c) and operator<<(o, b) 1638 (matcher = cxxOperatorCallExpr()) 1639 ostream &operator<< (ostream &out, int i) { }; 1640 ostream &o; int b = 1, c = 1; 1641 o << b << c; 1642See also the binaryOperation() matcher for more-general matching of binary 1643uses of this AST node. 1644</pre></td></tr> 1645 1646 1647<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>>...</td></tr> 1648<tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. 1649 1650Either the source expression or the destination type can be matched 1651using has(), but hasDestinationType() is more specific and can be 1652more readable. 1653 1654Example matches reinterpret_cast<char*>(&p) in 1655 void* p = reinterpret_cast<char*>(&p); 1656</pre></td></tr> 1657 1658 1659<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxRewrittenBinaryOperator0')"><a name="cxxRewrittenBinaryOperator0Anchor">cxxRewrittenBinaryOperator</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>>...</td></tr> 1660<tr><td colspan="4" class="doc" id="cxxRewrittenBinaryOperator0"><pre>Matches rewritten binary operators 1661 1662Example matches use of "<": 1663 #include <compare> 1664 struct HasSpaceshipMem { 1665 int a; 1666 constexpr auto operator<=>(const HasSpaceshipMem&) const = default; 1667 }; 1668 void compare() { 1669 HasSpaceshipMem hs1, hs2; 1670 if (hs1 < hs2) 1671 return; 1672 } 1673See also the binaryOperation() matcher for more-general matching 1674of this AST node. 1675</pre></td></tr> 1676 1677 1678<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>>...</td></tr> 1679<tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression. 1680 1681See also: hasDestinationType 1682See also: reinterpretCast 1683 1684Example: 1685 cxxStaticCastExpr() 1686matches 1687 static_cast<long>(8) 1688in 1689 long eight(static_cast<long>(8)); 1690</pre></td></tr> 1691 1692 1693<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxStdInitializerListExpr0')"><a name="cxxStdInitializerListExpr0Anchor">cxxStdInitializerListExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXStdInitializerListExpr.html">CXXStdInitializerListExpr</a>>...</td></tr> 1694<tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions. 1695 1696Given 1697 std::vector<int> a({ 1, 2, 3 }); 1698 std::vector<int> b = { 4, 5 }; 1699 int c[] = { 6, 7 }; 1700 std::pair<int, int> d = { 8, 9 }; 1701cxxStdInitializerListExpr() 1702 matches "{ 1, 2, 3 }" and "{ 4, 5 }" 1703</pre></td></tr> 1704 1705 1706<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>...</td></tr> 1707<tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments 1708 1709Example: Matches Foo(bar, bar) 1710 Foo h = Foo(bar, bar); 1711</pre></td></tr> 1712 1713 1714<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>>...</td></tr> 1715<tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions. 1716 1717Example matches the implicit this expression in "return i". 1718 (matcher = cxxThisExpr()) 1719struct foo { 1720 int i; 1721 int f() { return i; } 1722}; 1723</pre></td></tr> 1724 1725 1726<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>>...</td></tr> 1727<tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions. 1728 1729 try { throw 5; } catch(int i) {} 1730cxxThrowExpr() 1731 matches 'throw 5' 1732</pre></td></tr> 1733 1734 1735<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>>...</td></tr> 1736<tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements. 1737 1738 try {} catch(int i) {} 1739cxxTryStmt() 1740 matches 'try {}' 1741</pre></td></tr> 1742 1743 1744<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>...</td></tr> 1745<tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. 1746 1747Example matches T(t) in return statement of f 1748 (matcher = cxxUnresolvedConstructExpr()) 1749 template <typename T> 1750 void f(const T& t) { return T(t); } 1751</pre></td></tr> 1752 1753 1754<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>...</td></tr> 1755<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. 1756 1757Example matches x in if (x) 1758 bool x; 1759 if (x) {} 1760</pre></td></tr> 1761 1762 1763<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>>...</td></tr> 1764<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. 1765 1766Given 1767 int a; 1768declStmt() 1769 matches 'int a'. 1770</pre></td></tr> 1771 1772 1773<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DefaultStmt.html">DefaultStmt</a>>...</td></tr> 1774<tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. 1775 1776Given 1777 switch(a) { case 42: break; default: break; } 1778defaultStmt() 1779 matches 'default:'. 1780</pre></td></tr> 1781 1782 1783<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('dependentCoawaitExpr0')"><a name="dependentCoawaitExpr0Anchor">dependentCoawaitExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentCoawaitExpr.html">DependentCoawaitExpr</a>>...</td></tr> 1784<tr><td colspan="4" class="doc" id="dependentCoawaitExpr0"><pre>Matches co_await expressions where the type of the promise is dependent 1785</pre></td></tr> 1786 1787 1788<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('designatedInitExpr0')"><a name="designatedInitExpr0Anchor">designatedInitExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DesignatedInitExpr.html">DesignatedInitExpr</a>>...</td></tr> 1789<tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8]. 1790 1791Example: Matches { [2].y = 1.0, [0].x = 1.0 } 1792 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; 1793</pre></td></tr> 1794 1795 1796<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>>...</td></tr> 1797<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. 1798 1799Given 1800 do {} while (true); 1801doStmt() 1802 matches 'do {} while(true)' 1803</pre></td></tr> 1804 1805 1806<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>...</td></tr> 1807<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. 1808 1809Matches any cast expression written in user code, whether it be a 1810C-style cast, a functional-style cast, or a keyword cast. 1811 1812Does not match implicit conversions. 1813 1814Note: the name "explicitCast" is chosen to match Clang's terminology, as 1815Clang uses the term "cast" to apply to implicit conversions as well as to 1816actual cast expressions. 1817 1818See also: hasDestinationType. 1819 1820Example: matches all five of the casts in 1821 int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) 1822but does not match the implicit conversion in 1823 long ell = 42; 1824</pre></td></tr> 1825 1826 1827<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>...</td></tr> 1828<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. 1829 1830Example matches x() 1831 void f() { x(); } 1832</pre></td></tr> 1833 1834 1835<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ExprWithCleanups.html">ExprWithCleanups</a>>...</td></tr> 1836<tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end 1837of the sub-expression's evaluation. 1838 1839Example matches std::string() 1840 const std::string str = std::string(); 1841</pre></td></tr> 1842 1843 1844<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('fixedPointLiteral0')"><a name="fixedPointLiteral0Anchor">fixedPointLiteral</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FixedPointLiteral.html">FixedPointLiteral</a>>...</td></tr> 1845<tr><td colspan="4" class="doc" id="fixedPointLiteral0"><pre>Matches fixed point literals 1846</pre></td></tr> 1847 1848 1849<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>...</td></tr> 1850<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g. 18511.0, 1.0f, 1.0L and 1e10. 1852 1853Does not match implicit conversions such as 1854 float a = 10; 1855</pre></td></tr> 1856 1857 1858<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>>...</td></tr> 1859<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. 1860 1861Example matches 'for (;;) {}' 1862 for (;;) {} 1863 int i[] = {1, 2, 3}; for (auto a : i); 1864</pre></td></tr> 1865 1866 1867<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('genericSelectionExpr0')"><a name="genericSelectionExpr0Anchor">genericSelectionExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1GenericSelectionExpr.html">GenericSelectionExpr</a>>...</td></tr> 1868<tr><td colspan="4" class="doc" id="genericSelectionExpr0"><pre>Matches C11 _Generic expression. 1869</pre></td></tr> 1870 1871 1872<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1GNUNullExpr.html">GNUNullExpr</a>>...</td></tr> 1873<tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. 1874</pre></td></tr> 1875 1876 1877<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1GotoStmt.html">GotoStmt</a>>...</td></tr> 1878<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. 1879 1880Given 1881 goto FOO; 1882 FOO: bar(); 1883gotoStmt() 1884 matches 'goto FOO' 1885</pre></td></tr> 1886 1887 1888<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>>...</td></tr> 1889<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. 1890 1891Example matches 'if (x) {}' 1892 if (x) {} 1893</pre></td></tr> 1894 1895 1896<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('imaginaryLiteral0')"><a name="imaginaryLiteral0Anchor">imaginaryLiteral</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ImaginaryLiteral.html">ImaginaryLiteral</a>>...</td></tr> 1897<tr><td colspan="4" class="doc" id="imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating 1898point literals e.g.: 1i, 1.0i 1899</pre></td></tr> 1900 1901 1902<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr</a>>...</td></tr> 1903<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. 1904 1905This matches many different places, including function call return value 1906eliding, as well as any type conversions. 1907</pre></td></tr> 1908 1909 1910<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('implicitValueInitExpr0')"><a name="implicitValueInitExpr0Anchor">implicitValueInitExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ImplicitValueInitExpr.html">ImplicitValueInitExpr</a>>...</td></tr> 1911<tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions. 1912 1913Given 1914 point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; 1915implicitValueInitExpr() 1916 matches "[0].y" (implicitly) 1917</pre></td></tr> 1918 1919 1920<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>>...</td></tr> 1921<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. 1922 1923Given 1924 int a[] = { 1, 2 }; 1925 struct B { int x, y; }; 1926 B b = { 5, 6 }; 1927initListExpr() 1928 matches "{ 1, 2 }" and "{ 5, 6 }" 1929</pre></td></tr> 1930 1931 1932<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>...</td></tr> 1933<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g. 19341, 1L, 0x1 and 1U. 1935 1936Does not match character-encoded integers such as L'a'. 1937</pre></td></tr> 1938 1939 1940<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>...</td></tr> 1941<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. 1942 1943Given 1944 goto FOO; 1945 FOO: bar(); 1946labelStmt() 1947 matches 'FOO:' 1948</pre></td></tr> 1949 1950 1951<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>>...</td></tr> 1952<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. 1953 1954Example matches [&](){return 5;} 1955 [&](){return 5;} 1956</pre></td></tr> 1957 1958 1959<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1MaterializeTemporaryExpr.html">MaterializeTemporaryExpr</a>>...</td></tr> 1960<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. 1961 1962Example: Given 1963 struct T {void func();}; 1964 T f(); 1965 void g(T); 1966materializeTemporaryExpr() matches 'f()' in these statements 1967 T u(f()); 1968 g(f()); 1969 f().func(); 1970but does not match 1971 f(); 1972</pre></td></tr> 1973 1974 1975<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>...</td></tr> 1976<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. 1977 1978Given 1979 class Y { 1980 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 1981 int a; static int b; 1982 }; 1983memberExpr() 1984 matches this->x, x, y.x, a, this->b 1985</pre></td></tr> 1986 1987 1988<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NullStmt.html">NullStmt</a>>...</td></tr> 1989<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. 1990 1991 foo();; 1992nullStmt() 1993 matches the second ';' 1994</pre></td></tr> 1995 1996 1997<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcCatchStmt0')"><a name="objcCatchStmt0Anchor">objcCatchStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtCatchStmt.html">ObjCAtCatchStmt</a>>...</td></tr> 1998<tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements. 1999 2000Example matches @catch 2001 @try {} 2002 @catch (...) {} 2003</pre></td></tr> 2004 2005 2006<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcFinallyStmt0')"><a name="objcFinallyStmt0Anchor">objcFinallyStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtFinallyStmt.html">ObjCAtFinallyStmt</a>>...</td></tr> 2007<tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements. 2008 2009Example matches @finally 2010 @try {} 2011 @finally {} 2012</pre></td></tr> 2013 2014 2015<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcIvarRefExpr0')"><a name="objcIvarRefExpr0Anchor">objcIvarRefExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCIvarRefExpr.html">ObjCIvarRefExpr</a>>...</td></tr> 2016<tr><td colspan="4" class="doc" id="objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar. 2017 2018Example: matches "a" in "init" method: 2019@implementation A { 2020 NSString *a; 2021} 2022- (void) init { 2023 a = @"hello"; 2024} 2025</pre></td></tr> 2026 2027 2028<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>>...</td></tr> 2029<tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions. 2030 2031The innermost message send invokes the "alloc" class method on the 2032NSString class, while the outermost message send invokes the 2033"initWithString" instance method on the object returned from 2034NSString's "alloc". This matcher should match both message sends. 2035 [[NSString alloc] initWithString:@"Hello"] 2036</pre></td></tr> 2037 2038 2039<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcStringLiteral0')"><a name="objcStringLiteral0Anchor">objcStringLiteral</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCStringLiteral.html">ObjCStringLiteral</a>>...</td></tr> 2040<tr><td colspan="4" class="doc" id="objcStringLiteral0"><pre>Matches ObjectiveC String literal expressions. 2041 2042Example matches @"abcd" 2043 NSString *s = @"abcd"; 2044</pre></td></tr> 2045 2046 2047<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcThrowStmt0')"><a name="objcThrowStmt0Anchor">objcThrowStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtThrowStmt.html">ObjCAtThrowStmt</a>>...</td></tr> 2048<tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements. 2049 2050Example matches @throw obj; 2051</pre></td></tr> 2052 2053 2054<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcTryStmt0')"><a name="objcTryStmt0Anchor">objcTryStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtTryStmt.html">ObjCAtTryStmt</a>>...</td></tr> 2055<tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements. 2056 2057Example matches @try 2058 @try {} 2059 @catch (...) {} 2060</pre></td></tr> 2061 2062 2063<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('ompExecutableDirective0')"><a name="ompExecutableDirective0Anchor">ompExecutableDirective</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective</a>>...</td></tr> 2064<tr><td colspan="4" class="doc" id="ompExecutableDirective0"><pre>Matches any ``#pragma omp`` executable directive. 2065 2066Given 2067 2068 #pragma omp parallel 2069 #pragma omp parallel default(none) 2070 #pragma omp taskyield 2071 2072``ompExecutableDirective()`` matches ``omp parallel``, 2073``omp parallel default(none)`` and ``omp taskyield``. 2074</pre></td></tr> 2075 2076 2077<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('opaqueValueExpr0')"><a name="opaqueValueExpr0Anchor">opaqueValueExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html">OpaqueValueExpr</a>>...</td></tr> 2078<tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers 2079to reference another expressions and can be met 2080in BinaryConditionalOperators, for example. 2081 2082Example matches 'a' 2083 (a ?: c) + 42; 2084</pre></td></tr> 2085 2086 2087<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('parenExpr0')"><a name="parenExpr0Anchor">parenExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenExpr.html">ParenExpr</a>>...</td></tr> 2088<tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions. 2089 2090Example matches (foo() + 1) 2091 int foo() { return 1; } 2092 int a = (foo() + 1); 2093</pre></td></tr> 2094 2095 2096<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('parenListExpr0')"><a name="parenListExpr0Anchor">parenListExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenListExpr.html">ParenListExpr</a>>...</td></tr> 2097<tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions. 2098ParenListExprs don't have a predefined type and are used for late parsing. 2099In the final AST, they can be met in template declarations. 2100 2101Given 2102 template<typename T> class X { 2103 void f() { 2104 X x(*this); 2105 int a = 0, b = 1; int i = (a, b); 2106 } 2107 }; 2108parenListExpr() matches "*this" but NOT matches (a, b) because (a, b) 2109has a predefined type and is a ParenExpr, not a ParenListExpr. 2110</pre></td></tr> 2111 2112 2113<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('predefinedExpr0')"><a name="predefinedExpr0Anchor">predefinedExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PredefinedExpr.html">PredefinedExpr</a>>...</td></tr> 2114<tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2]. 2115 2116Example: Matches __func__ 2117 printf("%s", __func__); 2118</pre></td></tr> 2119 2120 2121<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>>...</td></tr> 2122<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. 2123 2124Given 2125 return 1; 2126returnStmt() 2127 matches 'return 1' 2128</pre></td></tr> 2129 2130 2131<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>...</td></tr> 2132<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. 2133 2134Given 2135 { ++a; } 2136stmt() 2137 matches both the compound statement '{ ++a; }' and '++a'. 2138</pre></td></tr> 2139 2140 2141<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('stmtExpr0')"><a name="stmtExpr0Anchor">stmtExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1StmtExpr.html">StmtExpr</a>>...</td></tr> 2142<tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension). 2143 2144Example match: ({ int X = 4; X; }) 2145 int C = ({ int X = 4; X; }); 2146</pre></td></tr> 2147 2148 2149<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>>...</td></tr> 2150<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). 2151 2152Example matches "abcd", L"abcd" 2153 char *s = "abcd"; 2154 wchar_t *ws = L"abcd"; 2155</pre></td></tr> 2156 2157 2158<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1SubstNonTypeTemplateParmExpr.html">SubstNonTypeTemplateParmExpr</a>>...</td></tr> 2159<tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. 2160 2161Given 2162 template <int N> 2163 struct A { static const int n = N; }; 2164 struct B : public A<42> {}; 2165substNonTypeTemplateParmExpr() 2166 matches "N" in the right-hand side of "static const int n = N;" 2167</pre></td></tr> 2168 2169 2170<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>>...</td></tr> 2171<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. 2172 2173Given 2174 switch(a) { case 42: break; default: break; } 2175switchCase() 2176 matches 'case 42:' and 'default:'. 2177</pre></td></tr> 2178 2179 2180<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>>...</td></tr> 2181<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. 2182 2183Given 2184 switch(a) { case 42: break; default: break; } 2185switchStmt() 2186 matches 'switch(a)'. 2187</pre></td></tr> 2188 2189 2190<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>>...</td></tr> 2191<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) 2192 2193Given 2194 Foo x = bar; 2195 int y = sizeof(x) + alignof(x); 2196unaryExprOrTypeTraitExpr() 2197 matches sizeof(x) and alignof(x) 2198</pre></td></tr> 2199 2200 2201<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>>...</td></tr> 2202<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. 2203 2204Example matches !a 2205 !a || b 2206</pre></td></tr> 2207 2208 2209<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unresolvedLookupExpr0')"><a name="unresolvedLookupExpr0Anchor">unresolvedLookupExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedLookupExpr.html">UnresolvedLookupExpr</a>>...</td></tr> 2210<tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing 2211but could not be resolved to a specific declaration. 2212 2213Given 2214 template<typename T> 2215 T foo() { T a; return a; } 2216 template<typename T> 2217 void bar() { 2218 foo<T>(); 2219 } 2220unresolvedLookupExpr() 2221 matches foo<T>() </pre></td></tr> 2222 2223 2224<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unresolvedMemberExpr0')"><a name="unresolvedMemberExpr0Anchor">unresolvedMemberExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html">UnresolvedMemberExpr</a>>...</td></tr> 2225<tr><td colspan="4" class="doc" id="unresolvedMemberExpr0"><pre>Matches unresolved member expressions. 2226 2227Given 2228 struct X { 2229 template <class T> void f(); 2230 void g(); 2231 }; 2232 template <class T> void h() { X x; x.f<T>(); x.g(); } 2233unresolvedMemberExpr() 2234 matches x.f<T> 2235</pre></td></tr> 2236 2237 2238<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UserDefinedLiteral.html">UserDefinedLiteral</a>>...</td></tr> 2239<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. 2240 2241Example match: "foo"_suffix 2242</pre></td></tr> 2243 2244 2245<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>>...</td></tr> 2246<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. 2247 2248Given 2249 while (true) {} 2250whileStmt() 2251 matches 'while (true) {}'. 2252</pre></td></tr> 2253 2254 2255<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>></td><td class="name" onclick="toggle('templateArgumentLoc0')"><a name="templateArgumentLoc0Anchor">templateArgumentLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>...</td></tr> 2256<tr><td colspan="4" class="doc" id="templateArgumentLoc0"><pre>Matches template arguments (with location info). 2257 2258Given 2259 template <typename T> struct C {}; 2260 C<int> c; 2261templateArgumentLoc() 2262 matches 'int' in C<int>. 2263</pre></td></tr> 2264 2265 2266<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>>...</td></tr> 2267<tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. 2268 2269Given 2270 template <typename T> struct C {}; 2271 C<int> c; 2272templateArgument() 2273 matches 'int' in C<int>. 2274</pre></td></tr> 2275 2276 2277<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>></td><td class="name" onclick="toggle('templateName0')"><a name="templateName0Anchor">templateName</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>>...</td></tr> 2278<tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name. 2279 2280Given 2281 template <typename T> class X { }; 2282 X<int> xi; 2283templateName() 2284 matches 'X' in X<int>. 2285</pre></td></tr> 2286 2287 2288<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('elaboratedTypeLoc0')"><a name="elaboratedTypeLoc0Anchor">elaboratedTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedTypeLoc.html">ElaboratedTypeLoc</a>>...</td></tr> 2289<tr><td colspan="4" class="doc" id="elaboratedTypeLoc0"><pre>Matches C or C++ elaborated `TypeLoc`s. 2290 2291Given 2292 struct s {}; 2293 struct s ss; 2294elaboratedTypeLoc() 2295 matches the `TypeLoc` of the variable declaration of `ss`. 2296</pre></td></tr> 2297 2298 2299<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('pointerTypeLoc0')"><a name="pointerTypeLoc0Anchor">pointerTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>>...</td></tr> 2300<tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer `TypeLoc`s. 2301 2302Given 2303 int* x; 2304pointerTypeLoc() 2305 matches `int*`. 2306</pre></td></tr> 2307 2308 2309<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('qualifiedTypeLoc0')"><a name="qualifiedTypeLoc0Anchor">qualifiedTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualifiedTypeLoc.html">QualifiedTypeLoc</a>>...</td></tr> 2310<tr><td colspan="4" class="doc" id="qualifiedTypeLoc0"><pre>Matches `QualifiedTypeLoc`s in the clang AST. 2311 2312Given 2313 const int x = 0; 2314qualifiedTypeLoc() 2315 matches `const int`. 2316</pre></td></tr> 2317 2318 2319<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('referenceTypeLoc0')"><a name="referenceTypeLoc0Anchor">referenceTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>>...</td></tr> 2320<tr><td colspan="4" class="doc" id="referenceTypeLoc0"><pre>Matches reference `TypeLoc`s. 2321 2322Given 2323 int x = 3; 2324 int& l = x; 2325 int&& r = 3; 2326referenceTypeLoc() 2327 matches `int&` and `int&&`. 2328</pre></td></tr> 2329 2330 2331<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('templateSpecializationTypeLoc0')"><a name="templateSpecializationTypeLoc0Anchor">templateSpecializationTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>>...</td></tr> 2332<tr><td colspan="4" class="doc" id="templateSpecializationTypeLoc0"><pre>Matches template specialization `TypeLoc`s. 2333 2334Given 2335 template <typename T> class C {}; 2336 C<char> var; 2337varDecl(hasTypeLoc(templateSpecializationTypeLoc(typeLoc()))) 2338 matches `C<char> var`. 2339</pre></td></tr> 2340 2341 2342<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>...</td></tr> 2343<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. 2344</pre></td></tr> 2345 2346 2347<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>...</td></tr> 2348<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. 2349 2350Given 2351 int a[] = { 2, 3 }; 2352 int b[4]; 2353 void f() { int c[a[0]]; } 2354arrayType() 2355 matches "int a[]", "int b[4]" and "int c[a[0]]"; 2356</pre></td></tr> 2357 2358 2359<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>>...</td></tr> 2360<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. 2361 2362Given 2363 _Atomic(int) i; 2364atomicType() 2365 matches "_Atomic(int) i" 2366</pre></td></tr> 2367 2368 2369<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>>...</td></tr> 2370<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. 2371 2372Given: 2373 auto n = 4; 2374 int v[] = { 2, 3 } 2375 for (auto i : v) { } 2376autoType() 2377 matches "auto n" and "auto i" 2378</pre></td></tr> 2379 2380 2381<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>...</td></tr> 2382<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as 2383"void (^)(int)". 2384 2385The pointee is always required to be a FunctionType. 2386</pre></td></tr> 2387 2388 2389<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BuiltinType.html">BuiltinType</a>>...</td></tr> 2390<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. 2391 2392Given 2393 struct A {}; 2394 A a; 2395 int b; 2396 float c; 2397 bool d; 2398builtinType() 2399 matches "int b", "float c" and "bool d" 2400</pre></td></tr> 2401 2402 2403<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>>...</td></tr> 2404<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. 2405 2406Given 2407 _Complex float f; 2408complexType() 2409 matches "_Complex float f" 2410</pre></td></tr> 2411 2412 2413<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>>...</td></tr> 2414<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. 2415 2416Given 2417 void() { 2418 int a[2]; 2419 int b[] = { 2, 3 }; 2420 int c[b[0]]; 2421 } 2422constantArrayType() 2423 matches "int a[2]" 2424</pre></td></tr> 2425 2426 2427<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>>...</td></tr> 2428<tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type 2429Example matches i[] in declaration of f. 2430 (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) 2431Example matches i[1]. 2432 (matcher = expr(hasType(decayedType(hasDecayedType(pointerType()))))) 2433 void f(int i[]) { 2434 i[1] = 0; 2435 } 2436</pre></td></tr> 2437 2438 2439<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('decltypeType0')"><a name="decltypeType0Anchor">decltypeType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>>...</td></tr> 2440<tr><td colspan="4" class="doc" id="decltypeType0"><pre>Matches types nodes representing C++11 decltype(<expr>) types. 2441 2442Given: 2443 short i = 1; 2444 int j = 42; 2445 decltype(i + j) result = i + j; 2446decltypeType() 2447 matches "decltype(i + j)" 2448</pre></td></tr> 2449 2450 2451<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('deducedTemplateSpecializationType0')"><a name="deducedTemplateSpecializationType0Anchor">deducedTemplateSpecializationType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeducedTemplateSpecializationType.html">DeducedTemplateSpecializationType</a>>...</td></tr> 2452<tr><td colspan="4" class="doc" id="deducedTemplateSpecializationType0"><pre>Matches C++17 deduced template specialization types, e.g. deduced class 2453template types. 2454 2455Given 2456 template <typename T> 2457 class C { public: C(T); }; 2458 2459 C c(123); 2460deducedTemplateSpecializationType() matches the type in the declaration 2461of the variable c. 2462</pre></td></tr> 2463 2464 2465<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html">DependentSizedArrayType</a>>...</td></tr> 2466<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. 2467 2468Given 2469 template<typename T, int Size> 2470 class array { 2471 T data[Size]; 2472 }; 2473dependentSizedArrayType 2474 matches "T data[Size]" 2475</pre></td></tr> 2476 2477 2478<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>>...</td></tr> 2479<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a 2480qualified name. 2481 2482Given 2483 namespace N { 2484 namespace M { 2485 class D {}; 2486 } 2487 } 2488 class C {}; 2489 2490 class C c; 2491 N::M::D d; 2492 2493elaboratedType() matches the type of the variable declarations of both 2494c and d. 2495</pre></td></tr> 2496 2497 2498<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('enumType0')"><a name="enumType0Anchor">enumType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>...</td></tr> 2499<tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types. 2500 2501Given 2502 enum C { Green }; 2503 enum class S { Red }; 2504 2505 C c; 2506 S s; 2507 2508enumType() matches the type of the variable declarations of both c and 2509s. 2510</pre></td></tr> 2511 2512 2513<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('functionProtoType0')"><a name="functionProtoType0Anchor">functionProtoType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>>...</td></tr> 2514<tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes. 2515 2516Given 2517 int (*f)(int); 2518 void g(); 2519functionProtoType() 2520 matches "int (*f)(int)" and the type of "g" in C++ mode. 2521 In C mode, "g" is not matched because it does not contain a prototype. 2522</pre></td></tr> 2523 2524 2525<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FunctionType.html">FunctionType</a>>...</td></tr> 2526<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. 2527 2528Given 2529 int (*f)(int); 2530 void g(); 2531functionType() 2532 matches "int (*f)(int)" and the type of "g". 2533</pre></td></tr> 2534 2535 2536<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1IncompleteArrayType.html">IncompleteArrayType</a>>...</td></tr> 2537<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. 2538 2539Given 2540 int a[] = { 2, 3 }; 2541 int b[42]; 2542 void f(int c[]) { int d[a[0]]; }; 2543incompleteArrayType() 2544 matches "int a[]" and "int c[]" 2545</pre></td></tr> 2546 2547 2548<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>...</td></tr> 2549<tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types. 2550 2551Example matches S s, but not S<T> s. 2552 (matcher = parmVarDecl(hasType(injectedClassNameType()))) 2553 template <typename T> struct S { 2554 void f(S s); 2555 void g(S<T> s); 2556 }; 2557</pre></td></tr> 2558 2559 2560<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType</a>>...</td></tr> 2561<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. 2562 2563Given: 2564 int *a; 2565 int &b = *a; 2566 int &&c = 1; 2567 auto &d = b; 2568 auto &&e = c; 2569 auto &&f = 2; 2570 int g = 5; 2571 2572lValueReferenceType() matches the types of b, d, and e. e is 2573matched since the type is deduced as int& by reference collapsing rules. 2574</pre></td></tr> 2575 2576 2577<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>...</td></tr> 2578<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. 2579Given 2580 struct A { int i; } 2581 A::* ptr = A::i; 2582memberPointerType() 2583 matches "A::* ptr" 2584</pre></td></tr> 2585 2586 2587<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>>...</td></tr> 2588<tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from 2589a pointer type, despite being syntactically similar. 2590 2591Given 2592 int *a; 2593 2594 @interface Foo 2595 @end 2596 Foo *f; 2597pointerType() 2598 matches "Foo *f", but does not match "int *a". 2599</pre></td></tr> 2600 2601 2602<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>>...</td></tr> 2603<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. 2604 2605Given 2606 int (*ptr_to_array)[4]; 2607 int *array_of_ptrs[4]; 2608 2609varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not 2610array_of_ptrs. 2611</pre></td></tr> 2612 2613 2614<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>...</td></tr> 2615<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer 2616types. 2617 2618Given 2619 int *a; 2620 int &b = *a; 2621 int c = 5; 2622 2623 @interface Foo 2624 @end 2625 Foo *f; 2626pointerType() 2627 matches "int *a", but does not match "Foo *f". 2628</pre></td></tr> 2629 2630 2631<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType</a>>...</td></tr> 2632<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. 2633 2634Given: 2635 int *a; 2636 int &b = *a; 2637 int &&c = 1; 2638 auto &d = b; 2639 auto &&e = c; 2640 auto &&f = 2; 2641 int g = 5; 2642 2643rValueReferenceType() matches the types of c and f. e is not 2644matched as it is deduced to int& by reference collapsing rules. 2645</pre></td></tr> 2646 2647 2648<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>...</td></tr> 2649<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). 2650 2651Given 2652 class C {}; 2653 struct S {}; 2654 2655 C c; 2656 S s; 2657 2658recordType() matches the type of the variable declarations of both c 2659and s. 2660</pre></td></tr> 2661 2662 2663<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>...</td></tr> 2664<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. 2665 2666Given 2667 int *a; 2668 int &b = *a; 2669 int &&c = 1; 2670 auto &d = b; 2671 auto &&e = c; 2672 auto &&f = 2; 2673 int g = 5; 2674 2675referenceType() matches the types of b, c, d, e, and f. 2676</pre></td></tr> 2677 2678 2679<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html">SubstTemplateTypeParmType</a>>...</td></tr> 2680<tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a 2681template type parameter. 2682 2683Given 2684 template <typename T> 2685 void F(T t) { 2686 int i = 1 + t; 2687 } 2688 2689substTemplateTypeParmType() matches the type of 't' but not '1' 2690</pre></td></tr> 2691 2692 2693<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('tagType0')"><a name="tagType0Anchor">tagType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>...</td></tr> 2694<tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types). 2695 2696Given 2697 enum E {}; 2698 class C {}; 2699 2700 E e; 2701 C c; 2702 2703tagType() matches the type of the variable declarations of both e 2704and c. 2705</pre></td></tr> 2706 2707 2708<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>...</td></tr> 2709<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. 2710 2711Given 2712 template <typename T> 2713 class C { }; 2714 2715 template class C<int>; // A 2716 C<char> var; // B 2717 2718templateSpecializationType() matches the type of the explicit 2719instantiation in A and the type of the variable declaration in B. 2720</pre></td></tr> 2721 2722 2723<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>...</td></tr> 2724<tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types. 2725 2726Example matches T, but not int. 2727 (matcher = templateTypeParmType()) 2728 template <typename T> void f(int i); 2729</pre></td></tr> 2730 2731 2732<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>>...</td></tr> 2733<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. 2734</pre></td></tr> 2735 2736 2737<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>...</td></tr> 2738<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. 2739 2740Given 2741 typedef int X; 2742typedefType() 2743 matches "typedef int X" 2744</pre></td></tr> 2745 2746 2747<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnaryTransformType.html">UnaryTransformType</a>>...</td></tr> 2748<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. 2749 2750Given: 2751 typedef __underlying_type(T) type; 2752unaryTransformType() 2753 matches "__underlying_type(T)" 2754</pre></td></tr> 2755 2756 2757<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('usingType0')"><a name="usingType0Anchor">usingType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>>...</td></tr> 2758<tr><td colspan="4" class="doc" id="usingType0"><pre>Matches types specified through a using declaration. 2759 2760Given 2761 namespace a { struct S {}; } 2762 using a::S; 2763 S s; 2764 2765usingType() matches the type of the variable declaration of s. 2766</pre></td></tr> 2767 2768 2769<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html">VariableArrayType</a>>...</td></tr> 2770<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an 2771integer-constant-expression. 2772 2773Given 2774 void f() { 2775 int a[] = { 2, 3 } 2776 int b[42]; 2777 int c[a[0]]; 2778 } 2779variableArrayType() 2780 matches "int c[a[0]]" 2781</pre></td></tr> 2782 2783<!--END_DECL_MATCHERS --> 2784</table> 2785 2786<!-- ======================================================================= --> 2787<h2 id="narrowing-matchers">Narrowing Matchers</h2> 2788<!-- ======================================================================= --> 2789 2790<p>Narrowing matchers match certain attributes on the current node, thus 2791narrowing down the set of nodes of the current type to match on.</p> 2792 2793<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) 2794which allow users to create more powerful match expressions.</p> 2795 2796<table> 2797<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 2798<!-- START_NARROWING_MATCHERS --> 2799 2800<tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 2801<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. 2802 2803Usable as: Any Matcher 2804</pre></td></tr> 2805 2806 2807<tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 2808<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. 2809 2810Usable as: Any Matcher 2811</pre></td></tr> 2812 2813 2814<tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> 2815<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. 2816 2817Useful when another matcher requires a child matcher, but there's no 2818additional constraint. This will often be used with an explicit conversion 2819to an internal::Matcher<> type such as TypeMatcher. 2820 2821Example: DeclarationMatcher(anything()) matches all declarations, e.g., 2822"int* p" and "void f()" in 2823 int* p; 2824 void f(); 2825 2826Usable as: Any Matcher 2827</pre></td></tr> 2828 2829 2830<tr><td><em>unspecified</em></td><td class="name" onclick="toggle('mapAnyOf0')"><a name="mapAnyOf0Anchor">mapAnyOf</a></td><td>nodeMatcherFunction...</td></tr> 2831<tr><td colspan="4" class="doc" id="mapAnyOf0"><pre>Matches any of the NodeMatchers with InnerMatchers nested within 2832 2833Given 2834 if (true); 2835 for (; true; ); 2836with the matcher 2837 mapAnyOf(ifStmt, forStmt).with( 2838 hasCondition(cxxBoolLiteralExpr(equals(true))) 2839 ).bind("trueCond") 2840matches the if and the for. It is equivalent to: 2841 auto trueCond = hasCondition(cxxBoolLiteralExpr(equals(true))); 2842 anyOf( 2843 ifStmt(trueCond).bind("trueCond"), 2844 forStmt(trueCond).bind("trueCond") 2845 ); 2846 2847The with() chain-call accepts zero or more matchers which are combined 2848as-if with allOf() in each of the node matchers. 2849Usable as: Any Matcher 2850</pre></td></tr> 2851 2852 2853<tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> 2854<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. 2855 2856Example matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) 2857 class X {}; 2858 class Y {}; 2859 2860Usable as: Any Matcher 2861</pre></td></tr> 2862 2863 2864<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>></td><td class="name" onclick="toggle('isImplicit1')"><a name="isImplicit1Anchor">isImplicit</a></td><td></td></tr> 2865<tr><td colspan="4" class="doc" id="isImplicit1"><pre>Matches an entity that has been implicitly added by the compiler (e.g. 2866implicit default/copy constructors). 2867</pre></td></tr> 2868 2869 2870<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('hasAnyOperatorName0')"><a name="hasAnyOperatorName0Anchor">hasAnyOperatorName</a></td><td>StringRef, ..., StringRef</td></tr> 2871<tr><td colspan="4" class="doc" id="hasAnyOperatorName0"><pre>Matches operator expressions (binary or unary) that have any of the 2872specified names. 2873 2874 hasAnyOperatorName("+", "-") 2875 Is equivalent to 2876 anyOf(hasOperatorName("+"), hasOperatorName("-")) 2877</pre></td></tr> 2878 2879 2880<tr><td>Matcher<<a href="https://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> 2881<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or 2882unary). 2883 2884Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 2885 !(a || b) 2886</pre></td></tr> 2887 2888 2889<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('isAssignmentOperator0')"><a name="isAssignmentOperator0Anchor">isAssignmentOperator</a></td><td></td></tr> 2890<tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators. 2891 2892Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) 2893 if (a == b) 2894 a += b; 2895 2896Example 2: matches s1 = s2 2897 (matcher = cxxOperatorCallExpr(isAssignmentOperator())) 2898 struct S { S& operator=(const S&); }; 2899 void x() { S s1, s2; s1 = s2; } 2900</pre></td></tr> 2901 2902 2903<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('isComparisonOperator0')"><a name="isComparisonOperator0Anchor">isComparisonOperator</a></td><td></td></tr> 2904<tr><td colspan="4" class="doc" id="isComparisonOperator0"><pre>Matches comparison operators. 2905 2906Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator())) 2907 if (a == b) 2908 a += b; 2909 2910Example 2: matches s1 < s2 2911 (matcher = cxxOperatorCallExpr(isComparisonOperator())) 2912 struct S { bool operator<(const S& other); }; 2913 void x(S s1, S s2) { bool b1 = s1 < s2; } 2914</pre></td></tr> 2915 2916 2917<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>></td><td class="name" onclick="toggle('isPrivate1')"><a name="isPrivate1Anchor">isPrivate</a></td><td></td></tr> 2918<tr><td colspan="4" class="doc" id="isPrivate1"><pre>Matches private C++ declarations and C++ base specifers that specify private 2919inheritance. 2920 2921Examples: 2922 class C { 2923 public: int a; 2924 protected: int b; 2925 private: int c; // fieldDecl(isPrivate()) matches 'c' 2926 }; 2927 2928 struct Base {}; 2929 struct Derived1 : private Base {}; // matches 'Base' 2930 class Derived2 : Base {}; // matches 'Base' 2931</pre></td></tr> 2932 2933 2934<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>></td><td class="name" onclick="toggle('isProtected1')"><a name="isProtected1Anchor">isProtected</a></td><td></td></tr> 2935<tr><td colspan="4" class="doc" id="isProtected1"><pre>Matches protected C++ declarations and C++ base specifers that specify 2936protected inheritance. 2937 2938Examples: 2939 class C { 2940 public: int a; 2941 protected: int b; // fieldDecl(isProtected()) matches 'b' 2942 private: int c; 2943 }; 2944 2945 class Base {}; 2946 class Derived : protected Base {}; // matches 'Base' 2947</pre></td></tr> 2948 2949 2950<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>></td><td class="name" onclick="toggle('isPublic1')"><a name="isPublic1Anchor">isPublic</a></td><td></td></tr> 2951<tr><td colspan="4" class="doc" id="isPublic1"><pre>Matches public C++ declarations and C++ base specifers that specify public 2952inheritance. 2953 2954Examples: 2955 class C { 2956 public: int a; // fieldDecl(isPublic()) matches 'a' 2957 protected: int b; 2958 private: int c; 2959 }; 2960 2961 class Base {}; 2962 class Derived1 : public Base {}; // matches 'Base' 2963 struct Derived2 : Base {}; // matches 'Base' 2964</pre></td></tr> 2965 2966 2967<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>></td><td class="name" onclick="toggle('isVirtual1')"><a name="isVirtual1Anchor">isVirtual</a></td><td></td></tr> 2968<tr><td colspan="4" class="doc" id="isVirtual1"><pre>Matches declarations of virtual methods and C++ base specifers that specify 2969virtual inheritance. 2970 2971Example: 2972 class A { 2973 public: 2974 virtual void x(); // matches x 2975 }; 2976 2977Example: 2978 class Base {}; 2979 class DirectlyDerived : virtual Base {}; // matches Base 2980 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base 2981 2982Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> 2983</pre></td></tr> 2984 2985 2986<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals5')"><a name="equals5Anchor">equals</a></td><td>bool Value</td></tr> 2987<tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr> 2988 2989 2990<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>const ValueT Value</td></tr> 2991<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT. 2992 2993Given 2994 f('false, 3.14, 42); 2995characterLiteral(equals(0)) 2996 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 2997 match false 2998floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 2999 match 3.14 3000integerLiteral(equals(42)) 3001 matches 42 3002 3003Note that you cannot directly match a negative numeric literal because the 3004minus sign is not part of the literal: It is a unary operator whose operand 3005is the positive numeric literal. Instead, you must use a unaryOperator() 3006matcher to match the minus sign: 3007 3008unaryOperator(hasOperatorName("-"), 3009 hasUnaryOperand(integerLiteral(equals(13)))) 3010 3011Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, 3012 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> 3013</pre></td></tr> 3014 3015 3016<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals11')"><a name="equals11Anchor">equals</a></td><td>double Value</td></tr> 3017<tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr> 3018 3019 3020<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals8')"><a name="equals8Anchor">equals</a></td><td>unsigned Value</td></tr> 3021<tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr> 3022 3023 3024<tr><td>Matcher<<a href="https://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> 3025<tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. 3026 3027Given 3028 try { 3029 // ... 3030 } catch (int) { 3031 // ... 3032 } catch (...) { 3033 // ... 3034 } 3035cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). 3036</pre></td></tr> 3037 3038 3039<tr><td>Matcher<<a href="https://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> 3040<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has 3041a specific number of arguments (including absent default arguments). 3042 3043Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 3044 void f(int x, int y); 3045 f(0, 0); 3046</pre></td></tr> 3047 3048 3049<tr><td>Matcher<<a href="https://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> 3050<tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. 3051</pre></td></tr> 3052 3053 3054<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('requiresZeroInitialization0')"><a name="requiresZeroInitialization0Anchor">requiresZeroInitialization</a></td><td></td></tr> 3055<tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires 3056zero initialization. 3057 3058Given 3059void foo() { 3060 struct point { double x; double y; }; 3061 point pt[2] = { { 1.0, 2.0 } }; 3062} 3063initListExpr(has(cxxConstructExpr(requiresZeroInitialization())) 3064will match the implicit array filler for pt[1]. 3065</pre></td></tr> 3066 3067 3068<tr><td>Matcher<<a href="https://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> 3069<tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. 3070 3071Given 3072 struct S { 3073 S(); // #1 3074 S(const S &); // #2 3075 S(S &&); // #3 3076 }; 3077cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. 3078</pre></td></tr> 3079 3080 3081<tr><td>Matcher<<a href="https://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> 3082<tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. 3083 3084Given 3085 struct S { 3086 S(); // #1 3087 S(const S &); // #2 3088 S(S &&); // #3 3089 }; 3090cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. 3091</pre></td></tr> 3092 3093 3094<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isDelegatingConstructor0')"><a name="isDelegatingConstructor0Anchor">isDelegatingConstructor</a></td><td></td></tr> 3095<tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor. 3096 3097Given 3098 struct S { 3099 S(); // #1 3100 S(int) {} // #2 3101 S(S &&) : S() {} // #3 3102 }; 3103 S::S() : S(0) {} // #4 3104cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not 3105#1 or #2. 3106</pre></td></tr> 3107 3108 3109<tr><td>Matcher<<a href="https://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> 3110<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor, conversion function, and deduction guide declarations 3111that have an explicit specifier if this explicit specifier is resolved to 3112true. 3113 3114Given 3115 template<bool b> 3116 struct S { 3117 S(int); // #1 3118 explicit S(double); // #2 3119 operator int(); // #3 3120 explicit operator bool(); // #4 3121 explicit(false) S(bool) // # 7 3122 explicit(true) S(char) // # 8 3123 explicit(b) S(S) // # 9 3124 }; 3125 S(int) -> S<true> // #5 3126 explicit S(double) -> S<false> // #6 3127cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. 3128cxxConversionDecl(isExplicit()) will match #4, but not #3. 3129cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5. 3130</pre></td></tr> 3131 3132 3133<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isInheritingConstructor0')"><a name="isInheritingConstructor0Anchor">isInheritingConstructor</a></td><td></td></tr> 3134<tr><td colspan="4" class="doc" id="isInheritingConstructor0"><pre></pre></td></tr> 3135 3136 3137<tr><td>Matcher<<a href="https://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> 3138<tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. 3139 3140Given 3141 struct S { 3142 S(); // #1 3143 S(const S &); // #2 3144 S(S &&); // #3 3145 }; 3146cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. 3147</pre></td></tr> 3148 3149 3150<tr><td>Matcher<<a href="https://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> 3151<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor, conversion function, and deduction guide declarations 3152that have an explicit specifier if this explicit specifier is resolved to 3153true. 3154 3155Given 3156 template<bool b> 3157 struct S { 3158 S(int); // #1 3159 explicit S(double); // #2 3160 operator int(); // #3 3161 explicit operator bool(); // #4 3162 explicit(false) S(bool) // # 7 3163 explicit(true) S(char) // # 8 3164 explicit(b) S(S) // # 9 3165 }; 3166 S(int) -> S<true> // #5 3167 explicit S(double) -> S<false> // #6 3168cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. 3169cxxConversionDecl(isExplicit()) will match #4, but not #3. 3170cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5. 3171</pre></td></tr> 3172 3173 3174<tr><td>Matcher<<a href="https://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> 3175<tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as 3176opposed to a member. 3177 3178Given 3179 struct B {}; 3180 struct D : B { 3181 int I; 3182 D(int i) : I(i) {} 3183 }; 3184 struct E : B { 3185 E() : B() {} 3186 }; 3187cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) 3188 will match E(), but not match D(int). 3189</pre></td></tr> 3190 3191 3192<tr><td>Matcher<<a href="https://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> 3193<tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as 3194opposed to a base. 3195 3196Given 3197 struct B {}; 3198 struct D : B { 3199 int I; 3200 D(int i) : I(i) {} 3201 }; 3202 struct E : B { 3203 E() : B() {} 3204 }; 3205cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) 3206 will match D(int), but not match E(). 3207</pre></td></tr> 3208 3209 3210<tr><td>Matcher<<a href="https://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> 3211<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in 3212code (as opposed to implicitly added by the compiler). 3213 3214Given 3215 struct Foo { 3216 Foo() { } 3217 Foo(int) : foo_("A") { } 3218 string foo_; 3219 }; 3220cxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) 3221 will match Foo(int), but not Foo() 3222</pre></td></tr> 3223 3224 3225<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDeductionGuideDecl.html">CXXDeductionGuideDecl</a>></td><td class="name" onclick="toggle('isExplicit2')"><a name="isExplicit2Anchor">isExplicit</a></td><td></td></tr> 3226<tr><td colspan="4" class="doc" id="isExplicit2"><pre>Matches constructor, conversion function, and deduction guide declarations 3227that have an explicit specifier if this explicit specifier is resolved to 3228true. 3229 3230Given 3231 template<bool b> 3232 struct S { 3233 S(int); // #1 3234 explicit S(double); // #2 3235 operator int(); // #3 3236 explicit operator bool(); // #4 3237 explicit(false) S(bool) // # 7 3238 explicit(true) S(char) // # 8 3239 explicit(b) S(S) // # 9 3240 }; 3241 S(int) -> S<true> // #5 3242 explicit S(double) -> S<false> // #6 3243cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. 3244cxxConversionDecl(isExplicit()) will match #4, but not #3. 3245cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5. 3246</pre></td></tr> 3247 3248 3249<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>></td><td class="name" onclick="toggle('hasMemberName0')"><a name="hasMemberName0Anchor">hasMemberName</a></td><td>std::string N</td></tr> 3250<tr><td colspan="4" class="doc" id="hasMemberName0"><pre>Matches template-dependent, but known, member names. 3251 3252In template declarations, dependent members are not resolved and so can 3253not be matched to particular named declarations. 3254 3255This matcher allows to match on the known name of members. 3256 3257Given 3258 template <typename T> 3259 struct S { 3260 void mem(); 3261 }; 3262 template <typename T> 3263 void x() { 3264 S<T> s; 3265 s.mem(); 3266 } 3267cxxDependentScopeMemberExpr(hasMemberName("mem")) matches `s.mem()` 3268</pre></td></tr> 3269 3270 3271<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>></td><td class="name" onclick="toggle('isArrow2')"><a name="isArrow2Anchor">isArrow</a></td><td></td></tr> 3272<tr><td colspan="4" class="doc" id="isArrow2"><pre>Matches member expressions that are called with '->' as opposed 3273to '.'. 3274 3275Member calls on the implicit this pointer match as called with '->'. 3276 3277Given 3278 class Y { 3279 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 3280 template <class T> void f() { this->f<T>(); f<T>(); } 3281 int a; 3282 static int b; 3283 }; 3284 template <class T> 3285 class Z { 3286 void x() { this->m; } 3287 }; 3288memberExpr(isArrow()) 3289 matches this->x, x, y.x, a, this->b 3290cxxDependentScopeMemberExpr(isArrow()) 3291 matches this->m 3292unresolvedMemberExpr(isArrow()) 3293 matches this->f<T>, f<T> 3294</pre></td></tr> 3295 3296 3297<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>></td><td class="name" onclick="toggle('memberHasSameNameAsBoundNode0')"><a name="memberHasSameNameAsBoundNode0Anchor">memberHasSameNameAsBoundNode</a></td><td>std::string BindingID</td></tr> 3298<tr><td colspan="4" class="doc" id="memberHasSameNameAsBoundNode0"><pre>Matches template-dependent, but known, member names against an already-bound 3299node 3300 3301In template declarations, dependent members are not resolved and so can 3302not be matched to particular named declarations. 3303 3304This matcher allows to match on the name of already-bound VarDecl, FieldDecl 3305and CXXMethodDecl nodes. 3306 3307Given 3308 template <typename T> 3309 struct S { 3310 void mem(); 3311 }; 3312 template <typename T> 3313 void x() { 3314 S<T> s; 3315 s.mem(); 3316 } 3317The matcher 3318@code 3319cxxDependentScopeMemberExpr( 3320 hasObjectExpression(declRefExpr(hasType(templateSpecializationType( 3321 hasDeclaration(classTemplateDecl(has(cxxRecordDecl(has( 3322 cxxMethodDecl(hasName("mem")).bind("templMem") 3323 ))))) 3324 )))), 3325 memberHasSameNameAsBoundNode("templMem") 3326 ) 3327@endcode 3328first matches and binds the @c mem member of the @c S template, then 3329compares its name to the usage in @c s.mem() in the @c x function template 3330</pre></td></tr> 3331 3332 3333<tr><td>Matcher<<a href="https://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> 3334<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. 3335 3336Given 3337struct A { 3338 void foo() const; 3339 void bar(); 3340}; 3341 3342cxxMethodDecl(isConst()) matches A::foo() but not A::bar() 3343</pre></td></tr> 3344 3345 3346<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isCopyAssignmentOperator0')"><a name="isCopyAssignmentOperator0Anchor">isCopyAssignmentOperator</a></td><td></td></tr> 3347<tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment 3348operator. 3349 3350Given 3351struct A { 3352 A &operator=(const A &); 3353 A &operator=(A &&); 3354}; 3355 3356cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not 3357the second one. 3358</pre></td></tr> 3359 3360 3361<tr><td>Matcher<<a href="https://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> 3362<tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. 3363 3364Given: 3365 class A final {}; 3366 3367 struct B { 3368 virtual void f(); 3369 }; 3370 3371 struct C : B { 3372 void f() final; 3373 }; 3374matches A and C::f, but not B, C, or B::f 3375</pre></td></tr> 3376 3377 3378<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isMoveAssignmentOperator0')"><a name="isMoveAssignmentOperator0Anchor">isMoveAssignmentOperator</a></td><td></td></tr> 3379<tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment 3380operator. 3381 3382Given 3383struct A { 3384 A &operator=(const A &); 3385 A &operator=(A &&); 3386}; 3387 3388cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not 3389the first one. 3390</pre></td></tr> 3391 3392 3393<tr><td>Matcher<<a href="https://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> 3394<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. 3395 3396Given 3397 class A { 3398 public: 3399 virtual void x(); 3400 }; 3401 class B : public A { 3402 public: 3403 virtual void x(); 3404 }; 3405 matches B::x 3406</pre></td></tr> 3407 3408 3409<tr><td>Matcher<<a href="https://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> 3410<tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. 3411 3412Given 3413 class A { 3414 public: 3415 virtual void x() = 0; 3416 }; 3417 matches A::x 3418</pre></td></tr> 3419 3420 3421<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isUserProvided0')"><a name="isUserProvided0Anchor">isUserProvided</a></td><td></td></tr> 3422<tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided. 3423 3424Given 3425 struct S { 3426 S(); // #1 3427 S(const S &) = default; // #2 3428 S(S &&) = delete; // #3 3429 }; 3430cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3. 3431</pre></td></tr> 3432 3433 3434<tr><td>Matcher<<a href="https://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> 3435<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches declarations of virtual methods and C++ base specifers that specify 3436virtual inheritance. 3437 3438Example: 3439 class A { 3440 public: 3441 virtual void x(); // matches x 3442 }; 3443 3444Example: 3445 class Base {}; 3446 class DirectlyDerived : virtual Base {}; // matches Base 3447 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base 3448 3449Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> 3450</pre></td></tr> 3451 3452 3453<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isVirtualAsWritten0')"><a name="isVirtualAsWritten0Anchor">isVirtualAsWritten</a></td><td></td></tr> 3454<tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual". 3455 3456Given 3457 class A { 3458 public: 3459 virtual void x(); 3460 }; 3461 class B : public A { 3462 public: 3463 void x(); 3464 }; 3465 matches A::x but not B::x 3466</pre></td></tr> 3467 3468 3469<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('isArray0')"><a name="isArray0Anchor">isArray</a></td><td></td></tr> 3470<tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions. 3471 3472Given: 3473 MyClass *p1 = new MyClass[10]; 3474cxxNewExpr(isArray()) 3475 matches the expression 'new MyClass[10]'. 3476</pre></td></tr> 3477 3478 3479<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasAnyOperatorName1')"><a name="hasAnyOperatorName1Anchor">hasAnyOperatorName</a></td><td>StringRef, ..., StringRef</td></tr> 3480<tr><td colspan="4" class="doc" id="hasAnyOperatorName1"><pre>Matches operator expressions (binary or unary) that have any of the 3481specified names. 3482 3483 hasAnyOperatorName("+", "-") 3484 Is equivalent to 3485 anyOf(hasOperatorName("+"), hasOperatorName("-")) 3486</pre></td></tr> 3487 3488 3489<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasAnyOverloadedOperatorName0')"><a name="hasAnyOverloadedOperatorName0Anchor">hasAnyOverloadedOperatorName</a></td><td>StringRef, ..., StringRef</td></tr> 3490<tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName0"><pre>Matches overloaded operator names. 3491 3492Matches overloaded operator names specified in strings without the 3493"operator" prefix: e.g. "<<". 3494 3495 hasAnyOverloadedOperatorName("+", "-") 3496Is equivalent to 3497 anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-")) 3498</pre></td></tr> 3499 3500 3501<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasOperatorName1')"><a name="hasOperatorName1Anchor">hasOperatorName</a></td><td>std::string Name</td></tr> 3502<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 3503unary). 3504 3505Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 3506 !(a || b) 3507</pre></td></tr> 3508 3509 3510<tr><td>Matcher<<a href="https://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> 3511<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. 3512 3513Matches overloaded operator names specified in strings without the 3514"operator" prefix: e.g. "<<". 3515 3516Given: 3517 class A { int operator*(); }; 3518 const A &operator<<(const A &a, const A &b); 3519 A a; 3520 a << a; // <-- This matches 3521 3522cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the 3523specified line and 3524cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) 3525matches the declaration of A. 3526 3527Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> 3528</pre></td></tr> 3529 3530 3531<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('isAssignmentOperator1')"><a name="isAssignmentOperator1Anchor">isAssignmentOperator</a></td><td></td></tr> 3532<tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators. 3533 3534Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) 3535 if (a == b) 3536 a += b; 3537 3538Example 2: matches s1 = s2 3539 (matcher = cxxOperatorCallExpr(isAssignmentOperator())) 3540 struct S { S& operator=(const S&); }; 3541 void x() { S s1, s2; s1 = s2; } 3542</pre></td></tr> 3543 3544 3545<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('isComparisonOperator1')"><a name="isComparisonOperator1Anchor">isComparisonOperator</a></td><td></td></tr> 3546<tr><td colspan="4" class="doc" id="isComparisonOperator1"><pre>Matches comparison operators. 3547 3548Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator())) 3549 if (a == b) 3550 a += b; 3551 3552Example 2: matches s1 < s2 3553 (matcher = cxxOperatorCallExpr(isComparisonOperator())) 3554 struct S { bool operator<(const S& other); }; 3555 void x(S s1, S s2) { bool b1 = s1 < s2; } 3556</pre></td></tr> 3557 3558 3559<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('hasDefinition0')"><a name="hasDefinition0Anchor">hasDefinition</a></td><td></td></tr> 3560<tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined. 3561 3562Example matches x (matcher = cxxRecordDecl(hasDefinition())) 3563class x {}; 3564class y; 3565</pre></td></tr> 3566 3567 3568<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isDerivedFrom2')"><a name="isDerivedFrom2Anchor">isDerivedFrom</a></td><td>std::string BaseName</td></tr> 3569<tr><td colspan="4" class="doc" id="isDerivedFrom2"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). 3570</pre></td></tr> 3571 3572 3573<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isDirectlyDerivedFrom2')"><a name="isDirectlyDerivedFrom2Anchor">isDirectlyDerivedFrom</a></td><td>std::string BaseName</td></tr> 3574<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom2"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)). 3575</pre></td></tr> 3576 3577 3578<tr><td>Matcher<<a href="https://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> 3579<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or 3580static member variable template instantiations. 3581 3582Given 3583 template<typename T> void A(T t) { } 3584 template<> void A(int N) { } 3585functionDecl(isExplicitTemplateSpecialization()) 3586 matches the specialization A<int>(). 3587 3588Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 3589</pre></td></tr> 3590 3591 3592<tr><td>Matcher<<a href="https://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> 3593<tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. 3594 3595Given: 3596 class A final {}; 3597 3598 struct B { 3599 virtual void f(); 3600 }; 3601 3602 struct C : B { 3603 void f() final; 3604 }; 3605matches A and C::f, but not B, C, or B::f 3606</pre></td></tr> 3607 3608 3609<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isLambda0')"><a name="isLambda0Anchor">isLambda</a></td><td></td></tr> 3610<tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions. 3611 3612Given: 3613 auto x = []{}; 3614 3615cxxRecordDecl(isLambda()) matches the implicit class declaration of 3616decltype(x) 3617</pre></td></tr> 3618 3619 3620<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isSameOrDerivedFrom2')"><a name="isSameOrDerivedFrom2Anchor">isSameOrDerivedFrom</a></td><td>std::string BaseName</td></tr> 3621<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom2"><pre>Overloaded method as shortcut for 3622isSameOrDerivedFrom(hasName(...)). 3623</pre></td></tr> 3624 3625 3626<tr><td>Matcher<<a href="https://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> 3627<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static 3628member variable template instantiations. 3629 3630Given 3631 template <typename T> class X {}; class A {}; X<A> x; 3632or 3633 template <typename T> class X {}; class A {}; template class X<A>; 3634or 3635 template <typename T> class X {}; class A {}; extern template class X<A>; 3636cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 3637 matches the template instantiation of X<A>. 3638 3639But given 3640 template <typename T> class X {}; class A {}; 3641 template <> class X<A> {}; X<A> x; 3642cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 3643 does not match, as X<A> is an explicit template specialization. 3644 3645Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 3646</pre></td></tr> 3647 3648 3649<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>></td><td class="name" onclick="toggle('hasAnyOperatorName2')"><a name="hasAnyOperatorName2Anchor">hasAnyOperatorName</a></td><td>StringRef, ..., StringRef</td></tr> 3650<tr><td colspan="4" class="doc" id="hasAnyOperatorName2"><pre>Matches operator expressions (binary or unary) that have any of the 3651specified names. 3652 3653 hasAnyOperatorName("+", "-") 3654 Is equivalent to 3655 anyOf(hasOperatorName("+"), hasOperatorName("-")) 3656</pre></td></tr> 3657 3658 3659<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>></td><td class="name" onclick="toggle('hasOperatorName2')"><a name="hasOperatorName2Anchor">hasOperatorName</a></td><td>std::string Name</td></tr> 3660<tr><td colspan="4" class="doc" id="hasOperatorName2"><pre>Matches the operator Name of operator expressions (binary or 3661unary). 3662 3663Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 3664 !(a || b) 3665</pre></td></tr> 3666 3667 3668<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>></td><td class="name" onclick="toggle('isAssignmentOperator2')"><a name="isAssignmentOperator2Anchor">isAssignmentOperator</a></td><td></td></tr> 3669<tr><td colspan="4" class="doc" id="isAssignmentOperator2"><pre>Matches all kinds of assignment operators. 3670 3671Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) 3672 if (a == b) 3673 a += b; 3674 3675Example 2: matches s1 = s2 3676 (matcher = cxxOperatorCallExpr(isAssignmentOperator())) 3677 struct S { S& operator=(const S&); }; 3678 void x() { S s1, s2; s1 = s2; } 3679</pre></td></tr> 3680 3681 3682<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>></td><td class="name" onclick="toggle('isComparisonOperator2')"><a name="isComparisonOperator2Anchor">isComparisonOperator</a></td><td></td></tr> 3683<tr><td colspan="4" class="doc" id="isComparisonOperator2"><pre>Matches comparison operators. 3684 3685Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator())) 3686 if (a == b) 3687 a += b; 3688 3689Example 2: matches s1 < s2 3690 (matcher = cxxOperatorCallExpr(isComparisonOperator())) 3691 struct S { bool operator<(const S& other); }; 3692 void x(S s1, S s2) { bool b1 = s1 < s2; } 3693</pre></td></tr> 3694 3695 3696<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>></td><td class="name" onclick="toggle('argumentCountIs2')"><a name="argumentCountIs2Anchor">argumentCountIs</a></td><td>unsigned N</td></tr> 3697<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has 3698a specific number of arguments (including absent default arguments). 3699 3700Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 3701 void f(int x, int y); 3702 f(0, 0); 3703</pre></td></tr> 3704 3705 3706<tr><td>Matcher<<a href="https://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> 3707<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has 3708a specific number of arguments (including absent default arguments). 3709 3710Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 3711 void f(int x, int y); 3712 f(0, 0); 3713</pre></td></tr> 3714 3715 3716<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('usesADL0')"><a name="usesADL0Anchor">usesADL</a></td><td></td></tr> 3717<tr><td colspan="4" class="doc" id="usesADL0"><pre>Matches call expressions which were resolved using ADL. 3718 3719Example matches y(x) but not y(42) or NS::y(x). 3720 namespace NS { 3721 struct X {}; 3722 void y(X); 3723 } 3724 3725 void y(...); 3726 3727 void test() { 3728 NS::X x; 3729 y(x); // Matches 3730 NS::y(x); // Doesn't match 3731 y(42); // Doesn't match 3732 using NS::y; 3733 y(x); // Found by both unqualified lookup and ADL, doesn't match 3734 } 3735</pre></td></tr> 3736 3737 3738<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>></td><td class="name" onclick="toggle('hasCastKind0')"><a name="hasCastKind0Anchor">hasCastKind</a></td><td>CastKind Kind</td></tr> 3739<tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind. 3740 3741Example: matches the implicit cast around 0 3742(matcher = castExpr(hasCastKind(CK_NullToPointer))) 3743 int *p = 0; 3744 3745If the matcher is use from clang-query, CastKind parameter 3746should be passed as a quoted string. e.g., hasCastKind("CK_NullToPointer"). 3747</pre></td></tr> 3748 3749 3750<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals4')"><a name="equals4Anchor">equals</a></td><td>bool Value</td></tr> 3751<tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr> 3752 3753 3754<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals3')"><a name="equals3Anchor">equals</a></td><td>const ValueT Value</td></tr> 3755<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT. 3756 3757Given 3758 f('false, 3.14, 42); 3759characterLiteral(equals(0)) 3760 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 3761 match false 3762floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 3763 match 3.14 3764integerLiteral(equals(42)) 3765 matches 42 3766 3767Note that you cannot directly match a negative numeric literal because the 3768minus sign is not part of the literal: It is a unary operator whose operand 3769is the positive numeric literal. Instead, you must use a unaryOperator() 3770matcher to match the minus sign: 3771 3772unaryOperator(hasOperatorName("-"), 3773 hasUnaryOperand(integerLiteral(equals(13)))) 3774 3775Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, 3776 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> 3777</pre></td></tr> 3778 3779 3780<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals10')"><a name="equals10Anchor">equals</a></td><td>double Value</td></tr> 3781<tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr> 3782 3783 3784<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals7')"><a name="equals7Anchor">equals</a></td><td>unsigned Value</td></tr> 3785<tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr> 3786 3787 3788<tr><td>Matcher<<a href="https://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> 3789<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. 3790 3791Given 3792 template<typename T> struct C {}; 3793 C<int> c; 3794classTemplateSpecializationDecl(templateArgumentCountIs(1)) 3795 matches C<int>. 3796</pre></td></tr> 3797 3798 3799<tr><td>Matcher<<a href="https://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> 3800<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of 3801child statements. 3802 3803Example: Given 3804 { for (;;) {} } 3805compoundStmt(statementCountIs(0))) 3806 matches '{}' 3807 but does not match the outer compound statement. 3808</pre></td></tr> 3809 3810 3811<tr><td>Matcher<<a href="https://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> 3812<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size. 3813 3814Given 3815 int a[42]; 3816 int b[2 * 21]; 3817 int c[41], d[43]; 3818 char *s = "abcd"; 3819 wchar_t *ws = L"abcd"; 3820 char *w = "a"; 3821constantArrayType(hasSize(42)) 3822 matches "int a[42]" and "int b[2 * 21]" 3823stringLiteral(hasSize(4)) 3824 matches "abcd", L"abcd" 3825</pre></td></tr> 3826 3827 3828<tr><td>Matcher<<a href="https://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> 3829<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of 3830declarations. 3831 3832Example: Given 3833 int a, b; 3834 int c; 3835 int d = 2, e; 3836declCountIs(2) 3837 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. 3838</pre></td></tr> 3839 3840 3841<tr><td>Matcher<<a href="https://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> 3842<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. 3843 3844Matches a node if it equals the node previously bound to ID. 3845 3846Given 3847 class X { int a; int b; }; 3848cxxRecordDecl( 3849 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3850 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3851 matches the class X, as a and b have the same type. 3852 3853Note that when multiple matches are involved via forEach* matchers, 3854equalsBoundNodes acts as a filter. 3855For example: 3856compoundStmt( 3857 forEachDescendant(varDecl().bind("d")), 3858 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3859will trigger a match for each combination of variable declaration 3860and reference to that variable declaration within a compound statement. 3861</pre></td></tr> 3862 3863 3864<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('equalsNode0')"><a name="equalsNode0Anchor">equalsNode</a></td><td>const Decl* Other</td></tr> 3865<tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node. 3866 3867Decl has pointer identity in the AST. 3868</pre></td></tr> 3869 3870 3871<tr><td>Matcher<<a href="https://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> 3872<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. 3873 3874Given 3875 __attribute__((device)) void f() { ... } 3876decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of 3877f. If the matcher is used from clang-query, attr::Kind parameter should be 3878passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). 3879</pre></td></tr> 3880 3881 3882<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpandedFromMacro0')"><a name="isExpandedFromMacro0Anchor">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr> 3883<tr><td colspan="4" class="doc" id="isExpandedFromMacro0"><pre>Matches statements that are (transitively) expanded from the named macro. 3884Does not match if only part of the statement is expanded from that macro or 3885if different parts of the statement are expanded from different 3886appearances of the macro. 3887</pre></td></tr> 3888 3889 3890<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching0')"><a name="isExpansionInFileMatching0Anchor">isExpansionInFileMatching</a></td><td>StringRef RegExp, Regex::RegexFlags Flags = NoFlags</td></tr> 3891<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is 3892partially matching a given regex. 3893 3894Example matches Y but not X 3895 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 3896 #include "ASTMatcher.h" 3897 class X {}; 3898ASTMatcher.h: 3899 class Y {}; 3900 3901Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 3902 3903If the matcher is used in clang-query, RegexFlags parameter 3904should be passed as a quoted string. e.g: "NoFlags". 3905Flags can be combined with '|' example "IgnoreCase | BasicRegex" 3906</pre></td></tr> 3907 3908 3909<tr><td>Matcher<<a href="https://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> 3910<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. 3911 3912Example matches X but not Y 3913 (matcher = cxxRecordDecl(isExpansionInMainFile()) 3914 #include <Y.h> 3915 class X {}; 3916Y.h: 3917 class Y {}; 3918 3919Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 3920</pre></td></tr> 3921 3922 3923<tr><td>Matcher<<a href="https://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> 3924<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. 3925 3926Example matches Y but not X 3927 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 3928 #include <SystemHeader.h> 3929 class X {}; 3930SystemHeader.h: 3931 class Y {}; 3932 3933Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 3934</pre></td></tr> 3935 3936 3937<tr><td>Matcher<<a href="https://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> 3938<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches an entity that has been implicitly added by the compiler (e.g. 3939implicit default/copy constructors). 3940</pre></td></tr> 3941 3942 3943<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isInAnonymousNamespace0')"><a name="isInAnonymousNamespace0Anchor">isInAnonymousNamespace</a></td><td></td></tr> 3944<tr><td colspan="4" class="doc" id="isInAnonymousNamespace0"><pre>Matches declarations in an anonymous namespace. 3945 3946Given 3947 class vector {}; 3948 namespace foo { 3949 class vector {}; 3950 namespace { 3951 class vector {}; // #1 3952 } 3953 } 3954 namespace { 3955 class vector {}; // #2 3956 namespace foo { 3957 class vector{}; // #3 3958 } 3959 } 3960cxxRecordDecl(hasName("vector"), isInAnonymousNamespace()) will match 3961#1, #2 and #3. 3962</pre></td></tr> 3963 3964 3965<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isInStdNamespace0')"><a name="isInStdNamespace0Anchor">isInStdNamespace</a></td><td></td></tr> 3966<tr><td colspan="4" class="doc" id="isInStdNamespace0"><pre>Matches declarations in the namespace `std`, but not in nested namespaces. 3967 3968Given 3969 class vector {}; 3970 namespace foo { 3971 class vector {}; 3972 namespace std { 3973 class vector {}; 3974 } 3975 } 3976 namespace std { 3977 inline namespace __1 { 3978 class vector {}; // #1 3979 namespace experimental { 3980 class vector {}; 3981 } 3982 } 3983 } 3984cxxRecordDecl(hasName("vector"), isInStdNamespace()) will match only #1. 3985</pre></td></tr> 3986 3987 3988<tr><td>Matcher<<a href="https://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> 3989<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside 3990template instantiations. 3991 3992Given 3993 template<typename T> void A(T t) { T i; } 3994 A(0); 3995 A(0U); 3996functionDecl(isInstantiated()) 3997 matches 'A(int) {...};' and 'A(unsigned) {...}'. 3998</pre></td></tr> 3999 4000 4001<tr><td>Matcher<<a href="https://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> 4002<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations and C++ base specifers that specify private 4003inheritance. 4004 4005Examples: 4006 class C { 4007 public: int a; 4008 protected: int b; 4009 private: int c; // fieldDecl(isPrivate()) matches 'c' 4010 }; 4011 4012 struct Base {}; 4013 struct Derived1 : private Base {}; // matches 'Base' 4014 class Derived2 : Base {}; // matches 'Base' 4015</pre></td></tr> 4016 4017 4018<tr><td>Matcher<<a href="https://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> 4019<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations and C++ base specifers that specify 4020protected inheritance. 4021 4022Examples: 4023 class C { 4024 public: int a; 4025 protected: int b; // fieldDecl(isProtected()) matches 'b' 4026 private: int c; 4027 }; 4028 4029 class Base {}; 4030 class Derived : protected Base {}; // matches 'Base' 4031</pre></td></tr> 4032 4033 4034<tr><td>Matcher<<a href="https://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> 4035<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations and C++ base specifers that specify public 4036inheritance. 4037 4038Examples: 4039 class C { 4040 public: int a; // fieldDecl(isPublic()) matches 'a' 4041 protected: int b; 4042 private: int c; 4043 }; 4044 4045 class Base {}; 4046 class Derived1 : public Base {}; // matches 'Base' 4047 struct Derived2 : Base {}; // matches 'Base' 4048</pre></td></tr> 4049 4050 4051<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DesignatedInitExpr.html">DesignatedInitExpr</a>></td><td class="name" onclick="toggle('designatorCountIs0')"><a name="designatorCountIs0Anchor">designatorCountIs</a></td><td>unsigned N</td></tr> 4052<tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain 4053a specific number of designators. 4054 4055Example: Given 4056 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; 4057 point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }; 4058designatorCountIs(2) 4059 matches '{ [2].y = 1.0, [0].x = 1.0 }', 4060 but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'. 4061</pre></td></tr> 4062 4063 4064<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>></td><td class="name" onclick="toggle('isScoped0')"><a name="isScoped0Anchor">isScoped</a></td><td></td></tr> 4065<tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration. 4066 4067Example matches Y (matcher = enumDecl(isScoped())) 4068enum X {}; 4069enum class Y {}; 4070</pre></td></tr> 4071 4072 4073<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('isInstantiationDependent0')"><a name="isInstantiationDependent0Anchor">isInstantiationDependent</a></td><td></td></tr> 4074<tr><td colspan="4" class="doc" id="isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is 4075neither type- nor value-dependent. 4076 4077In the following example, the expression sizeof(sizeof(T() + T())) 4078is instantiation-dependent (since it involves a template parameter T), 4079but is neither type- nor value-dependent, since the type of the inner 4080sizeof is known (std::size_t) and therefore the size of the outer 4081sizeof is known. 4082 template<typename T> 4083 void f(T x, T y) { sizeof(sizeof(T() + T()); } 4084expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T()) 4085</pre></td></tr> 4086 4087 4088<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('isTypeDependent0')"><a name="isTypeDependent0Anchor">isTypeDependent</a></td><td></td></tr> 4089<tr><td colspan="4" class="doc" id="isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type 4090is not yet instantiated. 4091 4092For example, the expressions "x" and "x + y" are type-dependent in 4093the following code, but "y" is not type-dependent: 4094 template<typename T> 4095 void add(T x, int y) { 4096 x + y; 4097 } 4098expr(isTypeDependent()) matches x + y 4099</pre></td></tr> 4100 4101 4102<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('isValueDependent0')"><a name="isValueDependent0Anchor">isValueDependent</a></td><td></td></tr> 4103<tr><td colspan="4" class="doc" id="isValueDependent0"><pre>Matches expression that are value-dependent because they contain a 4104non-type template parameter. 4105 4106For example, the array bound of "Chars" in the following example is 4107value-dependent. 4108 template<int Size> int f() { return Size; } 4109expr(isValueDependent()) matches return Size 4110</pre></td></tr> 4111 4112 4113<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('nullPointerConstant0')"><a name="nullPointerConstant0Anchor">nullPointerConstant</a></td><td></td></tr> 4114<tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as 4115GNU's __null, C++11's nullptr, or C's NULL macro. 4116 4117Given: 4118 void *v1 = NULL; 4119 void *v2 = nullptr; 4120 void *v3 = __null; // GNU extension 4121 char *cp = (char *)0; 4122 int *ip = 0; 4123 int i = 0; 4124expr(nullPointerConstant()) 4125 matches the initializer for v1, v2, v3, cp, and ip. Does not match the 4126 initializer for i. 4127</pre></td></tr> 4128 4129 4130<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>></td><td class="name" onclick="toggle('hasBitWidth0')"><a name="hasBitWidth0Anchor">hasBitWidth</a></td><td>unsigned Width</td></tr> 4131<tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified 4132bit width. 4133 4134Given 4135 class C { 4136 int a : 2; 4137 int b : 4; 4138 int c : 2; 4139 }; 4140fieldDecl(hasBitWidth(2)) 4141 matches 'int a;' and 'int c;' but not 'int b;'. 4142</pre></td></tr> 4143 4144 4145<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>></td><td class="name" onclick="toggle('isBitField0')"><a name="isBitField0Anchor">isBitField</a></td><td></td></tr> 4146<tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields. 4147 4148Given 4149 class C { 4150 int a : 2; 4151 int b; 4152 }; 4153fieldDecl(isBitField()) 4154 matches 'int a;' but not 'int b;'. 4155</pre></td></tr> 4156 4157 4158<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>></td><td class="name" onclick="toggle('equals1')"><a name="equals1Anchor">equals</a></td><td>const ValueT Value</td></tr> 4159<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT. 4160 4161Given 4162 f('false, 3.14, 42); 4163characterLiteral(equals(0)) 4164 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 4165 match false 4166floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 4167 match 3.14 4168integerLiteral(equals(42)) 4169 matches 42 4170 4171Note that you cannot directly match a negative numeric literal because the 4172minus sign is not part of the literal: It is a unary operator whose operand 4173is the positive numeric literal. Instead, you must use a unaryOperator() 4174matcher to match the minus sign: 4175 4176unaryOperator(hasOperatorName("-"), 4177 hasUnaryOperand(integerLiteral(equals(13)))) 4178 4179Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, 4180 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> 4181</pre></td></tr> 4182 4183 4184<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>></td><td class="name" onclick="toggle('equals12')"><a name="equals12Anchor">equals</a></td><td>double Value</td></tr> 4185<tr><td colspan="4" class="doc" id="equals12"><pre></pre></td></tr> 4186 4187 4188<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasAnyOverloadedOperatorName1')"><a name="hasAnyOverloadedOperatorName1Anchor">hasAnyOverloadedOperatorName</a></td><td>StringRef, ..., StringRef</td></tr> 4189<tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName1"><pre>Matches overloaded operator names. 4190 4191Matches overloaded operator names specified in strings without the 4192"operator" prefix: e.g. "<<". 4193 4194 hasAnyOverloadedOperatorName("+", "-") 4195Is equivalent to 4196 anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-")) 4197</pre></td></tr> 4198 4199 4200<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasDynamicExceptionSpec0')"><a name="hasDynamicExceptionSpec0Anchor">hasDynamicExceptionSpec</a></td><td></td></tr> 4201<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification. 4202 4203Given: 4204 void f(); 4205 void g() noexcept; 4206 void h() noexcept(true); 4207 void i() noexcept(false); 4208 void j() throw(); 4209 void k() throw(int); 4210 void l() throw(...); 4211functionDecl(hasDynamicExceptionSpec()) and 4212 functionProtoType(hasDynamicExceptionSpec()) 4213 match the declarations of j, k, and l, but not f, g, h, or i. 4214</pre></td></tr> 4215 4216 4217<tr><td>Matcher<<a href="https://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> 4218<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. 4219 4220Matches overloaded operator names specified in strings without the 4221"operator" prefix: e.g. "<<". 4222 4223Given: 4224 class A { int operator*(); }; 4225 const A &operator<<(const A &a, const A &b); 4226 A a; 4227 a << a; // <-- This matches 4228 4229cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the 4230specified line and 4231cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) 4232matches the declaration of A. 4233 4234Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> 4235</pre></td></tr> 4236 4237 4238<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasTrailingReturn0')"><a name="hasTrailingReturn0Anchor">hasTrailingReturn</a></td><td></td></tr> 4239<tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type. 4240 4241Example matches Y (matcher = functionDecl(hasTrailingReturn())) 4242int X() {} 4243auto Y() -> int {} 4244</pre></td></tr> 4245 4246 4247<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isConsteval0')"><a name="isConsteval0Anchor">isConsteval</a></td><td></td></tr> 4248<tr><td colspan="4" class="doc" id="isConsteval0"><pre>Matches consteval function declarations and if consteval/if ! consteval 4249statements. 4250 4251Given: 4252 consteval int a(); 4253 void b() { if consteval {} } 4254 void c() { if ! consteval {} } 4255 void d() { if ! consteval {} else {} } 4256functionDecl(isConsteval()) 4257 matches the declaration of "int a()". 4258ifStmt(isConsteval()) 4259 matches the if statement in "void b()", "void c()", "void d()". 4260</pre></td></tr> 4261 4262 4263<tr><td>Matcher<<a href="https://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> 4264<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations, 4265 and if constexpr. 4266 4267Given: 4268 constexpr int foo = 42; 4269 constexpr int bar(); 4270 void baz() { if constexpr(1 > 0) {} } 4271varDecl(isConstexpr()) 4272 matches the declaration of foo. 4273functionDecl(isConstexpr()) 4274 matches the declaration of bar. 4275ifStmt(isConstexpr()) 4276 matches the if statement in baz. 4277</pre></td></tr> 4278 4279 4280<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDefaulted0')"><a name="isDefaulted0Anchor">isDefaulted</a></td><td></td></tr> 4281<tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations. 4282 4283Given: 4284 class A { ~A(); }; 4285 class B { ~B() = default; }; 4286functionDecl(isDefaulted()) 4287 matches the declaration of ~B, but not ~A. 4288</pre></td></tr> 4289 4290 4291<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDefinition3')"><a name="isDefinition3Anchor">isDefinition</a></td><td></td></tr> 4292<tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached. 4293 4294Example matches A, va, fa 4295 class A {}; 4296 class B; // Doesn't match, as it has no body. 4297 int va; 4298 extern int vb; // Doesn't match, as it doesn't define the variable. 4299 void fa() {} 4300 void fb(); // Doesn't match, as it has no body. 4301 @interface X 4302 - (void)ma; // Doesn't match, interface is declaration. 4303 @end 4304 @implementation X 4305 - (void)ma {} 4306 @end 4307 4308Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, 4309 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 4310</pre></td></tr> 4311 4312 4313<tr><td>Matcher<<a href="https://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> 4314<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. 4315 4316Given: 4317 void Func(); 4318 void DeletedFunc() = delete; 4319functionDecl(isDeleted()) 4320 matches the declaration of DeletedFunc, but not Func. 4321</pre></td></tr> 4322 4323 4324<tr><td>Matcher<<a href="https://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> 4325<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or 4326static member variable template instantiations. 4327 4328Given 4329 template<typename T> void A(T t) { } 4330 template<> void A(int N) { } 4331functionDecl(isExplicitTemplateSpecialization()) 4332 matches the specialization A<int>(). 4333 4334Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 4335</pre></td></tr> 4336 4337 4338<tr><td>Matcher<<a href="https://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> 4339<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations. 4340 4341Given: 4342 extern "C" void f() {} 4343 extern "C" { void g() {} } 4344 void h() {} 4345 extern "C" int x = 1; 4346 extern "C" int y = 2; 4347 int z = 3; 4348functionDecl(isExternC()) 4349 matches the declaration of f and g, but not the declaration of h. 4350varDecl(isExternC()) 4351 matches the declaration of x and y, but not the declaration of z. 4352</pre></td></tr> 4353 4354 4355<tr><td>Matcher<<a href="https://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> 4356<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches functions, variables and namespace declarations that are marked with 4357the inline keyword. 4358 4359Given 4360 inline void f(); 4361 void g(); 4362 namespace n { 4363 inline namespace m {} 4364 } 4365 inline int Foo = 5; 4366functionDecl(isInline()) will match ::f(). 4367namespaceDecl(isInline()) will match n::m. 4368varDecl(isInline()) will match Foo; 4369</pre></td></tr> 4370 4371 4372<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isMain0')"><a name="isMain0Anchor">isMain</a></td><td></td></tr> 4373<tr><td colspan="4" class="doc" id="isMain0"><pre>Determines whether the function is "main", which is the entry point 4374into an executable program. 4375</pre></td></tr> 4376 4377 4378<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isNoReturn0')"><a name="isNoReturn0Anchor">isNoReturn</a></td><td></td></tr> 4379<tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute. 4380 4381Given 4382 void nope(); 4383 [[noreturn]] void a(); 4384 __attribute__((noreturn)) void b(); 4385 struct c { [[noreturn]] c(); }; 4386functionDecl(isNoReturn()) 4387 matches all of those except 4388 void nope(); 4389</pre></td></tr> 4390 4391 4392<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isNoThrow0')"><a name="isNoThrow0Anchor">isNoThrow</a></td><td></td></tr> 4393<tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification. 4394 4395Given: 4396 void f(); 4397 void g() noexcept; 4398 void h() throw(); 4399 void i() throw(int); 4400 void j() noexcept(false); 4401functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) 4402 match the declarations of g, and h, but not f, i or j. 4403</pre></td></tr> 4404 4405 4406<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isStaticStorageClass0')"><a name="isStaticStorageClass0Anchor">isStaticStorageClass</a></td><td></td></tr> 4407<tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variable/function declarations that have "static" storage 4408class specifier ("static" keyword) written in the source. 4409 4410Given: 4411 static void f() {} 4412 static int i = 0; 4413 extern int j; 4414 int k; 4415functionDecl(isStaticStorageClass()) 4416 matches the function declaration f. 4417varDecl(isStaticStorageClass()) 4418 matches the variable declaration i. 4419</pre></td></tr> 4420 4421 4422<tr><td>Matcher<<a href="https://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> 4423<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 4424member variable template instantiations. 4425 4426Given 4427 template <typename T> class X {}; class A {}; X<A> x; 4428or 4429 template <typename T> class X {}; class A {}; template class X<A>; 4430or 4431 template <typename T> class X {}; class A {}; extern template class X<A>; 4432cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 4433 matches the template instantiation of X<A>. 4434 4435But given 4436 template <typename T> class X {}; class A {}; 4437 template <> class X<A> {}; X<A> x; 4438cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 4439 does not match, as X<A> is an explicit template specialization. 4440 4441Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 4442</pre></td></tr> 4443 4444 4445<tr><td>Matcher<<a href="https://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> 4446<tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. 4447 4448Example matches f, but not g or h. The function i will not match, even when 4449compiled in C mode. 4450 void f(...); 4451 void g(int); 4452 template <typename... Ts> void h(Ts...); 4453 void i(); 4454</pre></td></tr> 4455 4456 4457<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isWeak0')"><a name="isWeak0Anchor">isWeak</a></td><td></td></tr> 4458<tr><td colspan="4" class="doc" id="isWeak0"><pre>Matches weak function declarations. 4459 4460Given: 4461 void foo() __attribute__((__weakref__("__foo"))); 4462 void bar(); 4463functionDecl(isWeak()) 4464 matches the weak declaration "foo", but not "bar". 4465</pre></td></tr> 4466 4467 4468<tr><td>Matcher<<a href="https://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> 4469<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a 4470specific parameter count. 4471 4472Given 4473 void f(int i) {} 4474 void g(int i, int j) {} 4475 void h(int i, int j); 4476 void j(int i); 4477 void k(int x, int y, int z, ...); 4478functionDecl(parameterCountIs(2)) 4479 matches g and h 4480functionProtoType(parameterCountIs(2)) 4481 matches g and h 4482functionProtoType(parameterCountIs(3)) 4483 matches k 4484</pre></td></tr> 4485 4486 4487<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>></td><td class="name" onclick="toggle('hasDynamicExceptionSpec1')"><a name="hasDynamicExceptionSpec1Anchor">hasDynamicExceptionSpec</a></td><td></td></tr> 4488<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification. 4489 4490Given: 4491 void f(); 4492 void g() noexcept; 4493 void h() noexcept(true); 4494 void i() noexcept(false); 4495 void j() throw(); 4496 void k() throw(int); 4497 void l() throw(...); 4498functionDecl(hasDynamicExceptionSpec()) and 4499 functionProtoType(hasDynamicExceptionSpec()) 4500 match the declarations of j, k, and l, but not f, g, h, or i. 4501</pre></td></tr> 4502 4503 4504<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>></td><td class="name" onclick="toggle('isNoThrow1')"><a name="isNoThrow1Anchor">isNoThrow</a></td><td></td></tr> 4505<tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification. 4506 4507Given: 4508 void f(); 4509 void g() noexcept; 4510 void h() throw(); 4511 void i() throw(int); 4512 void j() noexcept(false); 4513functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) 4514 match the declarations of g, and h, but not f, i or j. 4515</pre></td></tr> 4516 4517 4518<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>></td><td class="name" onclick="toggle('parameterCountIs1')"><a name="parameterCountIs1Anchor">parameterCountIs</a></td><td>unsigned N</td></tr> 4519<tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a 4520specific parameter count. 4521 4522Given 4523 void f(int i) {} 4524 void g(int i, int j) {} 4525 void h(int i, int j); 4526 void j(int i); 4527 void k(int x, int y, int z, ...); 4528functionDecl(parameterCountIs(2)) 4529 matches g and h 4530functionProtoType(parameterCountIs(2)) 4531 matches g and h 4532functionProtoType(parameterCountIs(3)) 4533 matches k 4534</pre></td></tr> 4535 4536 4537<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('isConsteval1')"><a name="isConsteval1Anchor">isConsteval</a></td><td></td></tr> 4538<tr><td colspan="4" class="doc" id="isConsteval1"><pre>Matches consteval function declarations and if consteval/if ! consteval 4539statements. 4540 4541Given: 4542 consteval int a(); 4543 void b() { if consteval {} } 4544 void c() { if ! consteval {} } 4545 void d() { if ! consteval {} else {} } 4546functionDecl(isConsteval()) 4547 matches the declaration of "int a()". 4548ifStmt(isConsteval()) 4549 matches the if statement in "void b()", "void c()", "void d()". 4550</pre></td></tr> 4551 4552 4553<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('isConstexpr2')"><a name="isConstexpr2Anchor">isConstexpr</a></td><td></td></tr> 4554<tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations, 4555 and if constexpr. 4556 4557Given: 4558 constexpr int foo = 42; 4559 constexpr int bar(); 4560 void baz() { if constexpr(1 > 0) {} } 4561varDecl(isConstexpr()) 4562 matches the declaration of foo. 4563functionDecl(isConstexpr()) 4564 matches the declaration of bar. 4565ifStmt(isConstexpr()) 4566 matches the if statement in baz. 4567</pre></td></tr> 4568 4569 4570<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals6')"><a name="equals6Anchor">equals</a></td><td>bool Value</td></tr> 4571<tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr> 4572 4573 4574<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals0')"><a name="equals0Anchor">equals</a></td><td>const ValueT Value</td></tr> 4575<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT. 4576 4577Given 4578 f('false, 3.14, 42); 4579characterLiteral(equals(0)) 4580 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 4581 match false 4582floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 4583 match 3.14 4584integerLiteral(equals(42)) 4585 matches 42 4586 4587Note that you cannot directly match a negative numeric literal because the 4588minus sign is not part of the literal: It is a unary operator whose operand 4589is the positive numeric literal. Instead, you must use a unaryOperator() 4590matcher to match the minus sign: 4591 4592unaryOperator(hasOperatorName("-"), 4593 hasUnaryOperand(integerLiteral(equals(13)))) 4594 4595Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, 4596 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> 4597</pre></td></tr> 4598 4599 4600<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals13')"><a name="equals13Anchor">equals</a></td><td>double Value</td></tr> 4601<tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr> 4602 4603 4604<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals9')"><a name="equals9Anchor">equals</a></td><td>unsigned Value</td></tr> 4605<tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr> 4606 4607 4608<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>></td><td class="name" onclick="toggle('capturesThis0')"><a name="capturesThis0Anchor">capturesThis</a></td><td></td></tr> 4609<tr><td colspan="4" class="doc" id="capturesThis0"><pre>Matches a `LambdaCapture` that refers to 'this'. 4610 4611Given 4612class C { 4613 int cc; 4614 int f() { 4615 auto l = [this]() { return cc; }; 4616 return l(); 4617 } 4618}; 4619lambdaExpr(hasAnyCapture(lambdaCapture(capturesThis()))) 4620 matches `[this]() { return cc; }`. 4621</pre></td></tr> 4622 4623 4624<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>></td><td class="name" onclick="toggle('isImplicit2')"><a name="isImplicit2Anchor">isImplicit</a></td><td></td></tr> 4625<tr><td colspan="4" class="doc" id="isImplicit2"><pre>Matches an entity that has been implicitly added by the compiler (e.g. 4626implicit default/copy constructors). 4627</pre></td></tr> 4628 4629 4630<tr><td>Matcher<<a href="https://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> 4631<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 4632to '.'. 4633 4634Member calls on the implicit this pointer match as called with '->'. 4635 4636Given 4637 class Y { 4638 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 4639 template <class T> void f() { this->f<T>(); f<T>(); } 4640 int a; 4641 static int b; 4642 }; 4643 template <class T> 4644 class Z { 4645 void x() { this->m; } 4646 }; 4647memberExpr(isArrow()) 4648 matches this->x, x, y.x, a, this->b 4649cxxDependentScopeMemberExpr(isArrow()) 4650 matches this->m 4651unresolvedMemberExpr(isArrow()) 4652 matches this->f<T>, f<T> 4653</pre></td></tr> 4654 4655 4656<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('hasAnyName0')"><a name="hasAnyName0Anchor">hasAnyName</a></td><td>StringRef, ..., StringRef</td></tr> 4657<tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names. 4658 4659This matcher is only provided as a performance optimization of hasName. 4660 hasAnyName(a, b, c) 4661 is equivalent to, but faster than 4662 anyOf(hasName(a), hasName(b), hasName(c)) 4663</pre></td></tr> 4664 4665 4666<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('hasExternalFormalLinkage0')"><a name="hasExternalFormalLinkage0Anchor">hasExternalFormalLinkage</a></td><td></td></tr> 4667<tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage. 4668 4669Example matches only z (matcher = varDecl(hasExternalFormalLinkage())) 4670void f() { 4671 int x; 4672 static int y; 4673} 4674int z; 4675 4676Example matches f() because it has external formal linkage despite being 4677unique to the translation unit as though it has internal likage 4678(matcher = functionDecl(hasExternalFormalLinkage())) 4679 4680namespace { 4681void f() {} 4682} 4683</pre></td></tr> 4684 4685 4686<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('hasName0')"><a name="hasName0Anchor">hasName</a></td><td>StringRef Name</td></tr> 4687<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 4688 4689Supports specifying enclosing namespaces or classes by prefixing the name 4690with '<enclosing>::'. 4691Does not match typedefs of an underlying type with the given name. 4692 4693Example matches X (Name == "X") 4694 class X; 4695 4696Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 4697 namespace a { namespace b { class X; } } 4698</pre></td></tr> 4699 4700 4701<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('matchesName0')"><a name="matchesName0Anchor">matchesName</a></td><td>StringRef RegExp, Regex::RegexFlags Flags = NoFlags</td></tr> 4702<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain 4703a substring matched by the given RegExp. 4704 4705Supports specifying enclosing namespaces or classes by 4706prefixing the name with '<enclosing>::'. Does not match typedefs 4707of an underlying type with the given name. 4708 4709Example matches X (regexp == "::X") 4710 class X; 4711 4712Example matches X (regexp is one of "::X", "^foo::.*X", among others) 4713 namespace foo { namespace bar { class X; } } 4714 4715If the matcher is used in clang-query, RegexFlags parameter 4716should be passed as a quoted string. e.g: "NoFlags". 4717Flags can be combined with '|' example "IgnoreCase | BasicRegex" 4718</pre></td></tr> 4719 4720 4721<tr><td>Matcher<<a href="https://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> 4722<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. 4723 4724Given 4725 namespace n { 4726 namespace {} // #1 4727 } 4728namespaceDecl(isAnonymous()) will match #1 but not ::n. 4729</pre></td></tr> 4730 4731 4732<tr><td>Matcher<<a href="https://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> 4733<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches functions, variables and namespace declarations that are marked with 4734the inline keyword. 4735 4736Given 4737 inline void f(); 4738 void g(); 4739 namespace n { 4740 inline namespace m {} 4741 } 4742 inline int Foo = 5; 4743functionDecl(isInline()) will match ::f(). 4744namespaceDecl(isInline()) will match n::m. 4745varDecl(isInline()) will match Foo; 4746</pre></td></tr> 4747 4748 4749<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>></td><td class="name" onclick="toggle('isFirstPrivateKind0')"><a name="isFirstPrivateKind0Anchor">isFirstPrivateKind</a></td><td></td></tr> 4750<tr><td colspan="4" class="doc" id="isFirstPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``firstprivate`` kind 4751specified. 4752 4753Given 4754 4755 #pragma omp parallel 4756 #pragma omp parallel default(none) 4757 #pragma omp parallel default(shared) 4758 #pragma omp parallel default(private) 4759 #pragma omp parallel default(firstprivate) 4760 4761``ompDefaultClause(isFirstPrivateKind())`` matches only 4762``default(firstprivate)``. 4763</pre></td></tr> 4764 4765 4766<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>></td><td class="name" onclick="toggle('isNoneKind0')"><a name="isNoneKind0Anchor">isNoneKind</a></td><td></td></tr> 4767<tr><td colspan="4" class="doc" id="isNoneKind0"><pre>Matches if the OpenMP ``default`` clause has ``none`` kind specified. 4768 4769Given 4770 4771 #pragma omp parallel 4772 #pragma omp parallel default(none) 4773 #pragma omp parallel default(shared) 4774 #pragma omp parallel default(private) 4775 #pragma omp parallel default(firstprivate) 4776 4777``ompDefaultClause(isNoneKind())`` matches only ``default(none)``. 4778</pre></td></tr> 4779 4780 4781<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>></td><td class="name" onclick="toggle('isPrivateKind0')"><a name="isPrivateKind0Anchor">isPrivateKind</a></td><td></td></tr> 4782<tr><td colspan="4" class="doc" id="isPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``private`` kind 4783specified. 4784 4785Given 4786 4787 #pragma omp parallel 4788 #pragma omp parallel default(none) 4789 #pragma omp parallel default(shared) 4790 #pragma omp parallel default(private) 4791 #pragma omp parallel default(firstprivate) 4792 4793``ompDefaultClause(isPrivateKind())`` matches only 4794``default(private)``. 4795</pre></td></tr> 4796 4797 4798<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>></td><td class="name" onclick="toggle('isSharedKind0')"><a name="isSharedKind0Anchor">isSharedKind</a></td><td></td></tr> 4799<tr><td colspan="4" class="doc" id="isSharedKind0"><pre>Matches if the OpenMP ``default`` clause has ``shared`` kind specified. 4800 4801Given 4802 4803 #pragma omp parallel 4804 #pragma omp parallel default(none) 4805 #pragma omp parallel default(shared) 4806 #pragma omp parallel default(private) 4807 #pragma omp parallel default(firstprivate) 4808 4809``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``. 4810</pre></td></tr> 4811 4812 4813<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective</a>></td><td class="name" onclick="toggle('isAllowedToContainClauseKind0')"><a name="isAllowedToContainClauseKind0Anchor">isAllowedToContainClauseKind</a></td><td>OpenMPClauseKind CKind</td></tr> 4814<tr><td colspan="4" class="doc" id="isAllowedToContainClauseKind0"><pre>Matches if the OpenMP directive is allowed to contain the specified OpenMP 4815clause kind. 4816 4817Given 4818 4819 #pragma omp parallel 4820 #pragma omp parallel for 4821 #pragma omp for 4822 4823`ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches 4824``omp parallel`` and ``omp parallel for``. 4825 4826If the matcher is use from clang-query, ``OpenMPClauseKind`` parameter 4827should be passed as a quoted string. e.g., 4828``isAllowedToContainClauseKind("OMPC_default").`` 4829</pre></td></tr> 4830 4831 4832<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective</a>></td><td class="name" onclick="toggle('isStandaloneDirective0')"><a name="isStandaloneDirective0Anchor">isStandaloneDirective</a></td><td></td></tr> 4833<tr><td colspan="4" class="doc" id="isStandaloneDirective0"><pre>Matches standalone OpenMP directives, 4834i.e., directives that can't have a structured block. 4835 4836Given 4837 4838 #pragma omp parallel 4839 {} 4840 #pragma omp taskyield 4841 4842``ompExecutableDirective(isStandaloneDirective()))`` matches 4843``omp taskyield``. 4844</pre></td></tr> 4845 4846 4847<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>></td><td class="name" onclick="toggle('isDerivedFrom3')"><a name="isDerivedFrom3Anchor">isDerivedFrom</a></td><td>std::string BaseName</td></tr> 4848<tr><td colspan="4" class="doc" id="isDerivedFrom3"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). 4849</pre></td></tr> 4850 4851 4852<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>></td><td class="name" onclick="toggle('isDirectlyDerivedFrom3')"><a name="isDirectlyDerivedFrom3Anchor">isDirectlyDerivedFrom</a></td><td>std::string BaseName</td></tr> 4853<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom3"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)). 4854</pre></td></tr> 4855 4856 4857<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>></td><td class="name" onclick="toggle('isSameOrDerivedFrom3')"><a name="isSameOrDerivedFrom3Anchor">isSameOrDerivedFrom</a></td><td>std::string BaseName</td></tr> 4858<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom3"><pre>Overloaded method as shortcut for 4859isSameOrDerivedFrom(hasName(...)). 4860</pre></td></tr> 4861 4862 4863<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('argumentCountIs3')"><a name="argumentCountIs3Anchor">argumentCountIs</a></td><td>unsigned N</td></tr> 4864<tr><td colspan="4" class="doc" id="argumentCountIs3"><pre>Checks that a call expression or a constructor call expression has 4865a specific number of arguments (including absent default arguments). 4866 4867Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 4868 void f(int x, int y); 4869 f(0, 0); 4870</pre></td></tr> 4871 4872 4873<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasAnySelector0')"><a name="hasAnySelector0Anchor">hasAnySelector</a></td><td>StringRef, ..., StringRef</td></tr> 4874<tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the 4875Selector.getAsString() 4876 4877 matcher = objCMessageExpr(hasSelector("methodA:", "methodB:")); 4878 matches both of the expressions below: 4879 [myObj methodA:argA]; 4880 [myObj methodB:argB]; 4881</pre></td></tr> 4882 4883 4884<tr><td>Matcher<<a href="https://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> 4885<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector 4886 4887objCMessageExpr(hasKeywordSelector()) matches the generated setFrame 4888message expression in 4889 4890 UIWebView *webView = ...; 4891 CGRect bodyFrame = webView.frame; 4892 bodyFrame.size.height = self.bodyContentHeight; 4893 webView.frame = bodyFrame; 4894 // ^---- matches here 4895</pre></td></tr> 4896 4897 4898<tr><td>Matcher<<a href="https://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> 4899<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector 4900 4901Matches only when the selector of the objCMessageExpr is NULL. This may 4902represent an error condition in the tree! 4903</pre></td></tr> 4904 4905 4906<tr><td>Matcher<<a href="https://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> 4907<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() 4908 4909 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); 4910 matches the outer message expr in the code below, but NOT the message 4911 invocation for self.bodyView. 4912 [self.bodyView loadHTMLString:html baseURL:NULL]; 4913</pre></td></tr> 4914 4915 4916<tr><td>Matcher<<a href="https://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> 4917<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector 4918 4919 matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); 4920 matches self.bodyView in the code below, but NOT the outer message 4921 invocation of "loadHTMLString:baseURL:". 4922 [self.bodyView loadHTMLString:html baseURL:NULL]; 4923</pre></td></tr> 4924 4925 4926<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('isClassMessage0')"><a name="isClassMessage0Anchor">isClassMessage</a></td><td></td></tr> 4927<tr><td colspan="4" class="doc" id="isClassMessage0"><pre>Returns true when the Objective-C message is sent to a class. 4928 4929Example 4930matcher = objcMessageExpr(isClassMessage()) 4931matches 4932 [NSString stringWithFormat:@"format"]; 4933but not 4934 NSString *x = @"hello"; 4935 [x containsString:@"h"]; 4936</pre></td></tr> 4937 4938 4939<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('isInstanceMessage0')"><a name="isInstanceMessage0Anchor">isInstanceMessage</a></td><td></td></tr> 4940<tr><td colspan="4" class="doc" id="isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance. 4941 4942Example 4943matcher = objcMessageExpr(isInstanceMessage()) 4944matches 4945 NSString *x = @"hello"; 4946 [x containsString:@"h"]; 4947but not 4948 [NSString stringWithFormat:@"format"]; 4949</pre></td></tr> 4950 4951 4952<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('matchesSelector0')"><a name="matchesSelector0Anchor">matchesSelector</a></td><td>StringRef RegExp, Regex::RegexFlags Flags = NoFlags</td></tr> 4953<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains 4954a substring matched by the given RegExp. 4955 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message 4956 invocation for self.bodyView. 4957 [self.bodyView loadHTMLString:html baseURL:NULL]; 4958 4959If the matcher is used in clang-query, RegexFlags parameter 4960should be passed as a quoted string. e.g: "NoFlags". 4961Flags can be combined with '|' example "IgnoreCase | BasicRegex" 4962</pre></td></tr> 4963 4964 4965<tr><td>Matcher<<a href="https://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> 4966<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments 4967 4968 matcher = objCMessageExpr(numSelectorArgs(0)); 4969 matches self.bodyView in the code below 4970 4971 matcher = objCMessageExpr(numSelectorArgs(2)); 4972 matches the invocation of "loadHTMLString:baseURL:" but not that 4973 of self.bodyView 4974 [self.bodyView loadHTMLString:html baseURL:NULL]; 4975</pre></td></tr> 4976 4977 4978<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>></td><td class="name" onclick="toggle('isClassMethod0')"><a name="isClassMethod0Anchor">isClassMethod</a></td><td></td></tr> 4979<tr><td colspan="4" class="doc" id="isClassMethod0"><pre>Returns true when the Objective-C method declaration is a class method. 4980 4981Example 4982matcher = objcMethodDecl(isClassMethod()) 4983matches 4984@interface I + (void)foo; @end 4985but not 4986@interface I - (void)bar; @end 4987</pre></td></tr> 4988 4989 4990<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>></td><td class="name" onclick="toggle('isDefinition2')"><a name="isDefinition2Anchor">isDefinition</a></td><td></td></tr> 4991<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. 4992 4993Example matches A, va, fa 4994 class A {}; 4995 class B; // Doesn't match, as it has no body. 4996 int va; 4997 extern int vb; // Doesn't match, as it doesn't define the variable. 4998 void fa() {} 4999 void fb(); // Doesn't match, as it has no body. 5000 @interface X 5001 - (void)ma; // Doesn't match, interface is declaration. 5002 @end 5003 @implementation X 5004 - (void)ma {} 5005 @end 5006 5007Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, 5008 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 5009</pre></td></tr> 5010 5011 5012<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>></td><td class="name" onclick="toggle('isInstanceMethod0')"><a name="isInstanceMethod0Anchor">isInstanceMethod</a></td><td></td></tr> 5013<tr><td colspan="4" class="doc" id="isInstanceMethod0"><pre>Returns true when the Objective-C method declaration is an instance method. 5014 5015Example 5016matcher = objcMethodDecl(isInstanceMethod()) 5017matches 5018@interface I - (void)bar; @end 5019but not 5020@interface I + (void)foo; @end 5021</pre></td></tr> 5022 5023 5024<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>></td><td class="name" onclick="toggle('hasDefaultArgument0')"><a name="hasDefaultArgument0Anchor">hasDefaultArgument</a></td><td></td></tr> 5025<tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments. 5026 5027Example matches y (matcher = parmVarDecl(hasDefaultArgument())) 5028void x(int val) {} 5029void y(int val = 0) {} 5030 5031Deprecated. Use hasInitializer() instead to be able to 5032match on the contents of the default argument. For example: 5033 5034void x(int val = 7) {} 5035void y(int val = 42) {} 5036parmVarDecl(hasInitializer(integerLiteral(equals(42)))) 5037 matches the parameter of y 5038 5039A matcher such as 5040 parmVarDecl(hasInitializer(anything())) 5041is equivalent to parmVarDecl(hasDefaultArgument()). 5042</pre></td></tr> 5043 5044 5045<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>></td><td class="name" onclick="toggle('isAtPosition0')"><a name="isAtPosition0Anchor">isAtPosition</a></td><td>unsigned N</td></tr> 5046<tr><td colspan="4" class="doc" id="isAtPosition0"><pre>Matches the ParmVarDecl nodes that are at the N'th position in the parameter 5047list. The parameter list could be that of either a block, function, or 5048objc-method. 5049 5050 5051Given 5052 5053void f(int a, int b, int c) { 5054} 5055 5056``parmVarDecl(isAtPosition(0))`` matches ``int a``. 5057 5058``parmVarDecl(isAtPosition(1))`` matches ``int b``. 5059</pre></td></tr> 5060 5061 5062<tr><td>Matcher<<a href="https://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> 5063<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 5064 5065Given 5066 class Y { public: void x(); }; 5067 void z() { Y* y; y->x(); } 5068cxxMemberCallExpr(on(hasType(asString("class Y *")))) 5069 matches y->x() 5070</pre></td></tr> 5071 5072 5073<tr><td>Matcher<<a href="https://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> 5074<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. 5075 5076Matches a node if it equals the node previously bound to ID. 5077 5078Given 5079 class X { int a; int b; }; 5080cxxRecordDecl( 5081 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 5082 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 5083 matches the class X, as a and b have the same type. 5084 5085Note that when multiple matches are involved via forEach* matchers, 5086equalsBoundNodes acts as a filter. 5087For example: 5088compoundStmt( 5089 forEachDescendant(varDecl().bind("d")), 5090 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 5091will trigger a match for each combination of variable declaration 5092and reference to that variable declaration within a compound statement. 5093</pre></td></tr> 5094 5095 5096<tr><td>Matcher<<a href="https://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> 5097<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to 5098the node, not hidden within a typedef. 5099 5100Given 5101 typedef const int const_int; 5102 const_int i; 5103 int *const j; 5104 int *volatile k; 5105 int m; 5106varDecl(hasType(hasLocalQualifiers())) matches only j and k. 5107i is const-qualified but the qualifier is not local. 5108</pre></td></tr> 5109 5110 5111<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isAnyCharacter0')"><a name="isAnyCharacter0Anchor">isAnyCharacter</a></td><td></td></tr> 5112<tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type. 5113 5114Given 5115 void a(char); 5116 void b(wchar_t); 5117 void c(double); 5118functionDecl(hasAnyParameter(hasType(isAnyCharacter()))) 5119matches "a(char)", "b(wchar_t)", but not "c(double)". 5120</pre></td></tr> 5121 5122 5123<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isAnyPointer0')"><a name="isAnyPointer0Anchor">isAnyPointer</a></td><td></td></tr> 5124<tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes 5125the Objective-C object pointer type, which is different despite being 5126syntactically similar. 5127 5128Given 5129 int *i = nullptr; 5130 5131 @interface Foo 5132 @end 5133 Foo *f; 5134 5135 int j; 5136varDecl(hasType(isAnyPointer())) 5137 matches "int *i" and "Foo *f", but not "int j". 5138</pre></td></tr> 5139 5140 5141<tr><td>Matcher<<a href="https://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> 5142<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 5143include "top-level" const. 5144 5145Given 5146 void a(int); 5147 void b(int const); 5148 void c(const int); 5149 void d(const int*); 5150 void e(int const) {}; 5151functionDecl(hasAnyParameter(hasType(isConstQualified()))) 5152 matches "void b(int const)", "void c(const int)" and 5153 "void e(int const) {}". It does not match d as there 5154 is no top-level const on the parameter type "const int *". 5155</pre></td></tr> 5156 5157 5158<tr><td>Matcher<<a href="https://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> 5159<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 5160 5161Given 5162 void a(int); 5163 void b(long); 5164 void c(double); 5165functionDecl(hasAnyParameter(hasType(isInteger()))) 5166matches "a(int)", "b(long)", but not "c(double)". 5167</pre></td></tr> 5168 5169 5170<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isSignedInteger0')"><a name="isSignedInteger0Anchor">isSignedInteger</a></td><td></td></tr> 5171<tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type. 5172 5173Given 5174 void a(int); 5175 void b(unsigned long); 5176 void c(double); 5177functionDecl(hasAnyParameter(hasType(isSignedInteger()))) 5178matches "a(int)", but not "b(unsigned long)" and "c(double)". 5179</pre></td></tr> 5180 5181 5182<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isUnsignedInteger0')"><a name="isUnsignedInteger0Anchor">isUnsignedInteger</a></td><td></td></tr> 5183<tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type. 5184 5185Given 5186 void a(int); 5187 void b(unsigned long); 5188 void c(double); 5189functionDecl(hasAnyParameter(hasType(isUnsignedInteger()))) 5190matches "b(unsigned long)", but not "a(int)" and "c(double)". 5191</pre></td></tr> 5192 5193 5194<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isVolatileQualified0')"><a name="isVolatileQualified0Anchor">isVolatileQualified</a></td><td></td></tr> 5195<tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that 5196include "top-level" volatile. 5197 5198Given 5199 void a(int); 5200 void b(int volatile); 5201 void c(volatile int); 5202 void d(volatile int*); 5203 void e(int volatile) {}; 5204functionDecl(hasAnyParameter(hasType(isVolatileQualified()))) 5205 matches "void b(int volatile)", "void c(volatile int)" and 5206 "void e(int volatile) {}". It does not match d as there 5207 is no top-level volatile on the parameter type "volatile int *". 5208</pre></td></tr> 5209 5210 5211<tr><td>Matcher<<a href="https://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> 5212<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. 5213 5214Matches a node if it equals the node previously bound to ID. 5215 5216Given 5217 class X { int a; int b; }; 5218cxxRecordDecl( 5219 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 5220 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 5221 matches the class X, as a and b have the same type. 5222 5223Note that when multiple matches are involved via forEach* matchers, 5224equalsBoundNodes acts as a filter. 5225For example: 5226compoundStmt( 5227 forEachDescendant(varDecl().bind("d")), 5228 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 5229will trigger a match for each combination of variable declaration 5230and reference to that variable declaration within a compound statement. 5231</pre></td></tr> 5232 5233 5234<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('equalsNode1')"><a name="equalsNode1Anchor">equalsNode</a></td><td>const Stmt* Other</td></tr> 5235<tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. 5236 5237Stmt has pointer identity in the AST. 5238</pre></td></tr> 5239 5240 5241<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpandedFromMacro1')"><a name="isExpandedFromMacro1Anchor">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr> 5242<tr><td colspan="4" class="doc" id="isExpandedFromMacro1"><pre>Matches statements that are (transitively) expanded from the named macro. 5243Does not match if only part of the statement is expanded from that macro or 5244if different parts of the statement are expanded from different 5245appearances of the macro. 5246</pre></td></tr> 5247 5248 5249<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching1')"><a name="isExpansionInFileMatching1Anchor">isExpansionInFileMatching</a></td><td>StringRef RegExp, Regex::RegexFlags Flags = NoFlags</td></tr> 5250<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is 5251partially matching a given regex. 5252 5253Example matches Y but not X 5254 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 5255 #include "ASTMatcher.h" 5256 class X {}; 5257ASTMatcher.h: 5258 class Y {}; 5259 5260Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 5261 5262If the matcher is used in clang-query, RegexFlags parameter 5263should be passed as a quoted string. e.g: "NoFlags". 5264Flags can be combined with '|' example "IgnoreCase | BasicRegex" 5265</pre></td></tr> 5266 5267 5268<tr><td>Matcher<<a href="https://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> 5269<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. 5270 5271Example matches X but not Y 5272 (matcher = cxxRecordDecl(isExpansionInMainFile()) 5273 #include <Y.h> 5274 class X {}; 5275Y.h: 5276 class Y {}; 5277 5278Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 5279</pre></td></tr> 5280 5281 5282<tr><td>Matcher<<a href="https://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> 5283<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. 5284 5285Example matches Y but not X 5286 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 5287 #include <SystemHeader.h> 5288 class X {}; 5289SystemHeader.h: 5290 class Y {}; 5291 5292Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 5293</pre></td></tr> 5294 5295 5296<tr><td>Matcher<<a href="https://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> 5297<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. 5298 5299Given 5300 int j; 5301 template<typename T> void A(T t) { T i; j += 42;} 5302 A(0); 5303 A(0U); 5304declStmt(isInTemplateInstantiation()) 5305 matches 'int i;' and 'unsigned i'. 5306unless(stmt(isInTemplateInstantiation())) 5307 will NOT match j += 42; as it's shared between the template definition and 5308 instantiation. 5309</pre></td></tr> 5310 5311 5312<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>></td><td class="name" onclick="toggle('hasSize1')"><a name="hasSize1Anchor">hasSize</a></td><td>unsigned N</td></tr> 5313<tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size. 5314 5315Given 5316 int a[42]; 5317 int b[2 * 21]; 5318 int c[41], d[43]; 5319 char *s = "abcd"; 5320 wchar_t *ws = L"abcd"; 5321 char *w = "a"; 5322constantArrayType(hasSize(42)) 5323 matches "int a[42]" and "int b[2 * 21]" 5324stringLiteral(hasSize(4)) 5325 matches "abcd", L"abcd" 5326</pre></td></tr> 5327 5328 5329<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>></td><td class="name" onclick="toggle('isClass0')"><a name="isClass0Anchor">isClass</a></td><td></td></tr> 5330<tr><td colspan="4" class="doc" id="isClass0"><pre>Matches TagDecl object that are spelled with "class." 5331 5332Example matches C, but not S, U or E. 5333 struct S {}; 5334 class C {}; 5335 union U {}; 5336 enum E {}; 5337</pre></td></tr> 5338 5339 5340<tr><td>Matcher<<a href="https://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> 5341<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 5342 5343Example matches A, va, fa 5344 class A {}; 5345 class B; // Doesn't match, as it has no body. 5346 int va; 5347 extern int vb; // Doesn't match, as it doesn't define the variable. 5348 void fa() {} 5349 void fb(); // Doesn't match, as it has no body. 5350 @interface X 5351 - (void)ma; // Doesn't match, interface is declaration. 5352 @end 5353 @implementation X 5354 - (void)ma {} 5355 @end 5356 5357Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, 5358 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 5359</pre></td></tr> 5360 5361 5362<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>></td><td class="name" onclick="toggle('isEnum0')"><a name="isEnum0Anchor">isEnum</a></td><td></td></tr> 5363<tr><td colspan="4" class="doc" id="isEnum0"><pre>Matches TagDecl object that are spelled with "enum." 5364 5365Example matches E, but not C, S or U. 5366 struct S {}; 5367 class C {}; 5368 union U {}; 5369 enum E {}; 5370</pre></td></tr> 5371 5372 5373<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>></td><td class="name" onclick="toggle('isStruct0')"><a name="isStruct0Anchor">isStruct</a></td><td></td></tr> 5374<tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches TagDecl object that are spelled with "struct." 5375 5376Example matches S, but not C, U or E. 5377 struct S {}; 5378 class C {}; 5379 union U {}; 5380 enum E {}; 5381</pre></td></tr> 5382 5383 5384<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>></td><td class="name" onclick="toggle('isUnion0')"><a name="isUnion0Anchor">isUnion</a></td><td></td></tr> 5385<tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches TagDecl object that are spelled with "union." 5386 5387Example matches U, but not C, S or E. 5388 struct S {}; 5389 class C {}; 5390 union U {}; 5391 enum E {}; 5392</pre></td></tr> 5393 5394 5395<tr><td>Matcher<<a href="https://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> 5396<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. 5397 5398Note that 'Value' is a string as the template argument's value is 5399an arbitrary precision integer. 'Value' must be euqal to the canonical 5400representation of that integral value in base 10. 5401 5402Given 5403 template<int T> struct C {}; 5404 C<42> c; 5405classTemplateSpecializationDecl( 5406 hasAnyTemplateArgument(equalsIntegralValue("42"))) 5407 matches the implicit instantiation of C in C<42>. 5408</pre></td></tr> 5409 5410 5411<tr><td>Matcher<<a href="https://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> 5412<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. 5413 5414Given 5415 template<int T> struct C {}; 5416 C<42> c; 5417classTemplateSpecializationDecl( 5418 hasAnyTemplateArgument(isIntegral())) 5419 matches the implicit instantiation of C in C<42> 5420 with isIntegral() matching 42. 5421</pre></td></tr> 5422 5423 5424<tr><td>Matcher<<a href="https://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> 5425<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. 5426 5427Given 5428 template<typename T> struct C {}; 5429 C<int> c; 5430classTemplateSpecializationDecl(templateArgumentCountIs(1)) 5431 matches C<int>. 5432</pre></td></tr> 5433 5434 5435<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpandedFromMacro2')"><a name="isExpandedFromMacro2Anchor">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr> 5436<tr><td colspan="4" class="doc" id="isExpandedFromMacro2"><pre>Matches statements that are (transitively) expanded from the named macro. 5437Does not match if only part of the statement is expanded from that macro or 5438if different parts of the statement are expanded from different 5439appearances of the macro. 5440</pre></td></tr> 5441 5442 5443<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching2')"><a name="isExpansionInFileMatching2Anchor">isExpansionInFileMatching</a></td><td>StringRef RegExp, Regex::RegexFlags Flags = NoFlags</td></tr> 5444<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is 5445partially matching a given regex. 5446 5447Example matches Y but not X 5448 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 5449 #include "ASTMatcher.h" 5450 class X {}; 5451ASTMatcher.h: 5452 class Y {}; 5453 5454Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 5455 5456If the matcher is used in clang-query, RegexFlags parameter 5457should be passed as a quoted string. e.g: "NoFlags". 5458Flags can be combined with '|' example "IgnoreCase | BasicRegex" 5459</pre></td></tr> 5460 5461 5462<tr><td>Matcher<<a href="https://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> 5463<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. 5464 5465Example matches X but not Y 5466 (matcher = cxxRecordDecl(isExpansionInMainFile()) 5467 #include <Y.h> 5468 class X {}; 5469Y.h: 5470 class Y {}; 5471 5472Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 5473</pre></td></tr> 5474 5475 5476<tr><td>Matcher<<a href="https://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> 5477<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. 5478 5479Example matches Y but not X 5480 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 5481 #include <SystemHeader.h> 5482 class X {}; 5483SystemHeader.h: 5484 class Y {}; 5485 5486Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 5487</pre></td></tr> 5488 5489 5490<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('booleanType0')"><a name="booleanType0Anchor">booleanType</a></td><td></td></tr> 5491<tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool. 5492 5493Given 5494 struct S { bool func(); }; 5495functionDecl(returns(booleanType())) 5496 matches "bool func();" 5497</pre></td></tr> 5498 5499 5500<tr><td>Matcher<<a href="https://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> 5501<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. 5502 5503Matches a node if it equals the node previously bound to ID. 5504 5505Given 5506 class X { int a; int b; }; 5507cxxRecordDecl( 5508 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 5509 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 5510 matches the class X, as a and b have the same type. 5511 5512Note that when multiple matches are involved via forEach* matchers, 5513equalsBoundNodes acts as a filter. 5514For example: 5515compoundStmt( 5516 forEachDescendant(varDecl().bind("d")), 5517 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 5518will trigger a match for each combination of variable declaration 5519and reference to that variable declaration within a compound statement. 5520</pre></td></tr> 5521 5522 5523<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('equalsNode2')"><a name="equalsNode2Anchor">equalsNode</a></td><td>const Type* Other</td></tr> 5524<tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node. 5525 5526Type has pointer identity in the AST. 5527</pre></td></tr> 5528 5529 5530<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('realFloatingPointType0')"><a name="realFloatingPointType0Anchor">realFloatingPointType</a></td><td></td></tr> 5531<tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double). 5532 5533Given 5534 int i; 5535 float f; 5536realFloatingPointType() 5537 matches "float f" but not "int i" 5538</pre></td></tr> 5539 5540 5541<tr><td>Matcher<<a href="https://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> 5542<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. 5543 5544Given 5545 struct S { void func(); }; 5546functionDecl(returns(voidType())) 5547 matches "void func();" 5548</pre></td></tr> 5549 5550 5551<tr><td>Matcher<<a href="https://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> 5552<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 5553 5554Given 5555 int x; 5556 int s = sizeof(x) + alignof(x) 5557unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 5558 matches sizeof(x) 5559 5560If the matcher is use from clang-query, UnaryExprOrTypeTrait parameter 5561should be passed as a quoted string. e.g., ofKind("UETT_SizeOf"). 5562</pre></td></tr> 5563 5564 5565<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>></td><td class="name" onclick="toggle('hasAnyOperatorName3')"><a name="hasAnyOperatorName3Anchor">hasAnyOperatorName</a></td><td>StringRef, ..., StringRef</td></tr> 5566<tr><td colspan="4" class="doc" id="hasAnyOperatorName3"><pre>Matches operator expressions (binary or unary) that have any of the 5567specified names. 5568 5569 hasAnyOperatorName("+", "-") 5570 Is equivalent to 5571 anyOf(hasOperatorName("+"), hasOperatorName("-")) 5572</pre></td></tr> 5573 5574 5575<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>></td><td class="name" onclick="toggle('hasOperatorName3')"><a name="hasOperatorName3Anchor">hasOperatorName</a></td><td>std::string Name</td></tr> 5576<tr><td colspan="4" class="doc" id="hasOperatorName3"><pre>Matches the operator Name of operator expressions (binary or 5577unary). 5578 5579Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 5580 !(a || b) 5581</pre></td></tr> 5582 5583 5584<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html">UnresolvedMemberExpr</a>></td><td class="name" onclick="toggle('isArrow1')"><a name="isArrow1Anchor">isArrow</a></td><td></td></tr> 5585<tr><td colspan="4" class="doc" id="isArrow1"><pre>Matches member expressions that are called with '->' as opposed 5586to '.'. 5587 5588Member calls on the implicit this pointer match as called with '->'. 5589 5590Given 5591 class Y { 5592 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 5593 template <class T> void f() { this->f<T>(); f<T>(); } 5594 int a; 5595 static int b; 5596 }; 5597 template <class T> 5598 class Z { 5599 void x() { this->m; } 5600 }; 5601memberExpr(isArrow()) 5602 matches this->x, x, y.x, a, this->b 5603cxxDependentScopeMemberExpr(isArrow()) 5604 matches this->m 5605unresolvedMemberExpr(isArrow()) 5606 matches this->f<T>, f<T> 5607</pre></td></tr> 5608 5609 5610<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasAutomaticStorageDuration0')"><a name="hasAutomaticStorageDuration0Anchor">hasAutomaticStorageDuration</a></td><td></td></tr> 5611<tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration. 5612 5613Example matches x, but not y, z, or a. 5614(matcher = varDecl(hasAutomaticStorageDuration()) 5615void f() { 5616 int x; 5617 static int y; 5618 thread_local int z; 5619} 5620int a; 5621</pre></td></tr> 5622 5623 5624<tr><td>Matcher<<a href="https://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> 5625<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. 5626 5627Example matches y and z (matcher = varDecl(hasGlobalStorage()) 5628void f() { 5629 int x; 5630 static int y; 5631} 5632int z; 5633</pre></td></tr> 5634 5635 5636<tr><td>Matcher<<a href="https://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> 5637<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a 5638non-static local variable. 5639 5640Example matches x (matcher = varDecl(hasLocalStorage()) 5641void f() { 5642 int x; 5643 static int y; 5644} 5645int z; 5646</pre></td></tr> 5647 5648 5649<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasStaticStorageDuration0')"><a name="hasStaticStorageDuration0Anchor">hasStaticStorageDuration</a></td><td></td></tr> 5650<tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration. 5651It includes the variable declared at namespace scope and those declared 5652with "static" and "extern" storage class specifiers. 5653 5654void f() { 5655 int x; 5656 static int y; 5657 thread_local int z; 5658} 5659int a; 5660static int b; 5661extern int c; 5662varDecl(hasStaticStorageDuration()) 5663 matches the function declaration y, a, b and c. 5664</pre></td></tr> 5665 5666 5667<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasThreadStorageDuration0')"><a name="hasThreadStorageDuration0Anchor">hasThreadStorageDuration</a></td><td></td></tr> 5668<tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration. 5669 5670Example matches z, but not x, z, or a. 5671(matcher = varDecl(hasThreadStorageDuration()) 5672void f() { 5673 int x; 5674 static int y; 5675 thread_local int z; 5676} 5677int a; 5678</pre></td></tr> 5679 5680 5681<tr><td>Matcher<<a href="https://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> 5682<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations, 5683 and if constexpr. 5684 5685Given: 5686 constexpr int foo = 42; 5687 constexpr int bar(); 5688 void baz() { if constexpr(1 > 0) {} } 5689varDecl(isConstexpr()) 5690 matches the declaration of foo. 5691functionDecl(isConstexpr()) 5692 matches the declaration of bar. 5693ifStmt(isConstexpr()) 5694 matches the if statement in baz. 5695</pre></td></tr> 5696 5697 5698<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isConstinit0')"><a name="isConstinit0Anchor">isConstinit</a></td><td></td></tr> 5699<tr><td colspan="4" class="doc" id="isConstinit0"><pre>Matches constinit variable declarations. 5700 5701Given: 5702 constinit int foo = 42; 5703 constinit const char* bar = "bar"; 5704 int baz = 42; 5705 [[clang::require_constant_initialization]] int xyz = 42; 5706varDecl(isConstinit()) 5707 matches the declaration of `foo` and `bar`, but not `baz` and `xyz`. 5708</pre></td></tr> 5709 5710 5711<tr><td>Matcher<<a href="https://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> 5712<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 5713 5714Example matches A, va, fa 5715 class A {}; 5716 class B; // Doesn't match, as it has no body. 5717 int va; 5718 extern int vb; // Doesn't match, as it doesn't define the variable. 5719 void fa() {} 5720 void fb(); // Doesn't match, as it has no body. 5721 @interface X 5722 - (void)ma; // Doesn't match, interface is declaration. 5723 @end 5724 @implementation X 5725 - (void)ma {} 5726 @end 5727 5728Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, 5729 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 5730</pre></td></tr> 5731 5732 5733<tr><td>Matcher<<a href="https://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> 5734<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from 5735a C++ catch block, or an Objective-C statement. 5736 5737Example matches x (matcher = varDecl(isExceptionVariable()) 5738void f(int y) { 5739 try { 5740 } catch (int x) { 5741 } 5742} 5743</pre></td></tr> 5744 5745 5746<tr><td>Matcher<<a href="https://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> 5747<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 5748static member variable template instantiations. 5749 5750Given 5751 template<typename T> void A(T t) { } 5752 template<> void A(int N) { } 5753functionDecl(isExplicitTemplateSpecialization()) 5754 matches the specialization A<int>(). 5755 5756Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 5757</pre></td></tr> 5758 5759 5760<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isExternC1')"><a name="isExternC1Anchor">isExternC</a></td><td></td></tr> 5761<tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations. 5762 5763Given: 5764 extern "C" void f() {} 5765 extern "C" { void g() {} } 5766 void h() {} 5767 extern "C" int x = 1; 5768 extern "C" int y = 2; 5769 int z = 3; 5770functionDecl(isExternC()) 5771 matches the declaration of f and g, but not the declaration of h. 5772varDecl(isExternC()) 5773 matches the declaration of x and y, but not the declaration of z. 5774</pre></td></tr> 5775 5776 5777<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isInitCapture0')"><a name="isInitCapture0Anchor">isInitCapture</a></td><td></td></tr> 5778<tr><td colspan="4" class="doc" id="isInitCapture0"><pre>Matches a variable serving as the implicit variable for a lambda init- 5779capture. 5780 5781Example matches x (matcher = varDecl(isInitCapture())) 5782auto f = [x=3]() { return x; }; 5783</pre></td></tr> 5784 5785 5786<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isInline2')"><a name="isInline2Anchor">isInline</a></td><td></td></tr> 5787<tr><td colspan="4" class="doc" id="isInline2"><pre>Matches functions, variables and namespace declarations that are marked with 5788the inline keyword. 5789 5790Given 5791 inline void f(); 5792 void g(); 5793 namespace n { 5794 inline namespace m {} 5795 } 5796 inline int Foo = 5; 5797functionDecl(isInline()) will match ::f(). 5798namespaceDecl(isInline()) will match n::m. 5799varDecl(isInline()) will match Foo; 5800</pre></td></tr> 5801 5802 5803<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isStaticLocal0')"><a name="isStaticLocal0Anchor">isStaticLocal</a></td><td></td></tr> 5804<tr><td colspan="4" class="doc" id="isStaticLocal0"><pre>Matches a static variable with local scope. 5805 5806Example matches y (matcher = varDecl(isStaticLocal())) 5807void f() { 5808 int x; 5809 static int y; 5810} 5811static int z; 5812</pre></td></tr> 5813 5814 5815<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isStaticStorageClass1')"><a name="isStaticStorageClass1Anchor">isStaticStorageClass</a></td><td></td></tr> 5816<tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variable/function declarations that have "static" storage 5817class specifier ("static" keyword) written in the source. 5818 5819Given: 5820 static void f() {} 5821 static int i = 0; 5822 extern int j; 5823 int k; 5824functionDecl(isStaticStorageClass()) 5825 matches the function declaration f. 5826varDecl(isStaticStorageClass()) 5827 matches the variable declaration i. 5828</pre></td></tr> 5829 5830 5831<tr><td>Matcher<<a href="https://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> 5832<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 5833member variable template instantiations. 5834 5835Given 5836 template <typename T> class X {}; class A {}; X<A> x; 5837or 5838 template <typename T> class X {}; class A {}; template class X<A>; 5839or 5840 template <typename T> class X {}; class A {}; extern template class X<A>; 5841cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 5842 matches the template instantiation of X<A>. 5843 5844But given 5845 template <typename T> class X {}; class A {}; 5846 template <> class X<A> {}; X<A> x; 5847cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 5848 does not match, as X<A> is an explicit template specialization. 5849 5850Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 5851</pre></td></tr> 5852 5853<!--END_NARROWING_MATCHERS --> 5854</table> 5855 5856<!-- ======================================================================= --> 5857<h2 id="traversal-matchers">AST Traversal Matchers</h2> 5858<!-- ======================================================================= --> 5859 5860<p>Traversal matchers specify the relationship to other nodes that are 5861reachable from the current node.</p> 5862 5863<p>Note that there are special traversal matchers (has, hasDescendant, forEach and 5864forEachDescendant) which work on all nodes and allow users to write more generic 5865match expressions.</p> 5866 5867<table> 5868<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 5869<!-- START_TRAVERSAL_MATCHERS --> 5870 5871<tr><td>Matcher<*></td><td class="name" onclick="toggle('binaryOperation0')"><a name="binaryOperation0Anchor">binaryOperation</a></td><td>Matcher<*>...Matcher<*></td></tr> 5872<tr><td colspan="4" class="doc" id="binaryOperation0"><pre>Matches nodes which can be used with binary operators. 5873 5874The code 5875 var1 != var2; 5876might be represented in the clang AST as a binaryOperator, a 5877cxxOperatorCallExpr or a cxxRewrittenBinaryOperator, depending on 5878 5879* whether the types of var1 and var2 are fundamental (binaryOperator) or at 5880 least one is a class type (cxxOperatorCallExpr) 5881* whether the code appears in a template declaration, if at least one of the 5882 vars is a dependent-type (binaryOperator) 5883* whether the code relies on a rewritten binary operator, such as a 5884spaceship operator or an inverted equality operator 5885(cxxRewrittenBinaryOperator) 5886 5887This matcher elides details in places where the matchers for the nodes are 5888compatible. 5889 5890Given 5891 binaryOperation( 5892 hasOperatorName("!="), 5893 hasLHS(expr().bind("lhs")), 5894 hasRHS(expr().bind("rhs")) 5895 ) 5896matches each use of "!=" in: 5897 struct S{ 5898 bool operator!=(const S&) const; 5899 }; 5900 5901 void foo() 5902 { 5903 1 != 2; 5904 S() != S(); 5905 } 5906 5907 template<typename T> 5908 void templ() 5909 { 5910 1 != 2; 5911 T() != S(); 5912 } 5913 struct HasOpEq 5914 { 5915 bool operator==(const HasOpEq &) const; 5916 }; 5917 5918 void inverse() 5919 { 5920 HasOpEq s1; 5921 HasOpEq s2; 5922 if (s1 != s2) 5923 return; 5924 } 5925 5926 struct HasSpaceship 5927 { 5928 bool operator<=>(const HasOpEq &) const; 5929 }; 5930 5931 void use_spaceship() 5932 { 5933 HasSpaceship s1; 5934 HasSpaceship s2; 5935 if (s1 != s2) 5936 return; 5937 } 5938</pre></td></tr> 5939 5940 5941<tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 5942<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. 5943 5944Unlike anyOf, eachOf will generate a match result for each 5945matching submatcher. 5946 5947For example, in: 5948 class A { int a; int b; }; 5949The matcher: 5950 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), 5951 has(fieldDecl(hasName("b")).bind("v")))) 5952will generate two results binding "v", the first of which binds 5953the field declaration of a, the second the field declaration of 5954b. 5955 5956Usable as: Any Matcher 5957</pre></td></tr> 5958 5959 5960<tr><td>Matcher<*></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<*> Matcher</td></tr> 5961<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. 5962 5963Generates results for each match. 5964 5965For example, in: 5966 class A { class B {}; class C {}; }; 5967The matcher: 5968 cxxRecordDecl(hasName("::A"), 5969 findAll(cxxRecordDecl(isDefinition()).bind("m"))) 5970will generate results for A, B and C. 5971 5972Usable as: Any Matcher 5973</pre></td></tr> 5974 5975 5976<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> 5977<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 5978provided matcher. 5979 5980Example matches X, A, A::X, B, B::C, B::C::X 5981 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) 5982 class X {}; 5983 class A { class X {}; }; // Matches A, because A::X is a class of name 5984 // X inside A. 5985 class B { class C { class X {}; }; }; 5986 5987DescendantT must be an AST base type. 5988 5989As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 5990each result that matches instead of only on the first one. 5991 5992Note: Recursively combined ForEachDescendant can cause many matches: 5993 cxxRecordDecl(forEachDescendant(cxxRecordDecl( 5994 forEachDescendant(cxxRecordDecl()) 5995 ))) 5996will match 10 times (plus injected class name matches) on: 5997 class A { class B { class C { class D { class E {}; }; }; }; }; 5998 5999Usable as: Any Matcher 6000</pre></td></tr> 6001 6002 6003<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> 6004<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 6005provided matcher. 6006 6007Example matches X, Y, Y::X, Z::Y, Z::Y::X 6008 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) 6009 class X {}; 6010 class Y { class X {}; }; // Matches Y, because Y::X is a class of name X 6011 // inside Y. 6012 class Z { class Y { class X {}; }; }; // Does not match Z. 6013 6014ChildT must be an AST base type. 6015 6016As opposed to 'has', 'forEach' will cause a match for each result that 6017matches instead of only on the first one. 6018 6019Usable as: Any Matcher 6020</pre></td></tr> 6021 6022 6023<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> 6024<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 6025matcher. 6026 6027Given 6028void f() { if (true) { int x = 42; } } 6029void g() { for (;;) { int x = 43; } } 6030expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 6031 6032Usable as: Any Matcher 6033</pre></td></tr> 6034 6035 6036<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> 6037<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 6038provided matcher. 6039 6040Example matches X, Y, Z 6041 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) 6042 class X {}; // Matches X, because X::X is a class of name X inside X. 6043 class Y { class X {}; }; 6044 class Z { class Y { class X {}; }; }; 6045 6046DescendantT must be an AST base type. 6047 6048Usable as: Any Matcher 6049</pre></td></tr> 6050 6051 6052<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> 6053<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 6054provided matcher. 6055 6056Example matches X, Y 6057 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) 6058 class X {}; // Matches X, because X::X is a class of name X inside X. 6059 class Y { class X {}; }; 6060 class Z { class Y { class X {}; }; }; // Does not match Z. 6061 6062ChildT must be an AST base type. 6063 6064Usable as: Any Matcher 6065Note that has is direct matcher, so it also matches things like implicit 6066casts and paren casts. If you are matching with expr then you should 6067probably consider using ignoringParenImpCasts like: 6068has(ignoringParenImpCasts(expr())). 6069</pre></td></tr> 6070 6071 6072<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> 6073<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 6074matcher. 6075 6076Given 6077void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 6078compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 6079 6080Usable as: Any Matcher 6081</pre></td></tr> 6082 6083 6084<tr><td>Matcher<*></td><td class="name" onclick="toggle('invocation0')"><a name="invocation0Anchor">invocation</a></td><td>Matcher<*>...Matcher<*></td></tr> 6085<tr><td colspan="4" class="doc" id="invocation0"><pre>Matches function calls and constructor calls 6086 6087Because CallExpr and CXXConstructExpr do not share a common 6088base class with API accessing arguments etc, AST Matchers for code 6089which should match both are typically duplicated. This matcher 6090removes the need for duplication. 6091 6092Given code 6093struct ConstructorTakesInt 6094{ 6095 ConstructorTakesInt(int i) {} 6096}; 6097 6098void callTakesInt(int i) 6099{ 6100} 6101 6102void doCall() 6103{ 6104 callTakesInt(42); 6105} 6106 6107void doConstruct() 6108{ 6109 ConstructorTakesInt cti(42); 6110} 6111 6112The matcher 6113invocation(hasArgument(0, integerLiteral(equals(42)))) 6114matches the expression in both doCall and doConstruct 6115</pre></td></tr> 6116 6117 6118<tr><td>Matcher<*></td><td class="name" onclick="toggle('optionally0')"><a name="optionally0Anchor">optionally</a></td><td>Matcher<*></td></tr> 6119<tr><td colspan="4" class="doc" id="optionally0"><pre>Matches any node regardless of the submatcher. 6120 6121However, optionally will retain any bindings generated by the submatcher. 6122Useful when additional information which may or may not present about a main 6123matching node is desired. 6124 6125For example, in: 6126 class Foo { 6127 int bar; 6128 } 6129The matcher: 6130 cxxRecordDecl( 6131 optionally(has( 6132 fieldDecl(hasName("bar")).bind("var") 6133 ))).bind("record") 6134will produce a result binding for both "record" and "var". 6135The matcher will produce a "record" binding for even if there is no data 6136member named "bar" in that class. 6137 6138Usable as: Any Matcher 6139</pre></td></tr> 6140 6141 6142<tr><td>Matcher<*></td><td class="name" onclick="toggle('traverse0')"><a name="traverse0Anchor">traverse</a></td><td>TraversalKind TK, Matcher<*> InnerMatcher</td></tr> 6143<tr><td colspan="4" class="doc" id="traverse0"><pre>Causes all nested matchers to be matched with the specified traversal kind. 6144 6145Given 6146 void foo() 6147 { 6148 int i = 3.0; 6149 } 6150The matcher 6151 traverse(TK_IgnoreUnlessSpelledInSource, 6152 varDecl(hasInitializer(floatLiteral().bind("init"))) 6153 ) 6154matches the variable declaration with "init" bound to the "3.0". 6155</pre></td></tr> 6156 6157 6158<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</a>></td><td class="name" onclick="toggle('hasCondition5')"><a name="hasCondition5Anchor">hasCondition</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6159<tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop, 6160switch statement or conditional operator. 6161 6162Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 6163 if (true) {} 6164</pre></td></tr> 6165 6166 6167<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</a>></td><td class="name" onclick="toggle('hasFalseExpression0')"><a name="hasFalseExpression0Anchor">hasFalseExpression</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6168<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator 6169(binary or ternary). 6170 6171Example matches b 6172 condition ? a : b 6173 condition ?: b 6174</pre></td></tr> 6175 6176 6177<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</a>></td><td class="name" onclick="toggle('hasTrueExpression0')"><a name="hasTrueExpression0Anchor">hasTrueExpression</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6178<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 6179 6180Example 1 (conditional ternary operator): matches a 6181 condition ? a : b 6182 6183Example 2 (conditional binary operator): matches opaqueValueExpr(condition) 6184 condition ?: b 6185</pre></td></tr> 6186 6187 6188<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>></td><td class="name" onclick="toggle('hasDeclaration15')"><a name="hasDeclaration15Anchor">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6189<tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node 6190matches the given matcher. 6191 6192The associated declaration is: 6193- for type nodes, the declaration of the underlying type 6194- for CallExpr, the declaration of the callee 6195- for MemberExpr, the declaration of the referenced member 6196- for CXXConstructExpr, the declaration of the constructor 6197- for CXXNewExpr, the declaration of the operator new 6198- for ObjCIvarExpr, the declaration of the ivar 6199 6200For type nodes, hasDeclaration will generally match the declaration of the 6201sugared type. Given 6202 class X {}; 6203 typedef X Y; 6204 Y y; 6205in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6206typedefDecl. A common use case is to match the underlying, desugared type. 6207This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6208 varDecl(hasType(hasUnqualifiedDesugaredType( 6209 recordType(hasDeclaration(decl()))))) 6210In this matcher, the decl will match the CXXRecordDecl of class X. 6211 6212Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 6213 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 6214 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 6215 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 6216 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 6217 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 6218 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6219</pre></td></tr> 6220 6221 6222<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6223<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 6224 6225Given 6226 int i[5]; 6227 void f() { i[1] = 42; } 6228arraySubscriptExpression(hasBase(implicitCastExpr( 6229 hasSourceExpression(declRefExpr())))) 6230 matches i[1] with the declRefExpr() matching i 6231</pre></td></tr> 6232 6233 6234<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6235<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 6236 6237Given 6238 int i[5]; 6239 void f() { i[1] = 42; } 6240arraySubscriptExpression(hasIndex(integerLiteral())) 6241 matches i[1] with the integerLiteral() matching 1 6242</pre></td></tr> 6243 6244 6245<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>></td><td class="name" onclick="toggle('hasLHS3')"><a name="hasLHS3Anchor">hasLHS</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6246<tr><td colspan="4" class="doc" id="hasLHS3"><pre>Matches the left hand side of binary operator expressions. 6247 6248Example matches a (matcher = binaryOperator(hasLHS())) 6249 a || b 6250</pre></td></tr> 6251 6252 6253<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>></td><td class="name" onclick="toggle('hasRHS3')"><a name="hasRHS3Anchor">hasRHS</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6254<tr><td colspan="4" class="doc" id="hasRHS3"><pre>Matches the right hand side of binary operator expressions. 6255 6256Example matches b (matcher = binaryOperator(hasRHS())) 6257 a || b 6258</pre></td></tr> 6259 6260 6261<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 6262<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element 6263type. 6264 6265Given 6266 struct A {}; 6267 A a[7]; 6268 int b[7]; 6269arrayType(hasElementType(builtinType())) 6270 matches "int b[7]" 6271 6272Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> 6273</pre></td></tr> 6274 6275 6276<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 6277<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. 6278 6279Given 6280 _Atomic(int) i; 6281 _Atomic(float) f; 6282atomicType(hasValueType(isInteger())) 6283 matches "_Atomic(int) i" 6284 6285Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 6286</pre></td></tr> 6287 6288 6289<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 6290<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. 6291 6292Note: There is no TypeLoc for the deduced type and thus no 6293getDeducedLoc() matcher. 6294 6295Given 6296 auto a = 1; 6297 auto b = 2.0; 6298autoType(hasDeducedType(isInteger())) 6299 matches "auto a" 6300 6301Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> 6302</pre></td></tr> 6303 6304 6305<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BaseUsingDecl.html">BaseUsingDecl</a>></td><td class="name" onclick="toggle('hasAnyUsingShadowDecl0')"><a name="hasAnyUsingShadowDecl0Anchor">hasAnyUsingShadowDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>> InnerMatcher</td></tr> 6306<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 6307 6308Given 6309 namespace X { void b(); } 6310 using X::b; 6311usingDecl(hasAnyUsingShadowDecl(hasName("b")))) 6312 matches using X::b </pre></td></tr> 6313 6314 6315<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6316<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 6317binary operator matches. 6318</pre></td></tr> 6319 6320 6321<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6322<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 6323 6324Example matches a (matcher = binaryOperator(hasLHS())) 6325 a || b 6326</pre></td></tr> 6327 6328 6329<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('hasOperands0')"><a name="hasOperands0Anchor">hasOperands</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> Matcher1, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> Matcher2</td></tr> 6330<tr><td colspan="4" class="doc" id="hasOperands0"><pre>Matches if both matchers match with opposite sides of the binary operator. 6331 6332Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1), 6333 integerLiteral(equals(2))) 6334 1 + 2 // Match 6335 2 + 1 // Match 6336 1 + 1 // No match 6337 2 + 2 // No match 6338</pre></td></tr> 6339 6340 6341<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6342<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 6343 6344Example matches b (matcher = binaryOperator(hasRHS())) 6345 a || b 6346</pre></td></tr> 6347 6348 6349<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html">BindingDecl</a>></td><td class="name" onclick="toggle('forDecomposition0')"><a name="forDecomposition0Anchor">forDecomposition</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>> InnerMatcher</td></tr> 6350<tr><td colspan="4" class="doc" id="forDecomposition0"><pre>Matches the DecompositionDecl the binding belongs to. 6351 6352For example, in: 6353void foo() 6354{ 6355 int arr[3]; 6356 auto &[f, s, t] = arr; 6357 6358 f = 42; 6359} 6360The matcher: 6361 bindingDecl(hasName("f"), 6362 forDecomposition(decompositionDecl()) 6363matches 'f' in 'auto &[f, s, t]'. 6364</pre></td></tr> 6365 6366 6367<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>></td><td class="name" onclick="toggle('hasAnyParameter2')"><a name="hasAnyParameter2Anchor">hasAnyParameter</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> 6368<tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a 6369block. 6370 6371Does not match the 'this' parameter of a method. 6372 6373Given 6374 class X { void f(int x, int y, int z) {} }; 6375cxxMethodDecl(hasAnyParameter(hasName("y"))) 6376 matches f(int x, int y, int z) {} 6377with hasAnyParameter(...) 6378 matching int y 6379 6380For ObjectiveC, given 6381 @interface I - (void) f:(int) y; @end 6382 6383the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 6384matches the declaration of method f with hasParameter 6385matching y. 6386 6387For blocks, given 6388 b = ^(int y) { printf("%d", y) }; 6389 6390the matcher blockDecl(hasAnyParameter(hasName("y"))) 6391matches the declaration of the block b with hasParameter 6392matching y. 6393</pre></td></tr> 6394 6395 6396<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>></td><td class="name" onclick="toggle('hasParameter2')"><a name="hasParameter2Anchor">hasParameter</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> 6397<tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method 6398declaration or a block. 6399 6400Given 6401 class X { void f(int x) {} }; 6402cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 6403 matches f(int x) {} 6404with hasParameter(...) 6405 matching int x 6406 6407For ObjectiveC, given 6408 @interface I - (void) f:(int) y; @end 6409 6410the matcher objcMethodDecl(hasParameter(0, hasName("y"))) 6411matches the declaration of method f with hasParameter 6412matching y. 6413</pre></td></tr> 6414 6415 6416<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>></td><td class="name" onclick="toggle('hasTypeLoc0')"><a name="hasTypeLoc0Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 6417<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of a node matches the inner matcher. 6418 6419Examples: 6420 int x; 6421declaratorDecl(hasTypeLoc(loc(asString("int")))) 6422 matches int x 6423 6424auto x = int(3); 6425cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 6426 matches int(3) 6427 6428struct Foo { Foo(int, int); }; 6429auto x = Foo(1, 2); 6430cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 6431 matches Foo(1, 2) 6432 6433Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 6434 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 6435 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 6436 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 6437 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 6438 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 6439 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 6440 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 6441</pre></td></tr> 6442 6443 6444<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 6445<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the 6446pointee matches a given matcher. 6447 6448Given 6449 int *a; 6450 int const *b; 6451 float const *f; 6452pointerType(pointee(isConstQualified(), isInteger())) 6453 matches "int const *b" 6454 6455Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 6456 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 6457</pre></td></tr> 6458 6459 6460<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>></td><td class="name" onclick="toggle('hasTypeLoc1')"><a name="hasTypeLoc1Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 6461<tr><td colspan="4" class="doc" id="hasTypeLoc1"><pre>Matches if the type location of a node matches the inner matcher. 6462 6463Examples: 6464 int x; 6465declaratorDecl(hasTypeLoc(loc(asString("int")))) 6466 matches int x 6467 6468auto x = int(3); 6469cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 6470 matches int(3) 6471 6472struct Foo { Foo(int, int); }; 6473auto x = Foo(1, 2); 6474cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 6475 matches Foo(1, 2) 6476 6477Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 6478 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 6479 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 6480 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 6481 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 6482 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 6483 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 6484 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 6485</pre></td></tr> 6486 6487 6488<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>></td><td class="name" onclick="toggle('hasType8')"><a name="hasType8Anchor">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6489<tr><td colspan="4" class="doc" id="hasType8"><pre>Overloaded to match the declaration of the expression's or value 6490declaration's type. 6491 6492In case of a value declaration (for example a variable declaration), 6493this resolves one layer of indirection. For example, in the value 6494declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 6495X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 6496declaration of x. 6497 6498Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6499 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6500 and friend class X (matcher = friendDecl(hasType("X")) 6501 and public virtual X (matcher = cxxBaseSpecifier(hasType( 6502 cxxRecordDecl(hasName("X")))) 6503 class X {}; 6504 void y(X &x) { x; X z; } 6505 class Y { friend class X; }; 6506 class Z : public virtual X {}; 6507 6508Example matches class Derived 6509(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) 6510class Base {}; 6511class Derived : Base {}; 6512 6513Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>, 6514Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> 6515</pre></td></tr> 6516 6517 6518<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>></td><td class="name" onclick="toggle('hasType4')"><a name="hasType4Anchor">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 6519<tr><td colspan="4" class="doc" id="hasType4"><pre>Matches if the expression's or declaration's type matches a type 6520matcher. 6521 6522Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6523 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6524 and U (matcher = typedefDecl(hasType(asString("int"))) 6525 and friend class X (matcher = friendDecl(hasType("X")) 6526 and public virtual X (matcher = cxxBaseSpecifier(hasType( 6527 asString("class X"))) 6528 class X {}; 6529 void y(X &x) { x; X z; } 6530 typedef int U; 6531 class Y { friend class X; }; 6532 class Z : public virtual X {}; 6533</pre></td></tr> 6534 6535 6536<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('forEachArgumentWithParam1')"><a name="forEachArgumentWithParam1Anchor">forEachArgumentWithParam</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> ArgMatcher, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> ParamMatcher</td></tr> 6537<tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl. 6538 6539Given 6540 void f(int i); 6541 int y; 6542 f(y); 6543callExpr( 6544 forEachArgumentWithParam( 6545 declRefExpr(to(varDecl(hasName("y")))), 6546 parmVarDecl(hasType(isInteger())) 6547)) 6548 matches f(y); 6549with declRefExpr(...) 6550 matching int y 6551and parmVarDecl(...) 6552 matching int i 6553</pre></td></tr> 6554 6555 6556<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('forEachArgumentWithParamType1')"><a name="forEachArgumentWithParamType1Anchor">forEachArgumentWithParamType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> ArgMatcher, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> ParamMatcher</td></tr> 6557<tr><td colspan="4" class="doc" id="forEachArgumentWithParamType1"><pre>Matches all arguments and their respective types for a CallExpr or 6558CXXConstructExpr. It is very similar to forEachArgumentWithParam but 6559it works on calls through function pointers as well. 6560 6561The difference is, that function pointers do not provide access to a 6562ParmVarDecl, but only the QualType for each argument. 6563 6564Given 6565 void f(int i); 6566 int y; 6567 f(y); 6568 void (*f_ptr)(int) = f; 6569 f_ptr(y); 6570callExpr( 6571 forEachArgumentWithParamType( 6572 declRefExpr(to(varDecl(hasName("y")))), 6573 qualType(isInteger()).bind("type) 6574)) 6575 matches f(y) and f_ptr(y) 6576with declRefExpr(...) 6577 matching int y 6578and qualType(...) 6579 matching int 6580</pre></td></tr> 6581 6582 6583<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6584<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call 6585expression, or an ObjC-message-send expression. 6586 6587Given 6588 void x(int, int, int) { int y; x(1, y, 42); } 6589callExpr(hasAnyArgument(declRefExpr())) 6590 matches x(1, y, 42) 6591with hasAnyArgument(...) 6592 matching y 6593 6594For ObjectiveC, given 6595 @interface I - (void) f:(int) y; @end 6596 void foo(I *i) { [i f:12]; } 6597objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 6598 matches [i f:12] 6599</pre></td></tr> 6600 6601 6602<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6603<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor 6604call expression. 6605 6606Example matches y in x(y) 6607 (matcher = callExpr(hasArgument(0, declRefExpr()))) 6608 void x(int) { int y; x(y); } 6609</pre></td></tr> 6610 6611 6612<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasDeclaration13')"><a name="hasDeclaration13Anchor">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6613<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node 6614matches the given matcher. 6615 6616The associated declaration is: 6617- for type nodes, the declaration of the underlying type 6618- for CallExpr, the declaration of the callee 6619- for MemberExpr, the declaration of the referenced member 6620- for CXXConstructExpr, the declaration of the constructor 6621- for CXXNewExpr, the declaration of the operator new 6622- for ObjCIvarExpr, the declaration of the ivar 6623 6624For type nodes, hasDeclaration will generally match the declaration of the 6625sugared type. Given 6626 class X {}; 6627 typedef X Y; 6628 Y y; 6629in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6630typedefDecl. A common use case is to match the underlying, desugared type. 6631This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6632 varDecl(hasType(hasUnqualifiedDesugaredType( 6633 recordType(hasDeclaration(decl()))))) 6634In this matcher, the decl will match the CXXRecordDecl of class X. 6635 6636Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 6637 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 6638 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 6639 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 6640 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 6641 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 6642 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6643</pre></td></tr> 6644 6645 6646<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>> InnerMatcher</td></tr> 6647<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. 6648 6649Given 6650 class A { A() : i(42), j(42) {} int i; int j; }; 6651cxxConstructorDecl(forEachConstructorInitializer( 6652 forField(decl().bind("x")) 6653)) 6654 will trigger two matches, binding for 'i' and 'j' respectively. 6655</pre></td></tr> 6656 6657 6658<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>> InnerMatcher</td></tr> 6659<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 6660 6661Given 6662 struct Foo { 6663 Foo() : foo_(1) { } 6664 int foo_; 6665 }; 6666cxxRecordDecl(has(cxxConstructorDecl( 6667 hasAnyConstructorInitializer(anything()) 6668))) 6669 record matches Foo, hasAnyConstructorInitializer matches foo_(1) 6670</pre></td></tr> 6671 6672 6673<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>> InnerMatcher</td></tr> 6674<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 6675 6676Given 6677 struct Foo { 6678 Foo() : foo_(1) { } 6679 int foo_; 6680 }; 6681cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 6682 forField(hasName("foo_")))))) 6683 matches Foo 6684with forField matching foo_ 6685</pre></td></tr> 6686 6687 6688<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('hasTypeLoc2')"><a name="hasTypeLoc2Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 6689<tr><td colspan="4" class="doc" id="hasTypeLoc2"><pre>Matches if the type location of a node matches the inner matcher. 6690 6691Examples: 6692 int x; 6693declaratorDecl(hasTypeLoc(loc(asString("int")))) 6694 matches int x 6695 6696auto x = int(3); 6697cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 6698 matches int(3) 6699 6700struct Foo { Foo(int, int); }; 6701auto x = Foo(1, 2); 6702cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 6703 matches Foo(1, 2) 6704 6705Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 6706 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 6707 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 6708 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 6709 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 6710 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 6711 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 6712 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 6713</pre></td></tr> 6714 6715 6716<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6717<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 6718 6719Given 6720 struct Foo { 6721 Foo() : foo_(1) { } 6722 int foo_; 6723 }; 6724cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 6725 withInitializer(integerLiteral(equals(1))))))) 6726 matches Foo 6727with withInitializer matching (1) 6728</pre></td></tr> 6729 6730 6731<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>></td><td class="name" onclick="toggle('hasObjectExpression2')"><a name="hasObjectExpression2Anchor">hasObjectExpression</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6732<tr><td colspan="4" class="doc" id="hasObjectExpression2"><pre>Matches a member expression where the object expression is matched by a 6733given matcher. Implicit object expressions are included; that is, it matches 6734use of implicit `this`. 6735 6736Given 6737 struct X { 6738 int m; 6739 int f(X x) { x.m; return m; } 6740 }; 6741memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) 6742 matches `x.m`, but not `m`; however, 6743memberExpr(hasObjectExpression(hasType(pointsTo( 6744 cxxRecordDecl(hasName("X")))))) 6745 matches `m` (aka. `this->m`), but not `x.m`. 6746</pre></td></tr> 6747 6748 6749<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 6750<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'do' statement or a function definition that has 6751a given body. Note that in case of functions this matcher only matches the 6752definition itself and not the other declarations of the same function. 6753 6754Given 6755 for (;;) {} 6756forStmt(hasBody(compoundStmt())) 6757 matches 'for (;;) {}' 6758with compoundStmt() 6759 matching '{}' 6760 6761Given 6762 void f(); 6763 void f() {} 6764functionDecl(hasBody(compoundStmt())) 6765 matches 'void f() {}' 6766with compoundStmt() 6767 matching '{}' 6768 but does not match 'void f();' 6769</pre></td></tr> 6770 6771 6772<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasInitStatement2')"><a name="hasInitStatement2Anchor">hasInitStatement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 6773<tr><td colspan="4" class="doc" id="hasInitStatement2"><pre>Matches selection statements with initializer. 6774 6775Given: 6776 void foo() { 6777 if (int i = foobar(); i > 0) {} 6778 switch (int i = foobar(); i) {} 6779 for (auto& a = get_range(); auto& x : a) {} 6780 } 6781 void bar() { 6782 if (foobar() > 0) {} 6783 switch (foobar()) {} 6784 for (auto& x : get_range()) {} 6785 } 6786ifStmt(hasInitStatement(anything())) 6787 matches the if statement in foo but not in bar. 6788switchStmt(hasInitStatement(anything())) 6789 matches the switch statement in foo but not in bar. 6790cxxForRangeStmt(hasInitStatement(anything())) 6791 matches the range for statement in foo but not in bar. 6792</pre></td></tr> 6793 6794 6795<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>> InnerMatcher</td></tr> 6796<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. 6797 6798Example: 6799 forStmt(hasLoopVariable(anything())) 6800matches 'int x' in 6801 for (int x : a) { } 6802</pre></td></tr> 6803 6804 6805<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6806<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. 6807 6808Example: 6809 forStmt(hasRangeInit(anything())) 6810matches 'a' in 6811 for (int x : a) { } 6812</pre></td></tr> 6813 6814 6815<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>></td><td class="name" onclick="toggle('hasTypeLoc3')"><a name="hasTypeLoc3Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 6816<tr><td colspan="4" class="doc" id="hasTypeLoc3"><pre>Matches if the type location of a node matches the inner matcher. 6817 6818Examples: 6819 int x; 6820declaratorDecl(hasTypeLoc(loc(asString("int")))) 6821 matches int x 6822 6823auto x = int(3); 6824cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 6825 matches int(3) 6826 6827struct Foo { Foo(int, int); }; 6828auto x = Foo(1, 2); 6829cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 6830 matches Foo(1, 2) 6831 6832Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 6833 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 6834 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 6835 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 6836 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 6837 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 6838 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 6839 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 6840</pre></td></tr> 6841 6842 6843<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6844<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre>Matches on the implicit object argument of a member call expression. Unlike 6845`on`, matches the argument directly without stripping away anything. 6846 6847Given 6848 class Y { public: void m(); }; 6849 Y g(); 6850 class X : public Y { void g(); }; 6851 void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); } 6852cxxMemberCallExpr(onImplicitObjectArgument(hasType( 6853 cxxRecordDecl(hasName("Y"))))) 6854 matches `y.m()`, `x.m()` and (g()).m(), but not `x.g()`. 6855cxxMemberCallExpr(on(callExpr())) 6856 does not match `(g()).m()`, because the parens are not ignored. 6857 6858FIXME: Overload to allow directly matching types? 6859</pre></td></tr> 6860 6861 6862<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6863<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression, after 6864stripping off any parentheses or implicit casts. 6865 6866Given 6867 class Y { public: void m(); }; 6868 Y g(); 6869 class X : public Y {}; 6870 void z(Y y, X x) { y.m(); (g()).m(); x.m(); } 6871cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))))) 6872 matches `y.m()` and `(g()).m()`. 6873cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X"))))) 6874 matches `x.m()`. 6875cxxMemberCallExpr(on(callExpr())) 6876 matches `(g()).m()`. 6877 6878FIXME: Overload to allow directly matching types? 6879</pre></td></tr> 6880 6881 6882<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6883<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 6884</pre></td></tr> 6885 6886 6887<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 6888<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the type of the expression's implicit object argument either 6889matches the InnerMatcher, or is a pointer to a type that matches the 6890InnerMatcher. 6891 6892Given 6893 class Y { public: void m(); }; 6894 class X : public Y { void g(); }; 6895 void z() { Y y; y.m(); Y *p; p->m(); X x; x.m(); x.g(); } 6896cxxMemberCallExpr(thisPointerType(hasDeclaration( 6897 cxxRecordDecl(hasName("Y"))))) 6898 matches `y.m()`, `p->m()` and `x.m()`. 6899cxxMemberCallExpr(thisPointerType(hasDeclaration( 6900 cxxRecordDecl(hasName("X"))))) 6901 matches `x.g()`. 6902</pre></td></tr> 6903 6904 6905<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('forEachOverridden0')"><a name="forEachOverridden0Anchor">forEachOverridden</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> InnerMatcher</td></tr> 6906<tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may 6907produce multiple matches. 6908 6909Given 6910 class A { virtual void f(); }; 6911 class B : public A { void f(); }; 6912 class C : public B { void f(); }; 6913cxxMethodDecl(ofClass(hasName("C")), 6914 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") 6915 matches once, with "b" binding "A::f" and "d" binding "C::f" (Note 6916 that B::f is not overridden by C::f). 6917 6918The check can produce multiple matches in case of multiple inheritance, e.g. 6919 class A1 { virtual void f(); }; 6920 class A2 { virtual void f(); }; 6921 class C : public A1, public A2 { void f(); }; 6922cxxMethodDecl(ofClass(hasName("C")), 6923 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") 6924 matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and 6925 once with "b" binding "A2::f" and "d" binding "C::f". 6926</pre></td></tr> 6927 6928 6929<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> InnerMatcher</td></tr> 6930<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 6931belongs to. 6932 6933FIXME: Generalize this for other kinds of declarations. 6934FIXME: What other kind of declarations would we need to generalize 6935this to? 6936 6937Example matches A() in the last line 6938 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( 6939 ofClass(hasName("A")))))) 6940 class A { 6941 public: 6942 A(); 6943 }; 6944 A a = A(); 6945</pre></td></tr> 6946 6947 6948<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('hasAnyPlacementArg0')"><a name="hasAnyPlacementArg0Anchor">hasAnyPlacementArg</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6949<tr><td colspan="4" class="doc" id="hasAnyPlacementArg0"><pre>Matches any placement new expression arguments. 6950 6951Given: 6952 MyClass *p1 = new (Storage) MyClass(); 6953cxxNewExpr(hasAnyPlacementArg(anything())) 6954 matches the expression 'new (Storage, 16) MyClass()'. 6955</pre></td></tr> 6956 6957 6958<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('hasArraySize0')"><a name="hasArraySize0Anchor">hasArraySize</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6959<tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size. 6960 6961Given: 6962 MyClass *p1 = new MyClass[10]; 6963cxxNewExpr(hasArraySize(integerLiteral(equals(10)))) 6964 matches the expression 'new MyClass[10]'. 6965</pre></td></tr> 6966 6967 6968<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('hasDeclaration12')"><a name="hasDeclaration12Anchor">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6969<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node 6970matches the given matcher. 6971 6972The associated declaration is: 6973- for type nodes, the declaration of the underlying type 6974- for CallExpr, the declaration of the callee 6975- for MemberExpr, the declaration of the referenced member 6976- for CXXConstructExpr, the declaration of the constructor 6977- for CXXNewExpr, the declaration of the operator new 6978- for ObjCIvarExpr, the declaration of the ivar 6979 6980For type nodes, hasDeclaration will generally match the declaration of the 6981sugared type. Given 6982 class X {}; 6983 typedef X Y; 6984 Y y; 6985in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6986typedefDecl. A common use case is to match the underlying, desugared type. 6987This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6988 varDecl(hasType(hasUnqualifiedDesugaredType( 6989 recordType(hasDeclaration(decl()))))) 6990In this matcher, the decl will match the CXXRecordDecl of class X. 6991 6992Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 6993 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 6994 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 6995 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 6996 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 6997 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 6998 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6999</pre></td></tr> 7000 7001 7002<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('hasPlacementArg0')"><a name="hasPlacementArg0Anchor">hasPlacementArg</a></td><td>unsigned Index, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7003<tr><td colspan="4" class="doc" id="hasPlacementArg0"><pre>Matches placement new expression arguments. 7004 7005Given: 7006 MyClass *p1 = new (Storage, 16) MyClass(); 7007cxxNewExpr(hasPlacementArg(1, integerLiteral(equals(16)))) 7008 matches the expression 'new (Storage, 16) MyClass()'. 7009</pre></td></tr> 7010 7011 7012<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('hasTypeLoc4')"><a name="hasTypeLoc4Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 7013<tr><td colspan="4" class="doc" id="hasTypeLoc4"><pre>Matches if the type location of a node matches the inner matcher. 7014 7015Examples: 7016 int x; 7017declaratorDecl(hasTypeLoc(loc(asString("int")))) 7018 matches int x 7019 7020auto x = int(3); 7021cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 7022 matches int(3) 7023 7024struct Foo { Foo(int, int); }; 7025auto x = Foo(1, 2); 7026cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 7027 matches Foo(1, 2) 7028 7029Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 7030 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 7031 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 7032 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 7033 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 7034 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 7035 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 7036 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 7037</pre></td></tr> 7038 7039 7040<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasEitherOperand1')"><a name="hasEitherOperand1Anchor">hasEitherOperand</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7041<tr><td colspan="4" class="doc" id="hasEitherOperand1"><pre>Matches if either the left hand side or the right hand side of a 7042binary operator matches. 7043</pre></td></tr> 7044 7045 7046<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasLHS1')"><a name="hasLHS1Anchor">hasLHS</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7047<tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions. 7048 7049Example matches a (matcher = binaryOperator(hasLHS())) 7050 a || b 7051</pre></td></tr> 7052 7053 7054<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasOperands1')"><a name="hasOperands1Anchor">hasOperands</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> Matcher1, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> Matcher2</td></tr> 7055<tr><td colspan="4" class="doc" id="hasOperands1"><pre>Matches if both matchers match with opposite sides of the binary operator. 7056 7057Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1), 7058 integerLiteral(equals(2))) 7059 1 + 2 // Match 7060 2 + 1 // Match 7061 1 + 1 // No match 7062 2 + 2 // No match 7063</pre></td></tr> 7064 7065 7066<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasRHS1')"><a name="hasRHS1Anchor">hasRHS</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7067<tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions. 7068 7069Example matches b (matcher = binaryOperator(hasRHS())) 7070 a || b 7071</pre></td></tr> 7072 7073 7074<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasUnaryOperand1')"><a name="hasUnaryOperand1Anchor">hasUnaryOperand</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7075<tr><td colspan="4" class="doc" id="hasUnaryOperand1"><pre>Matches if the operand of a unary operator matches. 7076 7077Example matches true (matcher = hasUnaryOperand( 7078 cxxBoolLiteral(equals(true)))) 7079 !true 7080</pre></td></tr> 7081 7082 7083<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('hasAnyBase0')"><a name="hasAnyBase0Anchor">hasAnyBase</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> BaseSpecMatcher</td></tr> 7084<tr><td colspan="4" class="doc" id="hasAnyBase0"><pre>Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher. 7085 7086Example: 7087matcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase")))) 7088 class Foo; 7089 class Bar : Foo {}; 7090 class Baz : Bar {}; 7091 class SpecialBase; 7092 class Proxy : SpecialBase {}; // matches Proxy 7093 class IndirectlyDerived : Proxy {}; //matches IndirectlyDerived 7094 7095FIXME: Refactor this and isDerivedFrom to reuse implementation. 7096</pre></td></tr> 7097 7098 7099<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('hasDirectBase0')"><a name="hasDirectBase0Anchor">hasDirectBase</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> BaseSpecMatcher</td></tr> 7100<tr><td colspan="4" class="doc" id="hasDirectBase0"><pre>Matches C++ classes that have a direct base matching BaseSpecMatcher. 7101 7102Example: 7103matcher hasDirectBase(hasType(cxxRecordDecl(hasName("SpecialBase")))) 7104 class Foo; 7105 class Bar : Foo {}; 7106 class Baz : Bar {}; 7107 class SpecialBase; 7108 class Proxy : SpecialBase {}; // matches Proxy 7109 class IndirectlyDerived : Proxy {}; // doesn't match 7110</pre></td></tr> 7111 7112 7113<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> InnerMatcher</td></tr> 7114<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. 7115 7116Given: 7117 class A { void func(); }; 7118 class B { void member(); }; 7119 7120cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of 7121A but not B. 7122</pre></td></tr> 7123 7124 7125<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> Base</td></tr> 7126<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from a class 7127matching Base, or Objective-C classes that directly or indirectly 7128subclass a class matching Base. 7129 7130Note that a class is not considered to be derived from itself. 7131 7132Example matches Y, Z, C (Base == hasName("X")) 7133 class X; 7134 class Y : public X {}; // directly derived 7135 class Z : public Y {}; // indirectly derived 7136 typedef X A; 7137 typedef A B; 7138 class C : public B {}; // derived from a typedef of X 7139 7140In the following example, Bar matches isDerivedFrom(hasName("X")): 7141 class Foo; 7142 typedef Foo X; 7143 class Bar : public Foo {}; // derived from a type that X is a typedef of 7144 7145In the following example, Bar matches isDerivedFrom(hasName("NSObject")) 7146 @interface NSObject @end 7147 @interface Bar : NSObject @end 7148 7149Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>> 7150</pre></td></tr> 7151 7152 7153<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isDirectlyDerivedFrom0')"><a name="isDirectlyDerivedFrom0Anchor">isDirectlyDerivedFrom</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> Base</td></tr> 7154<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom0"><pre>Matches C++ or Objective-C classes that are directly derived from a class 7155matching Base. 7156 7157Note that a class is not considered to be derived from itself. 7158 7159Example matches Y, C (Base == hasName("X")) 7160 class X; 7161 class Y : public X {}; // directly derived 7162 class Z : public Y {}; // indirectly derived 7163 typedef X A; 7164 typedef A B; 7165 class C : public B {}; // derived from a typedef of X 7166 7167In the following example, Bar matches isDerivedFrom(hasName("X")): 7168 class Foo; 7169 typedef Foo X; 7170 class Bar : public Foo {}; // derived from a type that X is a typedef of 7171</pre></td></tr> 7172 7173 7174<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> Base</td></tr> 7175<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 7176match Base. 7177</pre></td></tr> 7178 7179 7180<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>></td><td class="name" onclick="toggle('hasEitherOperand2')"><a name="hasEitherOperand2Anchor">hasEitherOperand</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7181<tr><td colspan="4" class="doc" id="hasEitherOperand2"><pre>Matches if either the left hand side or the right hand side of a 7182binary operator matches. 7183</pre></td></tr> 7184 7185 7186<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>></td><td class="name" onclick="toggle('hasLHS2')"><a name="hasLHS2Anchor">hasLHS</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7187<tr><td colspan="4" class="doc" id="hasLHS2"><pre>Matches the left hand side of binary operator expressions. 7188 7189Example matches a (matcher = binaryOperator(hasLHS())) 7190 a || b 7191</pre></td></tr> 7192 7193 7194<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>></td><td class="name" onclick="toggle('hasOperands2')"><a name="hasOperands2Anchor">hasOperands</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> Matcher1, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> Matcher2</td></tr> 7195<tr><td colspan="4" class="doc" id="hasOperands2"><pre>Matches if both matchers match with opposite sides of the binary operator. 7196 7197Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1), 7198 integerLiteral(equals(2))) 7199 1 + 2 // Match 7200 2 + 1 // Match 7201 1 + 1 // No match 7202 2 + 2 // No match 7203</pre></td></tr> 7204 7205 7206<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>></td><td class="name" onclick="toggle('hasRHS2')"><a name="hasRHS2Anchor">hasRHS</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7207<tr><td colspan="4" class="doc" id="hasRHS2"><pre>Matches the right hand side of binary operator expressions. 7208 7209Example matches b (matcher = binaryOperator(hasRHS())) 7210 a || b 7211</pre></td></tr> 7212 7213 7214<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>></td><td class="name" onclick="toggle('hasTypeLoc5')"><a name="hasTypeLoc5Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 7215<tr><td colspan="4" class="doc" id="hasTypeLoc5"><pre>Matches if the type location of a node matches the inner matcher. 7216 7217Examples: 7218 int x; 7219declaratorDecl(hasTypeLoc(loc(asString("int")))) 7220 matches int x 7221 7222auto x = int(3); 7223cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 7224 matches int(3) 7225 7226struct Foo { Foo(int, int); }; 7227auto x = Foo(1, 2); 7228cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 7229 matches Foo(1, 2) 7230 7231Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 7232 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 7233 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 7234 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 7235 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 7236 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 7237 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 7238 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 7239</pre></td></tr> 7240 7241 7242<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>></td><td class="name" onclick="toggle('hasAnyArgument2')"><a name="hasAnyArgument2Anchor">hasAnyArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7243<tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call 7244expression, or an ObjC-message-send expression. 7245 7246Given 7247 void x(int, int, int) { int y; x(1, y, 42); } 7248callExpr(hasAnyArgument(declRefExpr())) 7249 matches x(1, y, 42) 7250with hasAnyArgument(...) 7251 matching y 7252 7253For ObjectiveC, given 7254 @interface I - (void) f:(int) y; @end 7255 void foo(I *i) { [i f:12]; } 7256objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 7257 matches [i f:12] 7258</pre></td></tr> 7259 7260 7261<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>></td><td class="name" onclick="toggle('hasArgument2')"><a name="hasArgument2Anchor">hasArgument</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7262<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor 7263call expression. 7264 7265Example matches y in x(y) 7266 (matcher = callExpr(hasArgument(0, declRefExpr()))) 7267 void x(int) { int y; x(y); } 7268</pre></td></tr> 7269 7270 7271<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>></td><td class="name" onclick="toggle('hasTypeLoc6')"><a name="hasTypeLoc6Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 7272<tr><td colspan="4" class="doc" id="hasTypeLoc6"><pre>Matches if the type location of a node matches the inner matcher. 7273 7274Examples: 7275 int x; 7276declaratorDecl(hasTypeLoc(loc(asString("int")))) 7277 matches int x 7278 7279auto x = int(3); 7280cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 7281 matches int(3) 7282 7283struct Foo { Foo(int, int); }; 7284auto x = Foo(1, 2); 7285cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 7286 matches Foo(1, 2) 7287 7288Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 7289 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 7290 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 7291 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 7292 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 7293 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 7294 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 7295 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 7296</pre></td></tr> 7297 7298 7299<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('callee2')"><a name="callee2Anchor">callee</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 7300<tr><td colspan="4" class="doc" id="callee2"><pre>Matches 1) if the call expression's callee's declaration matches the 7301given matcher; or 2) if the Obj-C message expression's callee's method 7302declaration matches the given matcher. 7303 7304Example matches y.x() (matcher = callExpr(callee( 7305 cxxMethodDecl(hasName("x"))))) 7306 class Y { public: void x(); }; 7307 void z() { Y y; y.x(); } 7308 7309Example 2. Matches [I foo] with 7310objcMessageExpr(callee(objcMethodDecl(hasName("foo")))) 7311 7312 @interface I: NSObject 7313 +(void)foo; 7314 @end 7315 ... 7316 [I foo] 7317</pre></td></tr> 7318 7319 7320<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 7321<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. 7322 7323Given 7324 class Y { void x() { this->x(); x(); Y y; y.x(); } }; 7325 void f() { f(); } 7326callExpr(callee(expr())) 7327 matches this->x(), x(), y.x(), f() 7328with callee(...) 7329 matching this->x, x, y.x, f respectively 7330 7331Note: Callee cannot take the more general internal::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> 7332because this introduces ambiguous overloads with calls to Callee taking a 7333internal::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely 7334implemented in terms of implicit casts. 7335</pre></td></tr> 7336 7337 7338<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('forEachArgumentWithParam0')"><a name="forEachArgumentWithParam0Anchor">forEachArgumentWithParam</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> ArgMatcher, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> ParamMatcher</td></tr> 7339<tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl. 7340 7341Given 7342 void f(int i); 7343 int y; 7344 f(y); 7345callExpr( 7346 forEachArgumentWithParam( 7347 declRefExpr(to(varDecl(hasName("y")))), 7348 parmVarDecl(hasType(isInteger())) 7349)) 7350 matches f(y); 7351with declRefExpr(...) 7352 matching int y 7353and parmVarDecl(...) 7354 matching int i 7355</pre></td></tr> 7356 7357 7358<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('forEachArgumentWithParamType0')"><a name="forEachArgumentWithParamType0Anchor">forEachArgumentWithParamType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> ArgMatcher, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> ParamMatcher</td></tr> 7359<tr><td colspan="4" class="doc" id="forEachArgumentWithParamType0"><pre>Matches all arguments and their respective types for a CallExpr or 7360CXXConstructExpr. It is very similar to forEachArgumentWithParam but 7361it works on calls through function pointers as well. 7362 7363The difference is, that function pointers do not provide access to a 7364ParmVarDecl, but only the QualType for each argument. 7365 7366Given 7367 void f(int i); 7368 int y; 7369 f(y); 7370 void (*f_ptr)(int) = f; 7371 f_ptr(y); 7372callExpr( 7373 forEachArgumentWithParamType( 7374 declRefExpr(to(varDecl(hasName("y")))), 7375 qualType(isInteger()).bind("type) 7376)) 7377 matches f(y) and f_ptr(y) 7378with declRefExpr(...) 7379 matching int y 7380and qualType(...) 7381 matching int 7382</pre></td></tr> 7383 7384 7385<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7386<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 7387expression, or an ObjC-message-send expression. 7388 7389Given 7390 void x(int, int, int) { int y; x(1, y, 42); } 7391callExpr(hasAnyArgument(declRefExpr())) 7392 matches x(1, y, 42) 7393with hasAnyArgument(...) 7394 matching y 7395 7396For ObjectiveC, given 7397 @interface I - (void) f:(int) y; @end 7398 void foo(I *i) { [i f:12]; } 7399objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 7400 matches [i f:12] 7401</pre></td></tr> 7402 7403 7404<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7405<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 7406call expression. 7407 7408Example matches y in x(y) 7409 (matcher = callExpr(hasArgument(0, declRefExpr()))) 7410 void x(int) { int y; x(y); } 7411</pre></td></tr> 7412 7413 7414<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasDeclaration14')"><a name="hasDeclaration14Anchor">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 7415<tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node 7416matches the given matcher. 7417 7418The associated declaration is: 7419- for type nodes, the declaration of the underlying type 7420- for CallExpr, the declaration of the callee 7421- for MemberExpr, the declaration of the referenced member 7422- for CXXConstructExpr, the declaration of the constructor 7423- for CXXNewExpr, the declaration of the operator new 7424- for ObjCIvarExpr, the declaration of the ivar 7425 7426For type nodes, hasDeclaration will generally match the declaration of the 7427sugared type. Given 7428 class X {}; 7429 typedef X Y; 7430 Y y; 7431in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 7432typedefDecl. A common use case is to match the underlying, desugared type. 7433This can be achieved by using the hasUnqualifiedDesugaredType matcher: 7434 varDecl(hasType(hasUnqualifiedDesugaredType( 7435 recordType(hasDeclaration(decl()))))) 7436In this matcher, the decl will match the CXXRecordDecl of class X. 7437 7438Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 7439 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 7440 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 7441 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 7442 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 7443 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 7444 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 7445</pre></td></tr> 7446 7447 7448<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7449<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range 7450extension, matches the constant given in the statement. 7451 7452Given 7453 switch (1) { case 1: case 1+1: case 3 ... 4: ; } 7454caseStmt(hasCaseConstant(integerLiteral())) 7455 matches "case 1:" 7456</pre></td></tr> 7457 7458 7459<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7460<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression 7461or opaque value's source expression matches the given matcher. 7462 7463Example 1: matches "a string" 7464(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) 7465class URL { URL(string); }; 7466URL url = "a string"; 7467 7468Example 2: matches 'b' (matcher = 7469opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) 7470int a = b ?: 1; 7471</pre></td></tr> 7472 7473 7474<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('forEachTemplateArgument0')"><a name="forEachTemplateArgument0Anchor">forEachTemplateArgument</a></td><td>clang::ast_matchers::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 7475<tr><td colspan="4" class="doc" id="forEachTemplateArgument0"><pre>Matches classTemplateSpecialization, templateSpecializationType and 7476functionDecl nodes where the template argument matches the inner matcher. 7477This matcher may produce multiple matches. 7478 7479Given 7480 template <typename T, unsigned N, unsigned M> 7481 struct Matrix {}; 7482 7483 constexpr unsigned R = 2; 7484 Matrix<int, R * 2, R * 4> M; 7485 7486 template <typename T, typename U> 7487 void f(T&& t, U&& u) {} 7488 7489 bool B = false; 7490 f(R, B); 7491templateSpecializationType(forEachTemplateArgument(isExpr(expr()))) 7492 matches twice, with expr() matching 'R * 2' and 'R * 4' 7493functionDecl(forEachTemplateArgument(refersToType(builtinType()))) 7494 matches the specialization f<unsigned, bool> twice, for 'unsigned' 7495 and 'bool' 7496</pre></td></tr> 7497 7498 7499<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 7500<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and 7501functionDecl that have at least one TemplateArgument matching the given 7502InnerMatcher. 7503 7504Given 7505 template<typename T> class A {}; 7506 template<> class A<double> {}; 7507 A<int> a; 7508 7509 template<typename T> f() {}; 7510 void func() { f<int>(); }; 7511 7512classTemplateSpecializationDecl(hasAnyTemplateArgument( 7513 refersToType(asString("int")))) 7514 matches the specialization A<int> 7515 7516functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 7517 matches the specialization f<int> 7518</pre></td></tr> 7519 7520 7521<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('hasSpecializedTemplate0')"><a name="hasSpecializedTemplate0Anchor">hasSpecializedTemplate</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>> InnerMatcher</td></tr> 7522<tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration. 7523 7524Given 7525 template<typename T> class A {}; #1 7526 template<> class A<int> {}; #2 7527classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl())) 7528 matches '#2' with classTemplateDecl() matching the class template 7529 declaration of 'A' at #1. 7530</pre></td></tr> 7531 7532 7533<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 7534<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and 7535functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 7536 7537Given 7538 template<typename T, typename U> class A {}; 7539 A<bool, int> b; 7540 A<int, bool> c; 7541 7542 template<typename T> void f() {} 7543 void func() { f<int>(); }; 7544classTemplateSpecializationDecl(hasTemplateArgument( 7545 1, refersToType(asString("int")))) 7546 matches the specialization A<bool, int> 7547 7548functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 7549 matches the specialization f<int> 7550</pre></td></tr> 7551 7552 7553<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('hasTypeLoc7')"><a name="hasTypeLoc7Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 7554<tr><td colspan="4" class="doc" id="hasTypeLoc7"><pre>Matches if the type location of a node matches the inner matcher. 7555 7556Examples: 7557 int x; 7558declaratorDecl(hasTypeLoc(loc(asString("int")))) 7559 matches int x 7560 7561auto x = int(3); 7562cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 7563 matches int(3) 7564 7565struct Foo { Foo(int, int); }; 7566auto x = Foo(1, 2); 7567cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 7568 matches Foo(1, 2) 7569 7570Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 7571 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 7572 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 7573 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 7574 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 7575 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 7576 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 7577 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 7578</pre></td></tr> 7579 7580 7581<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 7582<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element 7583type. 7584 7585Given 7586 struct A {}; 7587 A a[7]; 7588 int b[7]; 7589arrayType(hasElementType(builtinType())) 7590 matches "int b[7]" 7591 7592Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> 7593</pre></td></tr> 7594 7595 7596<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>></td><td class="name" onclick="toggle('hasTypeLoc8')"><a name="hasTypeLoc8Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 7597<tr><td colspan="4" class="doc" id="hasTypeLoc8"><pre>Matches if the type location of a node matches the inner matcher. 7598 7599Examples: 7600 int x; 7601declaratorDecl(hasTypeLoc(loc(asString("int")))) 7602 matches int x 7603 7604auto x = int(3); 7605cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 7606 matches int(3) 7607 7608struct Foo { Foo(int, int); }; 7609auto x = Foo(1, 2); 7610cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 7611 matches Foo(1, 2) 7612 7613Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 7614 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 7615 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 7616 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 7617 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 7618 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 7619 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 7620 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 7621</pre></td></tr> 7622 7623 7624<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 7625<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 7626a given matcher. Also matches StmtExprs that have CompoundStmt as children. 7627 7628Given 7629 { {}; 1+2; } 7630hasAnySubstatement(compoundStmt()) 7631 matches '{ {}; 1+2; }' 7632with compoundStmt() 7633 matching '{}' 7634</pre></td></tr> 7635 7636 7637<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerType</td></tr> 7638<tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whoes decayed type matches InnerMatcher 7639</pre></td></tr> 7640 7641 7642<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 7643<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node 7644matches the given matcher. 7645 7646The associated declaration is: 7647- for type nodes, the declaration of the underlying type 7648- for CallExpr, the declaration of the callee 7649- for MemberExpr, the declaration of the referenced member 7650- for CXXConstructExpr, the declaration of the constructor 7651- for CXXNewExpr, the declaration of the operator new 7652- for ObjCIvarExpr, the declaration of the ivar 7653 7654For type nodes, hasDeclaration will generally match the declaration of the 7655sugared type. Given 7656 class X {}; 7657 typedef X Y; 7658 Y y; 7659in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 7660typedefDecl. A common use case is to match the underlying, desugared type. 7661This can be achieved by using the hasUnqualifiedDesugaredType matcher: 7662 varDecl(hasType(hasUnqualifiedDesugaredType( 7663 recordType(hasDeclaration(decl()))))) 7664In this matcher, the decl will match the CXXRecordDecl of class X. 7665 7666Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 7667 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 7668 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 7669 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 7670 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 7671 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 7672 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 7673</pre></td></tr> 7674 7675 7676<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('hasTemplateArgumentLoc0')"><a name="hasTemplateArgumentLoc0Anchor">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> 7677<tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc0"><pre>Matches template specialization `TypeLoc`s where the n'th 7678`TemplateArgumentLoc` matches the given `InnerMatcher`. 7679 7680Given 7681 template<typename T, typename U> class A {}; 7682 A<double, int> b; 7683 A<int, double> c; 7684varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0, 7685 hasTypeLoc(loc(asString("double"))))))) 7686 matches `A<double, int> b`, but not `A<int, double> c`. 7687</pre></td></tr> 7688 7689 7690<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>> Inner</td></tr> 7691<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches if a node refers to a declaration through a specific 7692using shadow declaration. 7693 7694Examples: 7695 namespace a { int f(); } 7696 using a::f; 7697 int x = f(); 7698declRefExpr(throughUsingDecl(anything())) 7699 matches f 7700 7701 namespace a { class X{}; } 7702 using a::X; 7703 X x; 7704typeLoc(loc(usingType(throughUsingDecl(anything())))) 7705 matches X 7706 7707Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> 7708</pre></td></tr> 7709 7710 7711<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 7712<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 7713specified matcher. 7714 7715Example matches x in if(x) 7716 (matcher = declRefExpr(to(varDecl(hasName("x"))))) 7717 bool x; 7718 if (x) {} 7719</pre></td></tr> 7720 7721 7722<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 7723<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 7724 7725Note that this does not work for global declarations because the AST 7726breaks up multiple-declaration DeclStmt's into multiple single-declaration 7727DeclStmt's. 7728Example: Given non-global declarations 7729 int a, b = 0; 7730 int c; 7731 int d = 2, e; 7732declStmt(containsDeclaration( 7733 0, varDecl(hasInitializer(anything())))) 7734 matches only 'int d = 2, e;', and 7735declStmt(containsDeclaration(1, varDecl())) 7736 matches 'int a, b = 0' as well as 'int d = 2, e;' 7737 but 'int c;' is not matched. 7738</pre></td></tr> 7739 7740 7741<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 7742<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 7743 7744Given 7745 int a, b; 7746 int c; 7747declStmt(hasSingleDecl(anything())) 7748 matches 'int c;' but not 'int a, b;'. 7749</pre></td></tr> 7750 7751 7752<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>></td><td class="name" onclick="toggle('hasTypeLoc9')"><a name="hasTypeLoc9Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 7753<tr><td colspan="4" class="doc" id="hasTypeLoc9"><pre>Matches if the type location of a node matches the inner matcher. 7754 7755Examples: 7756 int x; 7757declaratorDecl(hasTypeLoc(loc(asString("int")))) 7758 matches int x 7759 7760auto x = int(3); 7761cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 7762 matches int(3) 7763 7764struct Foo { Foo(int, int); }; 7765auto x = Foo(1, 2); 7766cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 7767 matches Foo(1, 2) 7768 7769Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 7770 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 7771 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 7772 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 7773 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 7774 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 7775 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 7776 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 7777</pre></td></tr> 7778 7779 7780<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 7781<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a 7782Decl, matches InnerMatcher. 7783 7784Given 7785 namespace N { 7786 namespace M { 7787 class D {}; 7788 } 7789 } 7790 7791cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the 7792declaration of class D. 7793</pre></td></tr> 7794 7795 7796<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>></td><td class="name" onclick="toggle('hasUnderlyingType0')"><a name="hasUnderlyingType0Anchor">hasUnderlyingType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 7797<tr><td colspan="4" class="doc" id="hasUnderlyingType0"><pre>Matches DecltypeType or UsingType nodes to find the underlying type. 7798 7799Given 7800 decltype(1) a = 1; 7801 decltype(2.0) b = 2.0; 7802decltypeType(hasUnderlyingType(isInteger())) 7803 matches the type of "a" 7804 7805Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> 7806</pre></td></tr> 7807 7808 7809<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html">DecompositionDecl</a>></td><td class="name" onclick="toggle('hasAnyBinding0')"><a name="hasAnyBinding0Anchor">hasAnyBinding</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html">BindingDecl</a>> InnerMatcher</td></tr> 7810<tr><td colspan="4" class="doc" id="hasAnyBinding0"><pre>Matches any binding of a DecompositionDecl. 7811 7812For example, in: 7813void foo() 7814{ 7815 int arr[3]; 7816 auto &[f, s, t] = arr; 7817 7818 f = 42; 7819} 7820The matcher: 7821 decompositionDecl(hasAnyBinding(bindingDecl(hasName("f").bind("fBinding")))) 7822matches the decomposition decl with 'f' bound to "fBinding". 7823</pre></td></tr> 7824 7825 7826<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html">DecompositionDecl</a>></td><td class="name" onclick="toggle('hasBinding0')"><a name="hasBinding0Anchor">hasBinding</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html">BindingDecl</a>> InnerMatcher</td></tr> 7827<tr><td colspan="4" class="doc" id="hasBinding0"><pre>Matches the Nth binding of a DecompositionDecl. 7828 7829For example, in: 7830void foo() 7831{ 7832 int arr[3]; 7833 auto &[f, s, t] = arr; 7834 7835 f = 42; 7836} 7837The matcher: 7838 decompositionDecl(hasBinding(0, 7839 bindingDecl(hasName("f").bind("fBinding")))) 7840matches the decomposition decl with 'f' bound to "fBinding". 7841</pre></td></tr> 7842 7843 7844<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 7845<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'do' statement or a function definition that has 7846a given body. Note that in case of functions this matcher only matches the 7847definition itself and not the other declarations of the same function. 7848 7849Given 7850 for (;;) {} 7851forStmt(hasBody(compoundStmt())) 7852 matches 'for (;;) {}' 7853with compoundStmt() 7854 matching '{}' 7855 7856Given 7857 void f(); 7858 void f() {} 7859functionDecl(hasBody(compoundStmt())) 7860 matches 'void f() {}' 7861with compoundStmt() 7862 matching '{}' 7863 but does not match 'void f();' 7864</pre></td></tr> 7865 7866 7867<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 7868<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 7869switch statement or conditional operator. 7870 7871Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 7872 if (true) {} 7873</pre></td></tr> 7874 7875 7876<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedTypeLoc.html">ElaboratedTypeLoc</a>></td><td class="name" onclick="toggle('hasNamedTypeLoc0')"><a name="hasNamedTypeLoc0Anchor">hasNamedTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> InnerMatcher</td></tr> 7877<tr><td colspan="4" class="doc" id="hasNamedTypeLoc0"><pre>Matches elaborated `TypeLoc`s that have a named `TypeLoc` matching 7878`InnerMatcher`. 7879 7880Given 7881 template <typename T> 7882 class C {}; 7883 class C<int> c; 7884 7885 class D {}; 7886 class D d; 7887elaboratedTypeLoc(hasNamedTypeLoc(templateSpecializationTypeLoc())); 7888 matches the `TypeLoc` of the variable declaration of `c`, but not `d`. 7889</pre></td></tr> 7890 7891 7892<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr> 7893<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, 7894matches InnerMatcher if the qualifier exists. 7895 7896Given 7897 namespace N { 7898 namespace M { 7899 class D {}; 7900 } 7901 } 7902 N::M::D d; 7903 7904elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) 7905matches the type of the variable declaration of d. 7906</pre></td></tr> 7907 7908 7909<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 7910<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. 7911 7912Given 7913 namespace N { 7914 namespace M { 7915 class D {}; 7916 } 7917 } 7918 N::M::D d; 7919 7920elaboratedType(namesType(recordType( 7921hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable 7922declaration of d. 7923</pre></td></tr> 7924 7925 7926<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 7927<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node 7928matches the given matcher. 7929 7930The associated declaration is: 7931- for type nodes, the declaration of the underlying type 7932- for CallExpr, the declaration of the callee 7933- for MemberExpr, the declaration of the referenced member 7934- for CXXConstructExpr, the declaration of the constructor 7935- for CXXNewExpr, the declaration of the operator new 7936- for ObjCIvarExpr, the declaration of the ivar 7937 7938For type nodes, hasDeclaration will generally match the declaration of the 7939sugared type. Given 7940 class X {}; 7941 typedef X Y; 7942 Y y; 7943in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 7944typedefDecl. A common use case is to match the underlying, desugared type. 7945This can be achieved by using the hasUnqualifiedDesugaredType matcher: 7946 varDecl(hasType(hasUnqualifiedDesugaredType( 7947 recordType(hasDeclaration(decl()))))) 7948In this matcher, the decl will match the CXXRecordDecl of class X. 7949 7950Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 7951 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 7952 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 7953 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 7954 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 7955 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 7956 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 7957</pre></td></tr> 7958 7959 7960<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 7961<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 7962 7963(Note: Clang's AST refers to other conversions as "casts" too, and calls 7964actual casts "explicit" casts.) 7965</pre></td></tr> 7966 7967 7968<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>></td><td class="name" onclick="toggle('hasTypeLoc10')"><a name="hasTypeLoc10Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 7969<tr><td colspan="4" class="doc" id="hasTypeLoc10"><pre>Matches if the type location of a node matches the inner matcher. 7970 7971Examples: 7972 int x; 7973declaratorDecl(hasTypeLoc(loc(asString("int")))) 7974 matches int x 7975 7976auto x = int(3); 7977cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 7978 matches int(3) 7979 7980struct Foo { Foo(int, int); }; 7981auto x = Foo(1, 2); 7982cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 7983 matches Foo(1, 2) 7984 7985Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 7986 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 7987 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 7988 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 7989 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 7990 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 7991 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 7992 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 7993</pre></td></tr> 7994 7995 7996<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('hasType5')"><a name="hasType5Anchor">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 7997<tr><td colspan="4" class="doc" id="hasType5"><pre>Overloaded to match the declaration of the expression's or value 7998declaration's type. 7999 8000In case of a value declaration (for example a variable declaration), 8001this resolves one layer of indirection. For example, in the value 8002declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 8003X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 8004declaration of x. 8005 8006Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 8007 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 8008 and friend class X (matcher = friendDecl(hasType("X")) 8009 and public virtual X (matcher = cxxBaseSpecifier(hasType( 8010 cxxRecordDecl(hasName("X")))) 8011 class X {}; 8012 void y(X &x) { x; X z; } 8013 class Y { friend class X; }; 8014 class Z : public virtual X {}; 8015 8016Example matches class Derived 8017(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) 8018class Base {}; 8019class Derived : Base {}; 8020 8021Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>, 8022Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> 8023</pre></td></tr> 8024 8025 8026<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 8027<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type 8028matcher. 8029 8030Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 8031 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 8032 and U (matcher = typedefDecl(hasType(asString("int"))) 8033 and friend class X (matcher = friendDecl(hasType("X")) 8034 and public virtual X (matcher = cxxBaseSpecifier(hasType( 8035 asString("class X"))) 8036 class X {}; 8037 void y(X &x) { x; X z; } 8038 typedef int U; 8039 class Y { friend class X; }; 8040 class Z : public virtual X {}; 8041</pre></td></tr> 8042 8043 8044<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('ignoringElidableConstructorCall0')"><a name="ignoringElidableConstructorCall0Anchor">ignoringElidableConstructorCall</a></td><td>ast_matchers::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8045<tr><td colspan="4" class="doc" id="ignoringElidableConstructorCall0"><pre>Matches expressions that match InnerMatcher that are possibly wrapped in an 8046elidable constructor and other corresponding bookkeeping nodes. 8047 8048In C++17, elidable copy constructors are no longer being generated in the 8049AST as it is not permitted by the standard. They are, however, part of the 8050AST in C++14 and earlier. So, a matcher must abstract over these differences 8051to work in all language modes. This matcher skips elidable constructor-call 8052AST nodes, `ExprWithCleanups` nodes wrapping elidable constructor-calls and 8053various implicit nodes inside the constructor calls, all of which will not 8054appear in the C++17 AST. 8055 8056Given 8057 8058struct H {}; 8059H G(); 8060void f() { 8061 H D = G(); 8062} 8063 8064``varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr())))`` 8065matches ``H D = G()`` in C++11 through C++17 (and beyond). 8066</pre></td></tr> 8067 8068 8069<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8070<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 8071are stripped off. 8072 8073Parentheses and explicit casts are not discarded. 8074Given 8075 int arr[5]; 8076 int a = 0; 8077 char b = 0; 8078 const int c = a; 8079 int *d = arr; 8080 long e = (long) 0l; 8081The matchers 8082 varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 8083 varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 8084would match the declarations for a, b, c, and d, but not e. 8085While 8086 varDecl(hasInitializer(integerLiteral())) 8087 varDecl(hasInitializer(declRefExpr())) 8088only match the declarations for a. 8089</pre></td></tr> 8090 8091 8092<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('ignoringImplicit0')"><a name="ignoringImplicit0Anchor">ignoringImplicit</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8093<tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST 8094nodes are stripped off. 8095 8096Parentheses and explicit casts are not discarded. 8097Given 8098 class C {}; 8099 C a = C(); 8100 C b; 8101 C c = b; 8102The matchers 8103 varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr()))) 8104would match the declarations for a, b, and c. 8105While 8106 varDecl(hasInitializer(cxxConstructExpr())) 8107only match the declarations for b and c. 8108</pre></td></tr> 8109 8110 8111<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8112<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 8113casts are stripped off. 8114 8115Implicit and non-C Style casts are also discarded. 8116Given 8117 int a = 0; 8118 char b = (0); 8119 void* c = reinterpret_cast<char*>(0); 8120 char d = char(0); 8121The matcher 8122 varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 8123would match the declarations for a, b, c, and d. 8124while 8125 varDecl(hasInitializer(integerLiteral())) 8126only match the declaration for a. 8127</pre></td></tr> 8128 8129 8130<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8131<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 8132parentheses are stripped off. 8133 8134Explicit casts are not discarded. 8135Given 8136 int arr[5]; 8137 int a = 0; 8138 char b = (0); 8139 const int c = a; 8140 int *d = (arr); 8141 long e = ((long) 0l); 8142The matchers 8143 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 8144 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 8145would match the declarations for a, b, c, and d, but not e. 8146while 8147 varDecl(hasInitializer(integerLiteral())) 8148 varDecl(hasInitializer(declRefExpr())) 8149would only match the declaration for a. 8150</pre></td></tr> 8151 8152 8153<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('ignoringParens1')"><a name="ignoringParens1Anchor">ignoringParens</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8154<tr><td colspan="4" class="doc" id="ignoringParens1"><pre>Overload ignoringParens for Expr. 8155 8156Given 8157 const char* str = ("my-string"); 8158The matcher 8159 implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral()))) 8160would match the implicit cast resulting from the assignment. 8161</pre></td></tr> 8162 8163 8164<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>></td><td class="name" onclick="toggle('hasInClassInitializer0')"><a name="hasInClassInitializer0Anchor">hasInClassInitializer</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8165<tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer. 8166 8167Given 8168 class C { 8169 int a = 2; 8170 int b = 3; 8171 int c; 8172 }; 8173fieldDecl(hasInClassInitializer(integerLiteral(equals(2)))) 8174 matches 'int a;' but not 'int b;'. 8175fieldDecl(hasInClassInitializer(anything())) 8176 matches 'int a;' and 'int b;' but not 'int c;'. 8177</pre></td></tr> 8178 8179 8180<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 8181<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'do' statement or a function definition that has 8182a given body. Note that in case of functions this matcher only matches the 8183definition itself and not the other declarations of the same function. 8184 8185Given 8186 for (;;) {} 8187forStmt(hasBody(compoundStmt())) 8188 matches 'for (;;) {}' 8189with compoundStmt() 8190 matching '{}' 8191 8192Given 8193 void f(); 8194 void f() {} 8195functionDecl(hasBody(compoundStmt())) 8196 matches 'void f() {}' 8197with compoundStmt() 8198 matching '{}' 8199 but does not match 'void f();' 8200</pre></td></tr> 8201 8202 8203<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8204<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 8205switch statement or conditional operator. 8206 8207Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 8208 if (true) {} 8209</pre></td></tr> 8210 8211 8212<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 8213<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 8214 8215Example: 8216 forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 8217matches '++x' in 8218 for (x; x < N; ++x) { } 8219</pre></td></tr> 8220 8221 8222<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 8223<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 8224 8225Example: 8226 forStmt(hasLoopInit(declStmt())) 8227matches 'int x = 0' in 8228 for (int x = 0; x < N; ++x) { } 8229</pre></td></tr> 8230 8231 8232<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>></td><td class="name" onclick="toggle('hasType6')"><a name="hasType6Anchor">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 8233<tr><td colspan="4" class="doc" id="hasType6"><pre>Overloaded to match the declaration of the expression's or value 8234declaration's type. 8235 8236In case of a value declaration (for example a variable declaration), 8237this resolves one layer of indirection. For example, in the value 8238declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 8239X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 8240declaration of x. 8241 8242Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 8243 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 8244 and friend class X (matcher = friendDecl(hasType("X")) 8245 and public virtual X (matcher = cxxBaseSpecifier(hasType( 8246 cxxRecordDecl(hasName("X")))) 8247 class X {}; 8248 void y(X &x) { x; X z; } 8249 class Y { friend class X; }; 8250 class Z : public virtual X {}; 8251 8252Example matches class Derived 8253(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) 8254class Base {}; 8255class Derived : Base {}; 8256 8257Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>, 8258Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> 8259</pre></td></tr> 8260 8261 8262<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>></td><td class="name" onclick="toggle('hasType1')"><a name="hasType1Anchor">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 8263<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type 8264matcher. 8265 8266Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 8267 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 8268 and U (matcher = typedefDecl(hasType(asString("int"))) 8269 and friend class X (matcher = friendDecl(hasType("X")) 8270 and public virtual X (matcher = cxxBaseSpecifier(hasType( 8271 asString("class X"))) 8272 class X {}; 8273 void y(X &x) { x; X z; } 8274 typedef int U; 8275 class Y { friend class X; }; 8276 class Z : public virtual X {}; 8277</pre></td></tr> 8278 8279 8280<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('forEachTemplateArgument2')"><a name="forEachTemplateArgument2Anchor">forEachTemplateArgument</a></td><td>clang::ast_matchers::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 8281<tr><td colspan="4" class="doc" id="forEachTemplateArgument2"><pre>Matches classTemplateSpecialization, templateSpecializationType and 8282functionDecl nodes where the template argument matches the inner matcher. 8283This matcher may produce multiple matches. 8284 8285Given 8286 template <typename T, unsigned N, unsigned M> 8287 struct Matrix {}; 8288 8289 constexpr unsigned R = 2; 8290 Matrix<int, R * 2, R * 4> M; 8291 8292 template <typename T, typename U> 8293 void f(T&& t, U&& u) {} 8294 8295 bool B = false; 8296 f(R, B); 8297templateSpecializationType(forEachTemplateArgument(isExpr(expr()))) 8298 matches twice, with expr() matching 'R * 2' and 'R * 4' 8299functionDecl(forEachTemplateArgument(refersToType(builtinType()))) 8300 matches the specialization f<unsigned, bool> twice, for 'unsigned' 8301 and 'bool' 8302</pre></td></tr> 8303 8304 8305<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasAnyBody0')"><a name="hasAnyBody0Anchor">hasAnyBody</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 8306<tr><td colspan="4" class="doc" id="hasAnyBody0"><pre>Matches a function declaration that has a given body present in the AST. 8307Note that this matcher matches all the declarations of a function whose 8308body is present in the AST. 8309 8310Given 8311 void f(); 8312 void f() {} 8313 void g(); 8314functionDecl(hasAnyBody(compoundStmt())) 8315 matches both 'void f();' 8316 and 'void f() {}' 8317with compoundStmt() 8318 matching '{}' 8319 but does not match 'void g();' 8320</pre></td></tr> 8321 8322 8323<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> 8324<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a 8325block. 8326 8327Does not match the 'this' parameter of a method. 8328 8329Given 8330 class X { void f(int x, int y, int z) {} }; 8331cxxMethodDecl(hasAnyParameter(hasName("y"))) 8332 matches f(int x, int y, int z) {} 8333with hasAnyParameter(...) 8334 matching int y 8335 8336For ObjectiveC, given 8337 @interface I - (void) f:(int) y; @end 8338 8339the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 8340matches the declaration of method f with hasParameter 8341matching y. 8342 8343For blocks, given 8344 b = ^(int y) { printf("%d", y) }; 8345 8346the matcher blockDecl(hasAnyParameter(hasName("y"))) 8347matches the declaration of the block b with hasParameter 8348matching y. 8349</pre></td></tr> 8350 8351 8352<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgument2')"><a name="hasAnyTemplateArgument2Anchor">hasAnyTemplateArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 8353<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and 8354functionDecl that have at least one TemplateArgument matching the given 8355InnerMatcher. 8356 8357Given 8358 template<typename T> class A {}; 8359 template<> class A<double> {}; 8360 A<int> a; 8361 8362 template<typename T> f() {}; 8363 void func() { f<int>(); }; 8364 8365classTemplateSpecializationDecl(hasAnyTemplateArgument( 8366 refersToType(asString("int")))) 8367 matches the specialization A<int> 8368 8369functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 8370 matches the specialization f<int> 8371</pre></td></tr> 8372 8373 8374<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasBody4')"><a name="hasBody4Anchor">hasBody</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 8375<tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'do' statement or a function definition that has 8376a given body. Note that in case of functions this matcher only matches the 8377definition itself and not the other declarations of the same function. 8378 8379Given 8380 for (;;) {} 8381forStmt(hasBody(compoundStmt())) 8382 matches 'for (;;) {}' 8383with compoundStmt() 8384 matching '{}' 8385 8386Given 8387 void f(); 8388 void f() {} 8389functionDecl(hasBody(compoundStmt())) 8390 matches 'void f() {}' 8391with compoundStmt() 8392 matching '{}' 8393 but does not match 'void f();' 8394</pre></td></tr> 8395 8396 8397<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasExplicitSpecifier0')"><a name="hasExplicitSpecifier0Anchor">hasExplicitSpecifier</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8398<tr><td colspan="4" class="doc" id="hasExplicitSpecifier0"><pre>Matches the expression in an explicit specifier if present in the given 8399declaration. 8400 8401Given 8402 template<bool b> 8403 struct S { 8404 S(int); // #1 8405 explicit S(double); // #2 8406 operator int(); // #3 8407 explicit operator bool(); // #4 8408 explicit(false) S(bool) // # 7 8409 explicit(true) S(char) // # 8 8410 explicit(b) S(S) // # 9 8411 }; 8412 S(int) -> S<true> // #5 8413 explicit S(double) -> S<false> // #6 8414cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2. 8415cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4. 8416cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6. 8417</pre></td></tr> 8418 8419 8420<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> 8421<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method 8422declaration or a block. 8423 8424Given 8425 class X { void f(int x) {} }; 8426cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 8427 matches f(int x) {} 8428with hasParameter(...) 8429 matching int x 8430 8431For ObjectiveC, given 8432 @interface I - (void) f:(int) y; @end 8433 8434the matcher objcMethodDecl(hasParameter(0, hasName("y"))) 8435matches the declaration of method f with hasParameter 8436matching y. 8437</pre></td></tr> 8438 8439 8440<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasReturnTypeLoc0')"><a name="hasReturnTypeLoc0Anchor">hasReturnTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> ReturnMatcher</td></tr> 8441<tr><td colspan="4" class="doc" id="hasReturnTypeLoc0"><pre>Matches a function declared with the specified return `TypeLoc`. 8442 8443Given 8444 int f() { return 5; } 8445 void g() {} 8446functionDecl(hasReturnTypeLoc(loc(asString("int")))) 8447 matches the declaration of `f`, but not `g`. 8448</pre></td></tr> 8449 8450 8451<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasTemplateArgument2')"><a name="hasTemplateArgument2Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 8452<tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and 8453functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 8454 8455Given 8456 template<typename T, typename U> class A {}; 8457 A<bool, int> b; 8458 A<int, bool> c; 8459 8460 template<typename T> void f() {} 8461 void func() { f<int>(); }; 8462classTemplateSpecializationDecl(hasTemplateArgument( 8463 1, refersToType(asString("int")))) 8464 matches the specialization A<bool, int> 8465 8466functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 8467 matches the specialization f<int> 8468</pre></td></tr> 8469 8470 8471<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 8472<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 8473 8474Given: 8475 class X { int f() { return 1; } }; 8476cxxMethodDecl(returns(asString("int"))) 8477 matches int f() { return 1; } 8478</pre></td></tr> 8479 8480 8481<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8482<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 8483switch statement or conditional operator. 8484 8485Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 8486 if (true) {} 8487</pre></td></tr> 8488 8489 8490<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>> InnerMatcher</td></tr> 8491<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 8492 8493Given 8494 if (A* a = GetAPointer()) {} 8495hasConditionVariableStatement(...) 8496 matches 'A* a = GetAPointer()'. 8497</pre></td></tr> 8498 8499 8500<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 8501<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. 8502 8503Examples matches the if statement 8504 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) 8505 if (false) false; else true; 8506</pre></td></tr> 8507 8508 8509<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasInitStatement0')"><a name="hasInitStatement0Anchor">hasInitStatement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 8510<tr><td colspan="4" class="doc" id="hasInitStatement0"><pre>Matches selection statements with initializer. 8511 8512Given: 8513 void foo() { 8514 if (int i = foobar(); i > 0) {} 8515 switch (int i = foobar(); i) {} 8516 for (auto& a = get_range(); auto& x : a) {} 8517 } 8518 void bar() { 8519 if (foobar() > 0) {} 8520 switch (foobar()) {} 8521 for (auto& x : get_range()) {} 8522 } 8523ifStmt(hasInitStatement(anything())) 8524 matches the if statement in foo but not in bar. 8525switchStmt(hasInitStatement(anything())) 8526 matches the switch statement in foo but not in bar. 8527cxxForRangeStmt(hasInitStatement(anything())) 8528 matches the range for statement in foo but not in bar. 8529</pre></td></tr> 8530 8531 8532<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 8533<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. 8534 8535Examples matches the if statement 8536 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) 8537 if (false) true; else false; 8538</pre></td></tr> 8539 8540 8541<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 8542<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 8543matcher. 8544</pre></td></tr> 8545 8546 8547<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>></td><td class="name" onclick="toggle('hasInit0')"><a name="hasInit0Anchor">hasInit</a></td><td>unsigned N, ast_matchers::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8548<tr><td colspan="4" class="doc" id="hasInit0"><pre>Matches the n'th item of an initializer list expression. 8549 8550Example matches y. 8551 (matcher = initListExpr(hasInit(0, expr()))) 8552 int x{y}. 8553</pre></td></tr> 8554 8555 8556<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>></td><td class="name" onclick="toggle('hasSyntacticForm0')"><a name="hasSyntacticForm0Anchor">hasSyntacticForm</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8557<tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions 8558(if expression have it). 8559</pre></td></tr> 8560 8561 8562<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 8563<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node 8564matches the given matcher. 8565 8566The associated declaration is: 8567- for type nodes, the declaration of the underlying type 8568- for CallExpr, the declaration of the callee 8569- for MemberExpr, the declaration of the referenced member 8570- for CXXConstructExpr, the declaration of the constructor 8571- for CXXNewExpr, the declaration of the operator new 8572- for ObjCIvarExpr, the declaration of the ivar 8573 8574For type nodes, hasDeclaration will generally match the declaration of the 8575sugared type. Given 8576 class X {}; 8577 typedef X Y; 8578 Y y; 8579in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 8580typedefDecl. A common use case is to match the underlying, desugared type. 8581This can be achieved by using the hasUnqualifiedDesugaredType matcher: 8582 varDecl(hasType(hasUnqualifiedDesugaredType( 8583 recordType(hasDeclaration(decl()))))) 8584In this matcher, the decl will match the CXXRecordDecl of class X. 8585 8586Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 8587 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 8588 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 8589 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 8590 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 8591 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 8592 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 8593</pre></td></tr> 8594 8595 8596<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 8597<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node 8598matches the given matcher. 8599 8600The associated declaration is: 8601- for type nodes, the declaration of the underlying type 8602- for CallExpr, the declaration of the callee 8603- for MemberExpr, the declaration of the referenced member 8604- for CXXConstructExpr, the declaration of the constructor 8605- for CXXNewExpr, the declaration of the operator new 8606- for ObjCIvarExpr, the declaration of the ivar 8607 8608For type nodes, hasDeclaration will generally match the declaration of the 8609sugared type. Given 8610 class X {}; 8611 typedef X Y; 8612 Y y; 8613in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 8614typedefDecl. A common use case is to match the underlying, desugared type. 8615This can be achieved by using the hasUnqualifiedDesugaredType matcher: 8616 varDecl(hasType(hasUnqualifiedDesugaredType( 8617 recordType(hasDeclaration(decl()))))) 8618In this matcher, the decl will match the CXXRecordDecl of class X. 8619 8620Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 8621 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 8622 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 8623 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 8624 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 8625 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 8626 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 8627</pre></td></tr> 8628 8629 8630<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>></td><td class="name" onclick="toggle('capturesVar0')"><a name="capturesVar0Anchor">capturesVar</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>> InnerMatcher</td></tr> 8631<tr><td colspan="4" class="doc" id="capturesVar0"><pre>Matches a `LambdaCapture` that refers to the specified `VarDecl`. The 8632`VarDecl` can be a separate variable that is captured by value or 8633reference, or a synthesized variable if the capture has an initializer. 8634 8635Given 8636 void foo() { 8637 int x; 8638 auto f = [x](){}; 8639 auto g = [x = 1](){}; 8640 } 8641In the matcher 8642lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(hasName("x")))), 8643capturesVar(hasName("x")) matches `x` and `x = 1`. 8644</pre></td></tr> 8645 8646 8647<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>></td><td class="name" onclick="toggle('forEachLambdaCapture0')"><a name="forEachLambdaCapture0Anchor">forEachLambdaCapture</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>> InnerMatcher</td></tr> 8648<tr><td colspan="4" class="doc" id="forEachLambdaCapture0"><pre>Matches each lambda capture in a lambda expression. 8649 8650Given 8651 int main() { 8652 int x, y; 8653 float z; 8654 auto f = [=]() { return x + y + z; }; 8655 } 8656lambdaExpr(forEachLambdaCapture( 8657 lambdaCapture(capturesVar(varDecl(hasType(isInteger())))))) 8658will trigger two matches, binding for 'x' and 'y' respectively. 8659</pre></td></tr> 8660 8661 8662<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>></td><td class="name" onclick="toggle('hasAnyCapture0')"><a name="hasAnyCapture0Anchor">hasAnyCapture</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>> InnerMatcher</td></tr> 8663<tr><td colspan="4" class="doc" id="hasAnyCapture0"><pre>Matches any capture in a lambda expression. 8664 8665Given 8666 void foo() { 8667 int t = 5; 8668 auto f = [=](){ return t; }; 8669 } 8670lambdaExpr(hasAnyCapture(lambdaCapture())) and 8671lambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("t"))))) 8672 both match `[=](){ return t; }`. 8673</pre></td></tr> 8674 8675 8676<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 8677<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node 8678matches the given matcher. 8679 8680The associated declaration is: 8681- for type nodes, the declaration of the underlying type 8682- for CallExpr, the declaration of the callee 8683- for MemberExpr, the declaration of the referenced member 8684- for CXXConstructExpr, the declaration of the constructor 8685- for CXXNewExpr, the declaration of the operator new 8686- for ObjCIvarExpr, the declaration of the ivar 8687 8688For type nodes, hasDeclaration will generally match the declaration of the 8689sugared type. Given 8690 class X {}; 8691 typedef X Y; 8692 Y y; 8693in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 8694typedefDecl. A common use case is to match the underlying, desugared type. 8695This can be achieved by using the hasUnqualifiedDesugaredType matcher: 8696 varDecl(hasType(hasUnqualifiedDesugaredType( 8697 recordType(hasDeclaration(decl()))))) 8698In this matcher, the decl will match the CXXRecordDecl of class X. 8699 8700Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 8701 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 8702 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 8703 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 8704 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 8705 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 8706 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 8707</pre></td></tr> 8708 8709 8710<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8711<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is matched by a 8712given matcher. Implicit object expressions are included; that is, it matches 8713use of implicit `this`. 8714 8715Given 8716 struct X { 8717 int m; 8718 int f(X x) { x.m; return m; } 8719 }; 8720memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) 8721 matches `x.m`, but not `m`; however, 8722memberExpr(hasObjectExpression(hasType(pointsTo( 8723 cxxRecordDecl(hasName("X")))))) 8724 matches `m` (aka. `this->m`), but not `x.m`. 8725</pre></td></tr> 8726 8727 8728<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>> InnerMatcher</td></tr> 8729<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 8730given matcher. 8731 8732Given 8733 struct { int first, second; } first, second; 8734 int i(second.first); 8735 int j(first.second); 8736memberExpr(member(hasName("first"))) 8737 matches second.first 8738 but not first.second (because the member name there is "second"). 8739</pre></td></tr> 8740 8741 8742<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 8743<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the 8744pointee matches a given matcher. 8745 8746Given 8747 int *a; 8748 int const *b; 8749 float const *f; 8750pointerType(pointee(isConstQualified(), isInteger())) 8751 matches "int const *b" 8752 8753Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 8754 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 8755</pre></td></tr> 8756 8757 8758<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('hasUnderlyingDecl0')"><a name="hasUnderlyingDecl0Anchor">hasUnderlyingDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> InnerMatcher</td></tr> 8759<tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given 8760matcher. 8761 8762Given 8763 namespace N { template<class T> void f(T t); } 8764 template <class T> void g() { using N::f; f(T()); } 8765unresolvedLookupExpr(hasAnyDeclaration( 8766 namedDecl(hasUnderlyingDecl(hasName("::N::f"))))) 8767 matches the use of f in g() . 8768</pre></td></tr> 8769 8770 8771<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>> InnerMatcher</td></tr> 8772<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 8773 8774Given 8775 struct A { struct B { struct C {}; }; }; 8776 A::B::C c; 8777nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 8778 matches "A::" 8779</pre></td></tr> 8780 8781 8782<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr> 8783<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner 8784NestedNameSpecifier-matcher matches. 8785</pre></td></tr> 8786 8787 8788<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> InnerMatcher</td></tr> 8789<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 8790given TypeLoc. 8791 8792Given 8793 struct A { struct B { struct C {}; }; }; 8794 A::B::C c; 8795nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 8796 hasDeclaration(cxxRecordDecl(hasName("A"))))))) 8797 matches "A::" 8798</pre></td></tr> 8799 8800 8801<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr> 8802<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 8803 8804Given 8805 struct A { struct B { struct C {}; }; }; 8806 A::B::C c; 8807nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 8808 matches "A::" 8809</pre></td></tr> 8810 8811 8812<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>> InnerMatcher</td></tr> 8813<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 8814given namespace matcher. 8815 8816Given 8817 namespace ns { struct A {}; } 8818 ns::A a; 8819nestedNameSpecifier(specifiesNamespace(hasName("ns"))) 8820 matches "ns::" 8821</pre></td></tr> 8822 8823 8824<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 8825<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 8826given QualType matcher without qualifiers. 8827 8828Given 8829 struct A { struct B { struct C {}; }; }; 8830 A::B::C c; 8831nestedNameSpecifier(specifiesType( 8832 hasDeclaration(cxxRecordDecl(hasName("A"))) 8833)) 8834 matches "A::" 8835</pre></td></tr> 8836 8837 8838<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective</a>></td><td class="name" onclick="toggle('hasAnyClause0')"><a name="hasAnyClause0Anchor">hasAnyClause</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPClause.html">OMPClause</a>> InnerMatcher</td></tr> 8839<tr><td colspan="4" class="doc" id="hasAnyClause0"><pre>Matches any clause in an OpenMP directive. 8840 8841Given 8842 8843 #pragma omp parallel 8844 #pragma omp parallel default(none) 8845 8846``ompExecutableDirective(hasAnyClause(anything()))`` matches 8847``omp parallel default(none)``. 8848</pre></td></tr> 8849 8850 8851<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective</a>></td><td class="name" onclick="toggle('hasStructuredBlock0')"><a name="hasStructuredBlock0Anchor">hasStructuredBlock</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 8852<tr><td colspan="4" class="doc" id="hasStructuredBlock0"><pre>Matches the structured-block of the OpenMP executable directive 8853 8854Prerequisite: the executable directive must not be standalone directive. 8855If it is, it will never match. 8856 8857Given 8858 8859 #pragma omp parallel 8860 ; 8861 #pragma omp parallel 8862 {} 8863 8864``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;`` 8865</pre></td></tr> 8866 8867 8868<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>></td><td class="name" onclick="toggle('isDerivedFrom1')"><a name="isDerivedFrom1Anchor">isDerivedFrom</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> Base</td></tr> 8869<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Matches C++ classes that are directly or indirectly derived from a class 8870matching Base, or Objective-C classes that directly or indirectly 8871subclass a class matching Base. 8872 8873Note that a class is not considered to be derived from itself. 8874 8875Example matches Y, Z, C (Base == hasName("X")) 8876 class X; 8877 class Y : public X {}; // directly derived 8878 class Z : public Y {}; // indirectly derived 8879 typedef X A; 8880 typedef A B; 8881 class C : public B {}; // derived from a typedef of X 8882 8883In the following example, Bar matches isDerivedFrom(hasName("X")): 8884 class Foo; 8885 typedef Foo X; 8886 class Bar : public Foo {}; // derived from a type that X is a typedef of 8887 8888In the following example, Bar matches isDerivedFrom(hasName("NSObject")) 8889 @interface NSObject @end 8890 @interface Bar : NSObject @end 8891 8892Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>> 8893</pre></td></tr> 8894 8895 8896<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>></td><td class="name" onclick="toggle('isDirectlyDerivedFrom1')"><a name="isDirectlyDerivedFrom1Anchor">isDirectlyDerivedFrom</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> Base</td></tr> 8897<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom1"><pre>Matches C++ or Objective-C classes that are directly derived from a class 8898matching Base. 8899 8900Note that a class is not considered to be derived from itself. 8901 8902Example matches Y, C (Base == hasName("X")) 8903 class X; 8904 class Y : public X {}; // directly derived 8905 class Z : public Y {}; // indirectly derived 8906 typedef X A; 8907 typedef A B; 8908 class C : public B {}; // derived from a typedef of X 8909 8910In the following example, Bar matches isDerivedFrom(hasName("X")): 8911 class Foo; 8912 typedef Foo X; 8913 class Bar : public Foo {}; // derived from a type that X is a typedef of 8914</pre></td></tr> 8915 8916 8917<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>></td><td class="name" onclick="toggle('isSameOrDerivedFrom1')"><a name="isSameOrDerivedFrom1Anchor">isSameOrDerivedFrom</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> Base</td></tr> 8918<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Similar to isDerivedFrom(), but also matches classes that directly 8919match Base. 8920</pre></td></tr> 8921 8922 8923<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('callee1')"><a name="callee1Anchor">callee</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 8924<tr><td colspan="4" class="doc" id="callee1"><pre>Matches 1) if the call expression's callee's declaration matches the 8925given matcher; or 2) if the Obj-C message expression's callee's method 8926declaration matches the given matcher. 8927 8928Example matches y.x() (matcher = callExpr(callee( 8929 cxxMethodDecl(hasName("x"))))) 8930 class Y { public: void x(); }; 8931 void z() { Y y; y.x(); } 8932 8933Example 2. Matches [I foo] with 8934objcMessageExpr(callee(objcMethodDecl(hasName("foo")))) 8935 8936 @interface I: NSObject 8937 +(void)foo; 8938 @end 8939 ... 8940 [I foo] 8941</pre></td></tr> 8942 8943 8944<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasAnyArgument3')"><a name="hasAnyArgument3Anchor">hasAnyArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8945<tr><td colspan="4" class="doc" id="hasAnyArgument3"><pre>Matches any argument of a call expression or a constructor call 8946expression, or an ObjC-message-send expression. 8947 8948Given 8949 void x(int, int, int) { int y; x(1, y, 42); } 8950callExpr(hasAnyArgument(declRefExpr())) 8951 matches x(1, y, 42) 8952with hasAnyArgument(...) 8953 matching y 8954 8955For ObjectiveC, given 8956 @interface I - (void) f:(int) y; @end 8957 void foo(I *i) { [i f:12]; } 8958objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 8959 matches [i f:12] 8960</pre></td></tr> 8961 8962 8963<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasArgument3')"><a name="hasArgument3Anchor">hasArgument</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8964<tr><td colspan="4" class="doc" id="hasArgument3"><pre>Matches the n'th argument of a call expression or a constructor 8965call expression. 8966 8967Example matches y in x(y) 8968 (matcher = callExpr(hasArgument(0, declRefExpr()))) 8969 void x(int) { int y; x(y); } 8970</pre></td></tr> 8971 8972 8973<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasReceiver0')"><a name="hasReceiver0Anchor">hasReceiver</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 8974<tr><td colspan="4" class="doc" id="hasReceiver0"><pre>Matches if the Objective-C message is sent to an instance, 8975and the inner matcher matches on that instance. 8976 8977For example the method call in 8978 NSString *x = @"hello"; 8979 [x containsString:@"h"]; 8980is matched by 8981objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x")))))) 8982</pre></td></tr> 8983 8984 8985<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 8986<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. 8987 8988Example 8989matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *"))); 8990matches the [webView ...] message invocation. 8991 NSString *webViewJavaScript = ... 8992 UIWebView *webView = ... 8993 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; 8994</pre></td></tr> 8995 8996 8997<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>></td><td class="name" onclick="toggle('hasAnyParameter1')"><a name="hasAnyParameter1Anchor">hasAnyParameter</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> 8998<tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a 8999block. 9000 9001Does not match the 'this' parameter of a method. 9002 9003Given 9004 class X { void f(int x, int y, int z) {} }; 9005cxxMethodDecl(hasAnyParameter(hasName("y"))) 9006 matches f(int x, int y, int z) {} 9007with hasAnyParameter(...) 9008 matching int y 9009 9010For ObjectiveC, given 9011 @interface I - (void) f:(int) y; @end 9012 9013the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 9014matches the declaration of method f with hasParameter 9015matching y. 9016 9017For blocks, given 9018 b = ^(int y) { printf("%d", y) }; 9019 9020the matcher blockDecl(hasAnyParameter(hasName("y"))) 9021matches the declaration of the block b with hasParameter 9022matching y. 9023</pre></td></tr> 9024 9025 9026<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>></td><td class="name" onclick="toggle('hasParameter1')"><a name="hasParameter1Anchor">hasParameter</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> 9027<tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method 9028declaration or a block. 9029 9030Given 9031 class X { void f(int x) {} }; 9032cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 9033 matches f(int x) {} 9034with hasParameter(...) 9035 matching int x 9036 9037For ObjectiveC, given 9038 @interface I - (void) f:(int) y; @end 9039 9040the matcher objcMethodDecl(hasParameter(0, hasName("y"))) 9041matches the declaration of method f with hasParameter 9042matching y. 9043</pre></td></tr> 9044 9045 9046<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>></td><td class="name" onclick="toggle('hasTypeLoc11')"><a name="hasTypeLoc11Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 9047<tr><td colspan="4" class="doc" id="hasTypeLoc11"><pre>Matches if the type location of a node matches the inner matcher. 9048 9049Examples: 9050 int x; 9051declaratorDecl(hasTypeLoc(loc(asString("int")))) 9052 matches int x 9053 9054auto x = int(3); 9055cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 9056 matches int(3) 9057 9058struct Foo { Foo(int, int); }; 9059auto x = Foo(1, 2); 9060cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 9061 matches Foo(1, 2) 9062 9063Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 9064 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 9065 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 9066 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 9067 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 9068 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 9069 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 9070 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 9071</pre></td></tr> 9072 9073 9074<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html">OpaqueValueExpr</a>></td><td class="name" onclick="toggle('hasSourceExpression1')"><a name="hasSourceExpression1Anchor">hasSourceExpression</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 9075<tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression 9076or opaque value's source expression matches the given matcher. 9077 9078Example 1: matches "a string" 9079(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) 9080class URL { URL(string); }; 9081URL url = "a string"; 9082 9083Example 2: matches 'b' (matcher = 9084opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) 9085int a = b ?: 1; 9086</pre></td></tr> 9087 9088 9089<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OverloadExpr.html">OverloadExpr</a>></td><td class="name" onclick="toggle('hasAnyDeclaration0')"><a name="hasAnyDeclaration0Anchor">hasAnyDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9090<tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of 9091overloads matches the given matcher. 9092 9093Given 9094 template <typename T> void foo(T); 9095 template <typename T> void bar(T); 9096 template <typename T> void baz(T t) { 9097 foo(t); 9098 bar(t); 9099 } 9100unresolvedLookupExpr(hasAnyDeclaration( 9101 functionTemplateDecl(hasName("foo")))) 9102 matches foo in foo(t); but not bar in bar(t); 9103</pre></td></tr> 9104 9105 9106<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 9107<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. 9108 9109Given 9110 int (*ptr_to_array)[4]; 9111 int (*ptr_to_func)(int); 9112 9113varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches 9114ptr_to_func but not ptr_to_array. 9115 9116Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> 9117</pre></td></tr> 9118 9119 9120<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>></td><td class="name" onclick="toggle('hasPointeeLoc0')"><a name="hasPointeeLoc0Anchor">hasPointeeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> PointeeMatcher</td></tr> 9121<tr><td colspan="4" class="doc" id="hasPointeeLoc0"><pre>Matches pointer `TypeLoc`s that have a pointee `TypeLoc` matching 9122`PointeeMatcher`. 9123 9124Given 9125 int* x; 9126pointerTypeLoc(hasPointeeLoc(loc(asString("int")))) 9127 matches `int*`. 9128</pre></td></tr> 9129 9130 9131<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 9132<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the 9133pointee matches a given matcher. 9134 9135Given 9136 int *a; 9137 int const *b; 9138 float const *f; 9139pointerType(pointee(isConstQualified(), isInteger())) 9140 matches "int const *b" 9141 9142Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 9143 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 9144</pre></td></tr> 9145 9146 9147<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 9148<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. 9149 9150Given: 9151 typedef int &int_ref; 9152 int a; 9153 int_ref b = a; 9154 9155varDecl(hasType(qualType(referenceType()))))) will not match the 9156declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. 9157</pre></td></tr> 9158 9159 9160<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9161<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node 9162matches the given matcher. 9163 9164The associated declaration is: 9165- for type nodes, the declaration of the underlying type 9166- for CallExpr, the declaration of the callee 9167- for MemberExpr, the declaration of the referenced member 9168- for CXXConstructExpr, the declaration of the constructor 9169- for CXXNewExpr, the declaration of the operator new 9170- for ObjCIvarExpr, the declaration of the ivar 9171 9172For type nodes, hasDeclaration will generally match the declaration of the 9173sugared type. Given 9174 class X {}; 9175 typedef X Y; 9176 Y y; 9177in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 9178typedefDecl. A common use case is to match the underlying, desugared type. 9179This can be achieved by using the hasUnqualifiedDesugaredType matcher: 9180 varDecl(hasType(hasUnqualifiedDesugaredType( 9181 recordType(hasDeclaration(decl()))))) 9182In this matcher, the decl will match the CXXRecordDecl of class X. 9183 9184Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 9185 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 9186 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 9187 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 9188 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 9189 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 9190 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 9191</pre></td></tr> 9192 9193 9194<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('ignoringParens0')"><a name="ignoringParens0Anchor">ignoringParens</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 9195<tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped. 9196 9197Given 9198 void (*fp)(void); 9199The matcher 9200 varDecl(hasType(pointerType(pointee(ignoringParens(functionType()))))) 9201would match the declaration for fp. 9202</pre></td></tr> 9203 9204 9205<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9206<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 9207</pre></td></tr> 9208 9209 9210<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 9211<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type 9212matches the specified matcher. 9213 9214Example matches y->x() 9215 (matcher = cxxMemberCallExpr(on(hasType(pointsTo 9216 cxxRecordDecl(hasName("Y"))))))) 9217 class Y { public: void x(); }; 9218 void z() { Y *y; y->x(); } 9219</pre></td></tr> 9220 9221 9222<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9223<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 9224</pre></td></tr> 9225 9226 9227<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 9228<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced 9229type matches the specified matcher. 9230 9231Example matches X &x and const X &y 9232 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) 9233 class X { 9234 void a(X b) { 9235 X &x = b; 9236 const X &y = b; 9237 } 9238 }; 9239</pre></td></tr> 9240 9241 9242<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualifiedTypeLoc.html">QualifiedTypeLoc</a>></td><td class="name" onclick="toggle('hasUnqualifiedLoc0')"><a name="hasUnqualifiedLoc0Anchor">hasUnqualifiedLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> InnerMatcher</td></tr> 9243<tr><td colspan="4" class="doc" id="hasUnqualifiedLoc0"><pre>Matches `QualifiedTypeLoc`s that have an unqualified `TypeLoc` matching 9244`InnerMatcher`. 9245 9246Given 9247 int* const x; 9248 const int y; 9249qualifiedTypeLoc(hasUnqualifiedLoc(pointerTypeLoc())) 9250 matches the `TypeLoc` of the variable declaration of `x`, but not `y`. 9251</pre></td></tr> 9252 9253 9254<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9255<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node 9256matches the given matcher. 9257 9258The associated declaration is: 9259- for type nodes, the declaration of the underlying type 9260- for CallExpr, the declaration of the callee 9261- for MemberExpr, the declaration of the referenced member 9262- for CXXConstructExpr, the declaration of the constructor 9263- for CXXNewExpr, the declaration of the operator new 9264- for ObjCIvarExpr, the declaration of the ivar 9265 9266For type nodes, hasDeclaration will generally match the declaration of the 9267sugared type. Given 9268 class X {}; 9269 typedef X Y; 9270 Y y; 9271in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 9272typedefDecl. A common use case is to match the underlying, desugared type. 9273This can be achieved by using the hasUnqualifiedDesugaredType matcher: 9274 varDecl(hasType(hasUnqualifiedDesugaredType( 9275 recordType(hasDeclaration(decl()))))) 9276In this matcher, the decl will match the CXXRecordDecl of class X. 9277 9278Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 9279 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 9280 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 9281 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 9282 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 9283 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 9284 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 9285</pre></td></tr> 9286 9287 9288<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>></td><td class="name" onclick="toggle('hasReferentLoc0')"><a name="hasReferentLoc0Anchor">hasReferentLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> ReferentMatcher</td></tr> 9289<tr><td colspan="4" class="doc" id="hasReferentLoc0"><pre>Matches reference `TypeLoc`s that have a referent `TypeLoc` matching 9290`ReferentMatcher`. 9291 9292Given 9293 int x = 3; 9294 int& xx = x; 9295referenceTypeLoc(hasReferentLoc(loc(asString("int")))) 9296 matches `int&`. 9297</pre></td></tr> 9298 9299 9300<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 9301<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the 9302pointee matches a given matcher. 9303 9304Given 9305 int *a; 9306 int const *b; 9307 float const *f; 9308pointerType(pointee(isConstQualified(), isInteger())) 9309 matches "int const *b" 9310 9311Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 9312 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 9313</pre></td></tr> 9314 9315 9316<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>></td><td class="name" onclick="toggle('hasReturnValue0')"><a name="hasReturnValue0Anchor">hasReturnValue</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 9317<tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement 9318 9319Given 9320 return a + b; 9321hasReturnValue(binaryOperator()) 9322 matches 'return a + b' 9323with binaryOperator() 9324 matching 'a + b' 9325</pre></td></tr> 9326 9327 9328<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1StmtExpr.html">StmtExpr</a>></td><td class="name" onclick="toggle('hasAnySubstatement1')"><a name="hasAnySubstatement1Anchor">hasAnySubstatement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 9329<tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches 9330a given matcher. Also matches StmtExprs that have CompoundStmt as children. 9331 9332Given 9333 { {}; 1+2; } 9334hasAnySubstatement(compoundStmt()) 9335 matches '{ {}; 1+2; }' 9336with compoundStmt() 9337 matching '{}' 9338</pre></td></tr> 9339 9340 9341<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr> 9342<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 9343alignof. 9344</pre></td></tr> 9345 9346 9347<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('forCallable0')"><a name="forCallable0Anchor">forCallable</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9348<tr><td colspan="4" class="doc" id="forCallable0"><pre>Matches declaration of the function, method, or block the statement 9349belongs to. 9350 9351Given: 9352F& operator=(const F& o) { 9353 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); 9354 return *this; 9355} 9356returnStmt(forCallable(functionDecl(hasName("operator=")))) 9357 matches 'return *this' 9358 but does not match 'return v > 0' 9359 9360Given: 9361-(void) foo { 9362 int x = 1; 9363 dispatch_sync(queue, ^{ int y = 2; }); 9364} 9365declStmt(forCallable(objcMethodDecl())) 9366 matches 'int x = 1' 9367 but does not match 'int y = 2'. 9368whereas declStmt(forCallable(blockDecl())) 9369 matches 'int y = 2' 9370 but does not match 'int x = 1'. 9371</pre></td></tr> 9372 9373 9374<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('forFunction0')"><a name="forFunction0Anchor">forFunction</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> InnerMatcher</td></tr> 9375<tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to. 9376 9377Deprecated. Use forCallable() to correctly handle the situation when 9378the declaration is not a function (but a block or an Objective-C method). 9379forFunction() not only fails to take non-functions into account but also 9380may match the wrong declaration in their presence. 9381 9382Given: 9383F& operator=(const F& o) { 9384 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); 9385 return *this; 9386} 9387returnStmt(forFunction(hasName("operator="))) 9388 matches 'return *this' 9389 but does not match 'return v > 0' 9390</pre></td></tr> 9391 9392 9393<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr> 9394<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 9395sizeof. 9396</pre></td></tr> 9397 9398 9399<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html">SubstTemplateTypeParmType</a>></td><td class="name" onclick="toggle('hasReplacementType0')"><a name="hasReplacementType0Anchor">hasReplacementType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 9400<tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement 9401type that matches the provided matcher. 9402 9403Given 9404 template <typename T> 9405 double F(T t); 9406 int i; 9407 double j = F(i); 9408 9409substTemplateTypeParmType(hasReplacementType(type())) matches int 9410</pre></td></tr> 9411 9412 9413<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>> InnerMatcher</td></tr> 9414<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch 9415statement. This matcher may produce multiple matches. 9416 9417Given 9418 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } 9419switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") 9420 matches four times, with "c" binding each of "case 1:", "case 2:", 9421"case 3:" and "case 4:", and "s" respectively binding "switch (1)", 9422"switch (1)", "switch (2)" and "switch (2)". 9423</pre></td></tr> 9424 9425 9426<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>></td><td class="name" onclick="toggle('hasCondition4')"><a name="hasCondition4Anchor">hasCondition</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 9427<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 9428switch statement or conditional operator. 9429 9430Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 9431 if (true) {} 9432</pre></td></tr> 9433 9434 9435<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>></td><td class="name" onclick="toggle('hasInitStatement1')"><a name="hasInitStatement1Anchor">hasInitStatement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 9436<tr><td colspan="4" class="doc" id="hasInitStatement1"><pre>Matches selection statements with initializer. 9437 9438Given: 9439 void foo() { 9440 if (int i = foobar(); i > 0) {} 9441 switch (int i = foobar(); i) {} 9442 for (auto& a = get_range(); auto& x : a) {} 9443 } 9444 void bar() { 9445 if (foobar() > 0) {} 9446 switch (foobar()) {} 9447 for (auto& x : get_range()) {} 9448 } 9449ifStmt(hasInitStatement(anything())) 9450 matches the if statement in foo but not in bar. 9451switchStmt(hasInitStatement(anything())) 9452 matches the switch statement in foo but not in bar. 9453cxxForRangeStmt(hasInitStatement(anything())) 9454 matches the range for statement in foo but not in bar. 9455</pre></td></tr> 9456 9457 9458<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9459<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node 9460matches the given matcher. 9461 9462The associated declaration is: 9463- for type nodes, the declaration of the underlying type 9464- for CallExpr, the declaration of the callee 9465- for MemberExpr, the declaration of the referenced member 9466- for CXXConstructExpr, the declaration of the constructor 9467- for CXXNewExpr, the declaration of the operator new 9468- for ObjCIvarExpr, the declaration of the ivar 9469 9470For type nodes, hasDeclaration will generally match the declaration of the 9471sugared type. Given 9472 class X {}; 9473 typedef X Y; 9474 Y y; 9475in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 9476typedefDecl. A common use case is to match the underlying, desugared type. 9477This can be achieved by using the hasUnqualifiedDesugaredType matcher: 9478 varDecl(hasType(hasUnqualifiedDesugaredType( 9479 recordType(hasDeclaration(decl()))))) 9480In this matcher, the decl will match the CXXRecordDecl of class X. 9481 9482Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 9483 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 9484 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 9485 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 9486 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 9487 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 9488 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 9489</pre></td></tr> 9490 9491 9492<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>></td><td class="name" onclick="toggle('hasTypeLoc12')"><a name="hasTypeLoc12Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 9493<tr><td colspan="4" class="doc" id="hasTypeLoc12"><pre>Matches if the type location of a node matches the inner matcher. 9494 9495Examples: 9496 int x; 9497declaratorDecl(hasTypeLoc(loc(asString("int")))) 9498 matches int x 9499 9500auto x = int(3); 9501cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 9502 matches int(3) 9503 9504struct Foo { Foo(int, int); }; 9505auto x = Foo(1, 2); 9506cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 9507 matches Foo(1, 2) 9508 9509Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 9510 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 9511 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 9512 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 9513 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 9514 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 9515 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 9516 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 9517</pre></td></tr> 9518 9519 9520<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 9521<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. 9522 9523Given 9524 struct B { int next; }; 9525 template<int(B::*next_ptr)> struct A {}; 9526 A<&B::next> a; 9527templateSpecializationType(hasAnyTemplateArgument( 9528 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) 9529 matches the specialization A<&B::next> with fieldDecl(...) matching 9530 B::next 9531</pre></td></tr> 9532 9533 9534<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9535<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain 9536declaration. 9537 9538Given 9539 struct B { int next; }; 9540 template<int(B::*next_ptr)> struct A {}; 9541 A<&B::next> a; 9542classTemplateSpecializationDecl(hasAnyTemplateArgument( 9543 refersToDeclaration(fieldDecl(hasName("next"))))) 9544 matches the specialization A<&B::next> with fieldDecl(...) matching 9545 B::next 9546</pre></td></tr> 9547 9548 9549<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 9550<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that refers to an integral type. 9551 9552Given 9553 template<int T> struct C {}; 9554 C<42> c; 9555classTemplateSpecializationDecl( 9556 hasAnyTemplateArgument(refersToIntegralType(asString("int")))) 9557 matches the implicit instantiation of C in C<42>. 9558</pre></td></tr> 9559 9560 9561<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('refersToTemplate0')"><a name="refersToTemplate0Anchor">refersToTemplate</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>> InnerMatcher</td></tr> 9562<tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template. 9563 9564Given 9565 template<template <typename> class S> class X {}; 9566 template<typename T> class Y {}; 9567 X<Y> xi; 9568classTemplateSpecializationDecl(hasAnyTemplateArgument( 9569 refersToTemplate(templateName()))) 9570 matches the specialization X<Y> 9571</pre></td></tr> 9572 9573 9574<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 9575<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 9576 9577Given 9578 struct X {}; 9579 template<typename T> struct A {}; 9580 A<X> a; 9581classTemplateSpecializationDecl(hasAnyTemplateArgument(refersToType( 9582 recordType(hasDeclaration(recordDecl(hasName("X"))))))) 9583matches the specialization of struct A generated by A<X>. 9584</pre></td></tr> 9585 9586 9587<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgumentLoc0')"><a name="hasAnyTemplateArgumentLoc0Anchor">hasAnyTemplateArgumentLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> 9588<tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc0"><pre>Matches template specialization `TypeLoc`s that have at least one 9589`TemplateArgumentLoc` matching the given `InnerMatcher`. 9590 9591Given 9592 template<typename T> class A {}; 9593 A<int> a; 9594varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc( 9595 hasTypeLoc(loc(asString("int"))))))) 9596 matches `A<int> a`. 9597</pre></td></tr> 9598 9599 9600<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>></td><td class="name" onclick="toggle('hasTemplateArgumentLoc1')"><a name="hasTemplateArgumentLoc1Anchor">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> 9601<tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc1"><pre>Matches template specialization `TypeLoc`s where the n'th 9602`TemplateArgumentLoc` matches the given `InnerMatcher`. 9603 9604Given 9605 template<typename T, typename U> class A {}; 9606 A<double, int> b; 9607 A<int, double> c; 9608varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0, 9609 hasTypeLoc(loc(asString("double"))))))) 9610 matches `A<double, int> b`, but not `A<int, double> c`. 9611</pre></td></tr> 9612 9613 9614<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('forEachTemplateArgument1')"><a name="forEachTemplateArgument1Anchor">forEachTemplateArgument</a></td><td>clang::ast_matchers::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 9615<tr><td colspan="4" class="doc" id="forEachTemplateArgument1"><pre>Matches classTemplateSpecialization, templateSpecializationType and 9616functionDecl nodes where the template argument matches the inner matcher. 9617This matcher may produce multiple matches. 9618 9619Given 9620 template <typename T, unsigned N, unsigned M> 9621 struct Matrix {}; 9622 9623 constexpr unsigned R = 2; 9624 Matrix<int, R * 2, R * 4> M; 9625 9626 template <typename T, typename U> 9627 void f(T&& t, U&& u) {} 9628 9629 bool B = false; 9630 f(R, B); 9631templateSpecializationType(forEachTemplateArgument(isExpr(expr()))) 9632 matches twice, with expr() matching 'R * 2' and 'R * 4' 9633functionDecl(forEachTemplateArgument(refersToType(builtinType()))) 9634 matches the specialization f<unsigned, bool> twice, for 'unsigned' 9635 and 'bool' 9636</pre></td></tr> 9637 9638 9639<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 9640<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and 9641functionDecl that have at least one TemplateArgument matching the given 9642InnerMatcher. 9643 9644Given 9645 template<typename T> class A {}; 9646 template<> class A<double> {}; 9647 A<int> a; 9648 9649 template<typename T> f() {}; 9650 void func() { f<int>(); }; 9651 9652classTemplateSpecializationDecl(hasAnyTemplateArgument( 9653 refersToType(asString("int")))) 9654 matches the specialization A<int> 9655 9656functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 9657 matches the specialization f<int> 9658</pre></td></tr> 9659 9660 9661<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9662<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node 9663matches the given matcher. 9664 9665The associated declaration is: 9666- for type nodes, the declaration of the underlying type 9667- for CallExpr, the declaration of the callee 9668- for MemberExpr, the declaration of the referenced member 9669- for CXXConstructExpr, the declaration of the constructor 9670- for CXXNewExpr, the declaration of the operator new 9671- for ObjCIvarExpr, the declaration of the ivar 9672 9673For type nodes, hasDeclaration will generally match the declaration of the 9674sugared type. Given 9675 class X {}; 9676 typedef X Y; 9677 Y y; 9678in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 9679typedefDecl. A common use case is to match the underlying, desugared type. 9680This can be achieved by using the hasUnqualifiedDesugaredType matcher: 9681 varDecl(hasType(hasUnqualifiedDesugaredType( 9682 recordType(hasDeclaration(decl()))))) 9683In this matcher, the decl will match the CXXRecordDecl of class X. 9684 9685Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 9686 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 9687 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 9688 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 9689 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 9690 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 9691 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 9692</pre></td></tr> 9693 9694 9695<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 9696<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and 9697functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 9698 9699Given 9700 template<typename T, typename U> class A {}; 9701 A<bool, int> b; 9702 A<int, bool> c; 9703 9704 template<typename T> void f() {} 9705 void func() { f<int>(); }; 9706classTemplateSpecializationDecl(hasTemplateArgument( 9707 1, refersToType(asString("int")))) 9708 matches the specialization A<bool, int> 9709 9710functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 9711 matches the specialization f<int> 9712</pre></td></tr> 9713 9714 9715<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9716<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node 9717matches the given matcher. 9718 9719The associated declaration is: 9720- for type nodes, the declaration of the underlying type 9721- for CallExpr, the declaration of the callee 9722- for MemberExpr, the declaration of the referenced member 9723- for CXXConstructExpr, the declaration of the constructor 9724- for CXXNewExpr, the declaration of the operator new 9725- for ObjCIvarExpr, the declaration of the ivar 9726 9727For type nodes, hasDeclaration will generally match the declaration of the 9728sugared type. Given 9729 class X {}; 9730 typedef X Y; 9731 Y y; 9732in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 9733typedefDecl. A common use case is to match the underlying, desugared type. 9734This can be achieved by using the hasUnqualifiedDesugaredType matcher: 9735 varDecl(hasType(hasUnqualifiedDesugaredType( 9736 recordType(hasDeclaration(decl()))))) 9737In this matcher, the decl will match the CXXRecordDecl of class X. 9738 9739Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 9740 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 9741 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 9742 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 9743 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 9744 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 9745 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 9746</pre></td></tr> 9747 9748 9749<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 9750<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner 9751QualType-matcher matches. 9752</pre></td></tr> 9753 9754 9755<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>></td><td class="name" onclick="toggle('hasTypeLoc13')"><a name="hasTypeLoc13Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 9756<tr><td colspan="4" class="doc" id="hasTypeLoc13"><pre>Matches if the type location of a node matches the inner matcher. 9757 9758Examples: 9759 int x; 9760declaratorDecl(hasTypeLoc(loc(asString("int")))) 9761 matches int x 9762 9763auto x = int(3); 9764cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 9765 matches int(3) 9766 9767struct Foo { Foo(int, int); }; 9768auto x = Foo(1, 2); 9769cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 9770 matches Foo(1, 2) 9771 9772Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>, 9773 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>, 9774 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>, 9775 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 9776 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, 9777 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>, 9778 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>, 9779 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 9780</pre></td></tr> 9781 9782 9783<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>></td><td class="name" onclick="toggle('hasType2')"><a name="hasType2Anchor">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 9784<tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type 9785matcher. 9786 9787Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 9788 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 9789 and U (matcher = typedefDecl(hasType(asString("int"))) 9790 and friend class X (matcher = friendDecl(hasType("X")) 9791 and public virtual X (matcher = cxxBaseSpecifier(hasType( 9792 asString("class X"))) 9793 class X {}; 9794 void y(X &x) { x; X z; } 9795 typedef int U; 9796 class Y { friend class X; }; 9797 class Z : public virtual X {}; 9798</pre></td></tr> 9799 9800 9801<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9802<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node 9803matches the given matcher. 9804 9805The associated declaration is: 9806- for type nodes, the declaration of the underlying type 9807- for CallExpr, the declaration of the callee 9808- for MemberExpr, the declaration of the referenced member 9809- for CXXConstructExpr, the declaration of the constructor 9810- for CXXNewExpr, the declaration of the operator new 9811- for ObjCIvarExpr, the declaration of the ivar 9812 9813For type nodes, hasDeclaration will generally match the declaration of the 9814sugared type. Given 9815 class X {}; 9816 typedef X Y; 9817 Y y; 9818in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 9819typedefDecl. A common use case is to match the underlying, desugared type. 9820This can be achieved by using the hasUnqualifiedDesugaredType matcher: 9821 varDecl(hasType(hasUnqualifiedDesugaredType( 9822 recordType(hasDeclaration(decl()))))) 9823In this matcher, the decl will match the CXXRecordDecl of class X. 9824 9825Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 9826 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 9827 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 9828 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 9829 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 9830 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 9831 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 9832</pre></td></tr> 9833 9834 9835<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('hasUnqualifiedDesugaredType0')"><a name="hasUnqualifiedDesugaredType0Anchor">hasUnqualifiedDesugaredType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>> InnerMatcher</td></tr> 9836<tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared 9837type of the matched node. 9838 9839For example, in: 9840 class A {}; 9841 using B = A; 9842The matcher type(hasUnqualifiedDesugaredType(recordType())) matches 9843both B and A. 9844</pre></td></tr> 9845 9846 9847<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 9848<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 9849 9850Given 9851 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 9852unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 9853 matches sizeof(a) and alignof(c) 9854</pre></td></tr> 9855 9856 9857<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 9858<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 9859 9860Example matches true (matcher = hasUnaryOperand( 9861 cxxBoolLiteral(equals(true)))) 9862 !true 9863</pre></td></tr> 9864 9865 9866<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html">UnresolvedMemberExpr</a>></td><td class="name" onclick="toggle('hasObjectExpression1')"><a name="hasObjectExpression1Anchor">hasObjectExpression</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 9867<tr><td colspan="4" class="doc" id="hasObjectExpression1"><pre>Matches a member expression where the object expression is matched by a 9868given matcher. Implicit object expressions are included; that is, it matches 9869use of implicit `this`. 9870 9871Given 9872 struct X { 9873 int m; 9874 int f(X x) { x.m; return m; } 9875 }; 9876memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) 9877 matches `x.m`, but not `m`; however, 9878memberExpr(hasObjectExpression(hasType(pointsTo( 9879 cxxRecordDecl(hasName("X")))))) 9880 matches `m` (aka. `this->m`), but not `x.m`. 9881</pre></td></tr> 9882 9883 9884<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9885<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node 9886matches the given matcher. 9887 9888The associated declaration is: 9889- for type nodes, the declaration of the underlying type 9890- for CallExpr, the declaration of the callee 9891- for MemberExpr, the declaration of the referenced member 9892- for CXXConstructExpr, the declaration of the constructor 9893- for CXXNewExpr, the declaration of the operator new 9894- for ObjCIvarExpr, the declaration of the ivar 9895 9896For type nodes, hasDeclaration will generally match the declaration of the 9897sugared type. Given 9898 class X {}; 9899 typedef X Y; 9900 Y y; 9901in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 9902typedefDecl. A common use case is to match the underlying, desugared type. 9903This can be achieved by using the hasUnqualifiedDesugaredType matcher: 9904 varDecl(hasType(hasUnqualifiedDesugaredType( 9905 recordType(hasDeclaration(decl()))))) 9906In this matcher, the decl will match the CXXRecordDecl of class X. 9907 9908Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 9909 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 9910 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 9911 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 9912 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 9913 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 9914 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 9915</pre></td></tr> 9916 9917 9918<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> InnerMatcher</td></tr> 9919<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 9920matched by the given matcher. 9921 9922Given 9923 namespace X { int a; void b(); } 9924 using X::a; 9925 using X::b; 9926usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 9927 matches using X::b but not using X::a </pre></td></tr> 9928 9929 9930<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>></td><td class="name" onclick="toggle('hasUnderlyingType1')"><a name="hasUnderlyingType1Anchor">hasUnderlyingType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 9931<tr><td colspan="4" class="doc" id="hasUnderlyingType1"><pre>Matches DecltypeType or UsingType nodes to find the underlying type. 9932 9933Given 9934 decltype(1) a = 1; 9935 decltype(2.0) b = 2.0; 9936decltypeType(hasUnderlyingType(isInteger())) 9937 matches the type of "a" 9938 9939Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> 9940</pre></td></tr> 9941 9942 9943<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>></td><td class="name" onclick="toggle('throughUsingDecl1')"><a name="throughUsingDecl1Anchor">throughUsingDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>> Inner</td></tr> 9944<tr><td colspan="4" class="doc" id="throughUsingDecl1"><pre>Matches if a node refers to a declaration through a specific 9945using shadow declaration. 9946 9947Examples: 9948 namespace a { int f(); } 9949 using a::f; 9950 int x = f(); 9951declRefExpr(throughUsingDecl(anything())) 9952 matches f 9953 9954 namespace a { class X{}; } 9955 using a::X; 9956 X x; 9957typeLoc(loc(usingType(throughUsingDecl(anything())))) 9958 matches X 9959 9960Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> 9961</pre></td></tr> 9962 9963 9964<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType7')"><a name="hasType7Anchor">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 9965<tr><td colspan="4" class="doc" id="hasType7"><pre>Overloaded to match the declaration of the expression's or value 9966declaration's type. 9967 9968In case of a value declaration (for example a variable declaration), 9969this resolves one layer of indirection. For example, in the value 9970declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 9971X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 9972declaration of x. 9973 9974Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 9975 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 9976 and friend class X (matcher = friendDecl(hasType("X")) 9977 and public virtual X (matcher = cxxBaseSpecifier(hasType( 9978 cxxRecordDecl(hasName("X")))) 9979 class X {}; 9980 void y(X &x) { x; X z; } 9981 class Y { friend class X; }; 9982 class Z : public virtual X {}; 9983 9984Example matches class Derived 9985(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) 9986class Base {}; 9987class Derived : Base {}; 9988 9989Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>, 9990Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> 9991</pre></td></tr> 9992 9993 9994<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 9995<tr><td colspan="4" class="doc" id="hasType3"><pre>Matches if the expression's or declaration's type matches a type 9996matcher. 9997 9998Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 9999 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 10000 and U (matcher = typedefDecl(hasType(asString("int"))) 10001 and friend class X (matcher = friendDecl(hasType("X")) 10002 and public virtual X (matcher = cxxBaseSpecifier(hasType( 10003 asString("class X"))) 10004 class X {}; 10005 void y(X &x) { x; X z; } 10006 typedef int U; 10007 class Y { friend class X; }; 10008 class Z : public virtual X {}; 10009</pre></td></tr> 10010 10011 10012<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 10013<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 10014that matches the given matcher. 10015 10016Example matches x (matcher = varDecl(hasInitializer(callExpr()))) 10017 bool y() { return true; } 10018 bool x = y(); 10019</pre></td></tr> 10020 10021 10022<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 10023<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 10024expression. 10025 10026Given 10027 void f(int b) { 10028 int a[b]; 10029 } 10030variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 10031 varDecl(hasName("b"))))))) 10032 matches "int a[b]" 10033</pre></td></tr> 10034 10035 10036<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 10037<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'do' statement or a function definition that has 10038a given body. Note that in case of functions this matcher only matches the 10039definition itself and not the other declarations of the same function. 10040 10041Given 10042 for (;;) {} 10043forStmt(hasBody(compoundStmt())) 10044 matches 'for (;;) {}' 10045with compoundStmt() 10046 matching '{}' 10047 10048Given 10049 void f(); 10050 void f() {} 10051functionDecl(hasBody(compoundStmt())) 10052 matches 'void f() {}' 10053with compoundStmt() 10054 matching '{}' 10055 but does not match 'void f();' 10056</pre></td></tr> 10057 10058 10059<tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 10060<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 10061switch statement or conditional operator. 10062 10063Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 10064 if (true) {} 10065</pre></td></tr> 10066 10067<!--END_TRAVERSAL_MATCHERS --> 10068</table> 10069 10070</div> 10071</body> 10072</html> 10073 10074 10075