17330f729Sjoerg<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 27330f729Sjoerg "http://www.w3.org/TR/html4/strict.dtd"> 37330f729Sjoerg<html> 47330f729Sjoerg<head> 57330f729Sjoerg<title>AST Matcher Reference</title> 67330f729Sjoerg<link type="text/css" rel="stylesheet" href="../menu.css" /> 77330f729Sjoerg<link type="text/css" rel="stylesheet" href="../content.css" /> 87330f729Sjoerg<style type="text/css"> 97330f729Sjoergtd { 107330f729Sjoerg padding: .33em; 117330f729Sjoerg} 127330f729Sjoergtd.doc { 137330f729Sjoerg display: none; 147330f729Sjoerg border-bottom: 1px solid black; 157330f729Sjoerg} 167330f729Sjoergtd.name:hover { 177330f729Sjoerg color: blue; 187330f729Sjoerg cursor: pointer; 197330f729Sjoerg} 20*e038c9c4Sjoergspan.mono { font-family: monospace; } 21*e038c9c4Sjoerg 22*e038c9c4Sjoerg.traverse_compare, .traverse_compare td, .traverse_compare th { 23*e038c9c4Sjoerg border: 1px solid black; 24*e038c9c4Sjoerg border-collapse: collapse; 25*e038c9c4Sjoerg} 267330f729Sjoerg</style> 277330f729Sjoerg<script type="text/javascript"> 287330f729Sjoergfunction toggle(id) { 297330f729Sjoerg if (!id) return; 307330f729Sjoerg row = document.getElementById(id); 317330f729Sjoerg if (row.style.display != 'table-cell') 327330f729Sjoerg row.style.display = 'table-cell'; 337330f729Sjoerg else 347330f729Sjoerg row.style.display = 'none'; 357330f729Sjoerg} 367330f729Sjoerg</script> 377330f729Sjoerg</head> 387330f729Sjoerg<body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))"> 397330f729Sjoerg 407330f729Sjoerg<!--#include virtual="../menu.html.incl"--> 417330f729Sjoerg 427330f729Sjoerg<div id="content"> 437330f729Sjoerg 447330f729Sjoerg<h1>AST Matcher Reference</h1> 457330f729Sjoerg 467330f729Sjoerg<p>This document shows all currently implemented matchers. The matchers are grouped 477330f729Sjoergby category and node type they match. You can click on matcher names to show the 487330f729Sjoergmatcher's source documentation.</p> 497330f729Sjoerg 507330f729Sjoerg<p>There are three different basic categories of matchers: 517330f729Sjoerg<ul> 527330f729Sjoerg<li><a href="#decl-matchers">Node Matchers:</a> Matchers that match a specific type of AST node.</li> 537330f729Sjoerg<li><a href="#narrowing-matchers">Narrowing Matchers:</a> Matchers that match attributes on AST nodes.</li> 547330f729Sjoerg<li><a href="#traversal-matchers">Traversal Matchers:</a> Matchers that allow traversal between AST nodes.</li> 557330f729Sjoerg</ul> 567330f729Sjoerg</p> 577330f729Sjoerg 587330f729Sjoerg<p>Within each category the matchers are ordered by node type they match on. 59*e038c9c4SjoergNote that if a matcher can match multiple node types, it will appear 607330f729Sjoergmultiple times. This means that by searching for Matcher<Stmt> you can 617330f729Sjoergfind all matchers that can be used to match on Stmt nodes.</p> 627330f729Sjoerg 637330f729Sjoerg<p>The exception to that rule are matchers that can match on any node. Those 647330f729Sjoergare marked with a * and are listed in the beginning of each category.</p> 657330f729Sjoerg 667330f729Sjoerg<p>Note that the categorization of matchers is a great help when you combine 677330f729Sjoergthem into matcher expressions. You will usually want to form matcher expressions 687330f729Sjoergthat read like english sentences by alternating between node matchers and 697330f729Sjoergnarrowing or traversal matchers, like this: 707330f729Sjoerg<pre> 717330f729SjoergrecordDecl(hasDescendant( 727330f729Sjoerg ifStmt(hasTrueExpression( 737330f729Sjoerg expr(hasDescendant( 747330f729Sjoerg ifStmt())))))) 757330f729Sjoerg</pre> 767330f729Sjoerg</p> 777330f729Sjoerg 787330f729Sjoerg<!-- ======================================================================= --> 79*e038c9c4Sjoerg<h2 id="traverse-mode">Traverse Mode</h2> 80*e038c9c4Sjoerg<!-- ======================================================================= --> 81*e038c9c4Sjoerg 82*e038c9c4Sjoerg<p>The default mode of operation of AST Matchers visits all nodes in the AST, 83*e038c9c4Sjoergeven if they are not spelled in the source. This is 84*e038c9c4Sjoerg<span class="mono">AsIs</span> mode. This mode requires writing AST matchers 85*e038c9c4Sjoergthat explicitly traverse or ignore implicit nodes, such as parentheses 86*e038c9c4Sjoergsurrounding an expression or expressions with cleanups. These implicit 87*e038c9c4Sjoergnodes are not always obvious from the syntax of the source code, and so this 88*e038c9c4Sjoergmode requires careful consideration and testing to get the desired behavior 89*e038c9c4Sjoergfrom an AST matcher. 90*e038c9c4Sjoerg</p> 91*e038c9c4Sjoerg 92*e038c9c4Sjoerg<p>In addition, because template instantiations are matched in the default mode, 93*e038c9c4Sjoergtransformations can be accidentally made to template declarations. Finally, 94*e038c9c4Sjoergbecause implicit nodes are matched by default, transformations can be made on 95*e038c9c4Sjoergentirely incorrect places in the code.</p> 96*e038c9c4Sjoerg 97*e038c9c4Sjoerg<p>For these reasons, it is possible to ignore AST nodes which are not spelled 98*e038c9c4Sjoergin the source using the <span class="mono">IgnoreUnlessSpelledInSource</span> 99*e038c9c4Sjoergmode. This is likely to be far less error-prone for users who are not already 100*e038c9c4Sjoergvery familiar with where implicit nodes appear in the AST. It is also likely 101*e038c9c4Sjoergto be less error-prone for experienced AST users, as difficult cases do not 102*e038c9c4Sjoergneed to be encountered and matcher expressions adjusted for these cases.</p> 103*e038c9c4Sjoerg 104*e038c9c4Sjoerg<p>In clang-query, the mode can be changed with 105*e038c9c4Sjoerg<pre> 106*e038c9c4Sjoergset traversal IgnoreUnlessSpelledInSource 107*e038c9c4Sjoerg</pre> 108*e038c9c4Sjoerg</p> 109*e038c9c4SjoergThis affects both matchers and AST dump output in results. 110*e038c9c4Sjoerg 111*e038c9c4Sjoerg<p>When using the C++ API such as in clang-tidy checks, the 112*e038c9c4Sjoerg<span class="mono">traverse()</span> matcher is used to set the mode: 113*e038c9c4Sjoerg<pre> 114*e038c9c4SjoergFinder->addMatcher(traverse(TK_IgnoreUnlessSpelledInSource, 115*e038c9c4Sjoerg returnStmt(hasReturnArgument(integerLiteral(equals(0)))) 116*e038c9c4Sjoerg ), this); 117*e038c9c4Sjoerg</pre> 118*e038c9c4Sjoerg</p> 119*e038c9c4Sjoerg<p>The following table compares the <span class="mono">AsIs</span> mode with 120*e038c9c4Sjoergthe <span class="mono">IgnoreUnlessSpelledInSource</span> mode:</p> 121*e038c9c4Sjoerg 122*e038c9c4Sjoerg<table class="traverse_compare"> 123*e038c9c4Sjoerg<tr> 124*e038c9c4Sjoerg<th></th> 125*e038c9c4Sjoerg<th><span class="mono">AsIs</span></th> 126*e038c9c4Sjoerg<th><span class="mono">IgnoreUnlessSpelledInSource</span></th> 127*e038c9c4Sjoerg</tr> 128*e038c9c4Sjoerg<tr> 129*e038c9c4Sjoerg <td>AST dump of <span class="mono">func1</span>: 130*e038c9c4Sjoerg<pre> 131*e038c9c4Sjoergstruct B { 132*e038c9c4Sjoerg B(int); 133*e038c9c4Sjoerg}; 134*e038c9c4Sjoerg 135*e038c9c4SjoergB func1() { return 42; } 136*e038c9c4Sjoerg</pre> 137*e038c9c4Sjoerg 138*e038c9c4Sjoerg </td> 139*e038c9c4Sjoerg <td> 140*e038c9c4SjoergC++98 dialect: 141*e038c9c4Sjoerg<pre> 142*e038c9c4SjoergFunctionDecl 143*e038c9c4Sjoerg`-CompoundStmt 144*e038c9c4Sjoerg `-ReturnStmt 145*e038c9c4Sjoerg `-ExprWithCleanups 146*e038c9c4Sjoerg `-CXXConstructExpr 147*e038c9c4Sjoerg `-MaterializeTemporaryExpr 148*e038c9c4Sjoerg `-ImplicitCastExpr 149*e038c9c4Sjoerg `-ImplicitCastExpr 150*e038c9c4Sjoerg `-CXXConstructExpr 151*e038c9c4Sjoerg `-IntegerLiteral 'int' 42 152*e038c9c4Sjoerg</pre> 153*e038c9c4SjoergC++11, C++14 dialect: 154*e038c9c4Sjoerg<pre> 155*e038c9c4SjoergFunctionDecl 156*e038c9c4Sjoerg`-CompoundStmt 157*e038c9c4Sjoerg `-ReturnStmt 158*e038c9c4Sjoerg `-ExprWithCleanups 159*e038c9c4Sjoerg `-CXXConstructExpr 160*e038c9c4Sjoerg `-MaterializeTemporaryExpr 161*e038c9c4Sjoerg `-ImplicitCastExpr 162*e038c9c4Sjoerg `-CXXConstructExpr 163*e038c9c4Sjoerg `-IntegerLiteral 'int' 42 164*e038c9c4Sjoerg</pre> 165*e038c9c4SjoergC++17, C++20 dialect: 166*e038c9c4Sjoerg<pre> 167*e038c9c4SjoergFunctionDecl 168*e038c9c4Sjoerg`-CompoundStmt 169*e038c9c4Sjoerg `-ReturnStmt 170*e038c9c4Sjoerg `-ImplicitCastExpr 171*e038c9c4Sjoerg `-CXXConstructExpr 172*e038c9c4Sjoerg `-IntegerLiteral 'int' 42 173*e038c9c4Sjoerg</pre> 174*e038c9c4Sjoerg</td> 175*e038c9c4Sjoerg <td> 176*e038c9c4SjoergAll dialects: 177*e038c9c4Sjoerg <pre> 178*e038c9c4SjoergFunctionDecl 179*e038c9c4Sjoerg`-CompoundStmt 180*e038c9c4Sjoerg `-ReturnStmt 181*e038c9c4Sjoerg `-IntegerLiteral 'int' 42 182*e038c9c4Sjoerg</pre></td> 183*e038c9c4Sjoerg</tr> 184*e038c9c4Sjoerg 185*e038c9c4Sjoerg<tr> 186*e038c9c4Sjoerg<td>Matcher for returned <span class="mono">42</span>: 187*e038c9c4Sjoerg<pre> 188*e038c9c4Sjoergstruct B { 189*e038c9c4Sjoerg B(int); 190*e038c9c4Sjoerg}; 191*e038c9c4Sjoerg 192*e038c9c4SjoergB func1() { return 42; } 193*e038c9c4Sjoerg</pre> 194*e038c9c4Sjoerg 195*e038c9c4Sjoerg </td> 196*e038c9c4Sjoerg <td> 197*e038c9c4SjoergAll dialects: 198*e038c9c4Sjoerg<pre> 199*e038c9c4SjoergreturnStmt(hasReturnValue( 200*e038c9c4Sjoerg ignoringImplicit( 201*e038c9c4Sjoerg ignoringElidableConstructorCall( 202*e038c9c4Sjoerg ignoringImplicit( 203*e038c9c4Sjoerg cxxConstructExpr(hasArgument(0, 204*e038c9c4Sjoerg ignoringImplicit( 205*e038c9c4Sjoerg integerLiteral().bind("returnVal") 206*e038c9c4Sjoerg ) 207*e038c9c4Sjoerg )) 208*e038c9c4Sjoerg ) 209*e038c9c4Sjoerg ) 210*e038c9c4Sjoerg ) 211*e038c9c4Sjoerg )) 212*e038c9c4Sjoerg</pre></td> 213*e038c9c4Sjoerg <td> 214*e038c9c4SjoergAll dialects: 215*e038c9c4Sjoerg<pre> 216*e038c9c4SjoergreturnStmt(hasReturnValue( 217*e038c9c4Sjoerg integerLiteral().bind("returnVal") 218*e038c9c4Sjoerg)) 219*e038c9c4Sjoerg</pre></td> 220*e038c9c4Sjoerg</tr> 221*e038c9c4Sjoerg<tr> 222*e038c9c4Sjoerg<td>Match result for 223*e038c9c4Sjoerg<pre>implicitCastExpr()</pre> 224*e038c9c4Sjoerggiven: 225*e038c9c4Sjoerg<pre> 226*e038c9c4Sjoergstruct B { 227*e038c9c4Sjoerg B(int); 228*e038c9c4Sjoerg}; 229*e038c9c4Sjoerg 230*e038c9c4SjoergB func1() { return 42; } 231*e038c9c4Sjoerg</pre> 232*e038c9c4Sjoerg 233*e038c9c4Sjoerg</td> 234*e038c9c4Sjoerg<td> 235*e038c9c4SjoergMatch found.</td> 236*e038c9c4Sjoerg <td> 237*e038c9c4SjoergNo match.</td> 238*e038c9c4Sjoerg</tr> 239*e038c9c4Sjoerg<tr> 240*e038c9c4Sjoerg <td>Match result for: 241*e038c9c4Sjoerg<pre> 242*e038c9c4SjoergcxxConstructorDecl( 243*e038c9c4Sjoerg isCopyConstructor() 244*e038c9c4Sjoerg ).bind("prepend_explicit") 245*e038c9c4Sjoerg</pre> 246*e038c9c4Sjoerggiven: 247*e038c9c4Sjoerg<pre> 248*e038c9c4Sjoergstruct Other {}; 249*e038c9c4Sjoergstruct Copyable { 250*e038c9c4Sjoerg Other m_o; 251*e038c9c4Sjoerg Copyable(); 252*e038c9c4Sjoerg}; 253*e038c9c4Sjoerg</pre> 254*e038c9c4Sjoerg</td> 255*e038c9c4Sjoerg<td> 256*e038c9c4SjoergMatch found. Insertion produces incorrect output: 257*e038c9c4Sjoerg<pre> 258*e038c9c4Sjoergstruct Other {}; 259*e038c9c4Sjoergstruct explicit Copyable { 260*e038c9c4Sjoerg Other m_o; 261*e038c9c4Sjoerg Copyable(); 262*e038c9c4Sjoerg}; 263*e038c9c4Sjoerg</pre> 264*e038c9c4Sjoerg</td> 265*e038c9c4Sjoerg<td> 266*e038c9c4SjoergNo match found. Incorrect replacement not possible. 267*e038c9c4Sjoerg</td> 268*e038c9c4Sjoerg</tr> 269*e038c9c4Sjoerg<tr> 270*e038c9c4Sjoerg <td>Replacement of <span class="mono">begin()</span> 271*e038c9c4Sjoerg with <span class="mono">cbegin()</span>: 272*e038c9c4Sjoerg<pre> 273*e038c9c4SjoergcxxMemberCallExpr( 274*e038c9c4Sjoerg on(ConstContainerExpr), 275*e038c9c4Sjoerg callee(cxxMethodDecl(hasName("begin"))) 276*e038c9c4Sjoerg ).bind("replace_with_cbegin") 277*e038c9c4Sjoerg</pre> 278*e038c9c4Sjoerggiven: 279*e038c9c4Sjoerg<pre> 280*e038c9c4Sjoergvoid foo() { 281*e038c9c4Sjoerg const Container c; 282*e038c9c4Sjoerg c.begin(); 283*e038c9c4Sjoerg 284*e038c9c4Sjoerg for (auto i : c) { 285*e038c9c4Sjoerg } 286*e038c9c4Sjoerg} 287*e038c9c4Sjoerg</pre> 288*e038c9c4Sjoerg</td> 289*e038c9c4Sjoerg<td> 290*e038c9c4Sjoerg2 matches found. Replacement produces incorrect output: 291*e038c9c4Sjoerg<pre> 292*e038c9c4Sjoergvoid foo() { 293*e038c9c4Sjoerg const Container c; 294*e038c9c4Sjoerg c.cbegin(); 295*e038c9c4Sjoerg 296*e038c9c4Sjoerg for (auto i :.cbegin() c) { 297*e038c9c4Sjoerg } 298*e038c9c4Sjoerg} 299*e038c9c4Sjoerg</pre> 300*e038c9c4Sjoerg</td> 301*e038c9c4Sjoerg<td> 302*e038c9c4Sjoerg1 match found. Replacement produces correct output: 303*e038c9c4Sjoerg<pre> 304*e038c9c4Sjoergvoid foo() { 305*e038c9c4Sjoerg const Container c; 306*e038c9c4Sjoerg c.cbegin(); 307*e038c9c4Sjoerg 308*e038c9c4Sjoerg for (auto i : c) { 309*e038c9c4Sjoerg } 310*e038c9c4Sjoerg} 311*e038c9c4Sjoerg</pre> 312*e038c9c4Sjoerg</td> 313*e038c9c4Sjoerg</tr> 314*e038c9c4Sjoerg<tr> 315*e038c9c4Sjoerg <td>Replacement of <span class="mono">int</span> member 316*e038c9c4Sjoerg with <span class="mono">safe_int</span>: 317*e038c9c4Sjoerg<pre> 318*e038c9c4SjoergfieldDecl( 319*e038c9c4Sjoerg hasType(asString("int")) 320*e038c9c4Sjoerg ).bind("use_safe_int") 321*e038c9c4Sjoerg</pre> 322*e038c9c4Sjoerggiven: 323*e038c9c4Sjoerg<pre> 324*e038c9c4Sjoergstruct S { 325*e038c9c4Sjoerg int m_i; 326*e038c9c4Sjoerg}; 327*e038c9c4Sjoerg 328*e038c9c4Sjoergtemplate <typename T> struct TemplStruct { 329*e038c9c4Sjoerg TemplStruct() {} 330*e038c9c4Sjoerg ~TemplStruct() {} 331*e038c9c4Sjoerg 332*e038c9c4Sjoergprivate: 333*e038c9c4Sjoerg T m_t; 334*e038c9c4Sjoerg}; 335*e038c9c4Sjoerg 336*e038c9c4Sjoergvoid instantiate() { TemplStruct<int> ti; } 337*e038c9c4Sjoerg</pre> 338*e038c9c4Sjoerg</td> 339*e038c9c4Sjoerg<td> 340*e038c9c4Sjoerg2 matches found. Replacement produces incorrect output: 341*e038c9c4Sjoerg<pre> 342*e038c9c4Sjoergstruct S { 343*e038c9c4Sjoerg safe_int m_i; 344*e038c9c4Sjoerg}; 345*e038c9c4Sjoerg 346*e038c9c4Sjoergtemplate <typename T> struct TemplStruct { 347*e038c9c4Sjoerg TemplStruct() {} 348*e038c9c4Sjoerg ~TemplStruct() {} 349*e038c9c4Sjoerg 350*e038c9c4Sjoergprivate: 351*e038c9c4Sjoerg safe_int m_t; 352*e038c9c4Sjoerg}; 353*e038c9c4Sjoerg 354*e038c9c4Sjoergvoid instantiate() { TemplStruct<int> ti; } 355*e038c9c4Sjoerg</pre> 356*e038c9c4Sjoerg</td> 357*e038c9c4Sjoerg<td> 358*e038c9c4Sjoerg1 match found. Replacement produces correct output: 359*e038c9c4Sjoerg<pre> 360*e038c9c4Sjoergstruct S { 361*e038c9c4Sjoerg safe_int m_i; 362*e038c9c4Sjoerg}; 363*e038c9c4Sjoerg 364*e038c9c4Sjoergtemplate <typename T> struct TemplStruct { 365*e038c9c4Sjoerg TemplStruct() {} 366*e038c9c4Sjoerg ~TemplStruct() {} 367*e038c9c4Sjoerg 368*e038c9c4Sjoergprivate: 369*e038c9c4Sjoerg T m_t; 370*e038c9c4Sjoerg}; 371*e038c9c4Sjoerg 372*e038c9c4Sjoergvoid instantiate() { TemplStruct<int> ti; } 373*e038c9c4Sjoerg</pre> 374*e038c9c4Sjoerg</td> 375*e038c9c4Sjoerg</tr> 376*e038c9c4Sjoerg<tr> 377*e038c9c4Sjoerg <td>Add prefix to member initializer 378*e038c9c4Sjoerg<pre> 379*e038c9c4SjoergcxxCtorInitializer( 380*e038c9c4Sjoerg forField(fieldDecl()) 381*e038c9c4Sjoerg ).bind("add_prefix") 382*e038c9c4Sjoerg</pre> 383*e038c9c4Sjoerggiven: 384*e038c9c4Sjoerg<pre> 385*e038c9c4Sjoergstruct Simple {}; 386*e038c9c4Sjoerg 387*e038c9c4Sjoergstruct Record { 388*e038c9c4Sjoerg Record() : i(42) {} 389*e038c9c4Sjoergprivate: 390*e038c9c4Sjoerg int i; 391*e038c9c4Sjoerg Simple s; 392*e038c9c4Sjoerg}; 393*e038c9c4Sjoerg</pre> 394*e038c9c4Sjoerg</td> 395*e038c9c4Sjoerg<td> 396*e038c9c4Sjoerg2 matches found. Replacement produces incorrect output: 397*e038c9c4Sjoerg<pre> 398*e038c9c4Sjoergstruct Simple {}; 399*e038c9c4Sjoerg 400*e038c9c4Sjoergstruct Record { 401*e038c9c4Sjoerg m_Record() : m_i(42) {} 402*e038c9c4Sjoergprivate: 403*e038c9c4Sjoerg int i; 404*e038c9c4Sjoerg Simple s; 405*e038c9c4Sjoerg}; 406*e038c9c4Sjoerg</pre> 407*e038c9c4Sjoerg</td> 408*e038c9c4Sjoerg<td> 409*e038c9c4Sjoerg1 match found. Replacement produces correct output: 410*e038c9c4Sjoerg<pre> 411*e038c9c4Sjoergstruct Simple {}; 412*e038c9c4Sjoerg 413*e038c9c4Sjoergstruct Record { 414*e038c9c4Sjoerg Record() : m_i(42) {} 415*e038c9c4Sjoergprivate: 416*e038c9c4Sjoerg int i; 417*e038c9c4Sjoerg Simple s; 418*e038c9c4Sjoerg}; 419*e038c9c4Sjoerg</pre> 420*e038c9c4Sjoerg</td> 421*e038c9c4Sjoerg</tr> 422*e038c9c4Sjoerg<tr> 423*e038c9c4Sjoerg <td>Ignored default arguments 424*e038c9c4Sjoerg<pre> 425*e038c9c4SjoergcallExpr( 426*e038c9c4Sjoerg callee(functionDecl( 427*e038c9c4Sjoerg hasName("hasDefaultArg") 428*e038c9c4Sjoerg )), 429*e038c9c4Sjoerg argumentCountIs(1) 430*e038c9c4Sjoerg ).bind("add_prefix") 431*e038c9c4Sjoerg</pre> 432*e038c9c4Sjoerggiven: 433*e038c9c4Sjoerg<pre> 434*e038c9c4Sjoergvoid hasDefaultArg(int i, int j = 0) {} 435*e038c9c4Sjoergvoid callDefaultArg() { hasDefaultArg(42); } 436*e038c9c4Sjoerg</pre> 437*e038c9c4Sjoerg</td> 438*e038c9c4Sjoerg<td> 439*e038c9c4SjoergNo match. 440*e038c9c4Sjoerg</td> 441*e038c9c4Sjoerg<td> 442*e038c9c4Sjoerg1 match found. 443*e038c9c4Sjoerg</td> 444*e038c9c4Sjoerg</tr> 445*e038c9c4Sjoerg<tr> 446*e038c9c4Sjoerg <td>Lambda fields 447*e038c9c4Sjoerg<pre> 448*e038c9c4SjoergfieldDecl( 449*e038c9c4Sjoerg hasType(asString("int")) 450*e038c9c4Sjoerg ).bind("make_safe") 451*e038c9c4Sjoerg</pre> 452*e038c9c4Sjoerggiven: 453*e038c9c4Sjoerg<pre> 454*e038c9c4Sjoergstruct S { 455*e038c9c4Sjoerg int m_i; 456*e038c9c4Sjoerg}; 457*e038c9c4Sjoerg 458*e038c9c4Sjoergvoid func() { 459*e038c9c4Sjoerg int a = 0; 460*e038c9c4Sjoerg int c = 0; 461*e038c9c4Sjoerg 462*e038c9c4Sjoerg auto l = [a, b = c](int d) { int e = d; }; 463*e038c9c4Sjoerg l(43); 464*e038c9c4Sjoerg} 465*e038c9c4Sjoerg</pre> 466*e038c9c4Sjoerg</td> 467*e038c9c4Sjoerg<td> 468*e038c9c4Sjoerg2 matches found. Replacement produces incorrect output: 469*e038c9c4Sjoerg<pre> 470*e038c9c4Sjoergstruct S { 471*e038c9c4Sjoerg safe_int m_i; 472*e038c9c4Sjoerg}; 473*e038c9c4Sjoerg 474*e038c9c4Sjoergvoid func() { 475*e038c9c4Sjoerg int a = 0; 476*e038c9c4Sjoerg int c = 0; 477*e038c9c4Sjoerg 478*e038c9c4Sjoerg auto l = [safe_a, safe_b = c](int d) { int e = d; }; 479*e038c9c4Sjoerg l(43); 480*e038c9c4Sjoerg} 481*e038c9c4Sjoerg</pre> 482*e038c9c4Sjoerg</td> 483*e038c9c4Sjoerg<td> 484*e038c9c4Sjoerg1 match found. Replacement produces correct output: 485*e038c9c4Sjoerg<pre> 486*e038c9c4Sjoergstruct S { 487*e038c9c4Sjoerg safe_int m_i; 488*e038c9c4Sjoerg}; 489*e038c9c4Sjoerg 490*e038c9c4Sjoergvoid func() { 491*e038c9c4Sjoerg int a = 0; 492*e038c9c4Sjoerg int c = 0; 493*e038c9c4Sjoerg 494*e038c9c4Sjoerg auto l = [a, b = c](int d) { int e = d; }; 495*e038c9c4Sjoerg l(43); 496*e038c9c4Sjoerg} 497*e038c9c4Sjoerg</pre> 498*e038c9c4Sjoerg</td> 499*e038c9c4Sjoerg 500*e038c9c4Sjoerg</tr> 501*e038c9c4Sjoerg 502*e038c9c4Sjoerg 503*e038c9c4Sjoerg 504*e038c9c4Sjoerg 505*e038c9c4Sjoerg 506*e038c9c4Sjoerg<tr> 507*e038c9c4Sjoerg <td>Rewritten binary operators 508*e038c9c4Sjoerg<pre> 509*e038c9c4SjoergbinaryOperator( 510*e038c9c4Sjoerg hasOperatorName("<"), 511*e038c9c4Sjoerg hasRHS(hasDescendant(integerLiteral(equals(0)))) 512*e038c9c4Sjoerg ) 513*e038c9c4Sjoerg</pre> 514*e038c9c4Sjoerggiven: 515*e038c9c4Sjoerg<pre> 516*e038c9c4Sjoerg#include <compare> 517*e038c9c4Sjoerg 518*e038c9c4Sjoergclass HasSpaceship { 519*e038c9c4Sjoergpublic: 520*e038c9c4Sjoerg int x; 521*e038c9c4Sjoerg bool operator==(const HasSpaceship&) const = default; 522*e038c9c4Sjoerg std::strong_ordering operator<=>(const HasSpaceship&) const = default; 523*e038c9c4Sjoerg}; 524*e038c9c4Sjoerg 525*e038c9c4Sjoergbool isLess(const HasSpaceship& a, const HasSpaceship& b) { 526*e038c9c4Sjoerg return a < b; 527*e038c9c4Sjoerg} 528*e038c9c4Sjoerg</pre> 529*e038c9c4Sjoerg</td> 530*e038c9c4Sjoerg<td> 531*e038c9c4Sjoerg1 match found. 532*e038c9c4Sjoerg 533*e038c9c4Sjoerg<pre> 534*e038c9c4Sjoerg return a < b; 535*e038c9c4Sjoerg ^~~~~ 536*e038c9c4Sjoerg</pre> 537*e038c9c4Sjoerg 538*e038c9c4Sjoerg</td> 539*e038c9c4Sjoerg<td> 540*e038c9c4SjoergNo match found. 541*e038c9c4Sjoerg</td> 542*e038c9c4Sjoerg</tr> 543*e038c9c4Sjoerg</table> 544*e038c9c4Sjoerg 545*e038c9c4Sjoerg<!-- ======================================================================= --> 5467330f729Sjoerg<h2 id="decl-matchers">Node Matchers</h2> 5477330f729Sjoerg<!-- ======================================================================= --> 5487330f729Sjoerg 5497330f729Sjoerg<p>Node matchers are at the core of matcher expressions - they specify the type 5507330f729Sjoergof node that is expected. Every match expression starts with a node matcher, 5517330f729Sjoergwhich can then be further refined with a narrowing or traversal matcher. All 5527330f729Sjoergtraversal matchers take node matchers as their arguments.</p> 5537330f729Sjoerg 5547330f729Sjoerg<p>For convenience, all node matchers take an arbitrary number of arguments 5557330f729Sjoergand implicitly act as allOf matchers.</p> 5567330f729Sjoerg 5577330f729Sjoerg<p>Node matchers are the only matchers that support the bind("id") call to 5587330f729Sjoergbind the matched node to the given string, to be later retrieved from the 5597330f729Sjoergmatch callback.</p> 5607330f729Sjoerg 5617330f729Sjoerg<p>It is important to remember that the arguments to node matchers are 5627330f729Sjoergpredicates on the same node, just with additional information about the type. 5637330f729SjoergThis is often useful to make matcher expression more readable by inlining bind 5647330f729Sjoergcalls into redundant node matchers inside another node matcher: 5657330f729Sjoerg<pre> 5667330f729Sjoerg// This binds the CXXRecordDecl to "id", as the decl() matcher will stay on 5677330f729Sjoerg// the same node. 5687330f729SjoergrecordDecl(decl().bind("id"), hasName("::MyClass")) 5697330f729Sjoerg</pre> 5707330f729Sjoerg</p> 5717330f729Sjoerg 5727330f729Sjoerg<table> 5737330f729Sjoerg<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 5747330f729Sjoerg<!-- START_DECL_MATCHERS --> 5757330f729Sjoerg 576*e038c9c4Sjoerg<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> 577*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="cxxBaseSpecifier0"><pre>Matches class bases. 578*e038c9c4Sjoerg 579*e038c9c4SjoergExamples matches public virtual B. 580*e038c9c4Sjoerg class B {}; 581*e038c9c4Sjoerg class C : public virtual B {}; 582*e038c9c4Sjoerg</pre></td></tr> 583*e038c9c4Sjoerg 584*e038c9c4Sjoerg 5857330f729Sjoerg<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> 5867330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers. 5877330f729Sjoerg 5887330f729SjoergExamples matches i(42). 5897330f729Sjoerg class C { 5907330f729Sjoerg C() : i(42) {} 5917330f729Sjoerg int i; 5927330f729Sjoerg }; 5937330f729Sjoerg</pre></td></tr> 5947330f729Sjoerg 5957330f729Sjoerg 5967330f729Sjoerg<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> 5977330f729Sjoerg<tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations. 5987330f729Sjoerg 5997330f729SjoergGiven 6007330f729Sjoerg class C { 6017330f729Sjoerg public: 6027330f729Sjoerg int a; 6037330f729Sjoerg }; 6047330f729SjoergaccessSpecDecl() 6057330f729Sjoerg matches 'public:' 6067330f729Sjoerg</pre></td></tr> 6077330f729Sjoerg 6087330f729Sjoerg 609*e038c9c4Sjoerg<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> 610*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="bindingDecl0"><pre>Matches binding declarations 611*e038c9c4SjoergExample matches foo and bar 612*e038c9c4Sjoerg(matcher = bindingDecl() 613*e038c9c4Sjoerg 614*e038c9c4Sjoerg auto [foo, bar] = std::make_pair{42, 42}; 615*e038c9c4Sjoerg</pre></td></tr> 616*e038c9c4Sjoerg 617*e038c9c4Sjoerg 6187330f729Sjoerg<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> 6197330f729Sjoerg<tr><td colspan="4" class="doc" id="blockDecl0"><pre>Matches block declarations. 6207330f729Sjoerg 6217330f729SjoergExample matches the declaration of the nameless block printing an input 6227330f729Sjoerginteger. 6237330f729Sjoerg 6247330f729Sjoerg myFunc(^(int p) { 6257330f729Sjoerg printf("%d", p); 6267330f729Sjoerg }) 6277330f729Sjoerg</pre></td></tr> 6287330f729Sjoerg 6297330f729Sjoerg 6307330f729Sjoerg<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> 6317330f729Sjoerg<tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations. 6327330f729Sjoerg 6337330f729SjoergExample matches Z 6347330f729Sjoerg template<class T> class Z {}; 6357330f729Sjoerg</pre></td></tr> 6367330f729Sjoerg 6377330f729Sjoerg 6387330f729Sjoerg<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> 6397330f729Sjoerg<tr><td colspan="4" class="doc" id="classTemplatePartialSpecializationDecl0"><pre>Matches C++ class template partial specializations. 6407330f729Sjoerg 6417330f729SjoergGiven 6427330f729Sjoerg template<class T1, class T2, int I> 6437330f729Sjoerg class A {}; 6447330f729Sjoerg 6457330f729Sjoerg template<class T, int I> 6467330f729Sjoerg class A<T, T*, I> {}; 6477330f729Sjoerg 6487330f729Sjoerg template<> 6497330f729Sjoerg class A<int, int, 1> {}; 6507330f729SjoergclassTemplatePartialSpecializationDecl() 6517330f729Sjoerg matches the specialization A<T,T*,I> but not A<int,int,1> 6527330f729Sjoerg</pre></td></tr> 6537330f729Sjoerg 6547330f729Sjoerg 6557330f729Sjoerg<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> 6567330f729Sjoerg<tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations. 6577330f729Sjoerg 6587330f729SjoergGiven 6597330f729Sjoerg template<typename T> class A {}; 6607330f729Sjoerg template<> class A<double> {}; 6617330f729Sjoerg A<int> a; 6627330f729SjoergclassTemplateSpecializationDecl() 6637330f729Sjoerg matches the specializations A<int> and A<double> 6647330f729Sjoerg</pre></td></tr> 6657330f729Sjoerg 6667330f729Sjoerg 6677330f729Sjoerg<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> 6687330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations. 6697330f729Sjoerg 6707330f729SjoergExample matches Foo::Foo() and Foo::Foo(int) 6717330f729Sjoerg class Foo { 6727330f729Sjoerg public: 6737330f729Sjoerg Foo(); 6747330f729Sjoerg Foo(int); 6757330f729Sjoerg int DoSomething(); 6767330f729Sjoerg }; 6777330f729Sjoerg</pre></td></tr> 6787330f729Sjoerg 6797330f729Sjoerg 6807330f729Sjoerg<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> 6817330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations. 6827330f729Sjoerg 6837330f729SjoergExample matches the operator. 6847330f729Sjoerg class X { operator int() const; }; 6857330f729Sjoerg</pre></td></tr> 6867330f729Sjoerg 6877330f729Sjoerg 6887330f729Sjoerg<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> 6897330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxDeductionGuideDecl0"><pre>Matches user-defined and implicitly generated deduction guide. 6907330f729Sjoerg 6917330f729SjoergExample matches the deduction guide. 6927330f729Sjoerg template<typename T> 6937330f729Sjoerg class X { X(int) }; 6947330f729Sjoerg X(int) -> X<int>; 6957330f729Sjoerg</pre></td></tr> 6967330f729Sjoerg 6977330f729Sjoerg 6987330f729Sjoerg<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> 6997330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations. 7007330f729Sjoerg 7017330f729SjoergExample matches Foo::~Foo() 7027330f729Sjoerg class Foo { 7037330f729Sjoerg public: 7047330f729Sjoerg virtual ~Foo(); 7057330f729Sjoerg }; 7067330f729Sjoerg</pre></td></tr> 7077330f729Sjoerg 7087330f729Sjoerg 7097330f729Sjoerg<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> 7107330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations. 7117330f729Sjoerg 7127330f729SjoergExample matches y 7137330f729Sjoerg class X { void y(); }; 7147330f729Sjoerg</pre></td></tr> 7157330f729Sjoerg 7167330f729Sjoerg 7177330f729Sjoerg<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> 7187330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations. 7197330f729Sjoerg 7207330f729SjoergExample matches X, Z 7217330f729Sjoerg class X; 7227330f729Sjoerg template<class T> class Z {}; 7237330f729Sjoerg</pre></td></tr> 7247330f729Sjoerg 7257330f729Sjoerg 7267330f729Sjoerg<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> 7277330f729Sjoerg<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. 7287330f729Sjoerg 7297330f729SjoergExamples matches X, C, and the friend declaration inside C; 7307330f729Sjoerg void X(); 7317330f729Sjoerg class C { 7327330f729Sjoerg friend X; 7337330f729Sjoerg }; 7347330f729Sjoerg</pre></td></tr> 7357330f729Sjoerg 7367330f729Sjoerg 7377330f729Sjoerg<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> 7387330f729Sjoerg<tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function 7397330f729Sjoergand non-type template parameter declarations). 7407330f729Sjoerg 7417330f729SjoergGiven 7427330f729Sjoerg class X { int y; }; 7437330f729SjoergdeclaratorDecl() 7447330f729Sjoerg matches int y. 7457330f729Sjoerg</pre></td></tr> 7467330f729Sjoerg 7477330f729Sjoerg 748*e038c9c4Sjoerg<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> 749*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="decompositionDecl0"><pre>Matches decomposition-declarations. 750*e038c9c4Sjoerg 751*e038c9c4SjoergExamples matches the declaration node with foo and bar, but not 752*e038c9c4Sjoergnumber. 753*e038c9c4Sjoerg(matcher = declStmt(has(decompositionDecl()))) 754*e038c9c4Sjoerg 755*e038c9c4Sjoerg int number = 42; 756*e038c9c4Sjoerg auto [foo, bar] = std::make_pair{42, 42}; 757*e038c9c4Sjoerg</pre></td></tr> 758*e038c9c4Sjoerg 759*e038c9c4Sjoerg 7607330f729Sjoerg<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> 7617330f729Sjoerg<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. 7627330f729Sjoerg 7637330f729SjoergExample matches A, B, C 7647330f729Sjoerg enum X { 7657330f729Sjoerg A, B, C 7667330f729Sjoerg }; 7677330f729Sjoerg</pre></td></tr> 7687330f729Sjoerg 7697330f729Sjoerg 7707330f729Sjoerg<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> 7717330f729Sjoerg<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. 7727330f729Sjoerg 7737330f729SjoergExample matches X 7747330f729Sjoerg enum X { 7757330f729Sjoerg A, B, C 7767330f729Sjoerg }; 7777330f729Sjoerg</pre></td></tr> 7787330f729Sjoerg 7797330f729Sjoerg 7807330f729Sjoerg<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> 7817330f729Sjoerg<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. 7827330f729Sjoerg 7837330f729SjoergGiven 7847330f729Sjoerg class X { int m; }; 7857330f729SjoergfieldDecl() 7867330f729Sjoerg matches 'm'. 7877330f729Sjoerg</pre></td></tr> 7887330f729Sjoerg 7897330f729Sjoerg 7907330f729Sjoerg<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> 7917330f729Sjoerg<tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations. 7927330f729Sjoerg 7937330f729SjoergGiven 7947330f729Sjoerg class X { friend void foo(); }; 7957330f729SjoergfriendDecl() 7967330f729Sjoerg matches 'friend void foo()'. 7977330f729Sjoerg</pre></td></tr> 7987330f729Sjoerg 7997330f729Sjoerg 8007330f729Sjoerg<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> 8017330f729Sjoerg<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. 8027330f729Sjoerg 8037330f729SjoergExample matches f 8047330f729Sjoerg void f(); 8057330f729Sjoerg</pre></td></tr> 8067330f729Sjoerg 8077330f729Sjoerg 8087330f729Sjoerg<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> 8097330f729Sjoerg<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. 8107330f729Sjoerg 8117330f729SjoergExample matches f 8127330f729Sjoerg template<class T> void f(T t) {} 8137330f729Sjoerg</pre></td></tr> 8147330f729Sjoerg 8157330f729Sjoerg 8167330f729Sjoerg<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> 8177330f729Sjoerg<tr><td colspan="4" class="doc" id="indirectFieldDecl0"><pre>Matches indirect field declarations. 8187330f729Sjoerg 8197330f729SjoergGiven 8207330f729Sjoerg struct X { struct { int a; }; }; 8217330f729SjoergindirectFieldDecl() 8227330f729Sjoerg matches 'a'. 8237330f729Sjoerg</pre></td></tr> 8247330f729Sjoerg 8257330f729Sjoerg 8267330f729Sjoerg<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> 8277330f729Sjoerg<tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label. 8287330f729Sjoerg 8297330f729SjoergGiven 8307330f729Sjoerg goto FOO; 8317330f729Sjoerg FOO: bar(); 8327330f729SjoerglabelDecl() 8337330f729Sjoerg matches 'FOO:' 8347330f729Sjoerg</pre></td></tr> 8357330f729Sjoerg 8367330f729Sjoerg 8377330f729Sjoerg<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> 8387330f729Sjoerg<tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification. 8397330f729Sjoerg 8407330f729SjoergGiven 8417330f729Sjoerg extern "C" {} 8427330f729SjoerglinkageSpecDecl() 8437330f729Sjoerg matches "extern "C" {}" 8447330f729Sjoerg</pre></td></tr> 8457330f729Sjoerg 8467330f729Sjoerg 8477330f729Sjoerg<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> 8487330f729Sjoerg<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. 8497330f729Sjoerg 8507330f729SjoergExample matches X, S, the anonymous union type, i, and U; 8517330f729Sjoerg typedef int X; 8527330f729Sjoerg struct S { 8537330f729Sjoerg union { 8547330f729Sjoerg int i; 8557330f729Sjoerg } U; 8567330f729Sjoerg }; 8577330f729Sjoerg</pre></td></tr> 8587330f729Sjoerg 8597330f729Sjoerg 8607330f729Sjoerg<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> 8617330f729Sjoerg<tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias. 8627330f729Sjoerg 8637330f729SjoergGiven 8647330f729Sjoerg namespace test {} 8657330f729Sjoerg namespace alias = ::test; 8667330f729SjoergnamespaceAliasDecl() 8677330f729Sjoerg matches "namespace alias" but not "namespace test" 8687330f729Sjoerg</pre></td></tr> 8697330f729Sjoerg 8707330f729Sjoerg 8717330f729Sjoerg<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> 8727330f729Sjoerg<tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. 8737330f729Sjoerg 8747330f729SjoergGiven 8757330f729Sjoerg namespace {} 8767330f729Sjoerg namespace test {} 8777330f729SjoergnamespaceDecl() 8787330f729Sjoerg matches "namespace {}" and "namespace test {}" 8797330f729Sjoerg</pre></td></tr> 8807330f729Sjoerg 8817330f729Sjoerg 8827330f729Sjoerg<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> 8837330f729Sjoerg<tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations. 8847330f729Sjoerg 8857330f729SjoergGiven 8867330f729Sjoerg template <typename T, int N> struct C {}; 8877330f729SjoergnonTypeTemplateParmDecl() 8887330f729Sjoerg matches 'N', but not 'T'. 8897330f729Sjoerg</pre></td></tr> 8907330f729Sjoerg 8917330f729Sjoerg 8927330f729Sjoerg<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> 8937330f729Sjoerg<tr><td colspan="4" class="doc" id="objcCategoryDecl0"><pre>Matches Objective-C category declarations. 8947330f729Sjoerg 8957330f729SjoergExample matches Foo (Additions) 8967330f729Sjoerg @interface Foo (Additions) 8977330f729Sjoerg @end 8987330f729Sjoerg</pre></td></tr> 8997330f729Sjoerg 9007330f729Sjoerg 9017330f729Sjoerg<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> 9027330f729Sjoerg<tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions. 9037330f729Sjoerg 9047330f729SjoergExample matches Foo (Additions) 9057330f729Sjoerg @implementation Foo (Additions) 9067330f729Sjoerg @end 9077330f729Sjoerg</pre></td></tr> 9087330f729Sjoerg 9097330f729Sjoerg 9107330f729Sjoerg<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> 9117330f729Sjoerg<tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations. 9127330f729Sjoerg 9137330f729SjoergExample matches Foo 9147330f729Sjoerg @implementation Foo 9157330f729Sjoerg @end 9167330f729Sjoerg</pre></td></tr> 9177330f729Sjoerg 9187330f729Sjoerg 9197330f729Sjoerg<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> 9207330f729Sjoerg<tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations. 9217330f729Sjoerg 9227330f729SjoergExample matches Foo 9237330f729Sjoerg @interface Foo 9247330f729Sjoerg @end 9257330f729Sjoerg</pre></td></tr> 9267330f729Sjoerg 9277330f729Sjoerg 9287330f729Sjoerg<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> 9297330f729Sjoerg<tr><td colspan="4" class="doc" id="objcIvarDecl0"><pre>Matches Objective-C instance variable declarations. 9307330f729Sjoerg 9317330f729SjoergExample matches _enabled 9327330f729Sjoerg @implementation Foo { 9337330f729Sjoerg BOOL _enabled; 9347330f729Sjoerg } 9357330f729Sjoerg @end 9367330f729Sjoerg</pre></td></tr> 9377330f729Sjoerg 9387330f729Sjoerg 9397330f729Sjoerg<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> 9407330f729Sjoerg<tr><td colspan="4" class="doc" id="objcMethodDecl0"><pre>Matches Objective-C method declarations. 9417330f729Sjoerg 9427330f729SjoergExample matches both declaration and definition of -[Foo method] 9437330f729Sjoerg @interface Foo 9447330f729Sjoerg - (void)method; 9457330f729Sjoerg @end 9467330f729Sjoerg 9477330f729Sjoerg @implementation Foo 9487330f729Sjoerg - (void)method {} 9497330f729Sjoerg @end 9507330f729Sjoerg</pre></td></tr> 9517330f729Sjoerg 9527330f729Sjoerg 9537330f729Sjoerg<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> 9547330f729Sjoerg<tr><td colspan="4" class="doc" id="objcPropertyDecl0"><pre>Matches Objective-C property declarations. 9557330f729Sjoerg 9567330f729SjoergExample matches enabled 9577330f729Sjoerg @interface Foo 9587330f729Sjoerg @property BOOL enabled; 9597330f729Sjoerg @end 9607330f729Sjoerg</pre></td></tr> 9617330f729Sjoerg 9627330f729Sjoerg 9637330f729Sjoerg<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> 9647330f729Sjoerg<tr><td colspan="4" class="doc" id="objcProtocolDecl0"><pre>Matches Objective-C protocol declarations. 9657330f729Sjoerg 9667330f729SjoergExample matches FooDelegate 9677330f729Sjoerg @protocol FooDelegate 9687330f729Sjoerg @end 9697330f729Sjoerg</pre></td></tr> 9707330f729Sjoerg 9717330f729Sjoerg 9727330f729Sjoerg<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> 9737330f729Sjoerg<tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. 9747330f729Sjoerg 9757330f729SjoergGiven 9767330f729Sjoerg void f(int x); 9777330f729SjoergparmVarDecl() 9787330f729Sjoerg matches int x. 9797330f729Sjoerg</pre></td></tr> 9807330f729Sjoerg 9817330f729Sjoerg 9827330f729Sjoerg<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> 9837330f729Sjoerg<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations. 9847330f729Sjoerg 9857330f729SjoergExample matches X, Z, U, and S 9867330f729Sjoerg class X; 9877330f729Sjoerg template<class T> class Z {}; 9887330f729Sjoerg struct S {}; 9897330f729Sjoerg union U {}; 9907330f729Sjoerg</pre></td></tr> 9917330f729Sjoerg 9927330f729Sjoerg 9937330f729Sjoerg<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> 9947330f729Sjoerg<tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration. 9957330f729Sjoerg 9967330f729SjoergExample: 9977330f729Sjoerg staticAssertExpr() 9987330f729Sjoergmatches 9997330f729Sjoerg static_assert(sizeof(S) == sizeof(int)) 10007330f729Sjoergin 10017330f729Sjoerg struct S { 10027330f729Sjoerg int x; 10037330f729Sjoerg }; 10047330f729Sjoerg static_assert(sizeof(S) == sizeof(int)); 10057330f729Sjoerg</pre></td></tr> 10067330f729Sjoerg 10077330f729Sjoerg 1008*e038c9c4Sjoerg<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> 1009*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="tagDecl0"><pre>Matches tag declarations. 1010*e038c9c4Sjoerg 1011*e038c9c4SjoergExample matches X, Z, U, S, E 1012*e038c9c4Sjoerg class X; 1013*e038c9c4Sjoerg template<class T> class Z {}; 1014*e038c9c4Sjoerg struct S {}; 1015*e038c9c4Sjoerg union U {}; 1016*e038c9c4Sjoerg enum E { 1017*e038c9c4Sjoerg A, B, C 1018*e038c9c4Sjoerg }; 1019*e038c9c4Sjoerg</pre></td></tr> 1020*e038c9c4Sjoerg 1021*e038c9c4Sjoerg 1022*e038c9c4Sjoerg<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> 1023*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="templateTemplateParmDecl0"><pre>Matches template template parameter declarations. 1024*e038c9c4Sjoerg 1025*e038c9c4SjoergGiven 1026*e038c9c4Sjoerg template <template <typename> class Z, int N> struct C {}; 1027*e038c9c4SjoergtemplateTypeParmDecl() 1028*e038c9c4Sjoerg matches 'Z', but not 'N'. 1029*e038c9c4Sjoerg</pre></td></tr> 1030*e038c9c4Sjoerg 1031*e038c9c4Sjoerg 10327330f729Sjoerg<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> 10337330f729Sjoerg<tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations. 10347330f729Sjoerg 10357330f729SjoergGiven 10367330f729Sjoerg template <typename T, int N> struct C {}; 10377330f729SjoergtemplateTypeParmDecl() 10387330f729Sjoerg matches 'T', but not 'N'. 10397330f729Sjoerg</pre></td></tr> 10407330f729Sjoerg 10417330f729Sjoerg 10427330f729Sjoerg<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> 10437330f729Sjoerg<tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context. 10447330f729Sjoerg 10457330f729SjoergGiven 10467330f729Sjoerg int X; 10477330f729Sjoerg namespace NS { 10487330f729Sjoerg int Y; 10497330f729Sjoerg } // namespace NS 10507330f729Sjoergdecl(hasDeclContext(translationUnitDecl())) 10517330f729Sjoerg matches "int X", but not "int Y". 10527330f729Sjoerg</pre></td></tr> 10537330f729Sjoerg 10547330f729Sjoerg 10557330f729Sjoerg<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> 10567330f729Sjoerg<tr><td colspan="4" class="doc" id="typeAliasDecl0"><pre>Matches type alias declarations. 10577330f729Sjoerg 10587330f729SjoergGiven 10597330f729Sjoerg typedef int X; 10607330f729Sjoerg using Y = int; 10617330f729SjoergtypeAliasDecl() 10627330f729Sjoerg matches "using Y = int", but not "typedef int X" 10637330f729Sjoerg</pre></td></tr> 10647330f729Sjoerg 10657330f729Sjoerg 10667330f729Sjoerg<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> 10677330f729Sjoerg<tr><td colspan="4" class="doc" id="typeAliasTemplateDecl0"><pre>Matches type alias template declarations. 10687330f729Sjoerg 10697330f729SjoergtypeAliasTemplateDecl() matches 10707330f729Sjoerg template <typename T> 10717330f729Sjoerg using Y = X<T>; 10727330f729Sjoerg</pre></td></tr> 10737330f729Sjoerg 10747330f729Sjoerg 10757330f729Sjoerg<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> 10767330f729Sjoerg<tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations. 10777330f729Sjoerg 10787330f729SjoergGiven 10797330f729Sjoerg typedef int X; 10807330f729Sjoerg using Y = int; 10817330f729SjoergtypedefDecl() 10827330f729Sjoerg matches "typedef int X", but not "using Y = int" 10837330f729Sjoerg</pre></td></tr> 10847330f729Sjoerg 10857330f729Sjoerg 10867330f729Sjoerg<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> 10877330f729Sjoerg<tr><td colspan="4" class="doc" id="typedefNameDecl0"><pre>Matches typedef name declarations. 10887330f729Sjoerg 10897330f729SjoergGiven 10907330f729Sjoerg typedef int X; 10917330f729Sjoerg using Y = int; 10927330f729SjoergtypedefNameDecl() 10937330f729Sjoerg matches "typedef int X" and "using Y = int" 10947330f729Sjoerg</pre></td></tr> 10957330f729Sjoerg 10967330f729Sjoerg 10977330f729Sjoerg<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> 10987330f729Sjoerg<tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the 10997330f729Sjoergtypename. 11007330f729Sjoerg 11017330f729SjoergGiven 11027330f729Sjoerg template <typename T> 11037330f729Sjoerg struct Base { typedef T Foo; }; 11047330f729Sjoerg 11057330f729Sjoerg template<typename T> 11067330f729Sjoerg struct S : private Base<T> { 11077330f729Sjoerg using typename Base<T>::Foo; 11087330f729Sjoerg }; 11097330f729SjoergunresolvedUsingTypenameDecl() 11107330f729Sjoerg matches using Base<T>::Foo </pre></td></tr> 11117330f729Sjoerg 11127330f729Sjoerg 11137330f729Sjoerg<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> 11147330f729Sjoerg<tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations. 11157330f729Sjoerg 11167330f729SjoergGiven 11177330f729Sjoerg template<typename X> 11187330f729Sjoerg class C : private X { 11197330f729Sjoerg using X::x; 11207330f729Sjoerg }; 11217330f729SjoergunresolvedUsingValueDecl() 11227330f729Sjoerg matches using X::x </pre></td></tr> 11237330f729Sjoerg 11247330f729Sjoerg 11257330f729Sjoerg<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> 11267330f729Sjoerg<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. 11277330f729Sjoerg 11287330f729SjoergGiven 11297330f729Sjoerg namespace X { int x; } 11307330f729Sjoerg using X::x; 11317330f729SjoergusingDecl() 11327330f729Sjoerg matches using X::x </pre></td></tr> 11337330f729Sjoerg 11347330f729Sjoerg 11357330f729Sjoerg<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> 11367330f729Sjoerg<tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations. 11377330f729Sjoerg 11387330f729SjoergGiven 11397330f729Sjoerg namespace X { int x; } 11407330f729Sjoerg using namespace X; 11417330f729SjoergusingDirectiveDecl() 11427330f729Sjoerg matches using namespace X </pre></td></tr> 11437330f729Sjoerg 11447330f729Sjoerg 11457330f729Sjoerg<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> 11467330f729Sjoerg<tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration. 11477330f729Sjoerg 11487330f729SjoergExample matches A, B, C and F 11497330f729Sjoerg enum X { A, B, C }; 11507330f729Sjoerg void F(); 11517330f729Sjoerg</pre></td></tr> 11527330f729Sjoerg 11537330f729Sjoerg 11547330f729Sjoerg<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> 11557330f729Sjoerg<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. 11567330f729Sjoerg 11577330f729SjoergNote: this does not match declarations of member variables, which are 11587330f729Sjoerg"field" declarations in Clang parlance. 11597330f729Sjoerg 11607330f729SjoergExample matches a 11617330f729Sjoerg int a; 11627330f729Sjoerg</pre></td></tr> 11637330f729Sjoerg 11647330f729Sjoerg 11657330f729Sjoerg<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> 11667330f729Sjoerg<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. 11677330f729Sjoerg</pre></td></tr> 11687330f729Sjoerg 11697330f729Sjoerg 11707330f729Sjoerg<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> 11717330f729Sjoerg<tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. 11727330f729Sjoerg 11737330f729SjoergGiven 11747330f729Sjoerg namespace ns { 11757330f729Sjoerg struct A { static void f(); }; 11767330f729Sjoerg void A::f() {} 11777330f729Sjoerg void g() { A::f(); } 11787330f729Sjoerg } 11797330f729Sjoerg ns::A a; 11807330f729SjoergnestedNameSpecifier() 11817330f729Sjoerg matches "ns::" and both "A::" 11827330f729Sjoerg</pre></td></tr> 11837330f729Sjoerg 11847330f729Sjoerg 11857330f729Sjoerg<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> 11867330f729Sjoerg<tr><td colspan="4" class="doc" id="ompDefaultClause0"><pre>Matches OpenMP ``default`` clause. 11877330f729Sjoerg 11887330f729SjoergGiven 11897330f729Sjoerg 11907330f729Sjoerg #pragma omp parallel default(none) 11917330f729Sjoerg #pragma omp parallel default(shared) 1192*e038c9c4Sjoerg #pragma omp parallel default(firstprivate) 11937330f729Sjoerg #pragma omp parallel 11947330f729Sjoerg 1195*e038c9c4Sjoerg``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, and 1196*e038c9c4Sjoerg``default(firstprivate)`` 11977330f729Sjoerg</pre></td></tr> 11987330f729Sjoerg 11997330f729Sjoerg 12007330f729Sjoerg<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> 12017330f729Sjoerg<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. 12027330f729Sjoerg</pre></td></tr> 12037330f729Sjoerg 12047330f729Sjoerg 12057330f729Sjoerg<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> 12067330f729Sjoerg<tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension). 12077330f729Sjoerg 12087330f729SjoergGiven 12097330f729Sjoerg FOO: bar(); 12107330f729Sjoerg void *ptr = &&FOO; 12117330f729Sjoerg goto *bar; 12127330f729SjoergaddrLabelExpr() 12137330f729Sjoerg matches '&&FOO' 12147330f729Sjoerg</pre></td></tr> 12157330f729Sjoerg 12167330f729Sjoerg 12177330f729Sjoerg<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> 12187330f729Sjoerg<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. 12197330f729Sjoerg 12207330f729SjoergGiven 12217330f729Sjoerg int i = a[1]; 12227330f729SjoergarraySubscriptExpr() 12237330f729Sjoerg matches "a[1]" 12247330f729Sjoerg</pre></td></tr> 12257330f729Sjoerg 12267330f729Sjoerg 12277330f729Sjoerg<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> 12287330f729Sjoerg<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. 12297330f729Sjoerg 12307330f729Sjoerg int i = 100; 12317330f729Sjoerg __asm("mov al, 2"); 12327330f729SjoergasmStmt() 12337330f729Sjoerg matches '__asm("mov al, 2")' 12347330f729Sjoerg</pre></td></tr> 12357330f729Sjoerg 12367330f729Sjoerg 12377330f729Sjoerg<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> 12387330f729Sjoerg<tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins. 12397330f729SjoergExample matches __atomic_load_n(ptr, 1) 12407330f729Sjoerg void foo() { int *ptr; __atomic_load_n(ptr, 1); } 12417330f729Sjoerg</pre></td></tr> 12427330f729Sjoerg 12437330f729Sjoerg 12447330f729Sjoerg<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> 12457330f729Sjoerg<tr><td colspan="4" class="doc" id="autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement. 12467330f729Sjoerg 12477330f729SjoergGiven 12487330f729Sjoerg @autoreleasepool { 12497330f729Sjoerg int x = 0; 12507330f729Sjoerg } 12517330f729SjoergautoreleasePoolStmt(stmt()) matches the declaration of "x" 12527330f729Sjoerginside the autorelease pool. 12537330f729Sjoerg</pre></td></tr> 12547330f729Sjoerg 12557330f729Sjoerg 12567330f729Sjoerg<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> 12577330f729Sjoerg<tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension). 12587330f729Sjoerg 12597330f729SjoergExample matches a ?: b 12607330f729Sjoerg (a ?: b) + 42; 12617330f729Sjoerg</pre></td></tr> 12627330f729Sjoerg 12637330f729Sjoerg 12647330f729Sjoerg<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> 12657330f729Sjoerg<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. 12667330f729Sjoerg 12677330f729SjoergExample matches a || b 12687330f729Sjoerg !(a || b) 1269*e038c9c4SjoergSee also the binaryOperation() matcher for more-general matching. 12707330f729Sjoerg</pre></td></tr> 12717330f729Sjoerg 12727330f729Sjoerg 12737330f729Sjoerg<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> 12747330f729Sjoerg<tr><td colspan="4" class="doc" id="blockExpr0"><pre>Matches a reference to a block. 12757330f729Sjoerg 12767330f729SjoergExample: matches "^{}": 12777330f729Sjoerg void f() { ^{}(); } 12787330f729Sjoerg</pre></td></tr> 12797330f729Sjoerg 12807330f729Sjoerg 12817330f729Sjoerg<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> 12827330f729Sjoerg<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. 12837330f729Sjoerg 12847330f729SjoergGiven 12857330f729Sjoerg while (true) { break; } 12867330f729SjoergbreakStmt() 12877330f729Sjoerg matches 'break' 12887330f729Sjoerg</pre></td></tr> 12897330f729Sjoerg 12907330f729Sjoerg 12917330f729Sjoerg<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> 12927330f729Sjoerg<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. 12937330f729Sjoerg 12947330f729SjoergExample: Matches (int) 2.2f in 12957330f729Sjoerg int i = (int) 2.2f; 12967330f729Sjoerg</pre></td></tr> 12977330f729Sjoerg 12987330f729Sjoerg 12997330f729Sjoerg<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> 13007330f729Sjoerg<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. 13017330f729Sjoerg 13027330f729SjoergExample matches x.y() and y() 13037330f729Sjoerg X x; 13047330f729Sjoerg x.y(); 13057330f729Sjoerg y(); 13067330f729Sjoerg</pre></td></tr> 13077330f729Sjoerg 13087330f729Sjoerg 13097330f729Sjoerg<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> 13107330f729Sjoerg<tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. 13117330f729Sjoerg 13127330f729SjoergGiven 13137330f729Sjoerg switch(a) { case 42: break; default: break; } 13147330f729SjoergcaseStmt() 13157330f729Sjoerg matches 'case 42:'. 13167330f729Sjoerg</pre></td></tr> 13177330f729Sjoerg 13187330f729Sjoerg 13197330f729Sjoerg<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> 13207330f729Sjoerg<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. 13217330f729Sjoerg 13227330f729SjoergExample: castExpr() matches each of the following: 13237330f729Sjoerg (int) 3; 13247330f729Sjoerg const_cast<Expr *>(SubExpr); 13257330f729Sjoerg char c = 0; 13267330f729Sjoergbut does not match 13277330f729Sjoerg int i = (0); 13287330f729Sjoerg int k = 0; 13297330f729Sjoerg</pre></td></tr> 13307330f729Sjoerg 13317330f729Sjoerg 13327330f729Sjoerg<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> 13337330f729Sjoerg<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). 13347330f729Sjoerg 13357330f729SjoergNot matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), 13367330f729Sjoergthough. 13377330f729Sjoerg 13387330f729SjoergExample matches 'a', L'a' 13397330f729Sjoerg char ch = 'a'; 13407330f729Sjoerg wchar_t chw = L'a'; 13417330f729Sjoerg</pre></td></tr> 13427330f729Sjoerg 13437330f729Sjoerg 13447330f729Sjoerg<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> 13457330f729Sjoerg<tr><td colspan="4" class="doc" id="chooseExpr0"><pre>Matches GNU __builtin_choose_expr. 13467330f729Sjoerg</pre></td></tr> 13477330f729Sjoerg 13487330f729Sjoerg 1349*e038c9c4Sjoerg<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> 1350*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="coawaitExpr0"><pre>Matches co_await expressions. 1351*e038c9c4Sjoerg 1352*e038c9c4SjoergGiven 1353*e038c9c4Sjoerg co_await 1; 1354*e038c9c4SjoergcoawaitExpr() 1355*e038c9c4Sjoerg matches 'co_await 1' 1356*e038c9c4Sjoerg</pre></td></tr> 1357*e038c9c4Sjoerg 1358*e038c9c4Sjoerg 13597330f729Sjoerg<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> 13607330f729Sjoerg<tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals 13617330f729Sjoerg 13627330f729SjoergExample match: {1}, (1, 2) 13637330f729Sjoerg int array[4] = {1}; 13647330f729Sjoerg vector int myvec = (vector int)(1, 2); 13657330f729Sjoerg</pre></td></tr> 13667330f729Sjoerg 13677330f729Sjoerg 13687330f729Sjoerg<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> 13697330f729Sjoerg<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. 13707330f729Sjoerg 13717330f729SjoergExample matches '{}' and '{{}}' in 'for (;;) {{}}' 13727330f729Sjoerg for (;;) {{}} 13737330f729Sjoerg</pre></td></tr> 13747330f729Sjoerg 13757330f729Sjoerg 13767330f729Sjoerg<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> 13777330f729Sjoerg<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. 13787330f729Sjoerg 13797330f729SjoergExample matches a ? b : c 13807330f729Sjoerg (a ? b : c) + 42 13817330f729Sjoerg</pre></td></tr> 13827330f729Sjoerg 13837330f729Sjoerg 13847330f729Sjoerg<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> 13857330f729Sjoerg<tr><td colspan="4" class="doc" id="constantExpr0"><pre>Matches a constant expression wrapper. 13867330f729Sjoerg 13877330f729SjoergExample matches the constant in the case statement: 13887330f729Sjoerg (matcher = constantExpr()) 13897330f729Sjoerg switch (a) { 13907330f729Sjoerg case 37: break; 13917330f729Sjoerg } 13927330f729Sjoerg</pre></td></tr> 13937330f729Sjoerg 13947330f729Sjoerg 13957330f729Sjoerg<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> 13967330f729Sjoerg<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. 13977330f729Sjoerg 13987330f729SjoergGiven 13997330f729Sjoerg while (true) { continue; } 14007330f729SjoergcontinueStmt() 14017330f729Sjoerg matches 'continue' 14027330f729Sjoerg</pre></td></tr> 14037330f729Sjoerg 14047330f729Sjoerg 1405*e038c9c4Sjoerg<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> 1406*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="coreturnStmt0"><pre>Matches co_return statements. 1407*e038c9c4Sjoerg 1408*e038c9c4SjoergGiven 1409*e038c9c4Sjoerg while (true) { co_return; } 1410*e038c9c4SjoergcoreturnStmt() 1411*e038c9c4Sjoerg matches 'co_return' 1412*e038c9c4Sjoerg</pre></td></tr> 1413*e038c9c4Sjoerg 1414*e038c9c4Sjoerg 1415*e038c9c4Sjoerg<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> 1416*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="coyieldExpr0"><pre>Matches co_yield expressions. 1417*e038c9c4Sjoerg 1418*e038c9c4SjoergGiven 1419*e038c9c4Sjoerg co_yield 1; 1420*e038c9c4SjoergcoyieldExpr() 1421*e038c9c4Sjoerg matches 'co_yield 1' 1422*e038c9c4Sjoerg</pre></td></tr> 1423*e038c9c4Sjoerg 1424*e038c9c4Sjoerg 14257330f729Sjoerg<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> 14267330f729Sjoerg<tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression. 14277330f729Sjoerg 14287330f729SjoergExample matches, 14297330f729Sjoerg kernel<<<i,j>>>(); 14307330f729Sjoerg</pre></td></tr> 14317330f729Sjoerg 14327330f729Sjoerg 14337330f729Sjoerg<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> 14347330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created. 14357330f729Sjoerg 14367330f729SjoergExample matches FunctionTakesString(GetStringByValue()) 14377330f729Sjoerg (matcher = cxxBindTemporaryExpr()) 14387330f729Sjoerg FunctionTakesString(GetStringByValue()); 14397330f729Sjoerg FunctionTakesStringByPointer(GetStringPointer()); 14407330f729Sjoerg</pre></td></tr> 14417330f729Sjoerg 14427330f729Sjoerg 14437330f729Sjoerg<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> 14447330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals. 14457330f729Sjoerg 14467330f729SjoergExample matches true 14477330f729Sjoerg true 14487330f729Sjoerg</pre></td></tr> 14497330f729Sjoerg 14507330f729Sjoerg 14517330f729Sjoerg<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> 14527330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements. 14537330f729Sjoerg 14547330f729Sjoerg try {} catch(int i) {} 14557330f729SjoergcxxCatchStmt() 14567330f729Sjoerg matches 'catch(int i)' 14577330f729Sjoerg</pre></td></tr> 14587330f729Sjoerg 14597330f729Sjoerg 14607330f729Sjoerg<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> 14617330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression. 14627330f729Sjoerg 14637330f729SjoergExample: Matches const_cast<int*>(&r) in 14647330f729Sjoerg int n = 42; 14657330f729Sjoerg const int &r(n); 14667330f729Sjoerg int* p = const_cast<int*>(&r); 14677330f729Sjoerg</pre></td></tr> 14687330f729Sjoerg 14697330f729Sjoerg 14707330f729Sjoerg<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> 14717330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones). 14727330f729Sjoerg 14737330f729SjoergExample matches string(ptr, n) and ptr within arguments of f 14747330f729Sjoerg (matcher = cxxConstructExpr()) 14757330f729Sjoerg void f(const string &a, const string &b); 14767330f729Sjoerg char *ptr; 14777330f729Sjoerg int n; 14787330f729Sjoerg f(string(ptr, n), ptr); 14797330f729Sjoerg</pre></td></tr> 14807330f729Sjoerg 14817330f729Sjoerg 14827330f729Sjoerg<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> 14837330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site. 14847330f729Sjoerg 14857330f729SjoergExample matches the CXXDefaultArgExpr placeholder inserted for the 14867330f729Sjoerg default value of the second parameter in the call expression f(42) 14877330f729Sjoerg (matcher = cxxDefaultArgExpr()) 14887330f729Sjoerg void f(int x, int y = 0); 14897330f729Sjoerg f(42); 14907330f729Sjoerg</pre></td></tr> 14917330f729Sjoerg 14927330f729Sjoerg 14937330f729Sjoerg<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> 14947330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions. 14957330f729Sjoerg 14967330f729SjoergGiven 14977330f729Sjoerg delete X; 14987330f729SjoergcxxDeleteExpr() 14997330f729Sjoerg matches 'delete X'. 15007330f729Sjoerg</pre></td></tr> 15017330f729Sjoerg 15027330f729Sjoerg 15037330f729Sjoerg<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> 15047330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be 15057330f729Sjoergresolved because the base expression or the member name was dependent. 15067330f729Sjoerg 15077330f729SjoergGiven 15087330f729Sjoerg template <class T> void f() { T t; t.g(); } 15097330f729SjoergcxxDependentScopeMemberExpr() 15107330f729Sjoerg matches t.g 15117330f729Sjoerg</pre></td></tr> 15127330f729Sjoerg 15137330f729Sjoerg 15147330f729Sjoerg<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> 15157330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression. 15167330f729Sjoerg 15177330f729SjoergExample: 15187330f729Sjoerg cxxDynamicCastExpr() 15197330f729Sjoergmatches 15207330f729Sjoerg dynamic_cast<D*>(&b); 15217330f729Sjoergin 15227330f729Sjoerg struct B { virtual ~B() {} }; struct D : B {}; 15237330f729Sjoerg B b; 15247330f729Sjoerg D* p = dynamic_cast<D*>(&b); 15257330f729Sjoerg</pre></td></tr> 15267330f729Sjoerg 15277330f729Sjoerg 15287330f729Sjoerg<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> 15297330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements. 15307330f729Sjoerg 15317330f729SjoergcxxForRangeStmt() matches 'for (auto a : i)' 15327330f729Sjoerg int i[] = {1, 2, 3}; for (auto a : i); 15337330f729Sjoerg for(int j = 0; j < 5; ++j); 15347330f729Sjoerg</pre></td></tr> 15357330f729Sjoerg 15367330f729Sjoerg 15377330f729Sjoerg<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> 15387330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions 15397330f729Sjoerg 15407330f729SjoergExample: Matches Foo(bar); 15417330f729Sjoerg Foo f = bar; 15427330f729Sjoerg Foo g = (Foo) bar; 15437330f729Sjoerg Foo h = Foo(bar); 15447330f729Sjoerg</pre></td></tr> 15457330f729Sjoerg 15467330f729Sjoerg 15477330f729Sjoerg<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> 15487330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions. 15497330f729Sjoerg 15507330f729SjoergExample matches x.y() 15517330f729Sjoerg X x; 15527330f729Sjoerg x.y(); 15537330f729Sjoerg</pre></td></tr> 15547330f729Sjoerg 15557330f729Sjoerg 15567330f729Sjoerg<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> 15577330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions. 15587330f729Sjoerg 15597330f729SjoergGiven 15607330f729Sjoerg new X; 15617330f729SjoergcxxNewExpr() 15627330f729Sjoerg matches 'new X'. 15637330f729Sjoerg</pre></td></tr> 15647330f729Sjoerg 15657330f729Sjoerg 1566*e038c9c4Sjoerg<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> 1567*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="cxxNoexceptExpr0"><pre>Matches noexcept expressions. 1568*e038c9c4Sjoerg 1569*e038c9c4SjoergGiven 1570*e038c9c4Sjoerg bool a() noexcept; 1571*e038c9c4Sjoerg bool b() noexcept(true); 1572*e038c9c4Sjoerg bool c() noexcept(false); 1573*e038c9c4Sjoerg bool d() noexcept(noexcept(a())); 1574*e038c9c4Sjoerg bool e = noexcept(b()) || noexcept(c()); 1575*e038c9c4SjoergcxxNoexceptExpr() 1576*e038c9c4Sjoerg matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`. 1577*e038c9c4Sjoerg doesn't match the noexcept specifier in the declarations a, b, c or d. 1578*e038c9c4Sjoerg</pre></td></tr> 1579*e038c9c4Sjoerg 1580*e038c9c4Sjoerg 15817330f729Sjoerg<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> 15827330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal. 15837330f729Sjoerg</pre></td></tr> 15847330f729Sjoerg 15857330f729Sjoerg 15867330f729Sjoerg<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> 15877330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls. 15887330f729Sjoerg 15897330f729SjoergNote that if an operator isn't overloaded, it won't match. Instead, use 15907330f729SjoergbinaryOperator matcher. 15917330f729SjoergCurrently it does not match operators such as new delete. 15927330f729SjoergFIXME: figure out why these do not match? 15937330f729Sjoerg 15947330f729SjoergExample matches both operator<<((o << b), c) and operator<<(o, b) 15957330f729Sjoerg (matcher = cxxOperatorCallExpr()) 15967330f729Sjoerg ostream &operator<< (ostream &out, int i) { }; 15977330f729Sjoerg ostream &o; int b = 1, c = 1; 15987330f729Sjoerg o << b << c; 1599*e038c9c4SjoergSee also the binaryOperation() matcher for more-general matching of binary 1600*e038c9c4Sjoerguses of this AST node. 16017330f729Sjoerg</pre></td></tr> 16027330f729Sjoerg 16037330f729Sjoerg 16047330f729Sjoerg<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> 16057330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. 16067330f729Sjoerg 16077330f729SjoergEither the source expression or the destination type can be matched 16087330f729Sjoergusing has(), but hasDestinationType() is more specific and can be 16097330f729Sjoergmore readable. 16107330f729Sjoerg 16117330f729SjoergExample matches reinterpret_cast<char*>(&p) in 16127330f729Sjoerg void* p = reinterpret_cast<char*>(&p); 16137330f729Sjoerg</pre></td></tr> 16147330f729Sjoerg 16157330f729Sjoerg 1616*e038c9c4Sjoerg<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> 1617*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="cxxRewrittenBinaryOperator0"><pre>Matches rewritten binary operators 1618*e038c9c4Sjoerg 1619*e038c9c4SjoergExample matches use of "<": 1620*e038c9c4Sjoerg #include <compare> 1621*e038c9c4Sjoerg struct HasSpaceshipMem { 1622*e038c9c4Sjoerg int a; 1623*e038c9c4Sjoerg constexpr auto operator<=>(const HasSpaceshipMem&) const = default; 1624*e038c9c4Sjoerg }; 1625*e038c9c4Sjoerg void compare() { 1626*e038c9c4Sjoerg HasSpaceshipMem hs1, hs2; 1627*e038c9c4Sjoerg if (hs1 < hs2) 1628*e038c9c4Sjoerg return; 1629*e038c9c4Sjoerg } 1630*e038c9c4SjoergSee also the binaryOperation() matcher for more-general matching 1631*e038c9c4Sjoergof this AST node. 1632*e038c9c4Sjoerg</pre></td></tr> 1633*e038c9c4Sjoerg 1634*e038c9c4Sjoerg 16357330f729Sjoerg<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> 16367330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression. 16377330f729Sjoerg 16387330f729SjoergSee also: hasDestinationType 16397330f729SjoergSee also: reinterpretCast 16407330f729Sjoerg 16417330f729SjoergExample: 16427330f729Sjoerg cxxStaticCastExpr() 16437330f729Sjoergmatches 16447330f729Sjoerg static_cast<long>(8) 16457330f729Sjoergin 16467330f729Sjoerg long eight(static_cast<long>(8)); 16477330f729Sjoerg</pre></td></tr> 16487330f729Sjoerg 16497330f729Sjoerg 16507330f729Sjoerg<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> 16517330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions. 16527330f729Sjoerg 16537330f729SjoergGiven 16547330f729Sjoerg std::vector<int> a({ 1, 2, 3 }); 16557330f729Sjoerg std::vector<int> b = { 4, 5 }; 16567330f729Sjoerg int c[] = { 6, 7 }; 16577330f729Sjoerg std::pair<int, int> d = { 8, 9 }; 16587330f729SjoergcxxStdInitializerListExpr() 16597330f729Sjoerg matches "{ 1, 2, 3 }" and "{ 4, 5 }" 16607330f729Sjoerg</pre></td></tr> 16617330f729Sjoerg 16627330f729Sjoerg 16637330f729Sjoerg<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> 16647330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments 16657330f729Sjoerg 16667330f729SjoergExample: Matches Foo(bar, bar) 16677330f729Sjoerg Foo h = Foo(bar, bar); 16687330f729Sjoerg</pre></td></tr> 16697330f729Sjoerg 16707330f729Sjoerg 16717330f729Sjoerg<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> 16727330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions. 16737330f729Sjoerg 16747330f729SjoergExample matches the implicit this expression in "return i". 16757330f729Sjoerg (matcher = cxxThisExpr()) 16767330f729Sjoergstruct foo { 16777330f729Sjoerg int i; 16787330f729Sjoerg int f() { return i; } 16797330f729Sjoerg}; 16807330f729Sjoerg</pre></td></tr> 16817330f729Sjoerg 16827330f729Sjoerg 16837330f729Sjoerg<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> 16847330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions. 16857330f729Sjoerg 16867330f729Sjoerg try { throw 5; } catch(int i) {} 16877330f729SjoergcxxThrowExpr() 16887330f729Sjoerg matches 'throw 5' 16897330f729Sjoerg</pre></td></tr> 16907330f729Sjoerg 16917330f729Sjoerg 16927330f729Sjoerg<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> 16937330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements. 16947330f729Sjoerg 16957330f729Sjoerg try {} catch(int i) {} 16967330f729SjoergcxxTryStmt() 16977330f729Sjoerg matches 'try {}' 16987330f729Sjoerg</pre></td></tr> 16997330f729Sjoerg 17007330f729Sjoerg 17017330f729Sjoerg<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> 17027330f729Sjoerg<tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. 17037330f729Sjoerg 17047330f729SjoergExample matches T(t) in return statement of f 17057330f729Sjoerg (matcher = cxxUnresolvedConstructExpr()) 17067330f729Sjoerg template <typename T> 17077330f729Sjoerg void f(const T& t) { return T(t); } 17087330f729Sjoerg</pre></td></tr> 17097330f729Sjoerg 17107330f729Sjoerg 17117330f729Sjoerg<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> 17127330f729Sjoerg<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. 17137330f729Sjoerg 17147330f729SjoergExample matches x in if (x) 17157330f729Sjoerg bool x; 17167330f729Sjoerg if (x) {} 17177330f729Sjoerg</pre></td></tr> 17187330f729Sjoerg 17197330f729Sjoerg 17207330f729Sjoerg<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> 17217330f729Sjoerg<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. 17227330f729Sjoerg 17237330f729SjoergGiven 17247330f729Sjoerg int a; 17257330f729SjoergdeclStmt() 17267330f729Sjoerg matches 'int a'. 17277330f729Sjoerg</pre></td></tr> 17287330f729Sjoerg 17297330f729Sjoerg 17307330f729Sjoerg<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> 17317330f729Sjoerg<tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. 17327330f729Sjoerg 17337330f729SjoergGiven 17347330f729Sjoerg switch(a) { case 42: break; default: break; } 17357330f729SjoergdefaultStmt() 17367330f729Sjoerg matches 'default:'. 17377330f729Sjoerg</pre></td></tr> 17387330f729Sjoerg 17397330f729Sjoerg 1740*e038c9c4Sjoerg<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> 1741*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="dependentCoawaitExpr0"><pre>Matches co_await expressions where the type of the promise is dependent 1742*e038c9c4Sjoerg</pre></td></tr> 1743*e038c9c4Sjoerg 1744*e038c9c4Sjoerg 17457330f729Sjoerg<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> 17467330f729Sjoerg<tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8]. 17477330f729Sjoerg 17487330f729SjoergExample: Matches { [2].y = 1.0, [0].x = 1.0 } 17497330f729Sjoerg point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; 17507330f729Sjoerg</pre></td></tr> 17517330f729Sjoerg 17527330f729Sjoerg 17537330f729Sjoerg<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> 17547330f729Sjoerg<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. 17557330f729Sjoerg 17567330f729SjoergGiven 17577330f729Sjoerg do {} while (true); 17587330f729SjoergdoStmt() 17597330f729Sjoerg matches 'do {} while(true)' 17607330f729Sjoerg</pre></td></tr> 17617330f729Sjoerg 17627330f729Sjoerg 17637330f729Sjoerg<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> 17647330f729Sjoerg<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. 17657330f729Sjoerg 17667330f729SjoergMatches any cast expression written in user code, whether it be a 17677330f729SjoergC-style cast, a functional-style cast, or a keyword cast. 17687330f729Sjoerg 17697330f729SjoergDoes not match implicit conversions. 17707330f729Sjoerg 17717330f729SjoergNote: the name "explicitCast" is chosen to match Clang's terminology, as 17727330f729SjoergClang uses the term "cast" to apply to implicit conversions as well as to 17737330f729Sjoergactual cast expressions. 17747330f729Sjoerg 17757330f729SjoergSee also: hasDestinationType. 17767330f729Sjoerg 17777330f729SjoergExample: matches all five of the casts in 17787330f729Sjoerg int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) 17797330f729Sjoergbut does not match the implicit conversion in 17807330f729Sjoerg long ell = 42; 17817330f729Sjoerg</pre></td></tr> 17827330f729Sjoerg 17837330f729Sjoerg 17847330f729Sjoerg<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> 17857330f729Sjoerg<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. 17867330f729Sjoerg 17877330f729SjoergExample matches x() 17887330f729Sjoerg void f() { x(); } 17897330f729Sjoerg</pre></td></tr> 17907330f729Sjoerg 17917330f729Sjoerg 17927330f729Sjoerg<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> 17937330f729Sjoerg<tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end 17947330f729Sjoergof the sub-expression's evaluation. 17957330f729Sjoerg 17967330f729SjoergExample matches std::string() 17977330f729Sjoerg const std::string str = std::string(); 17987330f729Sjoerg</pre></td></tr> 17997330f729Sjoerg 18007330f729Sjoerg 1801*e038c9c4Sjoerg<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> 1802*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="fixedPointLiteral0"><pre>Matches fixed point literals 1803*e038c9c4Sjoerg</pre></td></tr> 1804*e038c9c4Sjoerg 1805*e038c9c4Sjoerg 18067330f729Sjoerg<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> 18077330f729Sjoerg<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g. 18087330f729Sjoerg1.0, 1.0f, 1.0L and 1e10. 18097330f729Sjoerg 18107330f729SjoergDoes not match implicit conversions such as 18117330f729Sjoerg float a = 10; 18127330f729Sjoerg</pre></td></tr> 18137330f729Sjoerg 18147330f729Sjoerg 18157330f729Sjoerg<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> 18167330f729Sjoerg<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. 18177330f729Sjoerg 18187330f729SjoergExample matches 'for (;;) {}' 18197330f729Sjoerg for (;;) {} 18207330f729Sjoerg int i[] = {1, 2, 3}; for (auto a : i); 18217330f729Sjoerg</pre></td></tr> 18227330f729Sjoerg 18237330f729Sjoerg 1824*e038c9c4Sjoerg<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> 1825*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="genericSelectionExpr0"><pre>Matches C11 _Generic expression. 1826*e038c9c4Sjoerg</pre></td></tr> 1827*e038c9c4Sjoerg 1828*e038c9c4Sjoerg 18297330f729Sjoerg<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> 18307330f729Sjoerg<tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. 18317330f729Sjoerg</pre></td></tr> 18327330f729Sjoerg 18337330f729Sjoerg 18347330f729Sjoerg<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> 18357330f729Sjoerg<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. 18367330f729Sjoerg 18377330f729SjoergGiven 18387330f729Sjoerg goto FOO; 18397330f729Sjoerg FOO: bar(); 18407330f729SjoerggotoStmt() 18417330f729Sjoerg matches 'goto FOO' 18427330f729Sjoerg</pre></td></tr> 18437330f729Sjoerg 18447330f729Sjoerg 18457330f729Sjoerg<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> 18467330f729Sjoerg<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. 18477330f729Sjoerg 18487330f729SjoergExample matches 'if (x) {}' 18497330f729Sjoerg if (x) {} 18507330f729Sjoerg</pre></td></tr> 18517330f729Sjoerg 18527330f729Sjoerg 18537330f729Sjoerg<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> 18547330f729Sjoerg<tr><td colspan="4" class="doc" id="imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating 18557330f729Sjoergpoint literals e.g.: 1i, 1.0i 18567330f729Sjoerg</pre></td></tr> 18577330f729Sjoerg 18587330f729Sjoerg 18597330f729Sjoerg<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> 18607330f729Sjoerg<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. 18617330f729Sjoerg 18627330f729SjoergThis matches many different places, including function call return value 18637330f729Sjoergeliding, as well as any type conversions. 18647330f729Sjoerg</pre></td></tr> 18657330f729Sjoerg 18667330f729Sjoerg 18677330f729Sjoerg<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> 18687330f729Sjoerg<tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions. 18697330f729Sjoerg 18707330f729SjoergGiven 18717330f729Sjoerg point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; 18727330f729SjoergimplicitValueInitExpr() 18737330f729Sjoerg matches "[0].y" (implicitly) 18747330f729Sjoerg</pre></td></tr> 18757330f729Sjoerg 18767330f729Sjoerg 18777330f729Sjoerg<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> 18787330f729Sjoerg<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. 18797330f729Sjoerg 18807330f729SjoergGiven 18817330f729Sjoerg int a[] = { 1, 2 }; 18827330f729Sjoerg struct B { int x, y; }; 18837330f729Sjoerg B b = { 5, 6 }; 18847330f729SjoerginitListExpr() 18857330f729Sjoerg matches "{ 1, 2 }" and "{ 5, 6 }" 18867330f729Sjoerg</pre></td></tr> 18877330f729Sjoerg 18887330f729Sjoerg 18897330f729Sjoerg<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> 18907330f729Sjoerg<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g. 18917330f729Sjoerg1, 1L, 0x1 and 1U. 18927330f729Sjoerg 18937330f729SjoergDoes not match character-encoded integers such as L'a'. 18947330f729Sjoerg</pre></td></tr> 18957330f729Sjoerg 18967330f729Sjoerg 18977330f729Sjoerg<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> 18987330f729Sjoerg<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. 18997330f729Sjoerg 19007330f729SjoergGiven 19017330f729Sjoerg goto FOO; 19027330f729Sjoerg FOO: bar(); 19037330f729SjoerglabelStmt() 19047330f729Sjoerg matches 'FOO:' 19057330f729Sjoerg</pre></td></tr> 19067330f729Sjoerg 19077330f729Sjoerg 19087330f729Sjoerg<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> 19097330f729Sjoerg<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. 19107330f729Sjoerg 19117330f729SjoergExample matches [&](){return 5;} 19127330f729Sjoerg [&](){return 5;} 19137330f729Sjoerg</pre></td></tr> 19147330f729Sjoerg 19157330f729Sjoerg 19167330f729Sjoerg<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> 19177330f729Sjoerg<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. 19187330f729Sjoerg 19197330f729SjoergExample: Given 19207330f729Sjoerg struct T {void func();}; 19217330f729Sjoerg T f(); 19227330f729Sjoerg void g(T); 19237330f729SjoergmaterializeTemporaryExpr() matches 'f()' in these statements 19247330f729Sjoerg T u(f()); 19257330f729Sjoerg g(f()); 19267330f729Sjoerg f().func(); 19277330f729Sjoergbut does not match 19287330f729Sjoerg f(); 19297330f729Sjoerg</pre></td></tr> 19307330f729Sjoerg 19317330f729Sjoerg 19327330f729Sjoerg<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> 19337330f729Sjoerg<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. 19347330f729Sjoerg 19357330f729SjoergGiven 19367330f729Sjoerg class Y { 19377330f729Sjoerg void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 19387330f729Sjoerg int a; static int b; 19397330f729Sjoerg }; 19407330f729SjoergmemberExpr() 19417330f729Sjoerg matches this->x, x, y.x, a, this->b 19427330f729Sjoerg</pre></td></tr> 19437330f729Sjoerg 19447330f729Sjoerg 19457330f729Sjoerg<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> 19467330f729Sjoerg<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. 19477330f729Sjoerg 19487330f729Sjoerg foo();; 19497330f729SjoergnullStmt() 19507330f729Sjoerg matches the second ';' 19517330f729Sjoerg</pre></td></tr> 19527330f729Sjoerg 19537330f729Sjoerg 19547330f729Sjoerg<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> 19557330f729Sjoerg<tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements. 19567330f729Sjoerg 19577330f729SjoergExample matches @catch 19587330f729Sjoerg @try {} 19597330f729Sjoerg @catch (...) {} 19607330f729Sjoerg</pre></td></tr> 19617330f729Sjoerg 19627330f729Sjoerg 19637330f729Sjoerg<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> 19647330f729Sjoerg<tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements. 19657330f729Sjoerg 19667330f729SjoergExample matches @finally 19677330f729Sjoerg @try {} 19687330f729Sjoerg @finally {} 19697330f729Sjoerg</pre></td></tr> 19707330f729Sjoerg 19717330f729Sjoerg 19727330f729Sjoerg<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> 19737330f729Sjoerg<tr><td colspan="4" class="doc" id="objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar. 19747330f729Sjoerg 19757330f729SjoergExample: matches "a" in "init" method: 19767330f729Sjoerg@implementation A { 19777330f729Sjoerg NSString *a; 19787330f729Sjoerg} 19797330f729Sjoerg- (void) init { 19807330f729Sjoerg a = @"hello"; 19817330f729Sjoerg} 19827330f729Sjoerg</pre></td></tr> 19837330f729Sjoerg 19847330f729Sjoerg 19857330f729Sjoerg<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> 19867330f729Sjoerg<tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions. 19877330f729Sjoerg 19887330f729SjoergThe innermost message send invokes the "alloc" class method on the 19897330f729SjoergNSString class, while the outermost message send invokes the 19907330f729Sjoerg"initWithString" instance method on the object returned from 19917330f729SjoergNSString's "alloc". This matcher should match both message sends. 19927330f729Sjoerg [[NSString alloc] initWithString:@"Hello"] 19937330f729Sjoerg</pre></td></tr> 19947330f729Sjoerg 19957330f729Sjoerg 19967330f729Sjoerg<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> 19977330f729Sjoerg<tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements. 19987330f729Sjoerg 19997330f729SjoergExample matches @throw obj; 20007330f729Sjoerg</pre></td></tr> 20017330f729Sjoerg 20027330f729Sjoerg 20037330f729Sjoerg<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> 20047330f729Sjoerg<tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements. 20057330f729Sjoerg 20067330f729SjoergExample matches @try 20077330f729Sjoerg @try {} 20087330f729Sjoerg @catch (...) {} 20097330f729Sjoerg</pre></td></tr> 20107330f729Sjoerg 20117330f729Sjoerg 20127330f729Sjoerg<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> 20137330f729Sjoerg<tr><td colspan="4" class="doc" id="ompExecutableDirective0"><pre>Matches any ``#pragma omp`` executable directive. 20147330f729Sjoerg 20157330f729SjoergGiven 20167330f729Sjoerg 20177330f729Sjoerg #pragma omp parallel 20187330f729Sjoerg #pragma omp parallel default(none) 20197330f729Sjoerg #pragma omp taskyield 20207330f729Sjoerg 20217330f729Sjoerg``ompExecutableDirective()`` matches ``omp parallel``, 20227330f729Sjoerg``omp parallel default(none)`` and ``omp taskyield``. 20237330f729Sjoerg</pre></td></tr> 20247330f729Sjoerg 20257330f729Sjoerg 20267330f729Sjoerg<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> 20277330f729Sjoerg<tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers 20287330f729Sjoergto reference another expressions and can be met 20297330f729Sjoergin BinaryConditionalOperators, for example. 20307330f729Sjoerg 20317330f729SjoergExample matches 'a' 20327330f729Sjoerg (a ?: c) + 42; 20337330f729Sjoerg</pre></td></tr> 20347330f729Sjoerg 20357330f729Sjoerg 20367330f729Sjoerg<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> 20377330f729Sjoerg<tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions. 20387330f729Sjoerg 20397330f729SjoergExample matches (foo() + 1) 20407330f729Sjoerg int foo() { return 1; } 20417330f729Sjoerg int a = (foo() + 1); 20427330f729Sjoerg</pre></td></tr> 20437330f729Sjoerg 20447330f729Sjoerg 20457330f729Sjoerg<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> 20467330f729Sjoerg<tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions. 20477330f729SjoergParenListExprs don't have a predefined type and are used for late parsing. 20487330f729SjoergIn the final AST, they can be met in template declarations. 20497330f729Sjoerg 20507330f729SjoergGiven 20517330f729Sjoerg template<typename T> class X { 20527330f729Sjoerg void f() { 20537330f729Sjoerg X x(*this); 20547330f729Sjoerg int a = 0, b = 1; int i = (a, b); 20557330f729Sjoerg } 20567330f729Sjoerg }; 20577330f729SjoergparenListExpr() matches "*this" but NOT matches (a, b) because (a, b) 20587330f729Sjoerghas a predefined type and is a ParenExpr, not a ParenListExpr. 20597330f729Sjoerg</pre></td></tr> 20607330f729Sjoerg 20617330f729Sjoerg 20627330f729Sjoerg<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> 20637330f729Sjoerg<tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2]. 20647330f729Sjoerg 20657330f729SjoergExample: Matches __func__ 20667330f729Sjoerg printf("%s", __func__); 20677330f729Sjoerg</pre></td></tr> 20687330f729Sjoerg 20697330f729Sjoerg 20707330f729Sjoerg<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> 20717330f729Sjoerg<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. 20727330f729Sjoerg 20737330f729SjoergGiven 20747330f729Sjoerg return 1; 20757330f729SjoergreturnStmt() 20767330f729Sjoerg matches 'return 1' 20777330f729Sjoerg</pre></td></tr> 20787330f729Sjoerg 20797330f729Sjoerg 20807330f729Sjoerg<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> 20817330f729Sjoerg<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. 20827330f729Sjoerg 20837330f729SjoergGiven 20847330f729Sjoerg { ++a; } 20857330f729Sjoergstmt() 20867330f729Sjoerg matches both the compound statement '{ ++a; }' and '++a'. 20877330f729Sjoerg</pre></td></tr> 20887330f729Sjoerg 20897330f729Sjoerg 20907330f729Sjoerg<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> 20917330f729Sjoerg<tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension). 20927330f729Sjoerg 20937330f729SjoergExample match: ({ int X = 4; X; }) 20947330f729Sjoerg int C = ({ int X = 4; X; }); 20957330f729Sjoerg</pre></td></tr> 20967330f729Sjoerg 20977330f729Sjoerg 20987330f729Sjoerg<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> 20997330f729Sjoerg<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). 21007330f729Sjoerg 21017330f729SjoergExample matches "abcd", L"abcd" 21027330f729Sjoerg char *s = "abcd"; 21037330f729Sjoerg wchar_t *ws = L"abcd"; 21047330f729Sjoerg</pre></td></tr> 21057330f729Sjoerg 21067330f729Sjoerg 21077330f729Sjoerg<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> 21087330f729Sjoerg<tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. 21097330f729Sjoerg 21107330f729SjoergGiven 21117330f729Sjoerg template <int N> 21127330f729Sjoerg struct A { static const int n = N; }; 21137330f729Sjoerg struct B : public A<42> {}; 21147330f729SjoergsubstNonTypeTemplateParmExpr() 21157330f729Sjoerg matches "N" in the right-hand side of "static const int n = N;" 21167330f729Sjoerg</pre></td></tr> 21177330f729Sjoerg 21187330f729Sjoerg 21197330f729Sjoerg<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> 21207330f729Sjoerg<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. 21217330f729Sjoerg 21227330f729SjoergGiven 21237330f729Sjoerg switch(a) { case 42: break; default: break; } 21247330f729SjoergswitchCase() 21257330f729Sjoerg matches 'case 42:' and 'default:'. 21267330f729Sjoerg</pre></td></tr> 21277330f729Sjoerg 21287330f729Sjoerg 21297330f729Sjoerg<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> 21307330f729Sjoerg<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. 21317330f729Sjoerg 21327330f729SjoergGiven 21337330f729Sjoerg switch(a) { case 42: break; default: break; } 21347330f729SjoergswitchStmt() 21357330f729Sjoerg matches 'switch(a)'. 21367330f729Sjoerg</pre></td></tr> 21377330f729Sjoerg 21387330f729Sjoerg 21397330f729Sjoerg<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> 21407330f729Sjoerg<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) 21417330f729Sjoerg 21427330f729SjoergGiven 21437330f729Sjoerg Foo x = bar; 21447330f729Sjoerg int y = sizeof(x) + alignof(x); 21457330f729SjoergunaryExprOrTypeTraitExpr() 21467330f729Sjoerg matches sizeof(x) and alignof(x) 21477330f729Sjoerg</pre></td></tr> 21487330f729Sjoerg 21497330f729Sjoerg 21507330f729Sjoerg<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> 21517330f729Sjoerg<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. 21527330f729Sjoerg 21537330f729SjoergExample matches !a 21547330f729Sjoerg !a || b 21557330f729Sjoerg</pre></td></tr> 21567330f729Sjoerg 21577330f729Sjoerg 21587330f729Sjoerg<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> 21597330f729Sjoerg<tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing 21607330f729Sjoergbut could not be resolved to a specific declaration. 21617330f729Sjoerg 21627330f729SjoergGiven 21637330f729Sjoerg template<typename T> 21647330f729Sjoerg T foo() { T a; return a; } 21657330f729Sjoerg template<typename T> 21667330f729Sjoerg void bar() { 21677330f729Sjoerg foo<T>(); 21687330f729Sjoerg } 21697330f729SjoergunresolvedLookupExpr() 21707330f729Sjoerg matches foo<T>() </pre></td></tr> 21717330f729Sjoerg 21727330f729Sjoerg 21737330f729Sjoerg<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> 21747330f729Sjoerg<tr><td colspan="4" class="doc" id="unresolvedMemberExpr0"><pre>Matches unresolved member expressions. 21757330f729Sjoerg 21767330f729SjoergGiven 21777330f729Sjoerg struct X { 21787330f729Sjoerg template <class T> void f(); 21797330f729Sjoerg void g(); 21807330f729Sjoerg }; 21817330f729Sjoerg template <class T> void h() { X x; x.f<T>(); x.g(); } 21827330f729SjoergunresolvedMemberExpr() 21837330f729Sjoerg matches x.f<T> 21847330f729Sjoerg</pre></td></tr> 21857330f729Sjoerg 21867330f729Sjoerg 21877330f729Sjoerg<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> 21887330f729Sjoerg<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. 21897330f729Sjoerg 21907330f729SjoergExample match: "foo"_suffix 21917330f729Sjoerg</pre></td></tr> 21927330f729Sjoerg 21937330f729Sjoerg 21947330f729Sjoerg<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> 21957330f729Sjoerg<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. 21967330f729Sjoerg 21977330f729SjoergGiven 21987330f729Sjoerg while (true) {} 21997330f729SjoergwhileStmt() 22007330f729Sjoerg matches 'while (true) {}'. 22017330f729Sjoerg</pre></td></tr> 22027330f729Sjoerg 22037330f729Sjoerg 2204*e038c9c4Sjoerg<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> 2205*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="templateArgumentLoc0"><pre>Matches template arguments (with location info). 2206*e038c9c4Sjoerg 2207*e038c9c4SjoergGiven 2208*e038c9c4Sjoerg template <typename T> struct C {}; 2209*e038c9c4Sjoerg C<int> c; 2210*e038c9c4SjoergtemplateArgumentLoc() 2211*e038c9c4Sjoerg matches 'int' in C<int>. 2212*e038c9c4Sjoerg</pre></td></tr> 2213*e038c9c4Sjoerg 2214*e038c9c4Sjoerg 22157330f729Sjoerg<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> 22167330f729Sjoerg<tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. 22177330f729Sjoerg 22187330f729SjoergGiven 22197330f729Sjoerg template <typename T> struct C {}; 22207330f729Sjoerg C<int> c; 22217330f729SjoergtemplateArgument() 22227330f729Sjoerg matches 'int' in C<int>. 22237330f729Sjoerg</pre></td></tr> 22247330f729Sjoerg 22257330f729Sjoerg 22267330f729Sjoerg<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> 22277330f729Sjoerg<tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name. 22287330f729Sjoerg 22297330f729SjoergGiven 22307330f729Sjoerg template <typename T> class X { }; 22317330f729Sjoerg X<int> xi; 22327330f729SjoergtemplateName() 22337330f729Sjoerg matches 'X' in X<int>. 22347330f729Sjoerg</pre></td></tr> 22357330f729Sjoerg 22367330f729Sjoerg 22377330f729Sjoerg<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> 22387330f729Sjoerg<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. 22397330f729Sjoerg</pre></td></tr> 22407330f729Sjoerg 22417330f729Sjoerg 22427330f729Sjoerg<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> 22437330f729Sjoerg<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. 22447330f729Sjoerg 22457330f729SjoergGiven 22467330f729Sjoerg int a[] = { 2, 3 }; 22477330f729Sjoerg int b[4]; 22487330f729Sjoerg void f() { int c[a[0]]; } 22497330f729SjoergarrayType() 22507330f729Sjoerg matches "int a[]", "int b[4]" and "int c[a[0]]"; 22517330f729Sjoerg</pre></td></tr> 22527330f729Sjoerg 22537330f729Sjoerg 22547330f729Sjoerg<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> 22557330f729Sjoerg<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. 22567330f729Sjoerg 22577330f729SjoergGiven 22587330f729Sjoerg _Atomic(int) i; 22597330f729SjoergatomicType() 22607330f729Sjoerg matches "_Atomic(int) i" 22617330f729Sjoerg</pre></td></tr> 22627330f729Sjoerg 22637330f729Sjoerg 22647330f729Sjoerg<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> 22657330f729Sjoerg<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. 22667330f729Sjoerg 22677330f729SjoergGiven: 22687330f729Sjoerg auto n = 4; 22697330f729Sjoerg int v[] = { 2, 3 } 22707330f729Sjoerg for (auto i : v) { } 22717330f729SjoergautoType() 22727330f729Sjoerg matches "auto n" and "auto i" 22737330f729Sjoerg</pre></td></tr> 22747330f729Sjoerg 22757330f729Sjoerg 22767330f729Sjoerg<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> 22777330f729Sjoerg<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as 22787330f729Sjoerg"void (^)(int)". 22797330f729Sjoerg 22807330f729SjoergThe pointee is always required to be a FunctionType. 22817330f729Sjoerg</pre></td></tr> 22827330f729Sjoerg 22837330f729Sjoerg 22847330f729Sjoerg<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> 22857330f729Sjoerg<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. 22867330f729Sjoerg 22877330f729SjoergGiven 22887330f729Sjoerg struct A {}; 22897330f729Sjoerg A a; 22907330f729Sjoerg int b; 22917330f729Sjoerg float c; 22927330f729Sjoerg bool d; 22937330f729SjoergbuiltinType() 22947330f729Sjoerg matches "int b", "float c" and "bool d" 22957330f729Sjoerg</pre></td></tr> 22967330f729Sjoerg 22977330f729Sjoerg 22987330f729Sjoerg<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> 22997330f729Sjoerg<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. 23007330f729Sjoerg 23017330f729SjoergGiven 23027330f729Sjoerg _Complex float f; 23037330f729SjoergcomplexType() 23047330f729Sjoerg matches "_Complex float f" 23057330f729Sjoerg</pre></td></tr> 23067330f729Sjoerg 23077330f729Sjoerg 23087330f729Sjoerg<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> 23097330f729Sjoerg<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. 23107330f729Sjoerg 23117330f729SjoergGiven 23127330f729Sjoerg void() { 23137330f729Sjoerg int a[2]; 23147330f729Sjoerg int b[] = { 2, 3 }; 23157330f729Sjoerg int c[b[0]]; 23167330f729Sjoerg } 23177330f729SjoergconstantArrayType() 23187330f729Sjoerg matches "int a[2]" 23197330f729Sjoerg</pre></td></tr> 23207330f729Sjoerg 23217330f729Sjoerg 23227330f729Sjoerg<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> 23237330f729Sjoerg<tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type 23247330f729SjoergExample matches i[] in declaration of f. 23257330f729Sjoerg (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) 23267330f729SjoergExample matches i[1]. 23277330f729Sjoerg (matcher = expr(hasType(decayedType(hasDecayedType(pointerType()))))) 23287330f729Sjoerg void f(int i[]) { 23297330f729Sjoerg i[1] = 0; 23307330f729Sjoerg } 23317330f729Sjoerg</pre></td></tr> 23327330f729Sjoerg 23337330f729Sjoerg 23347330f729Sjoerg<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> 23357330f729Sjoerg<tr><td colspan="4" class="doc" id="decltypeType0"><pre>Matches types nodes representing C++11 decltype(<expr>) types. 23367330f729Sjoerg 23377330f729SjoergGiven: 23387330f729Sjoerg short i = 1; 23397330f729Sjoerg int j = 42; 23407330f729Sjoerg decltype(i + j) result = i + j; 23417330f729SjoergdecltypeType() 23427330f729Sjoerg matches "decltype(i + j)" 23437330f729Sjoerg</pre></td></tr> 23447330f729Sjoerg 23457330f729Sjoerg 2346*e038c9c4Sjoerg<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> 2347*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="deducedTemplateSpecializationType0"><pre>Matches C++17 deduced template specialization types, e.g. deduced class 2348*e038c9c4Sjoergtemplate types. 2349*e038c9c4Sjoerg 2350*e038c9c4SjoergGiven 2351*e038c9c4Sjoerg template <typename T> 2352*e038c9c4Sjoerg class C { public: C(T); }; 2353*e038c9c4Sjoerg 2354*e038c9c4Sjoerg C c(123); 2355*e038c9c4SjoergdeducedTemplateSpecializationType() matches the type in the declaration 2356*e038c9c4Sjoergof the variable c. 2357*e038c9c4Sjoerg</pre></td></tr> 2358*e038c9c4Sjoerg 2359*e038c9c4Sjoerg 23607330f729Sjoerg<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> 23617330f729Sjoerg<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. 23627330f729Sjoerg 23637330f729SjoergGiven 23647330f729Sjoerg template<typename T, int Size> 23657330f729Sjoerg class array { 23667330f729Sjoerg T data[Size]; 23677330f729Sjoerg }; 23687330f729SjoergdependentSizedArrayType 23697330f729Sjoerg matches "T data[Size]" 23707330f729Sjoerg</pre></td></tr> 23717330f729Sjoerg 23727330f729Sjoerg 23737330f729Sjoerg<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> 23747330f729Sjoerg<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a 23757330f729Sjoergqualified name. 23767330f729Sjoerg 23777330f729SjoergGiven 23787330f729Sjoerg namespace N { 23797330f729Sjoerg namespace M { 23807330f729Sjoerg class D {}; 23817330f729Sjoerg } 23827330f729Sjoerg } 23837330f729Sjoerg class C {}; 23847330f729Sjoerg 23857330f729Sjoerg class C c; 23867330f729Sjoerg N::M::D d; 23877330f729Sjoerg 23887330f729SjoergelaboratedType() matches the type of the variable declarations of both 23897330f729Sjoergc and d. 23907330f729Sjoerg</pre></td></tr> 23917330f729Sjoerg 23927330f729Sjoerg 23937330f729Sjoerg<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> 23947330f729Sjoerg<tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types. 23957330f729Sjoerg 23967330f729SjoergGiven 23977330f729Sjoerg enum C { Green }; 23987330f729Sjoerg enum class S { Red }; 23997330f729Sjoerg 24007330f729Sjoerg C c; 24017330f729Sjoerg S s; 24027330f729Sjoerg 24037330f729SjoergenumType() matches the type of the variable declarations of both c and 24047330f729Sjoergs. 24057330f729Sjoerg</pre></td></tr> 24067330f729Sjoerg 24077330f729Sjoerg 24087330f729Sjoerg<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> 24097330f729Sjoerg<tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes. 24107330f729Sjoerg 24117330f729SjoergGiven 24127330f729Sjoerg int (*f)(int); 24137330f729Sjoerg void g(); 24147330f729SjoergfunctionProtoType() 24157330f729Sjoerg matches "int (*f)(int)" and the type of "g" in C++ mode. 24167330f729Sjoerg In C mode, "g" is not matched because it does not contain a prototype. 24177330f729Sjoerg</pre></td></tr> 24187330f729Sjoerg 24197330f729Sjoerg 24207330f729Sjoerg<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> 24217330f729Sjoerg<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. 24227330f729Sjoerg 24237330f729SjoergGiven 24247330f729Sjoerg int (*f)(int); 24257330f729Sjoerg void g(); 24267330f729SjoergfunctionType() 24277330f729Sjoerg matches "int (*f)(int)" and the type of "g". 24287330f729Sjoerg</pre></td></tr> 24297330f729Sjoerg 24307330f729Sjoerg 24317330f729Sjoerg<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> 24327330f729Sjoerg<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. 24337330f729Sjoerg 24347330f729SjoergGiven 24357330f729Sjoerg int a[] = { 2, 3 }; 24367330f729Sjoerg int b[42]; 24377330f729Sjoerg void f(int c[]) { int d[a[0]]; }; 24387330f729SjoergincompleteArrayType() 24397330f729Sjoerg matches "int a[]" and "int c[]" 24407330f729Sjoerg</pre></td></tr> 24417330f729Sjoerg 24427330f729Sjoerg 24437330f729Sjoerg<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> 24447330f729Sjoerg<tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types. 24457330f729Sjoerg 24467330f729SjoergExample matches S s, but not S<T> s. 24477330f729Sjoerg (matcher = parmVarDecl(hasType(injectedClassNameType()))) 24487330f729Sjoerg template <typename T> struct S { 24497330f729Sjoerg void f(S s); 24507330f729Sjoerg void g(S<T> s); 24517330f729Sjoerg }; 24527330f729Sjoerg</pre></td></tr> 24537330f729Sjoerg 24547330f729Sjoerg 24557330f729Sjoerg<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> 24567330f729Sjoerg<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. 24577330f729Sjoerg 24587330f729SjoergGiven: 24597330f729Sjoerg int *a; 24607330f729Sjoerg int &b = *a; 24617330f729Sjoerg int &&c = 1; 24627330f729Sjoerg auto &d = b; 24637330f729Sjoerg auto &&e = c; 24647330f729Sjoerg auto &&f = 2; 24657330f729Sjoerg int g = 5; 24667330f729Sjoerg 24677330f729SjoerglValueReferenceType() matches the types of b, d, and e. e is 24687330f729Sjoergmatched since the type is deduced as int& by reference collapsing rules. 24697330f729Sjoerg</pre></td></tr> 24707330f729Sjoerg 24717330f729Sjoerg 24727330f729Sjoerg<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> 24737330f729Sjoerg<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. 24747330f729SjoergGiven 24757330f729Sjoerg struct A { int i; } 24767330f729Sjoerg A::* ptr = A::i; 24777330f729SjoergmemberPointerType() 24787330f729Sjoerg matches "A::* ptr" 24797330f729Sjoerg</pre></td></tr> 24807330f729Sjoerg 24817330f729Sjoerg 24827330f729Sjoerg<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> 24837330f729Sjoerg<tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from 24847330f729Sjoerga pointer type, despite being syntactically similar. 24857330f729Sjoerg 24867330f729SjoergGiven 24877330f729Sjoerg int *a; 24887330f729Sjoerg 24897330f729Sjoerg @interface Foo 24907330f729Sjoerg @end 24917330f729Sjoerg Foo *f; 24927330f729SjoergpointerType() 24937330f729Sjoerg matches "Foo *f", but does not match "int *a". 24947330f729Sjoerg</pre></td></tr> 24957330f729Sjoerg 24967330f729Sjoerg 24977330f729Sjoerg<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> 24987330f729Sjoerg<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. 24997330f729Sjoerg 25007330f729SjoergGiven 25017330f729Sjoerg int (*ptr_to_array)[4]; 25027330f729Sjoerg int *array_of_ptrs[4]; 25037330f729Sjoerg 25047330f729SjoergvarDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not 25057330f729Sjoergarray_of_ptrs. 25067330f729Sjoerg</pre></td></tr> 25077330f729Sjoerg 25087330f729Sjoerg 25097330f729Sjoerg<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> 25107330f729Sjoerg<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer 25117330f729Sjoergtypes. 25127330f729Sjoerg 25137330f729SjoergGiven 25147330f729Sjoerg int *a; 25157330f729Sjoerg int &b = *a; 25167330f729Sjoerg int c = 5; 25177330f729Sjoerg 25187330f729Sjoerg @interface Foo 25197330f729Sjoerg @end 25207330f729Sjoerg Foo *f; 25217330f729SjoergpointerType() 25227330f729Sjoerg matches "int *a", but does not match "Foo *f". 25237330f729Sjoerg</pre></td></tr> 25247330f729Sjoerg 25257330f729Sjoerg 25267330f729Sjoerg<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> 25277330f729Sjoerg<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. 25287330f729Sjoerg 25297330f729SjoergGiven: 25307330f729Sjoerg int *a; 25317330f729Sjoerg int &b = *a; 25327330f729Sjoerg int &&c = 1; 25337330f729Sjoerg auto &d = b; 25347330f729Sjoerg auto &&e = c; 25357330f729Sjoerg auto &&f = 2; 25367330f729Sjoerg int g = 5; 25377330f729Sjoerg 25387330f729SjoergrValueReferenceType() matches the types of c and f. e is not 25397330f729Sjoergmatched as it is deduced to int& by reference collapsing rules. 25407330f729Sjoerg</pre></td></tr> 25417330f729Sjoerg 25427330f729Sjoerg 25437330f729Sjoerg<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> 25447330f729Sjoerg<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). 25457330f729Sjoerg 25467330f729SjoergGiven 25477330f729Sjoerg class C {}; 25487330f729Sjoerg struct S {}; 25497330f729Sjoerg 25507330f729Sjoerg C c; 25517330f729Sjoerg S s; 25527330f729Sjoerg 25537330f729SjoergrecordType() matches the type of the variable declarations of both c 25547330f729Sjoergand s. 25557330f729Sjoerg</pre></td></tr> 25567330f729Sjoerg 25577330f729Sjoerg 25587330f729Sjoerg<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> 25597330f729Sjoerg<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. 25607330f729Sjoerg 25617330f729SjoergGiven 25627330f729Sjoerg int *a; 25637330f729Sjoerg int &b = *a; 25647330f729Sjoerg int &&c = 1; 25657330f729Sjoerg auto &d = b; 25667330f729Sjoerg auto &&e = c; 25677330f729Sjoerg auto &&f = 2; 25687330f729Sjoerg int g = 5; 25697330f729Sjoerg 25707330f729SjoergreferenceType() matches the types of b, c, d, e, and f. 25717330f729Sjoerg</pre></td></tr> 25727330f729Sjoerg 25737330f729Sjoerg 25747330f729Sjoerg<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> 25757330f729Sjoerg<tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a 25767330f729Sjoergtemplate type parameter. 25777330f729Sjoerg 25787330f729SjoergGiven 25797330f729Sjoerg template <typename T> 25807330f729Sjoerg void F(T t) { 25817330f729Sjoerg int i = 1 + t; 25827330f729Sjoerg } 25837330f729Sjoerg 25847330f729SjoergsubstTemplateTypeParmType() matches the type of 't' but not '1' 25857330f729Sjoerg</pre></td></tr> 25867330f729Sjoerg 25877330f729Sjoerg 25887330f729Sjoerg<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> 25897330f729Sjoerg<tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types). 25907330f729Sjoerg 25917330f729SjoergGiven 25927330f729Sjoerg enum E {}; 25937330f729Sjoerg class C {}; 25947330f729Sjoerg 25957330f729Sjoerg E e; 25967330f729Sjoerg C c; 25977330f729Sjoerg 25987330f729SjoergtagType() matches the type of the variable declarations of both e 25997330f729Sjoergand c. 26007330f729Sjoerg</pre></td></tr> 26017330f729Sjoerg 26027330f729Sjoerg 26037330f729Sjoerg<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> 26047330f729Sjoerg<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. 26057330f729Sjoerg 26067330f729SjoergGiven 26077330f729Sjoerg template <typename T> 26087330f729Sjoerg class C { }; 26097330f729Sjoerg 26107330f729Sjoerg template class C<int>; // A 26117330f729Sjoerg C<char> var; // B 26127330f729Sjoerg 26137330f729SjoergtemplateSpecializationType() matches the type of the explicit 26147330f729Sjoerginstantiation in A and the type of the variable declaration in B. 26157330f729Sjoerg</pre></td></tr> 26167330f729Sjoerg 26177330f729Sjoerg 26187330f729Sjoerg<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> 26197330f729Sjoerg<tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types. 26207330f729Sjoerg 26217330f729SjoergExample matches T, but not int. 26227330f729Sjoerg (matcher = templateTypeParmType()) 26237330f729Sjoerg template <typename T> void f(int i); 26247330f729Sjoerg</pre></td></tr> 26257330f729Sjoerg 26267330f729Sjoerg 26277330f729Sjoerg<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> 26287330f729Sjoerg<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. 26297330f729Sjoerg</pre></td></tr> 26307330f729Sjoerg 26317330f729Sjoerg 26327330f729Sjoerg<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> 26337330f729Sjoerg<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. 26347330f729Sjoerg 26357330f729SjoergGiven 26367330f729Sjoerg typedef int X; 26377330f729SjoergtypedefType() 26387330f729Sjoerg matches "typedef int X" 26397330f729Sjoerg</pre></td></tr> 26407330f729Sjoerg 26417330f729Sjoerg 26427330f729Sjoerg<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> 26437330f729Sjoerg<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. 26447330f729Sjoerg 26457330f729SjoergGiven: 26467330f729Sjoerg typedef __underlying_type(T) type; 26477330f729SjoergunaryTransformType() 26487330f729Sjoerg matches "__underlying_type(T)" 26497330f729Sjoerg</pre></td></tr> 26507330f729Sjoerg 26517330f729Sjoerg 26527330f729Sjoerg<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> 26537330f729Sjoerg<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an 26547330f729Sjoerginteger-constant-expression. 26557330f729Sjoerg 26567330f729SjoergGiven 26577330f729Sjoerg void f() { 26587330f729Sjoerg int a[] = { 2, 3 } 26597330f729Sjoerg int b[42]; 26607330f729Sjoerg int c[a[0]]; 26617330f729Sjoerg } 26627330f729SjoergvariableArrayType() 26637330f729Sjoerg matches "int c[a[0]]" 26647330f729Sjoerg</pre></td></tr> 26657330f729Sjoerg 26667330f729Sjoerg<!--END_DECL_MATCHERS --> 26677330f729Sjoerg</table> 26687330f729Sjoerg 26697330f729Sjoerg<!-- ======================================================================= --> 26707330f729Sjoerg<h2 id="narrowing-matchers">Narrowing Matchers</h2> 26717330f729Sjoerg<!-- ======================================================================= --> 26727330f729Sjoerg 26737330f729Sjoerg<p>Narrowing matchers match certain attributes on the current node, thus 26747330f729Sjoergnarrowing down the set of nodes of the current type to match on.</p> 26757330f729Sjoerg 26767330f729Sjoerg<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) 26777330f729Sjoergwhich allow users to create more powerful match expressions.</p> 26787330f729Sjoerg 26797330f729Sjoerg<table> 26807330f729Sjoerg<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 26817330f729Sjoerg<!-- START_NARROWING_MATCHERS --> 26827330f729Sjoerg 26837330f729Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 26847330f729Sjoerg<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. 26857330f729Sjoerg 26867330f729SjoergUsable as: Any Matcher 26877330f729Sjoerg</pre></td></tr> 26887330f729Sjoerg 26897330f729Sjoerg 26907330f729Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 26917330f729Sjoerg<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. 26927330f729Sjoerg 26937330f729SjoergUsable as: Any Matcher 26947330f729Sjoerg</pre></td></tr> 26957330f729Sjoerg 26967330f729Sjoerg 26977330f729Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> 26987330f729Sjoerg<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. 26997330f729Sjoerg 27007330f729SjoergUseful when another matcher requires a child matcher, but there's no 27017330f729Sjoergadditional constraint. This will often be used with an explicit conversion 27027330f729Sjoergto an internal::Matcher<> type such as TypeMatcher. 27037330f729Sjoerg 27047330f729SjoergExample: DeclarationMatcher(anything()) matches all declarations, e.g., 27057330f729Sjoerg"int* p" and "void f()" in 27067330f729Sjoerg int* p; 27077330f729Sjoerg void f(); 27087330f729Sjoerg 27097330f729SjoergUsable as: Any Matcher 27107330f729Sjoerg</pre></td></tr> 27117330f729Sjoerg 27127330f729Sjoerg 2713*e038c9c4Sjoerg<tr><td><em>unspecified</em></td><td class="name" onclick="toggle('mapAnyOf0')"><a name="mapAnyOf0Anchor">mapAnyOf</a></td><td>nodeMatcherFunction...</td></tr> 2714*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="mapAnyOf0"><pre>Matches any of the NodeMatchers with InnerMatchers nested within 2715*e038c9c4Sjoerg 2716*e038c9c4SjoergGiven 2717*e038c9c4Sjoerg if (true); 2718*e038c9c4Sjoerg for (; true; ); 2719*e038c9c4Sjoergwith the matcher 2720*e038c9c4Sjoerg mapAnyOf(ifStmt, forStmt).with( 2721*e038c9c4Sjoerg hasCondition(cxxBoolLiteralExpr(equals(true))) 2722*e038c9c4Sjoerg ).bind("trueCond") 2723*e038c9c4Sjoergmatches the if and the for. It is equivalent to: 2724*e038c9c4Sjoerg auto trueCond = hasCondition(cxxBoolLiteralExpr(equals(true))); 2725*e038c9c4Sjoerg anyOf( 2726*e038c9c4Sjoerg ifStmt(trueCond).bind("trueCond"), 2727*e038c9c4Sjoerg forStmt(trueCond).bind("trueCond") 2728*e038c9c4Sjoerg ); 2729*e038c9c4Sjoerg 2730*e038c9c4SjoergThe with() chain-call accepts zero or more matchers which are combined 2731*e038c9c4Sjoergas-if with allOf() in each of the node matchers. 2732*e038c9c4SjoergUsable as: Any Matcher 2733*e038c9c4Sjoerg</pre></td></tr> 2734*e038c9c4Sjoerg 2735*e038c9c4Sjoerg 27367330f729Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> 27377330f729Sjoerg<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. 27387330f729Sjoerg 27397330f729SjoergExample matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) 27407330f729Sjoerg class X {}; 27417330f729Sjoerg class Y {}; 27427330f729Sjoerg 27437330f729SjoergUsable as: Any Matcher 27447330f729Sjoerg</pre></td></tr> 27457330f729Sjoerg 27467330f729Sjoerg 2747*e038c9c4Sjoerg<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> 2748*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyOperatorName0"><pre>Matches operator expressions (binary or unary) that have any of the 2749*e038c9c4Sjoergspecified names. 2750*e038c9c4Sjoerg 2751*e038c9c4Sjoerg hasAnyOperatorName("+", "-") 2752*e038c9c4Sjoerg Is equivalent to 2753*e038c9c4Sjoerg anyOf(hasOperatorName("+"), hasOperatorName("-")) 2754*e038c9c4Sjoerg</pre></td></tr> 2755*e038c9c4Sjoerg 2756*e038c9c4Sjoerg 27577330f729Sjoerg<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> 27587330f729Sjoerg<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or 27597330f729Sjoergunary). 27607330f729Sjoerg 27617330f729SjoergExample matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 27627330f729Sjoerg !(a || b) 27637330f729Sjoerg</pre></td></tr> 27647330f729Sjoerg 27657330f729Sjoerg 27667330f729Sjoerg<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> 27677330f729Sjoerg<tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators. 27687330f729Sjoerg 27697330f729SjoergExample 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) 27707330f729Sjoerg if (a == b) 27717330f729Sjoerg a += b; 27727330f729Sjoerg 27737330f729SjoergExample 2: matches s1 = s2 27747330f729Sjoerg (matcher = cxxOperatorCallExpr(isAssignmentOperator())) 27757330f729Sjoerg struct S { S& operator=(const S&); }; 2776*e038c9c4Sjoerg void x() { S s1, s2; s1 = s2; } 2777*e038c9c4Sjoerg</pre></td></tr> 2778*e038c9c4Sjoerg 2779*e038c9c4Sjoerg 2780*e038c9c4Sjoerg<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> 2781*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isComparisonOperator0"><pre>Matches comparison operators. 2782*e038c9c4Sjoerg 2783*e038c9c4SjoergExample 1: matches a == b (matcher = binaryOperator(isComparisonOperator())) 2784*e038c9c4Sjoerg if (a == b) 2785*e038c9c4Sjoerg a += b; 2786*e038c9c4Sjoerg 2787*e038c9c4SjoergExample 2: matches s1 < s2 2788*e038c9c4Sjoerg (matcher = cxxOperatorCallExpr(isComparisonOperator())) 2789*e038c9c4Sjoerg struct S { bool operator<(const S& other); }; 2790*e038c9c4Sjoerg void x(S s1, S s2) { bool b1 = s1 < s2; } 2791*e038c9c4Sjoerg</pre></td></tr> 2792*e038c9c4Sjoerg 2793*e038c9c4Sjoerg 2794*e038c9c4Sjoerg<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> 2795*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isPrivate1"><pre>Matches private C++ declarations and C++ base specifers that specify private 2796*e038c9c4Sjoerginheritance. 2797*e038c9c4Sjoerg 2798*e038c9c4SjoergExamples: 2799*e038c9c4Sjoerg class C { 2800*e038c9c4Sjoerg public: int a; 2801*e038c9c4Sjoerg protected: int b; 2802*e038c9c4Sjoerg private: int c; // fieldDecl(isPrivate()) matches 'c' 2803*e038c9c4Sjoerg }; 2804*e038c9c4Sjoerg 2805*e038c9c4Sjoerg struct Base {}; 2806*e038c9c4Sjoerg struct Derived1 : private Base {}; // matches 'Base' 2807*e038c9c4Sjoerg class Derived2 : Base {}; // matches 'Base' 2808*e038c9c4Sjoerg</pre></td></tr> 2809*e038c9c4Sjoerg 2810*e038c9c4Sjoerg 2811*e038c9c4Sjoerg<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> 2812*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isProtected1"><pre>Matches protected C++ declarations and C++ base specifers that specify 2813*e038c9c4Sjoergprotected inheritance. 2814*e038c9c4Sjoerg 2815*e038c9c4SjoergExamples: 2816*e038c9c4Sjoerg class C { 2817*e038c9c4Sjoerg public: int a; 2818*e038c9c4Sjoerg protected: int b; // fieldDecl(isProtected()) matches 'b' 2819*e038c9c4Sjoerg private: int c; 2820*e038c9c4Sjoerg }; 2821*e038c9c4Sjoerg 2822*e038c9c4Sjoerg class Base {}; 2823*e038c9c4Sjoerg class Derived : protected Base {}; // matches 'Base' 2824*e038c9c4Sjoerg</pre></td></tr> 2825*e038c9c4Sjoerg 2826*e038c9c4Sjoerg 2827*e038c9c4Sjoerg<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> 2828*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isPublic1"><pre>Matches public C++ declarations and C++ base specifers that specify public 2829*e038c9c4Sjoerginheritance. 2830*e038c9c4Sjoerg 2831*e038c9c4SjoergExamples: 2832*e038c9c4Sjoerg class C { 2833*e038c9c4Sjoerg public: int a; // fieldDecl(isPublic()) matches 'a' 2834*e038c9c4Sjoerg protected: int b; 2835*e038c9c4Sjoerg private: int c; 2836*e038c9c4Sjoerg }; 2837*e038c9c4Sjoerg 2838*e038c9c4Sjoerg class Base {}; 2839*e038c9c4Sjoerg class Derived1 : public Base {}; // matches 'Base' 2840*e038c9c4Sjoerg struct Derived2 : Base {}; // matches 'Base' 2841*e038c9c4Sjoerg</pre></td></tr> 2842*e038c9c4Sjoerg 2843*e038c9c4Sjoerg 2844*e038c9c4Sjoerg<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> 2845*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isVirtual1"><pre>Matches declarations of virtual methods and C++ base specifers that specify 2846*e038c9c4Sjoergvirtual inheritance. 2847*e038c9c4Sjoerg 2848*e038c9c4SjoergExample: 2849*e038c9c4Sjoerg class A { 2850*e038c9c4Sjoerg public: 2851*e038c9c4Sjoerg virtual void x(); // matches x 2852*e038c9c4Sjoerg }; 2853*e038c9c4Sjoerg 2854*e038c9c4SjoergExample: 2855*e038c9c4Sjoerg class Base {}; 2856*e038c9c4Sjoerg class DirectlyDerived : virtual Base {}; // matches Base 2857*e038c9c4Sjoerg class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base 2858*e038c9c4Sjoerg 2859*e038c9c4SjoergUsable 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>> 28607330f729Sjoerg</pre></td></tr> 28617330f729Sjoerg 28627330f729Sjoerg 28637330f729Sjoerg<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> 28647330f729Sjoerg<tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr> 28657330f729Sjoerg 28667330f729Sjoerg 28677330f729Sjoerg<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> 28687330f729Sjoerg<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT. 28697330f729Sjoerg 28707330f729SjoergGiven 28717330f729Sjoerg f('false, 3.14, 42); 28727330f729SjoergcharacterLiteral(equals(0)) 28737330f729Sjoerg matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 28747330f729Sjoerg match false 28757330f729SjoergfloatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 28767330f729Sjoerg match 3.14 28777330f729SjoergintegerLiteral(equals(42)) 28787330f729Sjoerg matches 42 28797330f729Sjoerg 28807330f729SjoergNote that you cannot directly match a negative numeric literal because the 28817330f729Sjoergminus sign is not part of the literal: It is a unary operator whose operand 28827330f729Sjoergis the positive numeric literal. Instead, you must use a unaryOperator() 28837330f729Sjoergmatcher to match the minus sign: 28847330f729Sjoerg 28857330f729SjoergunaryOperator(hasOperatorName("-"), 28867330f729Sjoerg hasUnaryOperand(integerLiteral(equals(13)))) 28877330f729Sjoerg 28887330f729SjoergUsable 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>>, 28897330f729Sjoerg 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>> 28907330f729Sjoerg</pre></td></tr> 28917330f729Sjoerg 28927330f729Sjoerg 28937330f729Sjoerg<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> 28947330f729Sjoerg<tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr> 28957330f729Sjoerg 28967330f729Sjoerg 28977330f729Sjoerg<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> 28987330f729Sjoerg<tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr> 28997330f729Sjoerg 29007330f729Sjoerg 29017330f729Sjoerg<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> 29027330f729Sjoerg<tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. 29037330f729Sjoerg 29047330f729SjoergGiven 29057330f729Sjoerg try { 29067330f729Sjoerg // ... 29077330f729Sjoerg } catch (int) { 29087330f729Sjoerg // ... 29097330f729Sjoerg } catch (...) { 29107330f729Sjoerg // ... 29117330f729Sjoerg } 29127330f729SjoergcxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). 29137330f729Sjoerg</pre></td></tr> 29147330f729Sjoerg 29157330f729Sjoerg 29167330f729Sjoerg<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> 29177330f729Sjoerg<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has 29187330f729Sjoerga specific number of arguments (including absent default arguments). 29197330f729Sjoerg 29207330f729SjoergExample matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 29217330f729Sjoerg void f(int x, int y); 29227330f729Sjoerg f(0, 0); 29237330f729Sjoerg</pre></td></tr> 29247330f729Sjoerg 29257330f729Sjoerg 29267330f729Sjoerg<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> 29277330f729Sjoerg<tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. 29287330f729Sjoerg</pre></td></tr> 29297330f729Sjoerg 29307330f729Sjoerg 29317330f729Sjoerg<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> 29327330f729Sjoerg<tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires 29337330f729Sjoergzero initialization. 29347330f729Sjoerg 29357330f729SjoergGiven 29367330f729Sjoergvoid foo() { 29377330f729Sjoerg struct point { double x; double y; }; 29387330f729Sjoerg point pt[2] = { { 1.0, 2.0 } }; 29397330f729Sjoerg} 29407330f729SjoerginitListExpr(has(cxxConstructExpr(requiresZeroInitialization())) 29417330f729Sjoergwill match the implicit array filler for pt[1]. 29427330f729Sjoerg</pre></td></tr> 29437330f729Sjoerg 29447330f729Sjoerg 29457330f729Sjoerg<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> 29467330f729Sjoerg<tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. 29477330f729Sjoerg 29487330f729SjoergGiven 29497330f729Sjoerg struct S { 29507330f729Sjoerg S(); // #1 29517330f729Sjoerg S(const S &); // #2 29527330f729Sjoerg S(S &&); // #3 29537330f729Sjoerg }; 29547330f729SjoergcxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. 29557330f729Sjoerg</pre></td></tr> 29567330f729Sjoerg 29577330f729Sjoerg 29587330f729Sjoerg<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> 29597330f729Sjoerg<tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. 29607330f729Sjoerg 29617330f729SjoergGiven 29627330f729Sjoerg struct S { 29637330f729Sjoerg S(); // #1 29647330f729Sjoerg S(const S &); // #2 29657330f729Sjoerg S(S &&); // #3 29667330f729Sjoerg }; 29677330f729SjoergcxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. 29687330f729Sjoerg</pre></td></tr> 29697330f729Sjoerg 29707330f729Sjoerg 29717330f729Sjoerg<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> 29727330f729Sjoerg<tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor. 29737330f729Sjoerg 29747330f729SjoergGiven 29757330f729Sjoerg struct S { 29767330f729Sjoerg S(); // #1 29777330f729Sjoerg S(int) {} // #2 29787330f729Sjoerg S(S &&) : S() {} // #3 29797330f729Sjoerg }; 29807330f729Sjoerg S::S() : S(0) {} // #4 29817330f729SjoergcxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not 29827330f729Sjoerg#1 or #2. 29837330f729Sjoerg</pre></td></tr> 29847330f729Sjoerg 29857330f729Sjoerg 29867330f729Sjoerg<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> 29877330f729Sjoerg<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor, conversion function, and deduction guide declarations 29887330f729Sjoergthat have an explicit specifier if this explicit specifier is resolved to 29897330f729Sjoergtrue. 29907330f729Sjoerg 29917330f729SjoergGiven 29927330f729Sjoerg template<bool b> 29937330f729Sjoerg struct S { 29947330f729Sjoerg S(int); // #1 29957330f729Sjoerg explicit S(double); // #2 29967330f729Sjoerg operator int(); // #3 29977330f729Sjoerg explicit operator bool(); // #4 29987330f729Sjoerg explicit(false) S(bool) // # 7 29997330f729Sjoerg explicit(true) S(char) // # 8 30007330f729Sjoerg explicit(b) S(S) // # 9 30017330f729Sjoerg }; 30027330f729Sjoerg S(int) -> S<true> // #5 30037330f729Sjoerg explicit S(double) -> S<false> // #6 30047330f729SjoergcxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. 30057330f729SjoergcxxConversionDecl(isExplicit()) will match #4, but not #3. 30067330f729SjoergcxxDeductionGuideDecl(isExplicit()) will match #6, but not #5. 30077330f729Sjoerg</pre></td></tr> 30087330f729Sjoerg 30097330f729Sjoerg 30107330f729Sjoerg<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> 30117330f729Sjoerg<tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. 30127330f729Sjoerg 30137330f729SjoergGiven 30147330f729Sjoerg struct S { 30157330f729Sjoerg S(); // #1 30167330f729Sjoerg S(const S &); // #2 30177330f729Sjoerg S(S &&); // #3 30187330f729Sjoerg }; 30197330f729SjoergcxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. 30207330f729Sjoerg</pre></td></tr> 30217330f729Sjoerg 30227330f729Sjoerg 30237330f729Sjoerg<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> 30247330f729Sjoerg<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor, conversion function, and deduction guide declarations 30257330f729Sjoergthat have an explicit specifier if this explicit specifier is resolved to 30267330f729Sjoergtrue. 30277330f729Sjoerg 30287330f729SjoergGiven 30297330f729Sjoerg template<bool b> 30307330f729Sjoerg struct S { 30317330f729Sjoerg S(int); // #1 30327330f729Sjoerg explicit S(double); // #2 30337330f729Sjoerg operator int(); // #3 30347330f729Sjoerg explicit operator bool(); // #4 30357330f729Sjoerg explicit(false) S(bool) // # 7 30367330f729Sjoerg explicit(true) S(char) // # 8 30377330f729Sjoerg explicit(b) S(S) // # 9 30387330f729Sjoerg }; 30397330f729Sjoerg S(int) -> S<true> // #5 30407330f729Sjoerg explicit S(double) -> S<false> // #6 30417330f729SjoergcxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. 30427330f729SjoergcxxConversionDecl(isExplicit()) will match #4, but not #3. 30437330f729SjoergcxxDeductionGuideDecl(isExplicit()) will match #6, but not #5. 30447330f729Sjoerg</pre></td></tr> 30457330f729Sjoerg 30467330f729Sjoerg 30477330f729Sjoerg<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> 30487330f729Sjoerg<tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as 30497330f729Sjoergopposed to a member. 30507330f729Sjoerg 30517330f729SjoergGiven 30527330f729Sjoerg struct B {}; 30537330f729Sjoerg struct D : B { 30547330f729Sjoerg int I; 30557330f729Sjoerg D(int i) : I(i) {} 30567330f729Sjoerg }; 30577330f729Sjoerg struct E : B { 30587330f729Sjoerg E() : B() {} 30597330f729Sjoerg }; 30607330f729SjoergcxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) 30617330f729Sjoerg will match E(), but not match D(int). 30627330f729Sjoerg</pre></td></tr> 30637330f729Sjoerg 30647330f729Sjoerg 30657330f729Sjoerg<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> 30667330f729Sjoerg<tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as 30677330f729Sjoergopposed to a base. 30687330f729Sjoerg 30697330f729SjoergGiven 30707330f729Sjoerg struct B {}; 30717330f729Sjoerg struct D : B { 30727330f729Sjoerg int I; 30737330f729Sjoerg D(int i) : I(i) {} 30747330f729Sjoerg }; 30757330f729Sjoerg struct E : B { 30767330f729Sjoerg E() : B() {} 30777330f729Sjoerg }; 30787330f729SjoergcxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) 30797330f729Sjoerg will match D(int), but not match E(). 30807330f729Sjoerg</pre></td></tr> 30817330f729Sjoerg 30827330f729Sjoerg 30837330f729Sjoerg<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> 30847330f729Sjoerg<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in 30857330f729Sjoergcode (as opposed to implicitly added by the compiler). 30867330f729Sjoerg 30877330f729SjoergGiven 30887330f729Sjoerg struct Foo { 30897330f729Sjoerg Foo() { } 30907330f729Sjoerg Foo(int) : foo_("A") { } 30917330f729Sjoerg string foo_; 30927330f729Sjoerg }; 30937330f729SjoergcxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) 30947330f729Sjoerg will match Foo(int), but not Foo() 30957330f729Sjoerg</pre></td></tr> 30967330f729Sjoerg 30977330f729Sjoerg 30987330f729Sjoerg<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> 30997330f729Sjoerg<tr><td colspan="4" class="doc" id="isExplicit2"><pre>Matches constructor, conversion function, and deduction guide declarations 31007330f729Sjoergthat have an explicit specifier if this explicit specifier is resolved to 31017330f729Sjoergtrue. 31027330f729Sjoerg 31037330f729SjoergGiven 31047330f729Sjoerg template<bool b> 31057330f729Sjoerg struct S { 31067330f729Sjoerg S(int); // #1 31077330f729Sjoerg explicit S(double); // #2 31087330f729Sjoerg operator int(); // #3 31097330f729Sjoerg explicit operator bool(); // #4 31107330f729Sjoerg explicit(false) S(bool) // # 7 31117330f729Sjoerg explicit(true) S(char) // # 8 31127330f729Sjoerg explicit(b) S(S) // # 9 31137330f729Sjoerg }; 31147330f729Sjoerg S(int) -> S<true> // #5 31157330f729Sjoerg explicit S(double) -> S<false> // #6 31167330f729SjoergcxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. 31177330f729SjoergcxxConversionDecl(isExplicit()) will match #4, but not #3. 31187330f729SjoergcxxDeductionGuideDecl(isExplicit()) will match #6, but not #5. 31197330f729Sjoerg</pre></td></tr> 31207330f729Sjoerg 31217330f729Sjoerg 3122*e038c9c4Sjoerg<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> 3123*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasMemberName0"><pre>Matches template-dependent, but known, member names. 3124*e038c9c4Sjoerg 3125*e038c9c4SjoergIn template declarations, dependent members are not resolved and so can 3126*e038c9c4Sjoergnot be matched to particular named declarations. 3127*e038c9c4Sjoerg 3128*e038c9c4SjoergThis matcher allows to match on the known name of members. 3129*e038c9c4Sjoerg 3130*e038c9c4SjoergGiven 3131*e038c9c4Sjoerg template <typename T> 3132*e038c9c4Sjoerg struct S { 3133*e038c9c4Sjoerg void mem(); 3134*e038c9c4Sjoerg }; 3135*e038c9c4Sjoerg template <typename T> 3136*e038c9c4Sjoerg void x() { 3137*e038c9c4Sjoerg S<T> s; 3138*e038c9c4Sjoerg s.mem(); 3139*e038c9c4Sjoerg } 3140*e038c9c4SjoergcxxDependentScopeMemberExpr(hasMemberName("mem")) matches `s.mem()` 3141*e038c9c4Sjoerg</pre></td></tr> 3142*e038c9c4Sjoerg 3143*e038c9c4Sjoerg 31447330f729Sjoerg<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> 31457330f729Sjoerg<tr><td colspan="4" class="doc" id="isArrow2"><pre>Matches member expressions that are called with '->' as opposed 31467330f729Sjoergto '.'. 31477330f729Sjoerg 31487330f729SjoergMember calls on the implicit this pointer match as called with '->'. 31497330f729Sjoerg 31507330f729SjoergGiven 31517330f729Sjoerg class Y { 31527330f729Sjoerg void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 31537330f729Sjoerg template <class T> void f() { this->f<T>(); f<T>(); } 31547330f729Sjoerg int a; 31557330f729Sjoerg static int b; 31567330f729Sjoerg }; 31577330f729Sjoerg template <class T> 31587330f729Sjoerg class Z { 31597330f729Sjoerg void x() { this->m; } 31607330f729Sjoerg }; 31617330f729SjoergmemberExpr(isArrow()) 31627330f729Sjoerg matches this->x, x, y.x, a, this->b 31637330f729SjoergcxxDependentScopeMemberExpr(isArrow()) 31647330f729Sjoerg matches this->m 31657330f729SjoergunresolvedMemberExpr(isArrow()) 31667330f729Sjoerg matches this->f<T>, f<T> 31677330f729Sjoerg</pre></td></tr> 31687330f729Sjoerg 31697330f729Sjoerg 3170*e038c9c4Sjoerg<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> 3171*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="memberHasSameNameAsBoundNode0"><pre>Matches template-dependent, but known, member names against an already-bound 3172*e038c9c4Sjoergnode 3173*e038c9c4Sjoerg 3174*e038c9c4SjoergIn template declarations, dependent members are not resolved and so can 3175*e038c9c4Sjoergnot be matched to particular named declarations. 3176*e038c9c4Sjoerg 3177*e038c9c4SjoergThis matcher allows to match on the name of already-bound VarDecl, FieldDecl 3178*e038c9c4Sjoergand CXXMethodDecl nodes. 3179*e038c9c4Sjoerg 3180*e038c9c4SjoergGiven 3181*e038c9c4Sjoerg template <typename T> 3182*e038c9c4Sjoerg struct S { 3183*e038c9c4Sjoerg void mem(); 3184*e038c9c4Sjoerg }; 3185*e038c9c4Sjoerg template <typename T> 3186*e038c9c4Sjoerg void x() { 3187*e038c9c4Sjoerg S<T> s; 3188*e038c9c4Sjoerg s.mem(); 3189*e038c9c4Sjoerg } 3190*e038c9c4SjoergThe matcher 3191*e038c9c4Sjoerg@code 3192*e038c9c4SjoergcxxDependentScopeMemberExpr( 3193*e038c9c4Sjoerg hasObjectExpression(declRefExpr(hasType(templateSpecializationType( 3194*e038c9c4Sjoerg hasDeclaration(classTemplateDecl(has(cxxRecordDecl(has( 3195*e038c9c4Sjoerg cxxMethodDecl(hasName("mem")).bind("templMem") 3196*e038c9c4Sjoerg ))))) 3197*e038c9c4Sjoerg )))), 3198*e038c9c4Sjoerg memberHasSameNameAsBoundNode("templMem") 3199*e038c9c4Sjoerg ) 3200*e038c9c4Sjoerg@endcode 3201*e038c9c4Sjoergfirst matches and binds the @c mem member of the @c S template, then 3202*e038c9c4Sjoergcompares its name to the usage in @c s.mem() in the @c x function template 3203*e038c9c4Sjoerg</pre></td></tr> 3204*e038c9c4Sjoerg 3205*e038c9c4Sjoerg 32067330f729Sjoerg<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> 32077330f729Sjoerg<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. 32087330f729Sjoerg 32097330f729SjoergGiven 32107330f729Sjoergstruct A { 32117330f729Sjoerg void foo() const; 32127330f729Sjoerg void bar(); 32137330f729Sjoerg}; 32147330f729Sjoerg 32157330f729SjoergcxxMethodDecl(isConst()) matches A::foo() but not A::bar() 32167330f729Sjoerg</pre></td></tr> 32177330f729Sjoerg 32187330f729Sjoerg 32197330f729Sjoerg<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> 32207330f729Sjoerg<tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment 32217330f729Sjoergoperator. 32227330f729Sjoerg 32237330f729SjoergGiven 32247330f729Sjoergstruct A { 32257330f729Sjoerg A &operator=(const A &); 32267330f729Sjoerg A &operator=(A &&); 32277330f729Sjoerg}; 32287330f729Sjoerg 32297330f729SjoergcxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not 32307330f729Sjoergthe second one. 32317330f729Sjoerg</pre></td></tr> 32327330f729Sjoerg 32337330f729Sjoerg 32347330f729Sjoerg<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> 32357330f729Sjoerg<tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. 32367330f729Sjoerg 32377330f729SjoergGiven: 32387330f729Sjoerg class A final {}; 32397330f729Sjoerg 32407330f729Sjoerg struct B { 32417330f729Sjoerg virtual void f(); 32427330f729Sjoerg }; 32437330f729Sjoerg 32447330f729Sjoerg struct C : B { 32457330f729Sjoerg void f() final; 32467330f729Sjoerg }; 32477330f729Sjoergmatches A and C::f, but not B, C, or B::f 32487330f729Sjoerg</pre></td></tr> 32497330f729Sjoerg 32507330f729Sjoerg 32517330f729Sjoerg<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> 32527330f729Sjoerg<tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment 32537330f729Sjoergoperator. 32547330f729Sjoerg 32557330f729SjoergGiven 32567330f729Sjoergstruct A { 32577330f729Sjoerg A &operator=(const A &); 32587330f729Sjoerg A &operator=(A &&); 32597330f729Sjoerg}; 32607330f729Sjoerg 32617330f729SjoergcxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not 32627330f729Sjoergthe first one. 32637330f729Sjoerg</pre></td></tr> 32647330f729Sjoerg 32657330f729Sjoerg 32667330f729Sjoerg<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> 32677330f729Sjoerg<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. 32687330f729Sjoerg 32697330f729SjoergGiven 32707330f729Sjoerg class A { 32717330f729Sjoerg public: 32727330f729Sjoerg virtual void x(); 32737330f729Sjoerg }; 32747330f729Sjoerg class B : public A { 32757330f729Sjoerg public: 32767330f729Sjoerg virtual void x(); 32777330f729Sjoerg }; 32787330f729Sjoerg matches B::x 32797330f729Sjoerg</pre></td></tr> 32807330f729Sjoerg 32817330f729Sjoerg 32827330f729Sjoerg<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> 32837330f729Sjoerg<tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. 32847330f729Sjoerg 32857330f729SjoergGiven 32867330f729Sjoerg class A { 32877330f729Sjoerg public: 32887330f729Sjoerg virtual void x() = 0; 32897330f729Sjoerg }; 32907330f729Sjoerg matches A::x 32917330f729Sjoerg</pre></td></tr> 32927330f729Sjoerg 32937330f729Sjoerg 32947330f729Sjoerg<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> 32957330f729Sjoerg<tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided. 32967330f729Sjoerg 32977330f729SjoergGiven 32987330f729Sjoerg struct S { 32997330f729Sjoerg S(); // #1 33007330f729Sjoerg S(const S &) = default; // #2 33017330f729Sjoerg S(S &&) = delete; // #3 33027330f729Sjoerg }; 33037330f729SjoergcxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3. 33047330f729Sjoerg</pre></td></tr> 33057330f729Sjoerg 33067330f729Sjoerg 33077330f729Sjoerg<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> 3308*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches declarations of virtual methods and C++ base specifers that specify 3309*e038c9c4Sjoergvirtual inheritance. 33107330f729Sjoerg 3311*e038c9c4SjoergExample: 33127330f729Sjoerg class A { 33137330f729Sjoerg public: 3314*e038c9c4Sjoerg virtual void x(); // matches x 33157330f729Sjoerg }; 3316*e038c9c4Sjoerg 3317*e038c9c4SjoergExample: 3318*e038c9c4Sjoerg class Base {}; 3319*e038c9c4Sjoerg class DirectlyDerived : virtual Base {}; // matches Base 3320*e038c9c4Sjoerg class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base 3321*e038c9c4Sjoerg 3322*e038c9c4SjoergUsable 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>> 33237330f729Sjoerg</pre></td></tr> 33247330f729Sjoerg 33257330f729Sjoerg 33267330f729Sjoerg<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> 33277330f729Sjoerg<tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual". 33287330f729Sjoerg 33297330f729SjoergGiven 33307330f729Sjoerg class A { 33317330f729Sjoerg public: 33327330f729Sjoerg virtual void x(); 33337330f729Sjoerg }; 33347330f729Sjoerg class B : public A { 33357330f729Sjoerg public: 33367330f729Sjoerg void x(); 33377330f729Sjoerg }; 33387330f729Sjoerg matches A::x but not B::x 33397330f729Sjoerg</pre></td></tr> 33407330f729Sjoerg 33417330f729Sjoerg 33427330f729Sjoerg<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> 33437330f729Sjoerg<tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions. 33447330f729Sjoerg 33457330f729SjoergGiven: 33467330f729Sjoerg MyClass *p1 = new MyClass[10]; 33477330f729SjoergcxxNewExpr(isArray()) 33487330f729Sjoerg matches the expression 'new MyClass[10]'. 33497330f729Sjoerg</pre></td></tr> 33507330f729Sjoerg 33517330f729Sjoerg 3352*e038c9c4Sjoerg<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> 3353*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyOperatorName1"><pre>Matches operator expressions (binary or unary) that have any of the 3354*e038c9c4Sjoergspecified names. 3355*e038c9c4Sjoerg 3356*e038c9c4Sjoerg hasAnyOperatorName("+", "-") 3357*e038c9c4Sjoerg Is equivalent to 3358*e038c9c4Sjoerg anyOf(hasOperatorName("+"), hasOperatorName("-")) 3359*e038c9c4Sjoerg</pre></td></tr> 3360*e038c9c4Sjoerg 3361*e038c9c4Sjoerg 3362*e038c9c4Sjoerg<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> 3363*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName0"><pre>Matches overloaded operator names. 3364*e038c9c4Sjoerg 3365*e038c9c4SjoergMatches overloaded operator names specified in strings without the 3366*e038c9c4Sjoerg"operator" prefix: e.g. "<<". 3367*e038c9c4Sjoerg 3368*e038c9c4Sjoerg hasAnyOverloadedOperatorName("+", "-") 3369*e038c9c4SjoergIs equivalent to 3370*e038c9c4Sjoerg anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-")) 3371*e038c9c4Sjoerg</pre></td></tr> 3372*e038c9c4Sjoerg 3373*e038c9c4Sjoerg 3374*e038c9c4Sjoerg<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> 3375*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 3376*e038c9c4Sjoergunary). 3377*e038c9c4Sjoerg 3378*e038c9c4SjoergExample matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 3379*e038c9c4Sjoerg !(a || b) 3380*e038c9c4Sjoerg</pre></td></tr> 3381*e038c9c4Sjoerg 3382*e038c9c4Sjoerg 33837330f729Sjoerg<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> 33847330f729Sjoerg<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. 33857330f729Sjoerg 33867330f729SjoergMatches overloaded operator names specified in strings without the 33877330f729Sjoerg"operator" prefix: e.g. "<<". 33887330f729Sjoerg 33897330f729SjoergGiven: 33907330f729Sjoerg class A { int operator*(); }; 33917330f729Sjoerg const A &operator<<(const A &a, const A &b); 33927330f729Sjoerg A a; 33937330f729Sjoerg a << a; // <-- This matches 33947330f729Sjoerg 33957330f729SjoergcxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the 33967330f729Sjoergspecified line and 33977330f729SjoergcxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) 33987330f729Sjoergmatches the declaration of A. 33997330f729Sjoerg 34007330f729SjoergUsable 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>> 34017330f729Sjoerg</pre></td></tr> 34027330f729Sjoerg 34037330f729Sjoerg 34047330f729Sjoerg<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> 34057330f729Sjoerg<tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators. 34067330f729Sjoerg 34077330f729SjoergExample 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) 34087330f729Sjoerg if (a == b) 34097330f729Sjoerg a += b; 34107330f729Sjoerg 34117330f729SjoergExample 2: matches s1 = s2 34127330f729Sjoerg (matcher = cxxOperatorCallExpr(isAssignmentOperator())) 34137330f729Sjoerg struct S { S& operator=(const S&); }; 3414*e038c9c4Sjoerg void x() { S s1, s2; s1 = s2; } 3415*e038c9c4Sjoerg</pre></td></tr> 3416*e038c9c4Sjoerg 3417*e038c9c4Sjoerg 3418*e038c9c4Sjoerg<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> 3419*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isComparisonOperator1"><pre>Matches comparison operators. 3420*e038c9c4Sjoerg 3421*e038c9c4SjoergExample 1: matches a == b (matcher = binaryOperator(isComparisonOperator())) 3422*e038c9c4Sjoerg if (a == b) 3423*e038c9c4Sjoerg a += b; 3424*e038c9c4Sjoerg 3425*e038c9c4SjoergExample 2: matches s1 < s2 3426*e038c9c4Sjoerg (matcher = cxxOperatorCallExpr(isComparisonOperator())) 3427*e038c9c4Sjoerg struct S { bool operator<(const S& other); }; 3428*e038c9c4Sjoerg void x(S s1, S s2) { bool b1 = s1 < s2; } 34297330f729Sjoerg</pre></td></tr> 34307330f729Sjoerg 34317330f729Sjoerg 34327330f729Sjoerg<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> 34337330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined. 34347330f729Sjoerg 34357330f729SjoergExample matches x (matcher = cxxRecordDecl(hasDefinition())) 34367330f729Sjoergclass x {}; 34377330f729Sjoergclass y; 34387330f729Sjoerg</pre></td></tr> 34397330f729Sjoerg 34407330f729Sjoerg 34417330f729Sjoerg<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> 34427330f729Sjoerg<tr><td colspan="4" class="doc" id="isDerivedFrom2"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). 34437330f729Sjoerg</pre></td></tr> 34447330f729Sjoerg 34457330f729Sjoerg 34467330f729Sjoerg<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> 34477330f729Sjoerg<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom2"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)). 34487330f729Sjoerg</pre></td></tr> 34497330f729Sjoerg 34507330f729Sjoerg 34517330f729Sjoerg<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> 34527330f729Sjoerg<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or 34537330f729Sjoergstatic member variable template instantiations. 34547330f729Sjoerg 34557330f729SjoergGiven 34567330f729Sjoerg template<typename T> void A(T t) { } 34577330f729Sjoerg template<> void A(int N) { } 34587330f729SjoergfunctionDecl(isExplicitTemplateSpecialization()) 34597330f729Sjoerg matches the specialization A<int>(). 34607330f729Sjoerg 34617330f729SjoergUsable 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>> 34627330f729Sjoerg</pre></td></tr> 34637330f729Sjoerg 34647330f729Sjoerg 34657330f729Sjoerg<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> 34667330f729Sjoerg<tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. 34677330f729Sjoerg 34687330f729SjoergGiven: 34697330f729Sjoerg class A final {}; 34707330f729Sjoerg 34717330f729Sjoerg struct B { 34727330f729Sjoerg virtual void f(); 34737330f729Sjoerg }; 34747330f729Sjoerg 34757330f729Sjoerg struct C : B { 34767330f729Sjoerg void f() final; 34777330f729Sjoerg }; 34787330f729Sjoergmatches A and C::f, but not B, C, or B::f 34797330f729Sjoerg</pre></td></tr> 34807330f729Sjoerg 34817330f729Sjoerg 34827330f729Sjoerg<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> 34837330f729Sjoerg<tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions. 34847330f729Sjoerg 34857330f729SjoergGiven: 34867330f729Sjoerg auto x = []{}; 34877330f729Sjoerg 34887330f729SjoergcxxRecordDecl(isLambda()) matches the implicit class declaration of 34897330f729Sjoergdecltype(x) 34907330f729Sjoerg</pre></td></tr> 34917330f729Sjoerg 34927330f729Sjoerg 34937330f729Sjoerg<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> 34947330f729Sjoerg<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom2"><pre>Overloaded method as shortcut for 34957330f729SjoergisSameOrDerivedFrom(hasName(...)). 34967330f729Sjoerg</pre></td></tr> 34977330f729Sjoerg 34987330f729Sjoerg 34997330f729Sjoerg<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> 35007330f729Sjoerg<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static 35017330f729Sjoergmember variable template instantiations. 35027330f729Sjoerg 35037330f729SjoergGiven 35047330f729Sjoerg template <typename T> class X {}; class A {}; X<A> x; 35057330f729Sjoergor 35067330f729Sjoerg template <typename T> class X {}; class A {}; template class X<A>; 35077330f729Sjoergor 35087330f729Sjoerg template <typename T> class X {}; class A {}; extern template class X<A>; 35097330f729SjoergcxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 35107330f729Sjoerg matches the template instantiation of X<A>. 35117330f729Sjoerg 35127330f729SjoergBut given 35137330f729Sjoerg template <typename T> class X {}; class A {}; 35147330f729Sjoerg template <> class X<A> {}; X<A> x; 35157330f729SjoergcxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 35167330f729Sjoerg does not match, as X<A> is an explicit template specialization. 35177330f729Sjoerg 35187330f729SjoergUsable 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>> 35197330f729Sjoerg</pre></td></tr> 35207330f729Sjoerg 35217330f729Sjoerg 3522*e038c9c4Sjoerg<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> 3523*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyOperatorName2"><pre>Matches operator expressions (binary or unary) that have any of the 3524*e038c9c4Sjoergspecified names. 3525*e038c9c4Sjoerg 3526*e038c9c4Sjoerg hasAnyOperatorName("+", "-") 3527*e038c9c4Sjoerg Is equivalent to 3528*e038c9c4Sjoerg anyOf(hasOperatorName("+"), hasOperatorName("-")) 3529*e038c9c4Sjoerg</pre></td></tr> 3530*e038c9c4Sjoerg 3531*e038c9c4Sjoerg 3532*e038c9c4Sjoerg<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> 3533*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasOperatorName2"><pre>Matches the operator Name of operator expressions (binary or 3534*e038c9c4Sjoergunary). 3535*e038c9c4Sjoerg 3536*e038c9c4SjoergExample matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 3537*e038c9c4Sjoerg !(a || b) 3538*e038c9c4Sjoerg</pre></td></tr> 3539*e038c9c4Sjoerg 3540*e038c9c4Sjoerg 3541*e038c9c4Sjoerg<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> 3542*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isAssignmentOperator2"><pre>Matches all kinds of assignment operators. 3543*e038c9c4Sjoerg 3544*e038c9c4SjoergExample 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) 3545*e038c9c4Sjoerg if (a == b) 3546*e038c9c4Sjoerg a += b; 3547*e038c9c4Sjoerg 3548*e038c9c4SjoergExample 2: matches s1 = s2 3549*e038c9c4Sjoerg (matcher = cxxOperatorCallExpr(isAssignmentOperator())) 3550*e038c9c4Sjoerg struct S { S& operator=(const S&); }; 3551*e038c9c4Sjoerg void x() { S s1, s2; s1 = s2; } 3552*e038c9c4Sjoerg</pre></td></tr> 3553*e038c9c4Sjoerg 3554*e038c9c4Sjoerg 3555*e038c9c4Sjoerg<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> 3556*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isComparisonOperator2"><pre>Matches comparison operators. 3557*e038c9c4Sjoerg 3558*e038c9c4SjoergExample 1: matches a == b (matcher = binaryOperator(isComparisonOperator())) 3559*e038c9c4Sjoerg if (a == b) 3560*e038c9c4Sjoerg a += b; 3561*e038c9c4Sjoerg 3562*e038c9c4SjoergExample 2: matches s1 < s2 3563*e038c9c4Sjoerg (matcher = cxxOperatorCallExpr(isComparisonOperator())) 3564*e038c9c4Sjoerg struct S { bool operator<(const S& other); }; 3565*e038c9c4Sjoerg void x(S s1, S s2) { bool b1 = s1 < s2; } 3566*e038c9c4Sjoerg</pre></td></tr> 3567*e038c9c4Sjoerg 3568*e038c9c4Sjoerg 3569*e038c9c4Sjoerg<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> 3570*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has 3571*e038c9c4Sjoerga specific number of arguments (including absent default arguments). 3572*e038c9c4Sjoerg 3573*e038c9c4SjoergExample matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 3574*e038c9c4Sjoerg void f(int x, int y); 3575*e038c9c4Sjoerg f(0, 0); 3576*e038c9c4Sjoerg</pre></td></tr> 3577*e038c9c4Sjoerg 3578*e038c9c4Sjoerg 35797330f729Sjoerg<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> 35807330f729Sjoerg<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has 35817330f729Sjoerga specific number of arguments (including absent default arguments). 35827330f729Sjoerg 35837330f729SjoergExample matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 35847330f729Sjoerg void f(int x, int y); 35857330f729Sjoerg f(0, 0); 35867330f729Sjoerg</pre></td></tr> 35877330f729Sjoerg 35887330f729Sjoerg 35897330f729Sjoerg<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> 35907330f729Sjoerg<tr><td colspan="4" class="doc" id="usesADL0"><pre>Matches call expressions which were resolved using ADL. 35917330f729Sjoerg 35927330f729SjoergExample matches y(x) but not y(42) or NS::y(x). 35937330f729Sjoerg namespace NS { 35947330f729Sjoerg struct X {}; 35957330f729Sjoerg void y(X); 35967330f729Sjoerg } 35977330f729Sjoerg 35987330f729Sjoerg void y(...); 35997330f729Sjoerg 36007330f729Sjoerg void test() { 36017330f729Sjoerg NS::X x; 36027330f729Sjoerg y(x); // Matches 36037330f729Sjoerg NS::y(x); // Doesn't match 36047330f729Sjoerg y(42); // Doesn't match 36057330f729Sjoerg using NS::y; 36067330f729Sjoerg y(x); // Found by both unqualified lookup and ADL, doesn't match 36077330f729Sjoerg } 36087330f729Sjoerg</pre></td></tr> 36097330f729Sjoerg 36107330f729Sjoerg 36117330f729Sjoerg<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> 36127330f729Sjoerg<tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind. 36137330f729Sjoerg 36147330f729SjoergExample: matches the implicit cast around 0 36157330f729Sjoerg(matcher = castExpr(hasCastKind(CK_NullToPointer))) 36167330f729Sjoerg int *p = 0; 36177330f729Sjoerg 36187330f729SjoergIf the matcher is use from clang-query, CastKind parameter 3619*e038c9c4Sjoergshould be passed as a quoted string. e.g., hasCastKind("CK_NullToPointer"). 36207330f729Sjoerg</pre></td></tr> 36217330f729Sjoerg 36227330f729Sjoerg 36237330f729Sjoerg<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> 36247330f729Sjoerg<tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr> 36257330f729Sjoerg 36267330f729Sjoerg 36277330f729Sjoerg<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> 36287330f729Sjoerg<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT. 36297330f729Sjoerg 36307330f729SjoergGiven 36317330f729Sjoerg f('false, 3.14, 42); 36327330f729SjoergcharacterLiteral(equals(0)) 36337330f729Sjoerg matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 36347330f729Sjoerg match false 36357330f729SjoergfloatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 36367330f729Sjoerg match 3.14 36377330f729SjoergintegerLiteral(equals(42)) 36387330f729Sjoerg matches 42 36397330f729Sjoerg 36407330f729SjoergNote that you cannot directly match a negative numeric literal because the 36417330f729Sjoergminus sign is not part of the literal: It is a unary operator whose operand 36427330f729Sjoergis the positive numeric literal. Instead, you must use a unaryOperator() 36437330f729Sjoergmatcher to match the minus sign: 36447330f729Sjoerg 36457330f729SjoergunaryOperator(hasOperatorName("-"), 36467330f729Sjoerg hasUnaryOperand(integerLiteral(equals(13)))) 36477330f729Sjoerg 36487330f729SjoergUsable 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>>, 36497330f729Sjoerg 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>> 36507330f729Sjoerg</pre></td></tr> 36517330f729Sjoerg 36527330f729Sjoerg 36537330f729Sjoerg<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> 36547330f729Sjoerg<tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr> 36557330f729Sjoerg 36567330f729Sjoerg 36577330f729Sjoerg<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> 36587330f729Sjoerg<tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr> 36597330f729Sjoerg 36607330f729Sjoerg 36617330f729Sjoerg<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> 36627330f729Sjoerg<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. 36637330f729Sjoerg 36647330f729SjoergGiven 36657330f729Sjoerg template<typename T> struct C {}; 36667330f729Sjoerg C<int> c; 36677330f729SjoergclassTemplateSpecializationDecl(templateArgumentCountIs(1)) 36687330f729Sjoerg matches C<int>. 36697330f729Sjoerg</pre></td></tr> 36707330f729Sjoerg 36717330f729Sjoerg 36727330f729Sjoerg<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> 36737330f729Sjoerg<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of 36747330f729Sjoergchild statements. 36757330f729Sjoerg 36767330f729SjoergExample: Given 36777330f729Sjoerg { for (;;) {} } 36787330f729SjoergcompoundStmt(statementCountIs(0))) 36797330f729Sjoerg matches '{}' 36807330f729Sjoerg but does not match the outer compound statement. 36817330f729Sjoerg</pre></td></tr> 36827330f729Sjoerg 36837330f729Sjoerg 36847330f729Sjoerg<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> 36857330f729Sjoerg<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size. 36867330f729Sjoerg 36877330f729SjoergGiven 36887330f729Sjoerg int a[42]; 36897330f729Sjoerg int b[2 * 21]; 36907330f729Sjoerg int c[41], d[43]; 36917330f729Sjoerg char *s = "abcd"; 36927330f729Sjoerg wchar_t *ws = L"abcd"; 36937330f729Sjoerg char *w = "a"; 36947330f729SjoergconstantArrayType(hasSize(42)) 36957330f729Sjoerg matches "int a[42]" and "int b[2 * 21]" 36967330f729SjoergstringLiteral(hasSize(4)) 36977330f729Sjoerg matches "abcd", L"abcd" 36987330f729Sjoerg</pre></td></tr> 36997330f729Sjoerg 37007330f729Sjoerg 37017330f729Sjoerg<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> 37027330f729Sjoerg<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of 37037330f729Sjoergdeclarations. 37047330f729Sjoerg 37057330f729SjoergExample: Given 37067330f729Sjoerg int a, b; 37077330f729Sjoerg int c; 37087330f729Sjoerg int d = 2, e; 37097330f729SjoergdeclCountIs(2) 37107330f729Sjoerg matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. 37117330f729Sjoerg</pre></td></tr> 37127330f729Sjoerg 37137330f729Sjoerg 37147330f729Sjoerg<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> 37157330f729Sjoerg<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. 37167330f729Sjoerg 37177330f729SjoergMatches a node if it equals the node previously bound to ID. 37187330f729Sjoerg 37197330f729SjoergGiven 37207330f729Sjoerg class X { int a; int b; }; 37217330f729SjoergcxxRecordDecl( 37227330f729Sjoerg has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 37237330f729Sjoerg has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 37247330f729Sjoerg matches the class X, as a and b have the same type. 37257330f729Sjoerg 37267330f729SjoergNote that when multiple matches are involved via forEach* matchers, 37277330f729SjoergequalsBoundNodes acts as a filter. 37287330f729SjoergFor example: 37297330f729SjoergcompoundStmt( 37307330f729Sjoerg forEachDescendant(varDecl().bind("d")), 37317330f729Sjoerg forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 37327330f729Sjoergwill trigger a match for each combination of variable declaration 37337330f729Sjoergand reference to that variable declaration within a compound statement. 37347330f729Sjoerg</pre></td></tr> 37357330f729Sjoerg 37367330f729Sjoerg 37377330f729Sjoerg<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> 37387330f729Sjoerg<tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node. 37397330f729Sjoerg 37407330f729SjoergDecl has pointer identity in the AST. 37417330f729Sjoerg</pre></td></tr> 37427330f729Sjoerg 37437330f729Sjoerg 37447330f729Sjoerg<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> 37457330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. 37467330f729Sjoerg 37477330f729SjoergGiven 37487330f729Sjoerg __attribute__((device)) void f() { ... } 37497330f729Sjoergdecl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of 37507330f729Sjoergf. If the matcher is used from clang-query, attr::Kind parameter should be 37517330f729Sjoergpassed as a quoted string. e.g., hasAttr("attr::CUDADevice"). 37527330f729Sjoerg</pre></td></tr> 37537330f729Sjoerg 37547330f729Sjoerg 3755*e038c9c4Sjoerg<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> 3756*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isExpandedFromMacro0"><pre>Matches statements that are (transitively) expanded from the named macro. 3757*e038c9c4SjoergDoes not match if only part of the statement is expanded from that macro or 3758*e038c9c4Sjoergif different parts of the the statement are expanded from different 3759*e038c9c4Sjoergappearances of the macro. 3760*e038c9c4Sjoerg</pre></td></tr> 3761*e038c9c4Sjoerg 3762*e038c9c4Sjoerg 3763*e038c9c4Sjoerg<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> 37647330f729Sjoerg<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is 37657330f729Sjoergpartially matching a given regex. 37667330f729Sjoerg 37677330f729SjoergExample matches Y but not X 37687330f729Sjoerg (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 37697330f729Sjoerg #include "ASTMatcher.h" 37707330f729Sjoerg class X {}; 37717330f729SjoergASTMatcher.h: 37727330f729Sjoerg class Y {}; 37737330f729Sjoerg 37747330f729SjoergUsable 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>> 3775*e038c9c4Sjoerg 3776*e038c9c4SjoergIf the matcher is used in clang-query, RegexFlags parameter 3777*e038c9c4Sjoergshould be passed as a quoted string. e.g: "NoFlags". 3778*e038c9c4SjoergFlags can be combined with '|' example "IgnoreCase | BasicRegex" 37797330f729Sjoerg</pre></td></tr> 37807330f729Sjoerg 37817330f729Sjoerg 37827330f729Sjoerg<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> 37837330f729Sjoerg<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. 37847330f729Sjoerg 37857330f729SjoergExample matches X but not Y 37867330f729Sjoerg (matcher = cxxRecordDecl(isExpansionInMainFile()) 37877330f729Sjoerg #include <Y.h> 37887330f729Sjoerg class X {}; 37897330f729SjoergY.h: 37907330f729Sjoerg class Y {}; 37917330f729Sjoerg 37927330f729SjoergUsable 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>> 37937330f729Sjoerg</pre></td></tr> 37947330f729Sjoerg 37957330f729Sjoerg 37967330f729Sjoerg<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> 37977330f729Sjoerg<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. 37987330f729Sjoerg 37997330f729SjoergExample matches Y but not X 38007330f729Sjoerg (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 38017330f729Sjoerg #include <SystemHeader.h> 38027330f729Sjoerg class X {}; 38037330f729SjoergSystemHeader.h: 38047330f729Sjoerg class Y {}; 38057330f729Sjoerg 38067330f729SjoergUsable 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>> 38077330f729Sjoerg</pre></td></tr> 38087330f729Sjoerg 38097330f729Sjoerg 38107330f729Sjoerg<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> 38117330f729Sjoerg<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added 38127330f729Sjoergby the compiler (eg. implicit default/copy constructors). 38137330f729Sjoerg</pre></td></tr> 38147330f729Sjoerg 38157330f729Sjoerg 38167330f729Sjoerg<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> 38177330f729Sjoerg<tr><td colspan="4" class="doc" id="isInStdNamespace0"><pre>Matches declarations in the namespace `std`, but not in nested namespaces. 38187330f729Sjoerg 38197330f729SjoergGiven 38207330f729Sjoerg class vector {}; 38217330f729Sjoerg namespace foo { 38227330f729Sjoerg class vector {}; 38237330f729Sjoerg namespace std { 38247330f729Sjoerg class vector {}; 38257330f729Sjoerg } 38267330f729Sjoerg } 38277330f729Sjoerg namespace std { 38287330f729Sjoerg inline namespace __1 { 38297330f729Sjoerg class vector {}; // #1 38307330f729Sjoerg namespace experimental { 38317330f729Sjoerg class vector {}; 38327330f729Sjoerg } 38337330f729Sjoerg } 38347330f729Sjoerg } 38357330f729SjoergcxxRecordDecl(hasName("vector"), isInStdNamespace()) will match only #1. 38367330f729Sjoerg</pre></td></tr> 38377330f729Sjoerg 38387330f729Sjoerg 3839*e038c9c4Sjoerg<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> 3840*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside 3841*e038c9c4Sjoergtemplate instantiations. 38427330f729Sjoerg 38437330f729SjoergGiven 3844*e038c9c4Sjoerg template<typename T> void A(T t) { T i; } 3845*e038c9c4Sjoerg A(0); 3846*e038c9c4Sjoerg A(0U); 3847*e038c9c4SjoergfunctionDecl(isInstantiated()) 3848*e038c9c4Sjoerg matches 'A(int) {...};' and 'A(unsigned) {...}'. 3849*e038c9c4Sjoerg</pre></td></tr> 3850*e038c9c4Sjoerg 3851*e038c9c4Sjoerg 3852*e038c9c4Sjoerg<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> 3853*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations and C++ base specifers that specify private 3854*e038c9c4Sjoerginheritance. 3855*e038c9c4Sjoerg 3856*e038c9c4SjoergExamples: 38577330f729Sjoerg class C { 38587330f729Sjoerg public: int a; 38597330f729Sjoerg protected: int b; 3860*e038c9c4Sjoerg private: int c; // fieldDecl(isPrivate()) matches 'c' 38617330f729Sjoerg }; 3862*e038c9c4Sjoerg 3863*e038c9c4Sjoerg struct Base {}; 3864*e038c9c4Sjoerg struct Derived1 : private Base {}; // matches 'Base' 3865*e038c9c4Sjoerg class Derived2 : Base {}; // matches 'Base' 38667330f729Sjoerg</pre></td></tr> 38677330f729Sjoerg 38687330f729Sjoerg 38697330f729Sjoerg<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> 3870*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations and C++ base specifers that specify 3871*e038c9c4Sjoergprotected inheritance. 38727330f729Sjoerg 3873*e038c9c4SjoergExamples: 38747330f729Sjoerg class C { 38757330f729Sjoerg public: int a; 3876*e038c9c4Sjoerg protected: int b; // fieldDecl(isProtected()) matches 'b' 38777330f729Sjoerg private: int c; 38787330f729Sjoerg }; 3879*e038c9c4Sjoerg 3880*e038c9c4Sjoerg class Base {}; 3881*e038c9c4Sjoerg class Derived : protected Base {}; // matches 'Base' 38827330f729Sjoerg</pre></td></tr> 38837330f729Sjoerg 38847330f729Sjoerg 38857330f729Sjoerg<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> 3886*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations and C++ base specifers that specify public 3887*e038c9c4Sjoerginheritance. 38887330f729Sjoerg 3889*e038c9c4SjoergExamples: 38907330f729Sjoerg class C { 3891*e038c9c4Sjoerg public: int a; // fieldDecl(isPublic()) matches 'a' 38927330f729Sjoerg protected: int b; 38937330f729Sjoerg private: int c; 38947330f729Sjoerg }; 3895*e038c9c4Sjoerg 3896*e038c9c4Sjoerg class Base {}; 3897*e038c9c4Sjoerg class Derived1 : public Base {}; // matches 'Base' 3898*e038c9c4Sjoerg struct Derived2 : Base {}; // matches 'Base' 38997330f729Sjoerg</pre></td></tr> 39007330f729Sjoerg 39017330f729Sjoerg 39027330f729Sjoerg<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> 39037330f729Sjoerg<tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain 39047330f729Sjoerga specific number of designators. 39057330f729Sjoerg 39067330f729SjoergExample: Given 39077330f729Sjoerg point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; 39087330f729Sjoerg point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }; 39097330f729SjoergdesignatorCountIs(2) 39107330f729Sjoerg matches '{ [2].y = 1.0, [0].x = 1.0 }', 39117330f729Sjoerg but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'. 39127330f729Sjoerg</pre></td></tr> 39137330f729Sjoerg 39147330f729Sjoerg 39157330f729Sjoerg<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> 39167330f729Sjoerg<tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration. 39177330f729Sjoerg 39187330f729SjoergExample matches Y (matcher = enumDecl(isScoped())) 39197330f729Sjoergenum X {}; 39207330f729Sjoergenum class Y {}; 39217330f729Sjoerg</pre></td></tr> 39227330f729Sjoerg 39237330f729Sjoerg 39247330f729Sjoerg<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> 39257330f729Sjoerg<tr><td colspan="4" class="doc" id="isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is 39267330f729Sjoergneither type- nor value-dependent. 39277330f729Sjoerg 39287330f729SjoergIn the following example, the expression sizeof(sizeof(T() + T())) 39297330f729Sjoergis instantiation-dependent (since it involves a template parameter T), 39307330f729Sjoergbut is neither type- nor value-dependent, since the type of the inner 39317330f729Sjoergsizeof is known (std::size_t) and therefore the size of the outer 39327330f729Sjoergsizeof is known. 39337330f729Sjoerg template<typename T> 39347330f729Sjoerg void f(T x, T y) { sizeof(sizeof(T() + T()); } 39357330f729Sjoergexpr(isInstantiationDependent()) matches sizeof(sizeof(T() + T()) 39367330f729Sjoerg</pre></td></tr> 39377330f729Sjoerg 39387330f729Sjoerg 39397330f729Sjoerg<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> 39407330f729Sjoerg<tr><td colspan="4" class="doc" id="isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type 39417330f729Sjoergis not yet instantiated. 39427330f729Sjoerg 39437330f729SjoergFor example, the expressions "x" and "x + y" are type-dependent in 39447330f729Sjoergthe following code, but "y" is not type-dependent: 39457330f729Sjoerg template<typename T> 39467330f729Sjoerg void add(T x, int y) { 39477330f729Sjoerg x + y; 39487330f729Sjoerg } 39497330f729Sjoergexpr(isTypeDependent()) matches x + y 39507330f729Sjoerg</pre></td></tr> 39517330f729Sjoerg 39527330f729Sjoerg 39537330f729Sjoerg<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> 39547330f729Sjoerg<tr><td colspan="4" class="doc" id="isValueDependent0"><pre>Matches expression that are value-dependent because they contain a 39557330f729Sjoergnon-type template parameter. 39567330f729Sjoerg 39577330f729SjoergFor example, the array bound of "Chars" in the following example is 39587330f729Sjoergvalue-dependent. 39597330f729Sjoerg template<int Size> int f() { return Size; } 39607330f729Sjoergexpr(isValueDependent()) matches return Size 39617330f729Sjoerg</pre></td></tr> 39627330f729Sjoerg 39637330f729Sjoerg 3964*e038c9c4Sjoerg<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> 3965*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as 3966*e038c9c4SjoergGNU's __null, C++11's nullptr, or C's NULL macro. 3967*e038c9c4Sjoerg 3968*e038c9c4SjoergGiven: 3969*e038c9c4Sjoerg void *v1 = NULL; 3970*e038c9c4Sjoerg void *v2 = nullptr; 3971*e038c9c4Sjoerg void *v3 = __null; // GNU extension 3972*e038c9c4Sjoerg char *cp = (char *)0; 3973*e038c9c4Sjoerg int *ip = 0; 3974*e038c9c4Sjoerg int i = 0; 3975*e038c9c4Sjoergexpr(nullPointerConstant()) 3976*e038c9c4Sjoerg matches the initializer for v1, v2, v3, cp, and ip. Does not match the 3977*e038c9c4Sjoerg initializer for i. 3978*e038c9c4Sjoerg</pre></td></tr> 3979*e038c9c4Sjoerg 3980*e038c9c4Sjoerg 39817330f729Sjoerg<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> 39827330f729Sjoerg<tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified 39837330f729Sjoergbit width. 39847330f729Sjoerg 39857330f729SjoergGiven 39867330f729Sjoerg class C { 39877330f729Sjoerg int a : 2; 39887330f729Sjoerg int b : 4; 39897330f729Sjoerg int c : 2; 39907330f729Sjoerg }; 39917330f729SjoergfieldDecl(hasBitWidth(2)) 39927330f729Sjoerg matches 'int a;' and 'int c;' but not 'int b;'. 39937330f729Sjoerg</pre></td></tr> 39947330f729Sjoerg 39957330f729Sjoerg 39967330f729Sjoerg<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> 39977330f729Sjoerg<tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields. 39987330f729Sjoerg 39997330f729SjoergGiven 40007330f729Sjoerg class C { 40017330f729Sjoerg int a : 2; 40027330f729Sjoerg int b; 40037330f729Sjoerg }; 40047330f729SjoergfieldDecl(isBitField()) 40057330f729Sjoerg matches 'int a;' but not 'int b;'. 40067330f729Sjoerg</pre></td></tr> 40077330f729Sjoerg 40087330f729Sjoerg 40097330f729Sjoerg<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> 40107330f729Sjoerg<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT. 40117330f729Sjoerg 40127330f729SjoergGiven 40137330f729Sjoerg f('false, 3.14, 42); 40147330f729SjoergcharacterLiteral(equals(0)) 40157330f729Sjoerg matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 40167330f729Sjoerg match false 40177330f729SjoergfloatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 40187330f729Sjoerg match 3.14 40197330f729SjoergintegerLiteral(equals(42)) 40207330f729Sjoerg matches 42 40217330f729Sjoerg 40227330f729SjoergNote that you cannot directly match a negative numeric literal because the 40237330f729Sjoergminus sign is not part of the literal: It is a unary operator whose operand 40247330f729Sjoergis the positive numeric literal. Instead, you must use a unaryOperator() 40257330f729Sjoergmatcher to match the minus sign: 40267330f729Sjoerg 40277330f729SjoergunaryOperator(hasOperatorName("-"), 40287330f729Sjoerg hasUnaryOperand(integerLiteral(equals(13)))) 40297330f729Sjoerg 40307330f729SjoergUsable 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>>, 40317330f729Sjoerg 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>> 40327330f729Sjoerg</pre></td></tr> 40337330f729Sjoerg 40347330f729Sjoerg 40357330f729Sjoerg<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> 40367330f729Sjoerg<tr><td colspan="4" class="doc" id="equals12"><pre></pre></td></tr> 40377330f729Sjoerg 40387330f729Sjoerg 4039*e038c9c4Sjoerg<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> 4040*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName1"><pre>Matches overloaded operator names. 4041*e038c9c4Sjoerg 4042*e038c9c4SjoergMatches overloaded operator names specified in strings without the 4043*e038c9c4Sjoerg"operator" prefix: e.g. "<<". 4044*e038c9c4Sjoerg 4045*e038c9c4Sjoerg hasAnyOverloadedOperatorName("+", "-") 4046*e038c9c4SjoergIs equivalent to 4047*e038c9c4Sjoerg anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-")) 4048*e038c9c4Sjoerg</pre></td></tr> 4049*e038c9c4Sjoerg 4050*e038c9c4Sjoerg 40517330f729Sjoerg<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> 40527330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification. 40537330f729Sjoerg 40547330f729SjoergGiven: 40557330f729Sjoerg void f(); 40567330f729Sjoerg void g() noexcept; 40577330f729Sjoerg void h() noexcept(true); 40587330f729Sjoerg void i() noexcept(false); 40597330f729Sjoerg void j() throw(); 40607330f729Sjoerg void k() throw(int); 40617330f729Sjoerg void l() throw(...); 40627330f729SjoergfunctionDecl(hasDynamicExceptionSpec()) and 40637330f729Sjoerg functionProtoType(hasDynamicExceptionSpec()) 40647330f729Sjoerg match the declarations of j, k, and l, but not f, g, h, or i. 40657330f729Sjoerg</pre></td></tr> 40667330f729Sjoerg 40677330f729Sjoerg 40687330f729Sjoerg<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> 40697330f729Sjoerg<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. 40707330f729Sjoerg 40717330f729SjoergMatches overloaded operator names specified in strings without the 40727330f729Sjoerg"operator" prefix: e.g. "<<". 40737330f729Sjoerg 40747330f729SjoergGiven: 40757330f729Sjoerg class A { int operator*(); }; 40767330f729Sjoerg const A &operator<<(const A &a, const A &b); 40777330f729Sjoerg A a; 40787330f729Sjoerg a << a; // <-- This matches 40797330f729Sjoerg 40807330f729SjoergcxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the 40817330f729Sjoergspecified line and 40827330f729SjoergcxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) 40837330f729Sjoergmatches the declaration of A. 40847330f729Sjoerg 40857330f729SjoergUsable 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>> 40867330f729Sjoerg</pre></td></tr> 40877330f729Sjoerg 40887330f729Sjoerg 40897330f729Sjoerg<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> 40907330f729Sjoerg<tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type. 40917330f729Sjoerg 40927330f729SjoergExample matches Y (matcher = functionDecl(hasTrailingReturn())) 40937330f729Sjoergint X() {} 40947330f729Sjoergauto Y() -> int {} 40957330f729Sjoerg</pre></td></tr> 40967330f729Sjoerg 40977330f729Sjoerg 40987330f729Sjoerg<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> 40997330f729Sjoerg<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations, 41007330f729Sjoerg and if constexpr. 41017330f729Sjoerg 41027330f729SjoergGiven: 41037330f729Sjoerg constexpr int foo = 42; 41047330f729Sjoerg constexpr int bar(); 41057330f729Sjoerg void baz() { if constexpr(1 > 0) {} } 41067330f729SjoergvarDecl(isConstexpr()) 41077330f729Sjoerg matches the declaration of foo. 41087330f729SjoergfunctionDecl(isConstexpr()) 41097330f729Sjoerg matches the declaration of bar. 41107330f729SjoergifStmt(isConstexpr()) 41117330f729Sjoerg matches the if statement in baz. 41127330f729Sjoerg</pre></td></tr> 41137330f729Sjoerg 41147330f729Sjoerg 41157330f729Sjoerg<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> 41167330f729Sjoerg<tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations. 41177330f729Sjoerg 41187330f729SjoergGiven: 41197330f729Sjoerg class A { ~A(); }; 41207330f729Sjoerg class B { ~B() = default; }; 41217330f729SjoergfunctionDecl(isDefaulted()) 41227330f729Sjoerg matches the declaration of ~B, but not ~A. 41237330f729Sjoerg</pre></td></tr> 41247330f729Sjoerg 41257330f729Sjoerg 41267330f729Sjoerg<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> 41277330f729Sjoerg<tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached. 41287330f729Sjoerg 41297330f729SjoergExample matches A, va, fa 41307330f729Sjoerg class A {}; 41317330f729Sjoerg class B; // Doesn't match, as it has no body. 41327330f729Sjoerg int va; 41337330f729Sjoerg extern int vb; // Doesn't match, as it doesn't define the variable. 41347330f729Sjoerg void fa() {} 41357330f729Sjoerg void fb(); // Doesn't match, as it has no body. 41367330f729Sjoerg @interface X 41377330f729Sjoerg - (void)ma; // Doesn't match, interface is declaration. 41387330f729Sjoerg @end 41397330f729Sjoerg @implementation X 41407330f729Sjoerg - (void)ma {} 41417330f729Sjoerg @end 41427330f729Sjoerg 41437330f729SjoergUsable 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>>, 41447330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 41457330f729Sjoerg</pre></td></tr> 41467330f729Sjoerg 41477330f729Sjoerg 41487330f729Sjoerg<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> 41497330f729Sjoerg<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. 41507330f729Sjoerg 41517330f729SjoergGiven: 41527330f729Sjoerg void Func(); 41537330f729Sjoerg void DeletedFunc() = delete; 41547330f729SjoergfunctionDecl(isDeleted()) 41557330f729Sjoerg matches the declaration of DeletedFunc, but not Func. 41567330f729Sjoerg</pre></td></tr> 41577330f729Sjoerg 41587330f729Sjoerg 41597330f729Sjoerg<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> 41607330f729Sjoerg<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or 41617330f729Sjoergstatic member variable template instantiations. 41627330f729Sjoerg 41637330f729SjoergGiven 41647330f729Sjoerg template<typename T> void A(T t) { } 41657330f729Sjoerg template<> void A(int N) { } 41667330f729SjoergfunctionDecl(isExplicitTemplateSpecialization()) 41677330f729Sjoerg matches the specialization A<int>(). 41687330f729Sjoerg 41697330f729SjoergUsable 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>> 41707330f729Sjoerg</pre></td></tr> 41717330f729Sjoerg 41727330f729Sjoerg 41737330f729Sjoerg<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> 41747330f729Sjoerg<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations. 41757330f729Sjoerg 41767330f729SjoergGiven: 41777330f729Sjoerg extern "C" void f() {} 41787330f729Sjoerg extern "C" { void g() {} } 41797330f729Sjoerg void h() {} 41807330f729Sjoerg extern "C" int x = 1; 41817330f729Sjoerg extern "C" int y = 2; 41827330f729Sjoerg int z = 3; 41837330f729SjoergfunctionDecl(isExternC()) 41847330f729Sjoerg matches the declaration of f and g, but not the declaration of h. 41857330f729SjoergvarDecl(isExternC()) 41867330f729Sjoerg matches the declaration of x and y, but not the declaration of z. 41877330f729Sjoerg</pre></td></tr> 41887330f729Sjoerg 41897330f729Sjoerg 41907330f729Sjoerg<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> 41917330f729Sjoerg<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with 41927330f729Sjoergthe inline keyword. 41937330f729Sjoerg 41947330f729SjoergGiven 41957330f729Sjoerg inline void f(); 41967330f729Sjoerg void g(); 41977330f729Sjoerg namespace n { 41987330f729Sjoerg inline namespace m {} 41997330f729Sjoerg } 42007330f729SjoergfunctionDecl(isInline()) will match ::f(). 42017330f729SjoergnamespaceDecl(isInline()) will match n::m. 42027330f729Sjoerg</pre></td></tr> 42037330f729Sjoerg 42047330f729Sjoerg 42057330f729Sjoerg<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> 42067330f729Sjoerg<tr><td colspan="4" class="doc" id="isMain0"><pre>Determines whether the function is "main", which is the entry point 42077330f729Sjoerginto an executable program. 42087330f729Sjoerg</pre></td></tr> 42097330f729Sjoerg 42107330f729Sjoerg 42117330f729Sjoerg<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> 42127330f729Sjoerg<tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute. 42137330f729Sjoerg 42147330f729SjoergGiven 42157330f729Sjoerg void nope(); 42167330f729Sjoerg [[noreturn]] void a(); 42177330f729Sjoerg __attribute__((noreturn)) void b(); 42187330f729Sjoerg struct c { [[noreturn]] c(); }; 42197330f729SjoergfunctionDecl(isNoReturn()) 42207330f729Sjoerg matches all of those except 42217330f729Sjoerg void nope(); 42227330f729Sjoerg</pre></td></tr> 42237330f729Sjoerg 42247330f729Sjoerg 42257330f729Sjoerg<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> 42267330f729Sjoerg<tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification. 42277330f729Sjoerg 42287330f729SjoergGiven: 42297330f729Sjoerg void f(); 42307330f729Sjoerg void g() noexcept; 42317330f729Sjoerg void h() throw(); 42327330f729Sjoerg void i() throw(int); 42337330f729Sjoerg void j() noexcept(false); 42347330f729SjoergfunctionDecl(isNoThrow()) and functionProtoType(isNoThrow()) 42357330f729Sjoerg match the declarations of g, and h, but not f, i or j. 42367330f729Sjoerg</pre></td></tr> 42377330f729Sjoerg 42387330f729Sjoerg 42397330f729Sjoerg<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> 42407330f729Sjoerg<tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variable/function declarations that have "static" storage 42417330f729Sjoergclass specifier ("static" keyword) written in the source. 42427330f729Sjoerg 42437330f729SjoergGiven: 42447330f729Sjoerg static void f() {} 42457330f729Sjoerg static int i = 0; 42467330f729Sjoerg extern int j; 42477330f729Sjoerg int k; 42487330f729SjoergfunctionDecl(isStaticStorageClass()) 42497330f729Sjoerg matches the function declaration f. 42507330f729SjoergvarDecl(isStaticStorageClass()) 42517330f729Sjoerg matches the variable declaration i. 42527330f729Sjoerg</pre></td></tr> 42537330f729Sjoerg 42547330f729Sjoerg 42557330f729Sjoerg<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> 42567330f729Sjoerg<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 42577330f729Sjoergmember variable template instantiations. 42587330f729Sjoerg 42597330f729SjoergGiven 42607330f729Sjoerg template <typename T> class X {}; class A {}; X<A> x; 42617330f729Sjoergor 42627330f729Sjoerg template <typename T> class X {}; class A {}; template class X<A>; 42637330f729Sjoergor 42647330f729Sjoerg template <typename T> class X {}; class A {}; extern template class X<A>; 42657330f729SjoergcxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 42667330f729Sjoerg matches the template instantiation of X<A>. 42677330f729Sjoerg 42687330f729SjoergBut given 42697330f729Sjoerg template <typename T> class X {}; class A {}; 42707330f729Sjoerg template <> class X<A> {}; X<A> x; 42717330f729SjoergcxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 42727330f729Sjoerg does not match, as X<A> is an explicit template specialization. 42737330f729Sjoerg 42747330f729SjoergUsable 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>> 42757330f729Sjoerg</pre></td></tr> 42767330f729Sjoerg 42777330f729Sjoerg 42787330f729Sjoerg<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> 42797330f729Sjoerg<tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. 42807330f729Sjoerg 42817330f729SjoergExample matches f, but not g or h. The function i will not match, even when 42827330f729Sjoergcompiled in C mode. 42837330f729Sjoerg void f(...); 42847330f729Sjoerg void g(int); 42857330f729Sjoerg template <typename... Ts> void h(Ts...); 42867330f729Sjoerg void i(); 42877330f729Sjoerg</pre></td></tr> 42887330f729Sjoerg 42897330f729Sjoerg 4290*e038c9c4Sjoerg<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> 4291*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isWeak0"><pre>Matches weak function declarations. 4292*e038c9c4Sjoerg 4293*e038c9c4SjoergGiven: 4294*e038c9c4Sjoerg void foo() __attribute__((__weakref__("__foo"))); 4295*e038c9c4Sjoerg void bar(); 4296*e038c9c4SjoergfunctionDecl(isWeak()) 4297*e038c9c4Sjoerg matches the weak declaration "foo", but not "bar". 4298*e038c9c4Sjoerg</pre></td></tr> 4299*e038c9c4Sjoerg 4300*e038c9c4Sjoerg 43017330f729Sjoerg<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> 43027330f729Sjoerg<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a 43037330f729Sjoergspecific parameter count. 43047330f729Sjoerg 43057330f729SjoergGiven 43067330f729Sjoerg void f(int i) {} 43077330f729Sjoerg void g(int i, int j) {} 43087330f729Sjoerg void h(int i, int j); 43097330f729Sjoerg void j(int i); 43107330f729Sjoerg void k(int x, int y, int z, ...); 43117330f729SjoergfunctionDecl(parameterCountIs(2)) 43127330f729Sjoerg matches g and h 43137330f729SjoergfunctionProtoType(parameterCountIs(2)) 43147330f729Sjoerg matches g and h 43157330f729SjoergfunctionProtoType(parameterCountIs(3)) 43167330f729Sjoerg matches k 43177330f729Sjoerg</pre></td></tr> 43187330f729Sjoerg 43197330f729Sjoerg 43207330f729Sjoerg<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> 43217330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification. 43227330f729Sjoerg 43237330f729SjoergGiven: 43247330f729Sjoerg void f(); 43257330f729Sjoerg void g() noexcept; 43267330f729Sjoerg void h() noexcept(true); 43277330f729Sjoerg void i() noexcept(false); 43287330f729Sjoerg void j() throw(); 43297330f729Sjoerg void k() throw(int); 43307330f729Sjoerg void l() throw(...); 43317330f729SjoergfunctionDecl(hasDynamicExceptionSpec()) and 43327330f729Sjoerg functionProtoType(hasDynamicExceptionSpec()) 43337330f729Sjoerg match the declarations of j, k, and l, but not f, g, h, or i. 43347330f729Sjoerg</pre></td></tr> 43357330f729Sjoerg 43367330f729Sjoerg 43377330f729Sjoerg<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> 43387330f729Sjoerg<tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification. 43397330f729Sjoerg 43407330f729SjoergGiven: 43417330f729Sjoerg void f(); 43427330f729Sjoerg void g() noexcept; 43437330f729Sjoerg void h() throw(); 43447330f729Sjoerg void i() throw(int); 43457330f729Sjoerg void j() noexcept(false); 43467330f729SjoergfunctionDecl(isNoThrow()) and functionProtoType(isNoThrow()) 43477330f729Sjoerg match the declarations of g, and h, but not f, i or j. 43487330f729Sjoerg</pre></td></tr> 43497330f729Sjoerg 43507330f729Sjoerg 43517330f729Sjoerg<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> 43527330f729Sjoerg<tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a 43537330f729Sjoergspecific parameter count. 43547330f729Sjoerg 43557330f729SjoergGiven 43567330f729Sjoerg void f(int i) {} 43577330f729Sjoerg void g(int i, int j) {} 43587330f729Sjoerg void h(int i, int j); 43597330f729Sjoerg void j(int i); 43607330f729Sjoerg void k(int x, int y, int z, ...); 43617330f729SjoergfunctionDecl(parameterCountIs(2)) 43627330f729Sjoerg matches g and h 43637330f729SjoergfunctionProtoType(parameterCountIs(2)) 43647330f729Sjoerg matches g and h 43657330f729SjoergfunctionProtoType(parameterCountIs(3)) 43667330f729Sjoerg matches k 43677330f729Sjoerg</pre></td></tr> 43687330f729Sjoerg 43697330f729Sjoerg 43707330f729Sjoerg<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> 43717330f729Sjoerg<tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations, 43727330f729Sjoerg and if constexpr. 43737330f729Sjoerg 43747330f729SjoergGiven: 43757330f729Sjoerg constexpr int foo = 42; 43767330f729Sjoerg constexpr int bar(); 43777330f729Sjoerg void baz() { if constexpr(1 > 0) {} } 43787330f729SjoergvarDecl(isConstexpr()) 43797330f729Sjoerg matches the declaration of foo. 43807330f729SjoergfunctionDecl(isConstexpr()) 43817330f729Sjoerg matches the declaration of bar. 43827330f729SjoergifStmt(isConstexpr()) 43837330f729Sjoerg matches the if statement in baz. 43847330f729Sjoerg</pre></td></tr> 43857330f729Sjoerg 43867330f729Sjoerg 43877330f729Sjoerg<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> 43887330f729Sjoerg<tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr> 43897330f729Sjoerg 43907330f729Sjoerg 43917330f729Sjoerg<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> 43927330f729Sjoerg<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT. 43937330f729Sjoerg 43947330f729SjoergGiven 43957330f729Sjoerg f('false, 3.14, 42); 43967330f729SjoergcharacterLiteral(equals(0)) 43977330f729Sjoerg matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 43987330f729Sjoerg match false 43997330f729SjoergfloatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 44007330f729Sjoerg match 3.14 44017330f729SjoergintegerLiteral(equals(42)) 44027330f729Sjoerg matches 42 44037330f729Sjoerg 44047330f729SjoergNote that you cannot directly match a negative numeric literal because the 44057330f729Sjoergminus sign is not part of the literal: It is a unary operator whose operand 44067330f729Sjoergis the positive numeric literal. Instead, you must use a unaryOperator() 44077330f729Sjoergmatcher to match the minus sign: 44087330f729Sjoerg 44097330f729SjoergunaryOperator(hasOperatorName("-"), 44107330f729Sjoerg hasUnaryOperand(integerLiteral(equals(13)))) 44117330f729Sjoerg 44127330f729SjoergUsable 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>>, 44137330f729Sjoerg 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>> 44147330f729Sjoerg</pre></td></tr> 44157330f729Sjoerg 44167330f729Sjoerg 44177330f729Sjoerg<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> 44187330f729Sjoerg<tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr> 44197330f729Sjoerg 44207330f729Sjoerg 44217330f729Sjoerg<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> 44227330f729Sjoerg<tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr> 44237330f729Sjoerg 44247330f729Sjoerg 44257330f729Sjoerg<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> 44267330f729Sjoerg<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 44277330f729Sjoergto '.'. 44287330f729Sjoerg 44297330f729SjoergMember calls on the implicit this pointer match as called with '->'. 44307330f729Sjoerg 44317330f729SjoergGiven 44327330f729Sjoerg class Y { 44337330f729Sjoerg void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 44347330f729Sjoerg template <class T> void f() { this->f<T>(); f<T>(); } 44357330f729Sjoerg int a; 44367330f729Sjoerg static int b; 44377330f729Sjoerg }; 44387330f729Sjoerg template <class T> 44397330f729Sjoerg class Z { 44407330f729Sjoerg void x() { this->m; } 44417330f729Sjoerg }; 44427330f729SjoergmemberExpr(isArrow()) 44437330f729Sjoerg matches this->x, x, y.x, a, this->b 44447330f729SjoergcxxDependentScopeMemberExpr(isArrow()) 44457330f729Sjoerg matches this->m 44467330f729SjoergunresolvedMemberExpr(isArrow()) 44477330f729Sjoerg matches this->f<T>, f<T> 44487330f729Sjoerg</pre></td></tr> 44497330f729Sjoerg 44507330f729Sjoerg 4451*e038c9c4Sjoerg<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> 4452*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names. 4453*e038c9c4Sjoerg 4454*e038c9c4SjoergThis matcher is only provided as a performance optimization of hasName. 4455*e038c9c4Sjoerg hasAnyName(a, b, c) 4456*e038c9c4Sjoerg is equivalent to, but faster than 4457*e038c9c4Sjoerg anyOf(hasName(a), hasName(b), hasName(c)) 4458*e038c9c4Sjoerg</pre></td></tr> 4459*e038c9c4Sjoerg 4460*e038c9c4Sjoerg 44617330f729Sjoerg<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> 44627330f729Sjoerg<tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage. 44637330f729Sjoerg 44647330f729SjoergExample matches only z (matcher = varDecl(hasExternalFormalLinkage())) 44657330f729Sjoergvoid f() { 44667330f729Sjoerg int x; 44677330f729Sjoerg static int y; 44687330f729Sjoerg} 44697330f729Sjoergint z; 44707330f729Sjoerg 44717330f729SjoergExample matches f() because it has external formal linkage despite being 44727330f729Sjoergunique to the translation unit as though it has internal likage 44737330f729Sjoerg(matcher = functionDecl(hasExternalFormalLinkage())) 44747330f729Sjoerg 44757330f729Sjoergnamespace { 44767330f729Sjoergvoid f() {} 44777330f729Sjoerg} 44787330f729Sjoerg</pre></td></tr> 44797330f729Sjoerg 44807330f729Sjoerg 4481*e038c9c4Sjoerg<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> 44827330f729Sjoerg<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 44837330f729Sjoerg 44847330f729SjoergSupports specifying enclosing namespaces or classes by prefixing the name 44857330f729Sjoergwith '<enclosing>::'. 44867330f729SjoergDoes not match typedefs of an underlying type with the given name. 44877330f729Sjoerg 44887330f729SjoergExample matches X (Name == "X") 44897330f729Sjoerg class X; 44907330f729Sjoerg 44917330f729SjoergExample matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 44927330f729Sjoerg namespace a { namespace b { class X; } } 44937330f729Sjoerg</pre></td></tr> 44947330f729Sjoerg 44957330f729Sjoerg 4496*e038c9c4Sjoerg<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> 44977330f729Sjoerg<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain 44987330f729Sjoerga substring matched by the given RegExp. 44997330f729Sjoerg 45007330f729SjoergSupports specifying enclosing namespaces or classes by 45017330f729Sjoergprefixing the name with '<enclosing>::'. Does not match typedefs 45027330f729Sjoergof an underlying type with the given name. 45037330f729Sjoerg 45047330f729SjoergExample matches X (regexp == "::X") 45057330f729Sjoerg class X; 45067330f729Sjoerg 45077330f729SjoergExample matches X (regexp is one of "::X", "^foo::.*X", among others) 45087330f729Sjoerg namespace foo { namespace bar { class X; } } 4509*e038c9c4Sjoerg 4510*e038c9c4SjoergIf the matcher is used in clang-query, RegexFlags parameter 4511*e038c9c4Sjoergshould be passed as a quoted string. e.g: "NoFlags". 4512*e038c9c4SjoergFlags can be combined with '|' example "IgnoreCase | BasicRegex" 45137330f729Sjoerg</pre></td></tr> 45147330f729Sjoerg 45157330f729Sjoerg 45167330f729Sjoerg<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> 45177330f729Sjoerg<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. 45187330f729Sjoerg 45197330f729SjoergGiven 45207330f729Sjoerg namespace n { 45217330f729Sjoerg namespace {} // #1 45227330f729Sjoerg } 45237330f729SjoergnamespaceDecl(isAnonymous()) will match #1 but not ::n. 45247330f729Sjoerg</pre></td></tr> 45257330f729Sjoerg 45267330f729Sjoerg 45277330f729Sjoerg<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> 45287330f729Sjoerg<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with 45297330f729Sjoergthe inline keyword. 45307330f729Sjoerg 45317330f729SjoergGiven 45327330f729Sjoerg inline void f(); 45337330f729Sjoerg void g(); 45347330f729Sjoerg namespace n { 45357330f729Sjoerg inline namespace m {} 45367330f729Sjoerg } 45377330f729SjoergfunctionDecl(isInline()) will match ::f(). 45387330f729SjoergnamespaceDecl(isInline()) will match n::m. 45397330f729Sjoerg</pre></td></tr> 45407330f729Sjoerg 45417330f729Sjoerg 4542*e038c9c4Sjoerg<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> 4543*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isFirstPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``firstprivate`` kind 4544*e038c9c4Sjoergspecified. 4545*e038c9c4Sjoerg 4546*e038c9c4SjoergGiven 4547*e038c9c4Sjoerg 4548*e038c9c4Sjoerg #pragma omp parallel 4549*e038c9c4Sjoerg #pragma omp parallel default(none) 4550*e038c9c4Sjoerg #pragma omp parallel default(shared) 4551*e038c9c4Sjoerg #pragma omp parallel default(firstprivate) 4552*e038c9c4Sjoerg 4553*e038c9c4Sjoerg``ompDefaultClause(isFirstPrivateKind())`` matches only 4554*e038c9c4Sjoerg``default(firstprivate)``. 4555*e038c9c4Sjoerg</pre></td></tr> 4556*e038c9c4Sjoerg 4557*e038c9c4Sjoerg 45587330f729Sjoerg<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> 45597330f729Sjoerg<tr><td colspan="4" class="doc" id="isNoneKind0"><pre>Matches if the OpenMP ``default`` clause has ``none`` kind specified. 45607330f729Sjoerg 45617330f729SjoergGiven 45627330f729Sjoerg 45637330f729Sjoerg #pragma omp parallel 45647330f729Sjoerg #pragma omp parallel default(none) 45657330f729Sjoerg #pragma omp parallel default(shared) 4566*e038c9c4Sjoerg #pragma omp parallel default(firstprivate) 45677330f729Sjoerg 45687330f729Sjoerg``ompDefaultClause(isNoneKind())`` matches only ``default(none)``. 45697330f729Sjoerg</pre></td></tr> 45707330f729Sjoerg 45717330f729Sjoerg 45727330f729Sjoerg<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> 45737330f729Sjoerg<tr><td colspan="4" class="doc" id="isSharedKind0"><pre>Matches if the OpenMP ``default`` clause has ``shared`` kind specified. 45747330f729Sjoerg 45757330f729SjoergGiven 45767330f729Sjoerg 45777330f729Sjoerg #pragma omp parallel 45787330f729Sjoerg #pragma omp parallel default(none) 45797330f729Sjoerg #pragma omp parallel default(shared) 4580*e038c9c4Sjoerg #pragma omp parallel default(firstprivate) 45817330f729Sjoerg 45827330f729Sjoerg``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``. 45837330f729Sjoerg</pre></td></tr> 45847330f729Sjoerg 45857330f729Sjoerg 45867330f729Sjoerg<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> 45877330f729Sjoerg<tr><td colspan="4" class="doc" id="isAllowedToContainClauseKind0"><pre>Matches if the OpenMP directive is allowed to contain the specified OpenMP 45887330f729Sjoergclause kind. 45897330f729Sjoerg 45907330f729SjoergGiven 45917330f729Sjoerg 45927330f729Sjoerg #pragma omp parallel 45937330f729Sjoerg #pragma omp parallel for 45947330f729Sjoerg #pragma omp for 45957330f729Sjoerg 45967330f729Sjoerg`ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches 45977330f729Sjoerg``omp parallel`` and ``omp parallel for``. 45987330f729Sjoerg 45997330f729SjoergIf the matcher is use from clang-query, ``OpenMPClauseKind`` parameter 46007330f729Sjoergshould be passed as a quoted string. e.g., 46017330f729Sjoerg``isAllowedToContainClauseKind("OMPC_default").`` 46027330f729Sjoerg</pre></td></tr> 46037330f729Sjoerg 46047330f729Sjoerg 46057330f729Sjoerg<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> 46067330f729Sjoerg<tr><td colspan="4" class="doc" id="isStandaloneDirective0"><pre>Matches standalone OpenMP directives, 46077330f729Sjoergi.e., directives that can't have a structured block. 46087330f729Sjoerg 46097330f729SjoergGiven 46107330f729Sjoerg 46117330f729Sjoerg #pragma omp parallel 46127330f729Sjoerg {} 46137330f729Sjoerg #pragma omp taskyield 46147330f729Sjoerg 46157330f729Sjoerg``ompExecutableDirective(isStandaloneDirective()))`` matches 46167330f729Sjoerg``omp taskyield``. 46177330f729Sjoerg</pre></td></tr> 46187330f729Sjoerg 46197330f729Sjoerg 46207330f729Sjoerg<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> 46217330f729Sjoerg<tr><td colspan="4" class="doc" id="isDerivedFrom3"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). 46227330f729Sjoerg</pre></td></tr> 46237330f729Sjoerg 46247330f729Sjoerg 46257330f729Sjoerg<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> 46267330f729Sjoerg<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom3"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)). 46277330f729Sjoerg</pre></td></tr> 46287330f729Sjoerg 46297330f729Sjoerg 46307330f729Sjoerg<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> 46317330f729Sjoerg<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom3"><pre>Overloaded method as shortcut for 46327330f729SjoergisSameOrDerivedFrom(hasName(...)). 46337330f729Sjoerg</pre></td></tr> 46347330f729Sjoerg 46357330f729Sjoerg 4636*e038c9c4Sjoerg<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> 4637*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="argumentCountIs3"><pre>Checks that a call expression or a constructor call expression has 46387330f729Sjoerga specific number of arguments (including absent default arguments). 46397330f729Sjoerg 46407330f729SjoergExample matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 46417330f729Sjoerg void f(int x, int y); 46427330f729Sjoerg f(0, 0); 46437330f729Sjoerg</pre></td></tr> 46447330f729Sjoerg 46457330f729Sjoerg 4646*e038c9c4Sjoerg<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> 4647*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the 4648*e038c9c4SjoergSelector.getAsString() 4649*e038c9c4Sjoerg 4650*e038c9c4Sjoerg matcher = objCMessageExpr(hasSelector("methodA:", "methodB:")); 4651*e038c9c4Sjoerg matches both of the expressions below: 4652*e038c9c4Sjoerg [myObj methodA:argA]; 4653*e038c9c4Sjoerg [myObj methodB:argB]; 4654*e038c9c4Sjoerg</pre></td></tr> 4655*e038c9c4Sjoerg 4656*e038c9c4Sjoerg 46577330f729Sjoerg<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> 46587330f729Sjoerg<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector 46597330f729Sjoerg 46607330f729SjoergobjCMessageExpr(hasKeywordSelector()) matches the generated setFrame 46617330f729Sjoergmessage expression in 46627330f729Sjoerg 46637330f729Sjoerg UIWebView *webView = ...; 46647330f729Sjoerg CGRect bodyFrame = webView.frame; 46657330f729Sjoerg bodyFrame.size.height = self.bodyContentHeight; 46667330f729Sjoerg webView.frame = bodyFrame; 46677330f729Sjoerg // ^---- matches here 46687330f729Sjoerg</pre></td></tr> 46697330f729Sjoerg 46707330f729Sjoerg 46717330f729Sjoerg<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> 46727330f729Sjoerg<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector 46737330f729Sjoerg 46747330f729SjoergMatches only when the selector of the objCMessageExpr is NULL. This may 46757330f729Sjoergrepresent an error condition in the tree! 46767330f729Sjoerg</pre></td></tr> 46777330f729Sjoerg 46787330f729Sjoerg 46797330f729Sjoerg<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> 46807330f729Sjoerg<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() 46817330f729Sjoerg 46827330f729Sjoerg matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); 46837330f729Sjoerg matches the outer message expr in the code below, but NOT the message 46847330f729Sjoerg invocation for self.bodyView. 46857330f729Sjoerg [self.bodyView loadHTMLString:html baseURL:NULL]; 46867330f729Sjoerg</pre></td></tr> 46877330f729Sjoerg 46887330f729Sjoerg 46897330f729Sjoerg<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> 46907330f729Sjoerg<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector 46917330f729Sjoerg 46927330f729Sjoerg matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); 46937330f729Sjoerg matches self.bodyView in the code below, but NOT the outer message 46947330f729Sjoerg invocation of "loadHTMLString:baseURL:". 46957330f729Sjoerg [self.bodyView loadHTMLString:html baseURL:NULL]; 46967330f729Sjoerg</pre></td></tr> 46977330f729Sjoerg 46987330f729Sjoerg 46997330f729Sjoerg<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> 47007330f729Sjoerg<tr><td colspan="4" class="doc" id="isClassMessage0"><pre>Returns true when the Objective-C message is sent to a class. 47017330f729Sjoerg 47027330f729SjoergExample 47037330f729Sjoergmatcher = objcMessageExpr(isClassMessage()) 47047330f729Sjoergmatches 47057330f729Sjoerg [NSString stringWithFormat:@"format"]; 47067330f729Sjoergbut not 47077330f729Sjoerg NSString *x = @"hello"; 47087330f729Sjoerg [x containsString:@"h"]; 47097330f729Sjoerg</pre></td></tr> 47107330f729Sjoerg 47117330f729Sjoerg 47127330f729Sjoerg<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> 47137330f729Sjoerg<tr><td colspan="4" class="doc" id="isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance. 47147330f729Sjoerg 47157330f729SjoergExample 47167330f729Sjoergmatcher = objcMessageExpr(isInstanceMessage()) 47177330f729Sjoergmatches 47187330f729Sjoerg NSString *x = @"hello"; 47197330f729Sjoerg [x containsString:@"h"]; 47207330f729Sjoergbut not 47217330f729Sjoerg [NSString stringWithFormat:@"format"]; 47227330f729Sjoerg</pre></td></tr> 47237330f729Sjoerg 47247330f729Sjoerg 4725*e038c9c4Sjoerg<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> 47267330f729Sjoerg<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains 47277330f729Sjoerga substring matched by the given RegExp. 47287330f729Sjoerg matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message 47297330f729Sjoerg invocation for self.bodyView. 47307330f729Sjoerg [self.bodyView loadHTMLString:html baseURL:NULL]; 4731*e038c9c4Sjoerg 4732*e038c9c4SjoergIf the matcher is used in clang-query, RegexFlags parameter 4733*e038c9c4Sjoergshould be passed as a quoted string. e.g: "NoFlags". 4734*e038c9c4SjoergFlags can be combined with '|' example "IgnoreCase | BasicRegex" 47357330f729Sjoerg</pre></td></tr> 47367330f729Sjoerg 47377330f729Sjoerg 47387330f729Sjoerg<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> 47397330f729Sjoerg<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments 47407330f729Sjoerg 47417330f729Sjoerg matcher = objCMessageExpr(numSelectorArgs(0)); 47427330f729Sjoerg matches self.bodyView in the code below 47437330f729Sjoerg 47447330f729Sjoerg matcher = objCMessageExpr(numSelectorArgs(2)); 47457330f729Sjoerg matches the invocation of "loadHTMLString:baseURL:" but not that 47467330f729Sjoerg of self.bodyView 47477330f729Sjoerg [self.bodyView loadHTMLString:html baseURL:NULL]; 47487330f729Sjoerg</pre></td></tr> 47497330f729Sjoerg 47507330f729Sjoerg 47517330f729Sjoerg<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> 47527330f729Sjoerg<tr><td colspan="4" class="doc" id="isClassMethod0"><pre>Returns true when the Objective-C method declaration is a class method. 47537330f729Sjoerg 47547330f729SjoergExample 47557330f729Sjoergmatcher = objcMethodDecl(isClassMethod()) 47567330f729Sjoergmatches 47577330f729Sjoerg@interface I + (void)foo; @end 47587330f729Sjoergbut not 47597330f729Sjoerg@interface I - (void)bar; @end 47607330f729Sjoerg</pre></td></tr> 47617330f729Sjoerg 47627330f729Sjoerg 47637330f729Sjoerg<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> 47647330f729Sjoerg<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. 47657330f729Sjoerg 47667330f729SjoergExample matches A, va, fa 47677330f729Sjoerg class A {}; 47687330f729Sjoerg class B; // Doesn't match, as it has no body. 47697330f729Sjoerg int va; 47707330f729Sjoerg extern int vb; // Doesn't match, as it doesn't define the variable. 47717330f729Sjoerg void fa() {} 47727330f729Sjoerg void fb(); // Doesn't match, as it has no body. 47737330f729Sjoerg @interface X 47747330f729Sjoerg - (void)ma; // Doesn't match, interface is declaration. 47757330f729Sjoerg @end 47767330f729Sjoerg @implementation X 47777330f729Sjoerg - (void)ma {} 47787330f729Sjoerg @end 47797330f729Sjoerg 47807330f729SjoergUsable 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>>, 47817330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 47827330f729Sjoerg</pre></td></tr> 47837330f729Sjoerg 47847330f729Sjoerg 47857330f729Sjoerg<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> 47867330f729Sjoerg<tr><td colspan="4" class="doc" id="isInstanceMethod0"><pre>Returns true when the Objective-C method declaration is an instance method. 47877330f729Sjoerg 47887330f729SjoergExample 47897330f729Sjoergmatcher = objcMethodDecl(isInstanceMethod()) 47907330f729Sjoergmatches 47917330f729Sjoerg@interface I - (void)bar; @end 47927330f729Sjoergbut not 47937330f729Sjoerg@interface I + (void)foo; @end 47947330f729Sjoerg</pre></td></tr> 47957330f729Sjoerg 47967330f729Sjoerg 47977330f729Sjoerg<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> 47987330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments. 47997330f729Sjoerg 48007330f729SjoergExample matches y (matcher = parmVarDecl(hasDefaultArgument())) 48017330f729Sjoergvoid x(int val) {} 48027330f729Sjoergvoid y(int val = 0) {} 4803*e038c9c4Sjoerg 4804*e038c9c4SjoergDeprecated. Use hasInitializer() instead to be able to 4805*e038c9c4Sjoergmatch on the contents of the default argument. For example: 4806*e038c9c4Sjoerg 4807*e038c9c4Sjoergvoid x(int val = 7) {} 4808*e038c9c4Sjoergvoid y(int val = 42) {} 4809*e038c9c4SjoergparmVarDecl(hasInitializer(integerLiteral(equals(42)))) 4810*e038c9c4Sjoerg matches the parameter of y 4811*e038c9c4Sjoerg 4812*e038c9c4SjoergA matcher such as 4813*e038c9c4Sjoerg parmVarDecl(hasInitializer(anything())) 4814*e038c9c4Sjoergis equivalent to parmVarDecl(hasDefaultArgument()). 4815*e038c9c4Sjoerg</pre></td></tr> 4816*e038c9c4Sjoerg 4817*e038c9c4Sjoerg 4818*e038c9c4Sjoerg<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> 4819*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isAtPosition0"><pre>Matches the ParmVarDecl nodes that are at the N'th position in the parameter 4820*e038c9c4Sjoerglist. The parameter list could be that of either a block, function, or 4821*e038c9c4Sjoergobjc-method. 4822*e038c9c4Sjoerg 4823*e038c9c4Sjoerg 4824*e038c9c4SjoergGiven 4825*e038c9c4Sjoerg 4826*e038c9c4Sjoergvoid f(int a, int b, int c) { 4827*e038c9c4Sjoerg} 4828*e038c9c4Sjoerg 4829*e038c9c4Sjoerg``parmVarDecl(isAtPosition(0))`` matches ``int a``. 4830*e038c9c4Sjoerg 4831*e038c9c4Sjoerg``parmVarDecl(isAtPosition(1))`` matches ``int b``. 48327330f729Sjoerg</pre></td></tr> 48337330f729Sjoerg 48347330f729Sjoerg 48357330f729Sjoerg<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> 48367330f729Sjoerg<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 48377330f729Sjoerg 48387330f729SjoergGiven 48397330f729Sjoerg class Y { public: void x(); }; 48407330f729Sjoerg void z() { Y* y; y->x(); } 48417330f729SjoergcxxMemberCallExpr(on(hasType(asString("class Y *")))) 48427330f729Sjoerg matches y->x() 48437330f729Sjoerg</pre></td></tr> 48447330f729Sjoerg 48457330f729Sjoerg 48467330f729Sjoerg<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> 48477330f729Sjoerg<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. 48487330f729Sjoerg 48497330f729SjoergMatches a node if it equals the node previously bound to ID. 48507330f729Sjoerg 48517330f729SjoergGiven 48527330f729Sjoerg class X { int a; int b; }; 48537330f729SjoergcxxRecordDecl( 48547330f729Sjoerg has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 48557330f729Sjoerg has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 48567330f729Sjoerg matches the class X, as a and b have the same type. 48577330f729Sjoerg 48587330f729SjoergNote that when multiple matches are involved via forEach* matchers, 48597330f729SjoergequalsBoundNodes acts as a filter. 48607330f729SjoergFor example: 48617330f729SjoergcompoundStmt( 48627330f729Sjoerg forEachDescendant(varDecl().bind("d")), 48637330f729Sjoerg forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 48647330f729Sjoergwill trigger a match for each combination of variable declaration 48657330f729Sjoergand reference to that variable declaration within a compound statement. 48667330f729Sjoerg</pre></td></tr> 48677330f729Sjoerg 48687330f729Sjoerg 48697330f729Sjoerg<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> 48707330f729Sjoerg<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to 48717330f729Sjoergthe node, not hidden within a typedef. 48727330f729Sjoerg 48737330f729SjoergGiven 48747330f729Sjoerg typedef const int const_int; 48757330f729Sjoerg const_int i; 48767330f729Sjoerg int *const j; 48777330f729Sjoerg int *volatile k; 48787330f729Sjoerg int m; 48797330f729SjoergvarDecl(hasType(hasLocalQualifiers())) matches only j and k. 48807330f729Sjoergi is const-qualified but the qualifier is not local. 48817330f729Sjoerg</pre></td></tr> 48827330f729Sjoerg 48837330f729Sjoerg 48847330f729Sjoerg<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> 48857330f729Sjoerg<tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type. 48867330f729Sjoerg 48877330f729SjoergGiven 48887330f729Sjoerg void a(char); 48897330f729Sjoerg void b(wchar_t); 48907330f729Sjoerg void c(double); 48917330f729SjoergfunctionDecl(hasAnyParameter(hasType(isAnyCharacter()))) 48927330f729Sjoergmatches "a(char)", "b(wchar_t)", but not "c(double)". 48937330f729Sjoerg</pre></td></tr> 48947330f729Sjoerg 48957330f729Sjoerg 48967330f729Sjoerg<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> 48977330f729Sjoerg<tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes 48987330f729Sjoergthe Objective-C object pointer type, which is different despite being 48997330f729Sjoergsyntactically similar. 49007330f729Sjoerg 49017330f729SjoergGiven 49027330f729Sjoerg int *i = nullptr; 49037330f729Sjoerg 49047330f729Sjoerg @interface Foo 49057330f729Sjoerg @end 49067330f729Sjoerg Foo *f; 49077330f729Sjoerg 49087330f729Sjoerg int j; 49097330f729SjoergvarDecl(hasType(isAnyPointer())) 49107330f729Sjoerg matches "int *i" and "Foo *f", but not "int j". 49117330f729Sjoerg</pre></td></tr> 49127330f729Sjoerg 49137330f729Sjoerg 49147330f729Sjoerg<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> 49157330f729Sjoerg<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 49167330f729Sjoerginclude "top-level" const. 49177330f729Sjoerg 49187330f729SjoergGiven 49197330f729Sjoerg void a(int); 49207330f729Sjoerg void b(int const); 49217330f729Sjoerg void c(const int); 49227330f729Sjoerg void d(const int*); 49237330f729Sjoerg void e(int const) {}; 49247330f729SjoergfunctionDecl(hasAnyParameter(hasType(isConstQualified()))) 49257330f729Sjoerg matches "void b(int const)", "void c(const int)" and 49267330f729Sjoerg "void e(int const) {}". It does not match d as there 49277330f729Sjoerg is no top-level const on the parameter type "const int *". 49287330f729Sjoerg</pre></td></tr> 49297330f729Sjoerg 49307330f729Sjoerg 49317330f729Sjoerg<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> 49327330f729Sjoerg<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 49337330f729Sjoerg 49347330f729SjoergGiven 49357330f729Sjoerg void a(int); 49367330f729Sjoerg void b(long); 49377330f729Sjoerg void c(double); 49387330f729SjoergfunctionDecl(hasAnyParameter(hasType(isInteger()))) 49397330f729Sjoergmatches "a(int)", "b(long)", but not "c(double)". 49407330f729Sjoerg</pre></td></tr> 49417330f729Sjoerg 49427330f729Sjoerg 49437330f729Sjoerg<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> 49447330f729Sjoerg<tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type. 49457330f729Sjoerg 49467330f729SjoergGiven 49477330f729Sjoerg void a(int); 49487330f729Sjoerg void b(unsigned long); 49497330f729Sjoerg void c(double); 49507330f729SjoergfunctionDecl(hasAnyParameter(hasType(isSignedInteger()))) 49517330f729Sjoergmatches "a(int)", but not "b(unsigned long)" and "c(double)". 49527330f729Sjoerg</pre></td></tr> 49537330f729Sjoerg 49547330f729Sjoerg 49557330f729Sjoerg<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> 49567330f729Sjoerg<tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type. 49577330f729Sjoerg 49587330f729SjoergGiven 49597330f729Sjoerg void a(int); 49607330f729Sjoerg void b(unsigned long); 49617330f729Sjoerg void c(double); 49627330f729SjoergfunctionDecl(hasAnyParameter(hasType(isUnsignedInteger()))) 49637330f729Sjoergmatches "b(unsigned long)", but not "a(int)" and "c(double)". 49647330f729Sjoerg</pre></td></tr> 49657330f729Sjoerg 49667330f729Sjoerg 49677330f729Sjoerg<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> 49687330f729Sjoerg<tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that 49697330f729Sjoerginclude "top-level" volatile. 49707330f729Sjoerg 49717330f729SjoergGiven 49727330f729Sjoerg void a(int); 49737330f729Sjoerg void b(int volatile); 49747330f729Sjoerg void c(volatile int); 49757330f729Sjoerg void d(volatile int*); 49767330f729Sjoerg void e(int volatile) {}; 49777330f729SjoergfunctionDecl(hasAnyParameter(hasType(isVolatileQualified()))) 49787330f729Sjoerg matches "void b(int volatile)", "void c(volatile int)" and 49797330f729Sjoerg "void e(int volatile) {}". It does not match d as there 49807330f729Sjoerg is no top-level volatile on the parameter type "volatile int *". 49817330f729Sjoerg</pre></td></tr> 49827330f729Sjoerg 49837330f729Sjoerg 49847330f729Sjoerg<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> 49857330f729Sjoerg<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. 49867330f729Sjoerg 49877330f729SjoergMatches a node if it equals the node previously bound to ID. 49887330f729Sjoerg 49897330f729SjoergGiven 49907330f729Sjoerg class X { int a; int b; }; 49917330f729SjoergcxxRecordDecl( 49927330f729Sjoerg has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 49937330f729Sjoerg has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 49947330f729Sjoerg matches the class X, as a and b have the same type. 49957330f729Sjoerg 49967330f729SjoergNote that when multiple matches are involved via forEach* matchers, 49977330f729SjoergequalsBoundNodes acts as a filter. 49987330f729SjoergFor example: 49997330f729SjoergcompoundStmt( 50007330f729Sjoerg forEachDescendant(varDecl().bind("d")), 50017330f729Sjoerg forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 50027330f729Sjoergwill trigger a match for each combination of variable declaration 50037330f729Sjoergand reference to that variable declaration within a compound statement. 50047330f729Sjoerg</pre></td></tr> 50057330f729Sjoerg 50067330f729Sjoerg 50077330f729Sjoerg<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> 50087330f729Sjoerg<tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. 50097330f729Sjoerg 50107330f729SjoergStmt has pointer identity in the AST. 50117330f729Sjoerg</pre></td></tr> 50127330f729Sjoerg 50137330f729Sjoerg 5014*e038c9c4Sjoerg<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> 5015*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isExpandedFromMacro1"><pre>Matches statements that are (transitively) expanded from the named macro. 5016*e038c9c4SjoergDoes not match if only part of the statement is expanded from that macro or 5017*e038c9c4Sjoergif different parts of the the statement are expanded from different 5018*e038c9c4Sjoergappearances of the macro. 5019*e038c9c4Sjoerg</pre></td></tr> 5020*e038c9c4Sjoerg 5021*e038c9c4Sjoerg 5022*e038c9c4Sjoerg<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> 50237330f729Sjoerg<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is 50247330f729Sjoergpartially matching a given regex. 50257330f729Sjoerg 50267330f729SjoergExample matches Y but not X 50277330f729Sjoerg (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 50287330f729Sjoerg #include "ASTMatcher.h" 50297330f729Sjoerg class X {}; 50307330f729SjoergASTMatcher.h: 50317330f729Sjoerg class Y {}; 50327330f729Sjoerg 50337330f729SjoergUsable 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>> 5034*e038c9c4Sjoerg 5035*e038c9c4SjoergIf the matcher is used in clang-query, RegexFlags parameter 5036*e038c9c4Sjoergshould be passed as a quoted string. e.g: "NoFlags". 5037*e038c9c4SjoergFlags can be combined with '|' example "IgnoreCase | BasicRegex" 50387330f729Sjoerg</pre></td></tr> 50397330f729Sjoerg 50407330f729Sjoerg 50417330f729Sjoerg<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> 50427330f729Sjoerg<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. 50437330f729Sjoerg 50447330f729SjoergExample matches X but not Y 50457330f729Sjoerg (matcher = cxxRecordDecl(isExpansionInMainFile()) 50467330f729Sjoerg #include <Y.h> 50477330f729Sjoerg class X {}; 50487330f729SjoergY.h: 50497330f729Sjoerg class Y {}; 50507330f729Sjoerg 50517330f729SjoergUsable 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>> 50527330f729Sjoerg</pre></td></tr> 50537330f729Sjoerg 50547330f729Sjoerg 50557330f729Sjoerg<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> 50567330f729Sjoerg<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. 50577330f729Sjoerg 50587330f729SjoergExample matches Y but not X 50597330f729Sjoerg (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 50607330f729Sjoerg #include <SystemHeader.h> 50617330f729Sjoerg class X {}; 50627330f729SjoergSystemHeader.h: 50637330f729Sjoerg class Y {}; 50647330f729Sjoerg 50657330f729SjoergUsable 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>> 50667330f729Sjoerg</pre></td></tr> 50677330f729Sjoerg 50687330f729Sjoerg 5069*e038c9c4Sjoerg<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> 5070*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. 50717330f729Sjoerg 50727330f729SjoergGiven 5073*e038c9c4Sjoerg int j; 5074*e038c9c4Sjoerg template<typename T> void A(T t) { T i; j += 42;} 5075*e038c9c4Sjoerg A(0); 5076*e038c9c4Sjoerg A(0U); 5077*e038c9c4SjoergdeclStmt(isInTemplateInstantiation()) 5078*e038c9c4Sjoerg matches 'int i;' and 'unsigned i'. 5079*e038c9c4Sjoergunless(stmt(isInTemplateInstantiation())) 5080*e038c9c4Sjoerg will NOT match j += 42; as it's shared between the template definition and 5081*e038c9c4Sjoerg instantiation. 50827330f729Sjoerg</pre></td></tr> 50837330f729Sjoerg 50847330f729Sjoerg 50857330f729Sjoerg<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> 50867330f729Sjoerg<tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size. 50877330f729Sjoerg 50887330f729SjoergGiven 50897330f729Sjoerg int a[42]; 50907330f729Sjoerg int b[2 * 21]; 50917330f729Sjoerg int c[41], d[43]; 50927330f729Sjoerg char *s = "abcd"; 50937330f729Sjoerg wchar_t *ws = L"abcd"; 50947330f729Sjoerg char *w = "a"; 50957330f729SjoergconstantArrayType(hasSize(42)) 50967330f729Sjoerg matches "int a[42]" and "int b[2 * 21]" 50977330f729SjoergstringLiteral(hasSize(4)) 50987330f729Sjoerg matches "abcd", L"abcd" 50997330f729Sjoerg</pre></td></tr> 51007330f729Sjoerg 51017330f729Sjoerg 5102*e038c9c4Sjoerg<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> 5103*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isClass0"><pre>Matches TagDecl object that are spelled with "class." 5104*e038c9c4Sjoerg 5105*e038c9c4SjoergExample matches C, but not S, U or E. 5106*e038c9c4Sjoerg struct S {}; 5107*e038c9c4Sjoerg class C {}; 5108*e038c9c4Sjoerg union U {}; 5109*e038c9c4Sjoerg enum E {}; 5110*e038c9c4Sjoerg</pre></td></tr> 5111*e038c9c4Sjoerg 5112*e038c9c4Sjoerg 51137330f729Sjoerg<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> 51147330f729Sjoerg<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 51157330f729Sjoerg 51167330f729SjoergExample matches A, va, fa 51177330f729Sjoerg class A {}; 51187330f729Sjoerg class B; // Doesn't match, as it has no body. 51197330f729Sjoerg int va; 51207330f729Sjoerg extern int vb; // Doesn't match, as it doesn't define the variable. 51217330f729Sjoerg void fa() {} 51227330f729Sjoerg void fb(); // Doesn't match, as it has no body. 51237330f729Sjoerg @interface X 51247330f729Sjoerg - (void)ma; // Doesn't match, interface is declaration. 51257330f729Sjoerg @end 51267330f729Sjoerg @implementation X 51277330f729Sjoerg - (void)ma {} 51287330f729Sjoerg @end 51297330f729Sjoerg 51307330f729SjoergUsable 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>>, 51317330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 51327330f729Sjoerg</pre></td></tr> 51337330f729Sjoerg 51347330f729Sjoerg 5135*e038c9c4Sjoerg<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> 5136*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isEnum0"><pre>Matches TagDecl object that are spelled with "enum." 5137*e038c9c4Sjoerg 5138*e038c9c4SjoergExample matches E, but not C, S or U. 5139*e038c9c4Sjoerg struct S {}; 5140*e038c9c4Sjoerg class C {}; 5141*e038c9c4Sjoerg union U {}; 5142*e038c9c4Sjoerg enum E {}; 5143*e038c9c4Sjoerg</pre></td></tr> 5144*e038c9c4Sjoerg 5145*e038c9c4Sjoerg 5146*e038c9c4Sjoerg<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> 5147*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches TagDecl object that are spelled with "struct." 5148*e038c9c4Sjoerg 5149*e038c9c4SjoergExample matches S, but not C, U or E. 5150*e038c9c4Sjoerg struct S {}; 5151*e038c9c4Sjoerg class C {}; 5152*e038c9c4Sjoerg union U {}; 5153*e038c9c4Sjoerg enum E {}; 5154*e038c9c4Sjoerg</pre></td></tr> 5155*e038c9c4Sjoerg 5156*e038c9c4Sjoerg 5157*e038c9c4Sjoerg<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> 5158*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches TagDecl object that are spelled with "union." 5159*e038c9c4Sjoerg 5160*e038c9c4SjoergExample matches U, but not C, S or E. 5161*e038c9c4Sjoerg struct S {}; 5162*e038c9c4Sjoerg class C {}; 5163*e038c9c4Sjoerg union U {}; 5164*e038c9c4Sjoerg enum E {}; 5165*e038c9c4Sjoerg</pre></td></tr> 5166*e038c9c4Sjoerg 5167*e038c9c4Sjoerg 51687330f729Sjoerg<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> 51697330f729Sjoerg<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. 51707330f729Sjoerg 51717330f729SjoergNote that 'Value' is a string as the template argument's value is 51727330f729Sjoergan arbitrary precision integer. 'Value' must be euqal to the canonical 51737330f729Sjoergrepresentation of that integral value in base 10. 51747330f729Sjoerg 51757330f729SjoergGiven 51767330f729Sjoerg template<int T> struct C {}; 51777330f729Sjoerg C<42> c; 51787330f729SjoergclassTemplateSpecializationDecl( 51797330f729Sjoerg hasAnyTemplateArgument(equalsIntegralValue("42"))) 51807330f729Sjoerg matches the implicit instantiation of C in C<42>. 51817330f729Sjoerg</pre></td></tr> 51827330f729Sjoerg 51837330f729Sjoerg 51847330f729Sjoerg<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> 51857330f729Sjoerg<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. 51867330f729Sjoerg 51877330f729SjoergGiven 51887330f729Sjoerg template<int T> struct C {}; 51897330f729Sjoerg C<42> c; 51907330f729SjoergclassTemplateSpecializationDecl( 51917330f729Sjoerg hasAnyTemplateArgument(isIntegral())) 51927330f729Sjoerg matches the implicit instantiation of C in C<42> 51937330f729Sjoerg with isIntegral() matching 42. 51947330f729Sjoerg</pre></td></tr> 51957330f729Sjoerg 51967330f729Sjoerg 51977330f729Sjoerg<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> 51987330f729Sjoerg<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. 51997330f729Sjoerg 52007330f729SjoergGiven 52017330f729Sjoerg template<typename T> struct C {}; 52027330f729Sjoerg C<int> c; 52037330f729SjoergclassTemplateSpecializationDecl(templateArgumentCountIs(1)) 52047330f729Sjoerg matches C<int>. 52057330f729Sjoerg</pre></td></tr> 52067330f729Sjoerg 52077330f729Sjoerg 5208*e038c9c4Sjoerg<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> 5209*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="isExpandedFromMacro2"><pre>Matches statements that are (transitively) expanded from the named macro. 5210*e038c9c4SjoergDoes not match if only part of the statement is expanded from that macro or 5211*e038c9c4Sjoergif different parts of the the statement are expanded from different 5212*e038c9c4Sjoergappearances of the macro. 5213*e038c9c4Sjoerg</pre></td></tr> 5214*e038c9c4Sjoerg 5215*e038c9c4Sjoerg 5216*e038c9c4Sjoerg<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> 52177330f729Sjoerg<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is 52187330f729Sjoergpartially matching a given regex. 52197330f729Sjoerg 52207330f729SjoergExample matches Y but not X 52217330f729Sjoerg (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 52227330f729Sjoerg #include "ASTMatcher.h" 52237330f729Sjoerg class X {}; 52247330f729SjoergASTMatcher.h: 52257330f729Sjoerg class Y {}; 52267330f729Sjoerg 52277330f729SjoergUsable 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>> 5228*e038c9c4Sjoerg 5229*e038c9c4SjoergIf the matcher is used in clang-query, RegexFlags parameter 5230*e038c9c4Sjoergshould be passed as a quoted string. e.g: "NoFlags". 5231*e038c9c4SjoergFlags can be combined with '|' example "IgnoreCase | BasicRegex" 52327330f729Sjoerg</pre></td></tr> 52337330f729Sjoerg 52347330f729Sjoerg 52357330f729Sjoerg<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> 52367330f729Sjoerg<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. 52377330f729Sjoerg 52387330f729SjoergExample matches X but not Y 52397330f729Sjoerg (matcher = cxxRecordDecl(isExpansionInMainFile()) 52407330f729Sjoerg #include <Y.h> 52417330f729Sjoerg class X {}; 52427330f729SjoergY.h: 52437330f729Sjoerg class Y {}; 52447330f729Sjoerg 52457330f729SjoergUsable 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>> 52467330f729Sjoerg</pre></td></tr> 52477330f729Sjoerg 52487330f729Sjoerg 52497330f729Sjoerg<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> 52507330f729Sjoerg<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. 52517330f729Sjoerg 52527330f729SjoergExample matches Y but not X 52537330f729Sjoerg (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 52547330f729Sjoerg #include <SystemHeader.h> 52557330f729Sjoerg class X {}; 52567330f729SjoergSystemHeader.h: 52577330f729Sjoerg class Y {}; 52587330f729Sjoerg 52597330f729SjoergUsable 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>> 52607330f729Sjoerg</pre></td></tr> 52617330f729Sjoerg 52627330f729Sjoerg 52637330f729Sjoerg<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> 52647330f729Sjoerg<tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool. 52657330f729Sjoerg 52667330f729SjoergGiven 52677330f729Sjoerg struct S { bool func(); }; 52687330f729SjoergfunctionDecl(returns(booleanType())) 52697330f729Sjoerg matches "bool func();" 52707330f729Sjoerg</pre></td></tr> 52717330f729Sjoerg 52727330f729Sjoerg 52737330f729Sjoerg<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> 52747330f729Sjoerg<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. 52757330f729Sjoerg 52767330f729SjoergMatches a node if it equals the node previously bound to ID. 52777330f729Sjoerg 52787330f729SjoergGiven 52797330f729Sjoerg class X { int a; int b; }; 52807330f729SjoergcxxRecordDecl( 52817330f729Sjoerg has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 52827330f729Sjoerg has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 52837330f729Sjoerg matches the class X, as a and b have the same type. 52847330f729Sjoerg 52857330f729SjoergNote that when multiple matches are involved via forEach* matchers, 52867330f729SjoergequalsBoundNodes acts as a filter. 52877330f729SjoergFor example: 52887330f729SjoergcompoundStmt( 52897330f729Sjoerg forEachDescendant(varDecl().bind("d")), 52907330f729Sjoerg forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 52917330f729Sjoergwill trigger a match for each combination of variable declaration 52927330f729Sjoergand reference to that variable declaration within a compound statement. 52937330f729Sjoerg</pre></td></tr> 52947330f729Sjoerg 52957330f729Sjoerg 52967330f729Sjoerg<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> 52977330f729Sjoerg<tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node. 52987330f729Sjoerg 52997330f729SjoergType has pointer identity in the AST. 53007330f729Sjoerg</pre></td></tr> 53017330f729Sjoerg 53027330f729Sjoerg 53037330f729Sjoerg<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> 53047330f729Sjoerg<tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double). 53057330f729Sjoerg 53067330f729SjoergGiven 53077330f729Sjoerg int i; 53087330f729Sjoerg float f; 53097330f729SjoergrealFloatingPointType() 53107330f729Sjoerg matches "float f" but not "int i" 53117330f729Sjoerg</pre></td></tr> 53127330f729Sjoerg 53137330f729Sjoerg 53147330f729Sjoerg<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> 53157330f729Sjoerg<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. 53167330f729Sjoerg 53177330f729SjoergGiven 53187330f729Sjoerg struct S { void func(); }; 53197330f729SjoergfunctionDecl(returns(voidType())) 53207330f729Sjoerg matches "void func();" 53217330f729Sjoerg</pre></td></tr> 53227330f729Sjoerg 53237330f729Sjoerg 53247330f729Sjoerg<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> 53257330f729Sjoerg<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 53267330f729Sjoerg 53277330f729SjoergGiven 53287330f729Sjoerg int x; 53297330f729Sjoerg int s = sizeof(x) + alignof(x) 53307330f729SjoergunaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 53317330f729Sjoerg matches sizeof(x) 53327330f729Sjoerg 53337330f729SjoergIf the matcher is use from clang-query, UnaryExprOrTypeTrait parameter 53347330f729Sjoergshould be passed as a quoted string. e.g., ofKind("UETT_SizeOf"). 53357330f729Sjoerg</pre></td></tr> 53367330f729Sjoerg 53377330f729Sjoerg 5338*e038c9c4Sjoerg<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> 5339*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyOperatorName3"><pre>Matches operator expressions (binary or unary) that have any of the 5340*e038c9c4Sjoergspecified names. 5341*e038c9c4Sjoerg 5342*e038c9c4Sjoerg hasAnyOperatorName("+", "-") 5343*e038c9c4Sjoerg Is equivalent to 5344*e038c9c4Sjoerg anyOf(hasOperatorName("+"), hasOperatorName("-")) 5345*e038c9c4Sjoerg</pre></td></tr> 5346*e038c9c4Sjoerg 5347*e038c9c4Sjoerg 5348*e038c9c4Sjoerg<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> 5349*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasOperatorName3"><pre>Matches the operator Name of operator expressions (binary or 53507330f729Sjoergunary). 53517330f729Sjoerg 53527330f729SjoergExample matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 53537330f729Sjoerg !(a || b) 53547330f729Sjoerg</pre></td></tr> 53557330f729Sjoerg 53567330f729Sjoerg 53577330f729Sjoerg<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> 53587330f729Sjoerg<tr><td colspan="4" class="doc" id="isArrow1"><pre>Matches member expressions that are called with '->' as opposed 53597330f729Sjoergto '.'. 53607330f729Sjoerg 53617330f729SjoergMember calls on the implicit this pointer match as called with '->'. 53627330f729Sjoerg 53637330f729SjoergGiven 53647330f729Sjoerg class Y { 53657330f729Sjoerg void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 53667330f729Sjoerg template <class T> void f() { this->f<T>(); f<T>(); } 53677330f729Sjoerg int a; 53687330f729Sjoerg static int b; 53697330f729Sjoerg }; 53707330f729Sjoerg template <class T> 53717330f729Sjoerg class Z { 53727330f729Sjoerg void x() { this->m; } 53737330f729Sjoerg }; 53747330f729SjoergmemberExpr(isArrow()) 53757330f729Sjoerg matches this->x, x, y.x, a, this->b 53767330f729SjoergcxxDependentScopeMemberExpr(isArrow()) 53777330f729Sjoerg matches this->m 53787330f729SjoergunresolvedMemberExpr(isArrow()) 53797330f729Sjoerg matches this->f<T>, f<T> 53807330f729Sjoerg</pre></td></tr> 53817330f729Sjoerg 53827330f729Sjoerg 53837330f729Sjoerg<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> 53847330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration. 53857330f729Sjoerg 53867330f729SjoergExample matches x, but not y, z, or a. 53877330f729Sjoerg(matcher = varDecl(hasAutomaticStorageDuration()) 53887330f729Sjoergvoid f() { 53897330f729Sjoerg int x; 53907330f729Sjoerg static int y; 53917330f729Sjoerg thread_local int z; 53927330f729Sjoerg} 53937330f729Sjoergint a; 53947330f729Sjoerg</pre></td></tr> 53957330f729Sjoerg 53967330f729Sjoerg 53977330f729Sjoerg<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> 53987330f729Sjoerg<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. 53997330f729Sjoerg 54007330f729SjoergExample matches y and z (matcher = varDecl(hasGlobalStorage()) 54017330f729Sjoergvoid f() { 54027330f729Sjoerg int x; 54037330f729Sjoerg static int y; 54047330f729Sjoerg} 54057330f729Sjoergint z; 54067330f729Sjoerg</pre></td></tr> 54077330f729Sjoerg 54087330f729Sjoerg 54097330f729Sjoerg<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> 54107330f729Sjoerg<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a 54117330f729Sjoergnon-static local variable. 54127330f729Sjoerg 54137330f729SjoergExample matches x (matcher = varDecl(hasLocalStorage()) 54147330f729Sjoergvoid f() { 54157330f729Sjoerg int x; 54167330f729Sjoerg static int y; 54177330f729Sjoerg} 54187330f729Sjoergint z; 54197330f729Sjoerg</pre></td></tr> 54207330f729Sjoerg 54217330f729Sjoerg 54227330f729Sjoerg<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> 54237330f729Sjoerg<tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration. 54247330f729SjoergIt includes the variable declared at namespace scope and those declared 54257330f729Sjoergwith "static" and "extern" storage class specifiers. 54267330f729Sjoerg 54277330f729Sjoergvoid f() { 54287330f729Sjoerg int x; 54297330f729Sjoerg static int y; 54307330f729Sjoerg thread_local int z; 54317330f729Sjoerg} 54327330f729Sjoergint a; 54337330f729Sjoergstatic int b; 54347330f729Sjoergextern int c; 54357330f729SjoergvarDecl(hasStaticStorageDuration()) 54367330f729Sjoerg matches the function declaration y, a, b and c. 54377330f729Sjoerg</pre></td></tr> 54387330f729Sjoerg 54397330f729Sjoerg 54407330f729Sjoerg<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> 54417330f729Sjoerg<tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration. 54427330f729Sjoerg 54437330f729SjoergExample matches z, but not x, z, or a. 54447330f729Sjoerg(matcher = varDecl(hasThreadStorageDuration()) 54457330f729Sjoergvoid f() { 54467330f729Sjoerg int x; 54477330f729Sjoerg static int y; 54487330f729Sjoerg thread_local int z; 54497330f729Sjoerg} 54507330f729Sjoergint a; 54517330f729Sjoerg</pre></td></tr> 54527330f729Sjoerg 54537330f729Sjoerg 54547330f729Sjoerg<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> 54557330f729Sjoerg<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations, 54567330f729Sjoerg and if constexpr. 54577330f729Sjoerg 54587330f729SjoergGiven: 54597330f729Sjoerg constexpr int foo = 42; 54607330f729Sjoerg constexpr int bar(); 54617330f729Sjoerg void baz() { if constexpr(1 > 0) {} } 54627330f729SjoergvarDecl(isConstexpr()) 54637330f729Sjoerg matches the declaration of foo. 54647330f729SjoergfunctionDecl(isConstexpr()) 54657330f729Sjoerg matches the declaration of bar. 54667330f729SjoergifStmt(isConstexpr()) 54677330f729Sjoerg matches the if statement in baz. 54687330f729Sjoerg</pre></td></tr> 54697330f729Sjoerg 54707330f729Sjoerg 54717330f729Sjoerg<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> 54727330f729Sjoerg<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 54737330f729Sjoerg 54747330f729SjoergExample matches A, va, fa 54757330f729Sjoerg class A {}; 54767330f729Sjoerg class B; // Doesn't match, as it has no body. 54777330f729Sjoerg int va; 54787330f729Sjoerg extern int vb; // Doesn't match, as it doesn't define the variable. 54797330f729Sjoerg void fa() {} 54807330f729Sjoerg void fb(); // Doesn't match, as it has no body. 54817330f729Sjoerg @interface X 54827330f729Sjoerg - (void)ma; // Doesn't match, interface is declaration. 54837330f729Sjoerg @end 54847330f729Sjoerg @implementation X 54857330f729Sjoerg - (void)ma {} 54867330f729Sjoerg @end 54877330f729Sjoerg 54887330f729SjoergUsable 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>>, 54897330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 54907330f729Sjoerg</pre></td></tr> 54917330f729Sjoerg 54927330f729Sjoerg 54937330f729Sjoerg<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> 54947330f729Sjoerg<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from 54957330f729Sjoerga C++ catch block, or an Objective-C statement. 54967330f729Sjoerg 54977330f729SjoergExample matches x (matcher = varDecl(isExceptionVariable()) 54987330f729Sjoergvoid f(int y) { 54997330f729Sjoerg try { 55007330f729Sjoerg } catch (int x) { 55017330f729Sjoerg } 55027330f729Sjoerg} 55037330f729Sjoerg</pre></td></tr> 55047330f729Sjoerg 55057330f729Sjoerg 55067330f729Sjoerg<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> 55077330f729Sjoerg<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 55087330f729Sjoergstatic member variable template instantiations. 55097330f729Sjoerg 55107330f729SjoergGiven 55117330f729Sjoerg template<typename T> void A(T t) { } 55127330f729Sjoerg template<> void A(int N) { } 55137330f729SjoergfunctionDecl(isExplicitTemplateSpecialization()) 55147330f729Sjoerg matches the specialization A<int>(). 55157330f729Sjoerg 55167330f729SjoergUsable 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>> 55177330f729Sjoerg</pre></td></tr> 55187330f729Sjoerg 55197330f729Sjoerg 55207330f729Sjoerg<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> 55217330f729Sjoerg<tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations. 55227330f729Sjoerg 55237330f729SjoergGiven: 55247330f729Sjoerg extern "C" void f() {} 55257330f729Sjoerg extern "C" { void g() {} } 55267330f729Sjoerg void h() {} 55277330f729Sjoerg extern "C" int x = 1; 55287330f729Sjoerg extern "C" int y = 2; 55297330f729Sjoerg int z = 3; 55307330f729SjoergfunctionDecl(isExternC()) 55317330f729Sjoerg matches the declaration of f and g, but not the declaration of h. 55327330f729SjoergvarDecl(isExternC()) 55337330f729Sjoerg matches the declaration of x and y, but not the declaration of z. 55347330f729Sjoerg</pre></td></tr> 55357330f729Sjoerg 55367330f729Sjoerg 55377330f729Sjoerg<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> 55387330f729Sjoerg<tr><td colspan="4" class="doc" id="isStaticLocal0"><pre>Matches a static variable with local scope. 55397330f729Sjoerg 55407330f729SjoergExample matches y (matcher = varDecl(isStaticLocal())) 55417330f729Sjoergvoid f() { 55427330f729Sjoerg int x; 55437330f729Sjoerg static int y; 55447330f729Sjoerg} 55457330f729Sjoergstatic int z; 55467330f729Sjoerg</pre></td></tr> 55477330f729Sjoerg 55487330f729Sjoerg 55497330f729Sjoerg<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> 55507330f729Sjoerg<tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variable/function declarations that have "static" storage 55517330f729Sjoergclass specifier ("static" keyword) written in the source. 55527330f729Sjoerg 55537330f729SjoergGiven: 55547330f729Sjoerg static void f() {} 55557330f729Sjoerg static int i = 0; 55567330f729Sjoerg extern int j; 55577330f729Sjoerg int k; 55587330f729SjoergfunctionDecl(isStaticStorageClass()) 55597330f729Sjoerg matches the function declaration f. 55607330f729SjoergvarDecl(isStaticStorageClass()) 55617330f729Sjoerg matches the variable declaration i. 55627330f729Sjoerg</pre></td></tr> 55637330f729Sjoerg 55647330f729Sjoerg 55657330f729Sjoerg<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> 55667330f729Sjoerg<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 55677330f729Sjoergmember variable template instantiations. 55687330f729Sjoerg 55697330f729SjoergGiven 55707330f729Sjoerg template <typename T> class X {}; class A {}; X<A> x; 55717330f729Sjoergor 55727330f729Sjoerg template <typename T> class X {}; class A {}; template class X<A>; 55737330f729Sjoergor 55747330f729Sjoerg template <typename T> class X {}; class A {}; extern template class X<A>; 55757330f729SjoergcxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 55767330f729Sjoerg matches the template instantiation of X<A>. 55777330f729Sjoerg 55787330f729SjoergBut given 55797330f729Sjoerg template <typename T> class X {}; class A {}; 55807330f729Sjoerg template <> class X<A> {}; X<A> x; 55817330f729SjoergcxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 55827330f729Sjoerg does not match, as X<A> is an explicit template specialization. 55837330f729Sjoerg 55847330f729SjoergUsable 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>> 55857330f729Sjoerg</pre></td></tr> 55867330f729Sjoerg 55877330f729Sjoerg<!--END_NARROWING_MATCHERS --> 55887330f729Sjoerg</table> 55897330f729Sjoerg 55907330f729Sjoerg<!-- ======================================================================= --> 55917330f729Sjoerg<h2 id="traversal-matchers">AST Traversal Matchers</h2> 55927330f729Sjoerg<!-- ======================================================================= --> 55937330f729Sjoerg 55947330f729Sjoerg<p>Traversal matchers specify the relationship to other nodes that are 55957330f729Sjoergreachable from the current node.</p> 55967330f729Sjoerg 55977330f729Sjoerg<p>Note that there are special traversal matchers (has, hasDescendant, forEach and 55987330f729SjoergforEachDescendant) which work on all nodes and allow users to write more generic 55997330f729Sjoergmatch expressions.</p> 56007330f729Sjoerg 56017330f729Sjoerg<table> 56027330f729Sjoerg<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 56037330f729Sjoerg<!-- START_TRAVERSAL_MATCHERS --> 56047330f729Sjoerg 5605*e038c9c4Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('binaryOperation0')"><a name="binaryOperation0Anchor">binaryOperation</a></td><td>Matcher<*>...Matcher<*></td></tr> 5606*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="binaryOperation0"><pre>Matches nodes which can be used with binary operators. 5607*e038c9c4Sjoerg 5608*e038c9c4SjoergThe code 5609*e038c9c4Sjoerg var1 != var2; 5610*e038c9c4Sjoergmight be represented in the clang AST as a binaryOperator, a 5611*e038c9c4SjoergcxxOperatorCallExpr or a cxxRewrittenBinaryOperator, depending on 5612*e038c9c4Sjoerg 5613*e038c9c4Sjoerg* whether the types of var1 and var2 are fundamental (binaryOperator) or at 5614*e038c9c4Sjoerg least one is a class type (cxxOperatorCallExpr) 5615*e038c9c4Sjoerg* whether the code appears in a template declaration, if at least one of the 5616*e038c9c4Sjoerg vars is a dependent-type (binaryOperator) 5617*e038c9c4Sjoerg* whether the code relies on a rewritten binary operator, such as a 5618*e038c9c4Sjoergspaceship operator or an inverted equality operator 5619*e038c9c4Sjoerg(cxxRewrittenBinaryOperator) 5620*e038c9c4Sjoerg 5621*e038c9c4SjoergThis matcher elides details in places where the matchers for the nodes are 5622*e038c9c4Sjoergcompatible. 5623*e038c9c4Sjoerg 5624*e038c9c4SjoergGiven 5625*e038c9c4Sjoerg binaryOperation( 5626*e038c9c4Sjoerg hasOperatorName("!="), 5627*e038c9c4Sjoerg hasLHS(expr().bind("lhs")), 5628*e038c9c4Sjoerg hasRHS(expr().bind("rhs")) 5629*e038c9c4Sjoerg ) 5630*e038c9c4Sjoergmatches each use of "!=" in: 5631*e038c9c4Sjoerg struct S{ 5632*e038c9c4Sjoerg bool operator!=(const S&) const; 5633*e038c9c4Sjoerg }; 5634*e038c9c4Sjoerg 5635*e038c9c4Sjoerg void foo() 5636*e038c9c4Sjoerg { 5637*e038c9c4Sjoerg 1 != 2; 5638*e038c9c4Sjoerg S() != S(); 5639*e038c9c4Sjoerg } 5640*e038c9c4Sjoerg 5641*e038c9c4Sjoerg template<typename T> 5642*e038c9c4Sjoerg void templ() 5643*e038c9c4Sjoerg { 5644*e038c9c4Sjoerg 1 != 2; 5645*e038c9c4Sjoerg T() != S(); 5646*e038c9c4Sjoerg } 5647*e038c9c4Sjoerg struct HasOpEq 5648*e038c9c4Sjoerg { 5649*e038c9c4Sjoerg bool operator==(const HasOpEq &) const; 5650*e038c9c4Sjoerg }; 5651*e038c9c4Sjoerg 5652*e038c9c4Sjoerg void inverse() 5653*e038c9c4Sjoerg { 5654*e038c9c4Sjoerg HasOpEq s1; 5655*e038c9c4Sjoerg HasOpEq s2; 5656*e038c9c4Sjoerg if (s1 != s2) 5657*e038c9c4Sjoerg return; 5658*e038c9c4Sjoerg } 5659*e038c9c4Sjoerg 5660*e038c9c4Sjoerg struct HasSpaceship 5661*e038c9c4Sjoerg { 5662*e038c9c4Sjoerg bool operator<=>(const HasOpEq &) const; 5663*e038c9c4Sjoerg }; 5664*e038c9c4Sjoerg 5665*e038c9c4Sjoerg void use_spaceship() 5666*e038c9c4Sjoerg { 5667*e038c9c4Sjoerg HasSpaceship s1; 5668*e038c9c4Sjoerg HasSpaceship s2; 5669*e038c9c4Sjoerg if (s1 != s2) 5670*e038c9c4Sjoerg return; 5671*e038c9c4Sjoerg } 5672*e038c9c4Sjoerg</pre></td></tr> 5673*e038c9c4Sjoerg 5674*e038c9c4Sjoerg 56757330f729Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 56767330f729Sjoerg<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. 56777330f729Sjoerg 56787330f729SjoergUnlike anyOf, eachOf will generate a match result for each 56797330f729Sjoergmatching submatcher. 56807330f729Sjoerg 56817330f729SjoergFor example, in: 56827330f729Sjoerg class A { int a; int b; }; 56837330f729SjoergThe matcher: 56847330f729Sjoerg cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), 56857330f729Sjoerg has(fieldDecl(hasName("b")).bind("v")))) 56867330f729Sjoergwill generate two results binding "v", the first of which binds 56877330f729Sjoergthe field declaration of a, the second the field declaration of 56887330f729Sjoergb. 56897330f729Sjoerg 56907330f729SjoergUsable as: Any Matcher 56917330f729Sjoerg</pre></td></tr> 56927330f729Sjoerg 56937330f729Sjoerg 5694*e038c9c4Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<*> Matcher</td></tr> 5695*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. 5696*e038c9c4Sjoerg 5697*e038c9c4SjoergGenerates results for each match. 5698*e038c9c4Sjoerg 5699*e038c9c4SjoergFor example, in: 5700*e038c9c4Sjoerg class A { class B {}; class C {}; }; 5701*e038c9c4SjoergThe matcher: 5702*e038c9c4Sjoerg cxxRecordDecl(hasName("::A"), 5703*e038c9c4Sjoerg findAll(cxxRecordDecl(isDefinition()).bind("m"))) 5704*e038c9c4Sjoergwill generate results for A, B and C. 5705*e038c9c4Sjoerg 5706*e038c9c4SjoergUsable as: Any Matcher 5707*e038c9c4Sjoerg</pre></td></tr> 5708*e038c9c4Sjoerg 5709*e038c9c4Sjoerg 57107330f729Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> 57117330f729Sjoerg<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 57127330f729Sjoergprovided matcher. 57137330f729Sjoerg 57147330f729SjoergExample matches X, A, A::X, B, B::C, B::C::X 57157330f729Sjoerg (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) 57167330f729Sjoerg class X {}; 57177330f729Sjoerg class A { class X {}; }; // Matches A, because A::X is a class of name 57187330f729Sjoerg // X inside A. 57197330f729Sjoerg class B { class C { class X {}; }; }; 57207330f729Sjoerg 57217330f729SjoergDescendantT must be an AST base type. 57227330f729Sjoerg 57237330f729SjoergAs opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 57247330f729Sjoergeach result that matches instead of only on the first one. 57257330f729Sjoerg 57267330f729SjoergNote: Recursively combined ForEachDescendant can cause many matches: 57277330f729Sjoerg cxxRecordDecl(forEachDescendant(cxxRecordDecl( 57287330f729Sjoerg forEachDescendant(cxxRecordDecl()) 57297330f729Sjoerg ))) 57307330f729Sjoergwill match 10 times (plus injected class name matches) on: 57317330f729Sjoerg class A { class B { class C { class D { class E {}; }; }; }; }; 57327330f729Sjoerg 57337330f729SjoergUsable as: Any Matcher 57347330f729Sjoerg</pre></td></tr> 57357330f729Sjoerg 57367330f729Sjoerg 57377330f729Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> 57387330f729Sjoerg<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 57397330f729Sjoergprovided matcher. 57407330f729Sjoerg 57417330f729SjoergExample matches X, Y, Y::X, Z::Y, Z::Y::X 57427330f729Sjoerg (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) 57437330f729Sjoerg class X {}; 57447330f729Sjoerg class Y { class X {}; }; // Matches Y, because Y::X is a class of name X 57457330f729Sjoerg // inside Y. 57467330f729Sjoerg class Z { class Y { class X {}; }; }; // Does not match Z. 57477330f729Sjoerg 57487330f729SjoergChildT must be an AST base type. 57497330f729Sjoerg 57507330f729SjoergAs opposed to 'has', 'forEach' will cause a match for each result that 57517330f729Sjoergmatches instead of only on the first one. 57527330f729Sjoerg 57537330f729SjoergUsable as: Any Matcher 57547330f729Sjoerg</pre></td></tr> 57557330f729Sjoerg 57567330f729Sjoerg 57577330f729Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> 57587330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 57597330f729Sjoergmatcher. 57607330f729Sjoerg 57617330f729SjoergGiven 57627330f729Sjoergvoid f() { if (true) { int x = 42; } } 57637330f729Sjoergvoid g() { for (;;) { int x = 43; } } 57647330f729Sjoergexpr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 57657330f729Sjoerg 57667330f729SjoergUsable as: Any Matcher 57677330f729Sjoerg</pre></td></tr> 57687330f729Sjoerg 57697330f729Sjoerg 57707330f729Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> 57717330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 57727330f729Sjoergprovided matcher. 57737330f729Sjoerg 57747330f729SjoergExample matches X, Y, Z 57757330f729Sjoerg (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) 57767330f729Sjoerg class X {}; // Matches X, because X::X is a class of name X inside X. 57777330f729Sjoerg class Y { class X {}; }; 57787330f729Sjoerg class Z { class Y { class X {}; }; }; 57797330f729Sjoerg 57807330f729SjoergDescendantT must be an AST base type. 57817330f729Sjoerg 57827330f729SjoergUsable as: Any Matcher 57837330f729Sjoerg</pre></td></tr> 57847330f729Sjoerg 57857330f729Sjoerg 57867330f729Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> 57877330f729Sjoerg<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 57887330f729Sjoergprovided matcher. 57897330f729Sjoerg 57907330f729SjoergExample matches X, Y 57917330f729Sjoerg (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) 57927330f729Sjoerg class X {}; // Matches X, because X::X is a class of name X inside X. 57937330f729Sjoerg class Y { class X {}; }; 57947330f729Sjoerg class Z { class Y { class X {}; }; }; // Does not match Z. 57957330f729Sjoerg 57967330f729SjoergChildT must be an AST base type. 57977330f729Sjoerg 57987330f729SjoergUsable as: Any Matcher 57997330f729SjoergNote that has is direct matcher, so it also matches things like implicit 58007330f729Sjoergcasts and paren casts. If you are matching with expr then you should 58017330f729Sjoergprobably consider using ignoringParenImpCasts like: 58027330f729Sjoerghas(ignoringParenImpCasts(expr())). 58037330f729Sjoerg</pre></td></tr> 58047330f729Sjoerg 58057330f729Sjoerg 58067330f729Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> 58077330f729Sjoerg<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 58087330f729Sjoergmatcher. 58097330f729Sjoerg 58107330f729SjoergGiven 58117330f729Sjoergvoid f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 58127330f729SjoergcompoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 58137330f729Sjoerg 58147330f729SjoergUsable as: Any Matcher 58157330f729Sjoerg</pre></td></tr> 58167330f729Sjoerg 58177330f729Sjoerg 5818*e038c9c4Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('invocation0')"><a name="invocation0Anchor">invocation</a></td><td>Matcher<*>...Matcher<*></td></tr> 5819*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="invocation0"><pre>Matches function calls and constructor calls 5820*e038c9c4Sjoerg 5821*e038c9c4SjoergBecause CallExpr and CXXConstructExpr do not share a common 5822*e038c9c4Sjoergbase class with API accessing arguments etc, AST Matchers for code 5823*e038c9c4Sjoergwhich should match both are typically duplicated. This matcher 5824*e038c9c4Sjoergremoves the need for duplication. 5825*e038c9c4Sjoerg 5826*e038c9c4SjoergGiven code 5827*e038c9c4Sjoergstruct ConstructorTakesInt 5828*e038c9c4Sjoerg{ 5829*e038c9c4Sjoerg ConstructorTakesInt(int i) {} 5830*e038c9c4Sjoerg}; 5831*e038c9c4Sjoerg 5832*e038c9c4Sjoergvoid callTakesInt(int i) 5833*e038c9c4Sjoerg{ 5834*e038c9c4Sjoerg} 5835*e038c9c4Sjoerg 5836*e038c9c4Sjoergvoid doCall() 5837*e038c9c4Sjoerg{ 5838*e038c9c4Sjoerg callTakesInt(42); 5839*e038c9c4Sjoerg} 5840*e038c9c4Sjoerg 5841*e038c9c4Sjoergvoid doConstruct() 5842*e038c9c4Sjoerg{ 5843*e038c9c4Sjoerg ConstructorTakesInt cti(42); 5844*e038c9c4Sjoerg} 5845*e038c9c4Sjoerg 5846*e038c9c4SjoergThe matcher 5847*e038c9c4Sjoerginvocation(hasArgument(0, integerLiteral(equals(42)))) 5848*e038c9c4Sjoergmatches the expression in both doCall and doConstruct 5849*e038c9c4Sjoerg</pre></td></tr> 5850*e038c9c4Sjoerg 5851*e038c9c4Sjoerg 5852*e038c9c4Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('optionally0')"><a name="optionally0Anchor">optionally</a></td><td>Matcher<*></td></tr> 5853*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="optionally0"><pre>Matches any node regardless of the submatcher. 5854*e038c9c4Sjoerg 5855*e038c9c4SjoergHowever, optionally will retain any bindings generated by the submatcher. 5856*e038c9c4SjoergUseful when additional information which may or may not present about a main 5857*e038c9c4Sjoergmatching node is desired. 5858*e038c9c4Sjoerg 5859*e038c9c4SjoergFor example, in: 5860*e038c9c4Sjoerg class Foo { 5861*e038c9c4Sjoerg int bar; 5862*e038c9c4Sjoerg } 5863*e038c9c4SjoergThe matcher: 5864*e038c9c4Sjoerg cxxRecordDecl( 5865*e038c9c4Sjoerg optionally(has( 5866*e038c9c4Sjoerg fieldDecl(hasName("bar")).bind("var") 5867*e038c9c4Sjoerg ))).bind("record") 5868*e038c9c4Sjoergwill produce a result binding for both "record" and "var". 5869*e038c9c4SjoergThe matcher will produce a "record" binding for even if there is no data 5870*e038c9c4Sjoergmember named "bar" in that class. 5871*e038c9c4Sjoerg 5872*e038c9c4SjoergUsable as: Any Matcher 5873*e038c9c4Sjoerg</pre></td></tr> 5874*e038c9c4Sjoerg 5875*e038c9c4Sjoerg 5876*e038c9c4Sjoerg<tr><td>Matcher<*></td><td class="name" onclick="toggle('traverse0')"><a name="traverse0Anchor">traverse</a></td><td>TraversalKind TK, Matcher<*> InnerMatcher</td></tr> 5877*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="traverse0"><pre>Causes all nested matchers to be matched with the specified traversal kind. 5878*e038c9c4Sjoerg 5879*e038c9c4SjoergGiven 5880*e038c9c4Sjoerg void foo() 5881*e038c9c4Sjoerg { 5882*e038c9c4Sjoerg int i = 3.0; 5883*e038c9c4Sjoerg } 5884*e038c9c4SjoergThe matcher 5885*e038c9c4Sjoerg traverse(TK_IgnoreUnlessSpelledInSource, 5886*e038c9c4Sjoerg varDecl(hasInitializer(floatLiteral().bind("init"))) 5887*e038c9c4Sjoerg ) 5888*e038c9c4Sjoergmatches the variable declaration with "init" bound to the "3.0". 5889*e038c9c4Sjoerg</pre></td></tr> 5890*e038c9c4Sjoerg 5891*e038c9c4Sjoerg 58927330f729Sjoerg<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> 58937330f729Sjoerg<tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop, 58947330f729Sjoergswitch statement or conditional operator. 58957330f729Sjoerg 58967330f729SjoergExample matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 58977330f729Sjoerg if (true) {} 58987330f729Sjoerg</pre></td></tr> 58997330f729Sjoerg 59007330f729Sjoerg 59017330f729Sjoerg<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> 59027330f729Sjoerg<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator 59037330f729Sjoerg(binary or ternary). 59047330f729Sjoerg 59057330f729SjoergExample matches b 59067330f729Sjoerg condition ? a : b 59077330f729Sjoerg condition ?: b 59087330f729Sjoerg</pre></td></tr> 59097330f729Sjoerg 59107330f729Sjoerg 59117330f729Sjoerg<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> 59127330f729Sjoerg<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 59137330f729Sjoerg 59147330f729SjoergExample 1 (conditional ternary operator): matches a 59157330f729Sjoerg condition ? a : b 59167330f729Sjoerg 59177330f729SjoergExample 2 (conditional binary operator): matches opaqueValueExpr(condition) 59187330f729Sjoerg condition ?: b 59197330f729Sjoerg</pre></td></tr> 59207330f729Sjoerg 59217330f729Sjoerg 5922*e038c9c4Sjoerg<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> 59237330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node 59247330f729Sjoergmatches the given matcher. 59257330f729Sjoerg 59267330f729SjoergThe associated declaration is: 59277330f729Sjoerg- for type nodes, the declaration of the underlying type 59287330f729Sjoerg- for CallExpr, the declaration of the callee 59297330f729Sjoerg- for MemberExpr, the declaration of the referenced member 59307330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 59317330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 59327330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 59337330f729Sjoerg 59347330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 59357330f729Sjoergsugared type. Given 59367330f729Sjoerg class X {}; 59377330f729Sjoerg typedef X Y; 59387330f729Sjoerg Y y; 59397330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 59407330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 59417330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 59427330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 59437330f729Sjoerg recordType(hasDeclaration(decl()))))) 59447330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 59457330f729Sjoerg 59467330f729SjoergUsable 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>>, 59477330f729Sjoerg 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>>, 59487330f729Sjoerg 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>>, 59497330f729Sjoerg 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>>, 59507330f729Sjoerg 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>>, 59517330f729Sjoerg 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>>, 59527330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 59537330f729Sjoerg</pre></td></tr> 59547330f729Sjoerg 59557330f729Sjoerg 59567330f729Sjoerg<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> 59577330f729Sjoerg<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 59587330f729Sjoerg 59597330f729SjoergGiven 59607330f729Sjoerg int i[5]; 59617330f729Sjoerg void f() { i[1] = 42; } 59627330f729SjoergarraySubscriptExpression(hasBase(implicitCastExpr( 59637330f729Sjoerg hasSourceExpression(declRefExpr())))) 59647330f729Sjoerg matches i[1] with the declRefExpr() matching i 59657330f729Sjoerg</pre></td></tr> 59667330f729Sjoerg 59677330f729Sjoerg 59687330f729Sjoerg<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> 59697330f729Sjoerg<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 59707330f729Sjoerg 59717330f729SjoergGiven 59727330f729Sjoerg int i[5]; 59737330f729Sjoerg void f() { i[1] = 42; } 59747330f729SjoergarraySubscriptExpression(hasIndex(integerLiteral())) 59757330f729Sjoerg matches i[1] with the integerLiteral() matching 1 59767330f729Sjoerg</pre></td></tr> 59777330f729Sjoerg 59787330f729Sjoerg 5979*e038c9c4Sjoerg<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> 5980*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasLHS3"><pre>Matches the left hand side of binary operator expressions. 59817330f729Sjoerg 59827330f729SjoergExample matches a (matcher = binaryOperator(hasLHS())) 59837330f729Sjoerg a || b 59847330f729Sjoerg</pre></td></tr> 59857330f729Sjoerg 59867330f729Sjoerg 5987*e038c9c4Sjoerg<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> 5988*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasRHS3"><pre>Matches the right hand side of binary operator expressions. 59897330f729Sjoerg 59907330f729SjoergExample matches b (matcher = binaryOperator(hasRHS())) 59917330f729Sjoerg a || b 59927330f729Sjoerg</pre></td></tr> 59937330f729Sjoerg 59947330f729Sjoerg 59957330f729Sjoerg<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> 59967330f729Sjoerg<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element 59977330f729Sjoergtype. 59987330f729Sjoerg 59997330f729SjoergGiven 60007330f729Sjoerg struct A {}; 60017330f729Sjoerg A a[7]; 60027330f729Sjoerg int b[7]; 60037330f729SjoergarrayType(hasElementType(builtinType())) 60047330f729Sjoerg matches "int b[7]" 60057330f729Sjoerg 60067330f729SjoergUsable 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>> 60077330f729Sjoerg</pre></td></tr> 60087330f729Sjoerg 60097330f729Sjoerg 60107330f729Sjoerg<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> 60117330f729Sjoerg<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. 60127330f729Sjoerg 60137330f729SjoergGiven 60147330f729Sjoerg _Atomic(int) i; 60157330f729Sjoerg _Atomic(float) f; 60167330f729SjoergatomicType(hasValueType(isInteger())) 60177330f729Sjoerg matches "_Atomic(int) i" 60187330f729Sjoerg 60197330f729SjoergUsable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 60207330f729Sjoerg</pre></td></tr> 60217330f729Sjoerg 60227330f729Sjoerg 60237330f729Sjoerg<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> 60247330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. 60257330f729Sjoerg 60267330f729SjoergNote: There is no TypeLoc for the deduced type and thus no 60277330f729SjoerggetDeducedLoc() matcher. 60287330f729Sjoerg 60297330f729SjoergGiven 60307330f729Sjoerg auto a = 1; 60317330f729Sjoerg auto b = 2.0; 60327330f729SjoergautoType(hasDeducedType(isInteger())) 60337330f729Sjoerg matches "auto a" 60347330f729Sjoerg 60357330f729SjoergUsable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> 60367330f729Sjoerg</pre></td></tr> 60377330f729Sjoerg 60387330f729Sjoerg 6039*e038c9c4Sjoerg<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> 60407330f729Sjoerg<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 60417330f729Sjoergbinary operator matches. 60427330f729Sjoerg</pre></td></tr> 60437330f729Sjoerg 60447330f729Sjoerg 60457330f729Sjoerg<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> 60467330f729Sjoerg<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 60477330f729Sjoerg 60487330f729SjoergExample matches a (matcher = binaryOperator(hasLHS())) 60497330f729Sjoerg a || b 60507330f729Sjoerg</pre></td></tr> 60517330f729Sjoerg 60527330f729Sjoerg 6053*e038c9c4Sjoerg<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> 6054*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasOperands0"><pre>Matches if both matchers match with opposite sides of the binary operator. 6055*e038c9c4Sjoerg 6056*e038c9c4SjoergExample matcher = binaryOperator(hasOperands(integerLiteral(equals(1), 6057*e038c9c4Sjoerg integerLiteral(equals(2))) 6058*e038c9c4Sjoerg 1 + 2 // Match 6059*e038c9c4Sjoerg 2 + 1 // Match 6060*e038c9c4Sjoerg 1 + 1 // No match 6061*e038c9c4Sjoerg 2 + 2 // No match 6062*e038c9c4Sjoerg</pre></td></tr> 6063*e038c9c4Sjoerg 6064*e038c9c4Sjoerg 60657330f729Sjoerg<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> 60667330f729Sjoerg<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 60677330f729Sjoerg 60687330f729SjoergExample matches b (matcher = binaryOperator(hasRHS())) 60697330f729Sjoerg a || b 60707330f729Sjoerg</pre></td></tr> 60717330f729Sjoerg 60727330f729Sjoerg 6073*e038c9c4Sjoerg<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> 6074*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="forDecomposition0"><pre>Matches the DecompositionDecl the binding belongs to. 6075*e038c9c4Sjoerg 6076*e038c9c4SjoergFor example, in: 6077*e038c9c4Sjoergvoid foo() 6078*e038c9c4Sjoerg{ 6079*e038c9c4Sjoerg int arr[3]; 6080*e038c9c4Sjoerg auto &[f, s, t] = arr; 6081*e038c9c4Sjoerg 6082*e038c9c4Sjoerg f = 42; 6083*e038c9c4Sjoerg} 6084*e038c9c4SjoergThe matcher: 6085*e038c9c4Sjoerg bindingDecl(hasName("f"), 6086*e038c9c4Sjoerg forDecomposition(decompositionDecl()) 6087*e038c9c4Sjoergmatches 'f' in 'auto &[f, s, t]'. 6088*e038c9c4Sjoerg</pre></td></tr> 6089*e038c9c4Sjoerg 6090*e038c9c4Sjoerg 60917330f729Sjoerg<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> 60927330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a 60937330f729Sjoergblock. 60947330f729Sjoerg 60957330f729SjoergDoes not match the 'this' parameter of a method. 60967330f729Sjoerg 60977330f729SjoergGiven 60987330f729Sjoerg class X { void f(int x, int y, int z) {} }; 60997330f729SjoergcxxMethodDecl(hasAnyParameter(hasName("y"))) 61007330f729Sjoerg matches f(int x, int y, int z) {} 61017330f729Sjoergwith hasAnyParameter(...) 61027330f729Sjoerg matching int y 61037330f729Sjoerg 61047330f729SjoergFor ObjectiveC, given 61057330f729Sjoerg @interface I - (void) f:(int) y; @end 61067330f729Sjoerg 61077330f729Sjoergthe matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 61087330f729Sjoergmatches the declaration of method f with hasParameter 61097330f729Sjoergmatching y. 61107330f729Sjoerg 61117330f729SjoergFor blocks, given 61127330f729Sjoerg b = ^(int y) { printf("%d", y) }; 61137330f729Sjoerg 61147330f729Sjoergthe matcher blockDecl(hasAnyParameter(hasName("y"))) 61157330f729Sjoergmatches the declaration of the block b with hasParameter 61167330f729Sjoergmatching y. 61177330f729Sjoerg</pre></td></tr> 61187330f729Sjoerg 61197330f729Sjoerg 61207330f729Sjoerg<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> 61217330f729Sjoerg<tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method 61227330f729Sjoergdeclaration or a block. 61237330f729Sjoerg 61247330f729SjoergGiven 61257330f729Sjoerg class X { void f(int x) {} }; 61267330f729SjoergcxxMethodDecl(hasParameter(0, hasType(varDecl()))) 61277330f729Sjoerg matches f(int x) {} 61287330f729Sjoergwith hasParameter(...) 61297330f729Sjoerg matching int x 61307330f729Sjoerg 61317330f729SjoergFor ObjectiveC, given 61327330f729Sjoerg @interface I - (void) f:(int) y; @end 61337330f729Sjoerg 61347330f729Sjoergthe matcher objcMethodDecl(hasParameter(0, hasName("y"))) 61357330f729Sjoergmatches the declaration of method f with hasParameter 61367330f729Sjoergmatching y. 61377330f729Sjoerg</pre></td></tr> 61387330f729Sjoerg 61397330f729Sjoerg 6140*e038c9c4Sjoerg<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> 6141*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of a node matches the inner matcher. 6142*e038c9c4Sjoerg 6143*e038c9c4SjoergExamples: 6144*e038c9c4Sjoerg int x; 6145*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 6146*e038c9c4Sjoerg matches int x 6147*e038c9c4Sjoerg 6148*e038c9c4Sjoergauto x = int(3); 6149*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 6150*e038c9c4Sjoerg matches int(3) 6151*e038c9c4Sjoerg 6152*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 6153*e038c9c4Sjoergauto x = Foo(1, 2); 6154*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 6155*e038c9c4Sjoerg matches Foo(1, 2) 6156*e038c9c4Sjoerg 6157*e038c9c4SjoergUsable 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>>, 6158*e038c9c4Sjoerg 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>>, 6159*e038c9c4Sjoerg 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>>, 6160*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 6161*e038c9c4Sjoerg 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>>, 6162*e038c9c4Sjoerg 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>>, 6163*e038c9c4Sjoerg 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>>, 6164*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 6165*e038c9c4Sjoerg</pre></td></tr> 6166*e038c9c4Sjoerg 6167*e038c9c4Sjoerg 61687330f729Sjoerg<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> 61697330f729Sjoerg<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the 61707330f729Sjoergpointee matches a given matcher. 61717330f729Sjoerg 61727330f729SjoergGiven 61737330f729Sjoerg int *a; 61747330f729Sjoerg int const *b; 61757330f729Sjoerg float const *f; 61767330f729SjoergpointerType(pointee(isConstQualified(), isInteger())) 61777330f729Sjoerg matches "int const *b" 61787330f729Sjoerg 61797330f729SjoergUsable 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>>, 61807330f729Sjoerg 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>> 61817330f729Sjoerg</pre></td></tr> 61827330f729Sjoerg 61837330f729Sjoerg 6184*e038c9c4Sjoerg<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> 6185*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc1"><pre>Matches if the type location of a node matches the inner matcher. 6186*e038c9c4Sjoerg 6187*e038c9c4SjoergExamples: 6188*e038c9c4Sjoerg int x; 6189*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 6190*e038c9c4Sjoerg matches int x 6191*e038c9c4Sjoerg 6192*e038c9c4Sjoergauto x = int(3); 6193*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 6194*e038c9c4Sjoerg matches int(3) 6195*e038c9c4Sjoerg 6196*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 6197*e038c9c4Sjoergauto x = Foo(1, 2); 6198*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 6199*e038c9c4Sjoerg matches Foo(1, 2) 6200*e038c9c4Sjoerg 6201*e038c9c4SjoergUsable 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>>, 6202*e038c9c4Sjoerg 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>>, 6203*e038c9c4Sjoerg 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>>, 6204*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 6205*e038c9c4Sjoerg 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>>, 6206*e038c9c4Sjoerg 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>>, 6207*e038c9c4Sjoerg 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>>, 6208*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 6209*e038c9c4Sjoerg</pre></td></tr> 6210*e038c9c4Sjoerg 6211*e038c9c4Sjoerg 6212*e038c9c4Sjoerg<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> 6213*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasType8"><pre>Overloaded to match the declaration of the expression's or value 6214*e038c9c4Sjoergdeclaration's type. 6215*e038c9c4Sjoerg 6216*e038c9c4SjoergIn case of a value declaration (for example a variable declaration), 6217*e038c9c4Sjoergthis resolves one layer of indirection. For example, in the value 6218*e038c9c4Sjoergdeclaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 6219*e038c9c4SjoergX, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 6220*e038c9c4Sjoergdeclaration of x. 6221*e038c9c4Sjoerg 6222*e038c9c4SjoergExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6223*e038c9c4Sjoerg and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6224*e038c9c4Sjoerg and friend class X (matcher = friendDecl(hasType("X")) 6225*e038c9c4Sjoerg and public virtual X (matcher = cxxBaseSpecifier(hasType( 6226*e038c9c4Sjoerg cxxRecordDecl(hasName("X")))) 6227*e038c9c4Sjoerg class X {}; 6228*e038c9c4Sjoerg void y(X &x) { x; X z; } 6229*e038c9c4Sjoerg class Y { friend class X; }; 6230*e038c9c4Sjoerg class Z : public virtual X {}; 6231*e038c9c4Sjoerg 6232*e038c9c4SjoergExample matches class Derived 6233*e038c9c4Sjoerg(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) 6234*e038c9c4Sjoergclass Base {}; 6235*e038c9c4Sjoergclass Derived : Base {}; 6236*e038c9c4Sjoerg 6237*e038c9c4SjoergUsable 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>>, 6238*e038c9c4SjoergMatcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> 6239*e038c9c4Sjoerg</pre></td></tr> 6240*e038c9c4Sjoerg 6241*e038c9c4Sjoerg 6242*e038c9c4Sjoerg<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> 6243*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasType4"><pre>Matches if the expression's or declaration's type matches a type 6244*e038c9c4Sjoergmatcher. 6245*e038c9c4Sjoerg 6246*e038c9c4SjoergExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6247*e038c9c4Sjoerg and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6248*e038c9c4Sjoerg and U (matcher = typedefDecl(hasType(asString("int"))) 6249*e038c9c4Sjoerg and friend class X (matcher = friendDecl(hasType("X")) 6250*e038c9c4Sjoerg and public virtual X (matcher = cxxBaseSpecifier(hasType( 6251*e038c9c4Sjoerg asString("class X"))) 6252*e038c9c4Sjoerg class X {}; 6253*e038c9c4Sjoerg void y(X &x) { x; X z; } 6254*e038c9c4Sjoerg typedef int U; 6255*e038c9c4Sjoerg class Y { friend class X; }; 6256*e038c9c4Sjoerg class Z : public virtual X {}; 6257*e038c9c4Sjoerg</pre></td></tr> 6258*e038c9c4Sjoerg 6259*e038c9c4Sjoerg 62607330f729Sjoerg<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> 62617330f729Sjoerg<tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl. 62627330f729Sjoerg 62637330f729SjoergGiven 62647330f729Sjoerg void f(int i); 62657330f729Sjoerg int y; 62667330f729Sjoerg f(y); 62677330f729SjoergcallExpr( 62687330f729Sjoerg forEachArgumentWithParam( 62697330f729Sjoerg declRefExpr(to(varDecl(hasName("y")))), 62707330f729Sjoerg parmVarDecl(hasType(isInteger())) 62717330f729Sjoerg)) 62727330f729Sjoerg matches f(y); 62737330f729Sjoergwith declRefExpr(...) 62747330f729Sjoerg matching int y 62757330f729Sjoergand parmVarDecl(...) 62767330f729Sjoerg matching int i 62777330f729Sjoerg</pre></td></tr> 62787330f729Sjoerg 62797330f729Sjoerg 6280*e038c9c4Sjoerg<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> 6281*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="forEachArgumentWithParamType1"><pre>Matches all arguments and their respective types for a CallExpr or 6282*e038c9c4SjoergCXXConstructExpr. It is very similar to forEachArgumentWithParam but 6283*e038c9c4Sjoergit works on calls through function pointers as well. 6284*e038c9c4Sjoerg 6285*e038c9c4SjoergThe difference is, that function pointers do not provide access to a 6286*e038c9c4SjoergParmVarDecl, but only the QualType for each argument. 6287*e038c9c4Sjoerg 6288*e038c9c4SjoergGiven 6289*e038c9c4Sjoerg void f(int i); 6290*e038c9c4Sjoerg int y; 6291*e038c9c4Sjoerg f(y); 6292*e038c9c4Sjoerg void (*f_ptr)(int) = f; 6293*e038c9c4Sjoerg f_ptr(y); 6294*e038c9c4SjoergcallExpr( 6295*e038c9c4Sjoerg forEachArgumentWithParamType( 6296*e038c9c4Sjoerg declRefExpr(to(varDecl(hasName("y")))), 6297*e038c9c4Sjoerg qualType(isInteger()).bind("type) 6298*e038c9c4Sjoerg)) 6299*e038c9c4Sjoerg matches f(y) and f_ptr(y) 6300*e038c9c4Sjoergwith declRefExpr(...) 6301*e038c9c4Sjoerg matching int y 6302*e038c9c4Sjoergand qualType(...) 6303*e038c9c4Sjoerg matching int 6304*e038c9c4Sjoerg</pre></td></tr> 6305*e038c9c4Sjoerg 6306*e038c9c4Sjoerg 63077330f729Sjoerg<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> 63087330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call 63097330f729Sjoergexpression, or an ObjC-message-send expression. 63107330f729Sjoerg 63117330f729SjoergGiven 63127330f729Sjoerg void x(int, int, int) { int y; x(1, y, 42); } 63137330f729SjoergcallExpr(hasAnyArgument(declRefExpr())) 63147330f729Sjoerg matches x(1, y, 42) 63157330f729Sjoergwith hasAnyArgument(...) 63167330f729Sjoerg matching y 63177330f729Sjoerg 63187330f729SjoergFor ObjectiveC, given 63197330f729Sjoerg @interface I - (void) f:(int) y; @end 63207330f729Sjoerg void foo(I *i) { [i f:12]; } 63217330f729SjoergobjcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 63227330f729Sjoerg matches [i f:12] 63237330f729Sjoerg</pre></td></tr> 63247330f729Sjoerg 63257330f729Sjoerg 63267330f729Sjoerg<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> 63277330f729Sjoerg<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor 63287330f729Sjoergcall expression. 63297330f729Sjoerg 63307330f729SjoergExample matches y in x(y) 63317330f729Sjoerg (matcher = callExpr(hasArgument(0, declRefExpr()))) 63327330f729Sjoerg void x(int) { int y; x(y); } 63337330f729Sjoerg</pre></td></tr> 63347330f729Sjoerg 63357330f729Sjoerg 6336*e038c9c4Sjoerg<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> 63377330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node 63387330f729Sjoergmatches the given matcher. 63397330f729Sjoerg 63407330f729SjoergThe associated declaration is: 63417330f729Sjoerg- for type nodes, the declaration of the underlying type 63427330f729Sjoerg- for CallExpr, the declaration of the callee 63437330f729Sjoerg- for MemberExpr, the declaration of the referenced member 63447330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 63457330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 63467330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 63477330f729Sjoerg 63487330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 63497330f729Sjoergsugared type. Given 63507330f729Sjoerg class X {}; 63517330f729Sjoerg typedef X Y; 63527330f729Sjoerg Y y; 63537330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 63547330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 63557330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 63567330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 63577330f729Sjoerg recordType(hasDeclaration(decl()))))) 63587330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 63597330f729Sjoerg 63607330f729SjoergUsable 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>>, 63617330f729Sjoerg 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>>, 63627330f729Sjoerg 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>>, 63637330f729Sjoerg 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>>, 63647330f729Sjoerg 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>>, 63657330f729Sjoerg 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>>, 63667330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 63677330f729Sjoerg</pre></td></tr> 63687330f729Sjoerg 63697330f729Sjoerg 63707330f729Sjoerg<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> 63717330f729Sjoerg<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. 63727330f729Sjoerg 63737330f729SjoergGiven 63747330f729Sjoerg class A { A() : i(42), j(42) {} int i; int j; }; 63757330f729SjoergcxxConstructorDecl(forEachConstructorInitializer( 63767330f729Sjoerg forField(decl().bind("x")) 63777330f729Sjoerg)) 63787330f729Sjoerg will trigger two matches, binding for 'i' and 'j' respectively. 63797330f729Sjoerg</pre></td></tr> 63807330f729Sjoerg 63817330f729Sjoerg 63827330f729Sjoerg<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> 63837330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 63847330f729Sjoerg 63857330f729SjoergGiven 63867330f729Sjoerg struct Foo { 63877330f729Sjoerg Foo() : foo_(1) { } 63887330f729Sjoerg int foo_; 63897330f729Sjoerg }; 63907330f729SjoergcxxRecordDecl(has(cxxConstructorDecl( 63917330f729Sjoerg hasAnyConstructorInitializer(anything()) 63927330f729Sjoerg))) 63937330f729Sjoerg record matches Foo, hasAnyConstructorInitializer matches foo_(1) 63947330f729Sjoerg</pre></td></tr> 63957330f729Sjoerg 63967330f729Sjoerg 63977330f729Sjoerg<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> 63987330f729Sjoerg<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 63997330f729Sjoerg 64007330f729SjoergGiven 64017330f729Sjoerg struct Foo { 64027330f729Sjoerg Foo() : foo_(1) { } 64037330f729Sjoerg int foo_; 64047330f729Sjoerg }; 64057330f729SjoergcxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 64067330f729Sjoerg forField(hasName("foo_")))))) 64077330f729Sjoerg matches Foo 64087330f729Sjoergwith forField matching foo_ 64097330f729Sjoerg</pre></td></tr> 64107330f729Sjoerg 64117330f729Sjoerg 6412*e038c9c4Sjoerg<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> 6413*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc2"><pre>Matches if the type location of a node matches the inner matcher. 6414*e038c9c4Sjoerg 6415*e038c9c4SjoergExamples: 6416*e038c9c4Sjoerg int x; 6417*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 6418*e038c9c4Sjoerg matches int x 6419*e038c9c4Sjoerg 6420*e038c9c4Sjoergauto x = int(3); 6421*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 6422*e038c9c4Sjoerg matches int(3) 6423*e038c9c4Sjoerg 6424*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 6425*e038c9c4Sjoergauto x = Foo(1, 2); 6426*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 6427*e038c9c4Sjoerg matches Foo(1, 2) 6428*e038c9c4Sjoerg 6429*e038c9c4SjoergUsable 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>>, 6430*e038c9c4Sjoerg 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>>, 6431*e038c9c4Sjoerg 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>>, 6432*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 6433*e038c9c4Sjoerg 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>>, 6434*e038c9c4Sjoerg 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>>, 6435*e038c9c4Sjoerg 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>>, 6436*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 6437*e038c9c4Sjoerg</pre></td></tr> 6438*e038c9c4Sjoerg 6439*e038c9c4Sjoerg 64407330f729Sjoerg<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> 64417330f729Sjoerg<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 64427330f729Sjoerg 64437330f729SjoergGiven 64447330f729Sjoerg struct Foo { 64457330f729Sjoerg Foo() : foo_(1) { } 64467330f729Sjoerg int foo_; 64477330f729Sjoerg }; 64487330f729SjoergcxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 64497330f729Sjoerg withInitializer(integerLiteral(equals(1))))))) 64507330f729Sjoerg matches Foo 64517330f729Sjoergwith withInitializer matching (1) 64527330f729Sjoerg</pre></td></tr> 64537330f729Sjoerg 64547330f729Sjoerg 64557330f729Sjoerg<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> 64567330f729Sjoerg<tr><td colspan="4" class="doc" id="hasObjectExpression2"><pre>Matches a member expression where the object expression is matched by a 64577330f729Sjoerggiven matcher. Implicit object expressions are included; that is, it matches 64587330f729Sjoerguse of implicit `this`. 64597330f729Sjoerg 64607330f729SjoergGiven 64617330f729Sjoerg struct X { 64627330f729Sjoerg int m; 64637330f729Sjoerg int f(X x) { x.m; return m; } 64647330f729Sjoerg }; 64657330f729SjoergmemberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) 64667330f729Sjoerg matches `x.m`, but not `m`; however, 64677330f729SjoergmemberExpr(hasObjectExpression(hasType(pointsTo( 64687330f729Sjoerg cxxRecordDecl(hasName("X")))))) 64697330f729Sjoerg matches `m` (aka. `this->m`), but not `x.m`. 64707330f729Sjoerg</pre></td></tr> 64717330f729Sjoerg 64727330f729Sjoerg 64737330f729Sjoerg<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> 6474*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasBody3"><pre></pre></td></tr> 64757330f729Sjoerg 6476*e038c9c4Sjoerg 6477*e038c9c4Sjoerg<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> 6478*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasInitStatement2"><pre>Matches selection statements with initializer. 6479*e038c9c4Sjoerg 6480*e038c9c4SjoergGiven: 6481*e038c9c4Sjoerg void foo() { 6482*e038c9c4Sjoerg if (int i = foobar(); i > 0) {} 6483*e038c9c4Sjoerg switch (int i = foobar(); i) {} 6484*e038c9c4Sjoerg for (auto& a = get_range(); auto& x : a) {} 6485*e038c9c4Sjoerg } 6486*e038c9c4Sjoerg void bar() { 6487*e038c9c4Sjoerg if (foobar() > 0) {} 6488*e038c9c4Sjoerg switch (foobar()) {} 6489*e038c9c4Sjoerg for (auto& x : get_range()) {} 6490*e038c9c4Sjoerg } 6491*e038c9c4SjoergifStmt(hasInitStatement(anything())) 6492*e038c9c4Sjoerg matches the if statement in foo but not in bar. 6493*e038c9c4SjoergswitchStmt(hasInitStatement(anything())) 6494*e038c9c4Sjoerg matches the switch statement in foo but not in bar. 6495*e038c9c4SjoergcxxForRangeStmt(hasInitStatement(anything())) 6496*e038c9c4Sjoerg matches the range for statement in foo but not in bar. 64977330f729Sjoerg</pre></td></tr> 64987330f729Sjoerg 64997330f729Sjoerg 65007330f729Sjoerg<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> 65017330f729Sjoerg<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. 65027330f729Sjoerg 65037330f729SjoergExample: 65047330f729Sjoerg forStmt(hasLoopVariable(anything())) 65057330f729Sjoergmatches 'int x' in 65067330f729Sjoerg for (int x : a) { } 65077330f729Sjoerg</pre></td></tr> 65087330f729Sjoerg 65097330f729Sjoerg 65107330f729Sjoerg<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> 65117330f729Sjoerg<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. 65127330f729Sjoerg 65137330f729SjoergExample: 65147330f729Sjoerg forStmt(hasRangeInit(anything())) 65157330f729Sjoergmatches 'a' in 65167330f729Sjoerg for (int x : a) { } 65177330f729Sjoerg</pre></td></tr> 65187330f729Sjoerg 65197330f729Sjoerg 6520*e038c9c4Sjoerg<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> 6521*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc3"><pre>Matches if the type location of a node matches the inner matcher. 6522*e038c9c4Sjoerg 6523*e038c9c4SjoergExamples: 6524*e038c9c4Sjoerg int x; 6525*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 6526*e038c9c4Sjoerg matches int x 6527*e038c9c4Sjoerg 6528*e038c9c4Sjoergauto x = int(3); 6529*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 6530*e038c9c4Sjoerg matches int(3) 6531*e038c9c4Sjoerg 6532*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 6533*e038c9c4Sjoergauto x = Foo(1, 2); 6534*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 6535*e038c9c4Sjoerg matches Foo(1, 2) 6536*e038c9c4Sjoerg 6537*e038c9c4SjoergUsable 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>>, 6538*e038c9c4Sjoerg 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>>, 6539*e038c9c4Sjoerg 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>>, 6540*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 6541*e038c9c4Sjoerg 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>>, 6542*e038c9c4Sjoerg 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>>, 6543*e038c9c4Sjoerg 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>>, 6544*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 6545*e038c9c4Sjoerg</pre></td></tr> 6546*e038c9c4Sjoerg 6547*e038c9c4Sjoerg 65487330f729Sjoerg<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> 65497330f729Sjoerg<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre>Matches on the implicit object argument of a member call expression. Unlike 65507330f729Sjoerg`on`, matches the argument directly without stripping away anything. 65517330f729Sjoerg 65527330f729SjoergGiven 65537330f729Sjoerg class Y { public: void m(); }; 65547330f729Sjoerg Y g(); 65557330f729Sjoerg class X : public Y { void g(); }; 65567330f729Sjoerg void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); } 65577330f729SjoergcxxMemberCallExpr(onImplicitObjectArgument(hasType( 65587330f729Sjoerg cxxRecordDecl(hasName("Y"))))) 65597330f729Sjoerg matches `y.m()`, `x.m()` and (g()).m(), but not `x.g()`. 65607330f729SjoergcxxMemberCallExpr(on(callExpr())) 65617330f729Sjoerg does not match `(g()).m()`, because the parens are not ignored. 65627330f729Sjoerg 65637330f729SjoergFIXME: Overload to allow directly matching types? 65647330f729Sjoerg</pre></td></tr> 65657330f729Sjoerg 65667330f729Sjoerg 65677330f729Sjoerg<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> 65687330f729Sjoerg<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression, after 65697330f729Sjoergstripping off any parentheses or implicit casts. 65707330f729Sjoerg 65717330f729SjoergGiven 65727330f729Sjoerg class Y { public: void m(); }; 65737330f729Sjoerg Y g(); 65747330f729Sjoerg class X : public Y {}; 65757330f729Sjoerg void z(Y y, X x) { y.m(); (g()).m(); x.m(); } 65767330f729SjoergcxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))))) 65777330f729Sjoerg matches `y.m()` and `(g()).m()`. 65787330f729SjoergcxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X"))))) 65797330f729Sjoerg matches `x.m()`. 65807330f729SjoergcxxMemberCallExpr(on(callExpr())) 65817330f729Sjoerg matches `(g()).m()`. 65827330f729Sjoerg 65837330f729SjoergFIXME: Overload to allow directly matching types? 65847330f729Sjoerg</pre></td></tr> 65857330f729Sjoerg 65867330f729Sjoerg 65877330f729Sjoerg<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> 65887330f729Sjoerg<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 65897330f729Sjoerg</pre></td></tr> 65907330f729Sjoerg 65917330f729Sjoerg 65927330f729Sjoerg<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> 65937330f729Sjoerg<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the type of the expression's implicit object argument either 65947330f729Sjoergmatches the InnerMatcher, or is a pointer to a type that matches the 65957330f729SjoergInnerMatcher. 65967330f729Sjoerg 65977330f729SjoergGiven 65987330f729Sjoerg class Y { public: void m(); }; 65997330f729Sjoerg class X : public Y { void g(); }; 66007330f729Sjoerg void z() { Y y; y.m(); Y *p; p->m(); X x; x.m(); x.g(); } 66017330f729SjoergcxxMemberCallExpr(thisPointerType(hasDeclaration( 66027330f729Sjoerg cxxRecordDecl(hasName("Y"))))) 66037330f729Sjoerg matches `y.m()`, `p->m()` and `x.m()`. 66047330f729SjoergcxxMemberCallExpr(thisPointerType(hasDeclaration( 66057330f729Sjoerg cxxRecordDecl(hasName("X"))))) 66067330f729Sjoerg matches `x.g()`. 66077330f729Sjoerg</pre></td></tr> 66087330f729Sjoerg 66097330f729Sjoerg 66107330f729Sjoerg<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> 66117330f729Sjoerg<tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may 66127330f729Sjoergproduce multiple matches. 66137330f729Sjoerg 66147330f729SjoergGiven 66157330f729Sjoerg class A { virtual void f(); }; 66167330f729Sjoerg class B : public A { void f(); }; 66177330f729Sjoerg class C : public B { void f(); }; 66187330f729SjoergcxxMethodDecl(ofClass(hasName("C")), 66197330f729Sjoerg forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") 66207330f729Sjoerg matches once, with "b" binding "A::f" and "d" binding "C::f" (Note 66217330f729Sjoerg that B::f is not overridden by C::f). 66227330f729Sjoerg 66237330f729SjoergThe check can produce multiple matches in case of multiple inheritance, e.g. 66247330f729Sjoerg class A1 { virtual void f(); }; 66257330f729Sjoerg class A2 { virtual void f(); }; 66267330f729Sjoerg class C : public A1, public A2 { void f(); }; 66277330f729SjoergcxxMethodDecl(ofClass(hasName("C")), 66287330f729Sjoerg forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") 66297330f729Sjoerg matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and 66307330f729Sjoerg once with "b" binding "A2::f" and "d" binding "C::f". 66317330f729Sjoerg</pre></td></tr> 66327330f729Sjoerg 66337330f729Sjoerg 66347330f729Sjoerg<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> 66357330f729Sjoerg<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 66367330f729Sjoergbelongs to. 66377330f729Sjoerg 66387330f729SjoergFIXME: Generalize this for other kinds of declarations. 66397330f729SjoergFIXME: What other kind of declarations would we need to generalize 66407330f729Sjoergthis to? 66417330f729Sjoerg 66427330f729SjoergExample matches A() in the last line 66437330f729Sjoerg (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( 66447330f729Sjoerg ofClass(hasName("A")))))) 66457330f729Sjoerg class A { 66467330f729Sjoerg public: 66477330f729Sjoerg A(); 66487330f729Sjoerg }; 66497330f729Sjoerg A a = A(); 66507330f729Sjoerg</pre></td></tr> 66517330f729Sjoerg 66527330f729Sjoerg 6653*e038c9c4Sjoerg<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> 6654*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyPlacementArg0"><pre>Matches any placement new expression arguments. 6655*e038c9c4Sjoerg 6656*e038c9c4SjoergGiven: 6657*e038c9c4Sjoerg MyClass *p1 = new (Storage) MyClass(); 6658*e038c9c4SjoergcxxNewExpr(hasAnyPlacementArg(anything())) 6659*e038c9c4Sjoerg matches the expression 'new (Storage, 16) MyClass()'. 6660*e038c9c4Sjoerg</pre></td></tr> 6661*e038c9c4Sjoerg 6662*e038c9c4Sjoerg 66637330f729Sjoerg<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> 66647330f729Sjoerg<tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size. 66657330f729Sjoerg 66667330f729SjoergGiven: 66677330f729Sjoerg MyClass *p1 = new MyClass[10]; 6668*e038c9c4SjoergcxxNewExpr(hasArraySize(integerLiteral(equals(10)))) 66697330f729Sjoerg matches the expression 'new MyClass[10]'. 66707330f729Sjoerg</pre></td></tr> 66717330f729Sjoerg 66727330f729Sjoerg 6673*e038c9c4Sjoerg<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> 66747330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node 66757330f729Sjoergmatches the given matcher. 66767330f729Sjoerg 66777330f729SjoergThe associated declaration is: 66787330f729Sjoerg- for type nodes, the declaration of the underlying type 66797330f729Sjoerg- for CallExpr, the declaration of the callee 66807330f729Sjoerg- for MemberExpr, the declaration of the referenced member 66817330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 66827330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 66837330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 66847330f729Sjoerg 66857330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 66867330f729Sjoergsugared type. Given 66877330f729Sjoerg class X {}; 66887330f729Sjoerg typedef X Y; 66897330f729Sjoerg Y y; 66907330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 66917330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 66927330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 66937330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 66947330f729Sjoerg recordType(hasDeclaration(decl()))))) 66957330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 66967330f729Sjoerg 66977330f729SjoergUsable 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>>, 66987330f729Sjoerg 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>>, 66997330f729Sjoerg 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>>, 67007330f729Sjoerg 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>>, 67017330f729Sjoerg 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>>, 67027330f729Sjoerg 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>>, 67037330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 67047330f729Sjoerg</pre></td></tr> 67057330f729Sjoerg 67067330f729Sjoerg 6707*e038c9c4Sjoerg<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> 6708*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasPlacementArg0"><pre>Matches placement new expression arguments. 6709*e038c9c4Sjoerg 6710*e038c9c4SjoergGiven: 6711*e038c9c4Sjoerg MyClass *p1 = new (Storage, 16) MyClass(); 6712*e038c9c4SjoergcxxNewExpr(hasPlacementArg(1, integerLiteral(equals(16)))) 6713*e038c9c4Sjoerg matches the expression 'new (Storage, 16) MyClass()'. 6714*e038c9c4Sjoerg</pre></td></tr> 6715*e038c9c4Sjoerg 6716*e038c9c4Sjoerg 6717*e038c9c4Sjoerg<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> 6718*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc4"><pre>Matches if the type location of a node matches the inner matcher. 6719*e038c9c4Sjoerg 6720*e038c9c4SjoergExamples: 6721*e038c9c4Sjoerg int x; 6722*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 6723*e038c9c4Sjoerg matches int x 6724*e038c9c4Sjoerg 6725*e038c9c4Sjoergauto x = int(3); 6726*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 6727*e038c9c4Sjoerg matches int(3) 6728*e038c9c4Sjoerg 6729*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 6730*e038c9c4Sjoergauto x = Foo(1, 2); 6731*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 6732*e038c9c4Sjoerg matches Foo(1, 2) 6733*e038c9c4Sjoerg 6734*e038c9c4SjoergUsable 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>>, 6735*e038c9c4Sjoerg 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>>, 6736*e038c9c4Sjoerg 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>>, 6737*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 6738*e038c9c4Sjoerg 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>>, 6739*e038c9c4Sjoerg 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>>, 6740*e038c9c4Sjoerg 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>>, 6741*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 6742*e038c9c4Sjoerg</pre></td></tr> 6743*e038c9c4Sjoerg 6744*e038c9c4Sjoerg 6745*e038c9c4Sjoerg<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> 6746*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasEitherOperand1"><pre>Matches if either the left hand side or the right hand side of a 6747*e038c9c4Sjoergbinary operator matches. 6748*e038c9c4Sjoerg</pre></td></tr> 6749*e038c9c4Sjoerg 6750*e038c9c4Sjoerg 6751*e038c9c4Sjoerg<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> 6752*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions. 6753*e038c9c4Sjoerg 6754*e038c9c4SjoergExample matches a (matcher = binaryOperator(hasLHS())) 6755*e038c9c4Sjoerg a || b 6756*e038c9c4Sjoerg</pre></td></tr> 6757*e038c9c4Sjoerg 6758*e038c9c4Sjoerg 6759*e038c9c4Sjoerg<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> 6760*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasOperands1"><pre>Matches if both matchers match with opposite sides of the binary operator. 6761*e038c9c4Sjoerg 6762*e038c9c4SjoergExample matcher = binaryOperator(hasOperands(integerLiteral(equals(1), 6763*e038c9c4Sjoerg integerLiteral(equals(2))) 6764*e038c9c4Sjoerg 1 + 2 // Match 6765*e038c9c4Sjoerg 2 + 1 // Match 6766*e038c9c4Sjoerg 1 + 1 // No match 6767*e038c9c4Sjoerg 2 + 2 // No match 6768*e038c9c4Sjoerg</pre></td></tr> 6769*e038c9c4Sjoerg 6770*e038c9c4Sjoerg 6771*e038c9c4Sjoerg<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> 6772*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions. 6773*e038c9c4Sjoerg 6774*e038c9c4SjoergExample matches b (matcher = binaryOperator(hasRHS())) 6775*e038c9c4Sjoerg a || b 6776*e038c9c4Sjoerg</pre></td></tr> 6777*e038c9c4Sjoerg 6778*e038c9c4Sjoerg 6779*e038c9c4Sjoerg<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> 6780*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasUnaryOperand1"><pre>Matches if the operand of a unary operator matches. 6781*e038c9c4Sjoerg 6782*e038c9c4SjoergExample matches true (matcher = hasUnaryOperand( 6783*e038c9c4Sjoerg cxxBoolLiteral(equals(true)))) 6784*e038c9c4Sjoerg !true 6785*e038c9c4Sjoerg</pre></td></tr> 6786*e038c9c4Sjoerg 6787*e038c9c4Sjoerg 6788*e038c9c4Sjoerg<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> 6789*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyBase0"><pre>Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher. 6790*e038c9c4Sjoerg 6791*e038c9c4SjoergExample: 6792*e038c9c4Sjoergmatcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase")))) 6793*e038c9c4Sjoerg class Foo; 6794*e038c9c4Sjoerg class Bar : Foo {}; 6795*e038c9c4Sjoerg class Baz : Bar {}; 6796*e038c9c4Sjoerg class SpecialBase; 6797*e038c9c4Sjoerg class Proxy : SpecialBase {}; // matches Proxy 6798*e038c9c4Sjoerg class IndirectlyDerived : Proxy {}; //matches IndirectlyDerived 6799*e038c9c4Sjoerg 6800*e038c9c4SjoergFIXME: Refactor this and isDerivedFrom to reuse implementation. 6801*e038c9c4Sjoerg</pre></td></tr> 6802*e038c9c4Sjoerg 6803*e038c9c4Sjoerg 6804*e038c9c4Sjoerg<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> 6805*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasDirectBase0"><pre>Matches C++ classes that have a direct base matching BaseSpecMatcher. 6806*e038c9c4Sjoerg 6807*e038c9c4SjoergExample: 6808*e038c9c4Sjoergmatcher hasDirectBase(hasType(cxxRecordDecl(hasName("SpecialBase")))) 6809*e038c9c4Sjoerg class Foo; 6810*e038c9c4Sjoerg class Bar : Foo {}; 6811*e038c9c4Sjoerg class Baz : Bar {}; 6812*e038c9c4Sjoerg class SpecialBase; 6813*e038c9c4Sjoerg class Proxy : SpecialBase {}; // matches Proxy 6814*e038c9c4Sjoerg class IndirectlyDerived : Proxy {}; // doesn't match 6815*e038c9c4Sjoerg</pre></td></tr> 6816*e038c9c4Sjoerg 6817*e038c9c4Sjoerg 68187330f729Sjoerg<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> 68197330f729Sjoerg<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. 68207330f729Sjoerg 68217330f729SjoergGiven: 68227330f729Sjoerg class A { void func(); }; 68237330f729Sjoerg class B { void member(); }; 68247330f729Sjoerg 68257330f729SjoergcxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of 68267330f729SjoergA but not B. 68277330f729Sjoerg</pre></td></tr> 68287330f729Sjoerg 68297330f729Sjoerg 68307330f729Sjoerg<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> 68317330f729Sjoerg<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from a class 68327330f729Sjoergmatching Base, or Objective-C classes that directly or indirectly 68337330f729Sjoergsubclass a class matching Base. 68347330f729Sjoerg 68357330f729SjoergNote that a class is not considered to be derived from itself. 68367330f729Sjoerg 68377330f729SjoergExample matches Y, Z, C (Base == hasName("X")) 68387330f729Sjoerg class X; 68397330f729Sjoerg class Y : public X {}; // directly derived 68407330f729Sjoerg class Z : public Y {}; // indirectly derived 68417330f729Sjoerg typedef X A; 68427330f729Sjoerg typedef A B; 68437330f729Sjoerg class C : public B {}; // derived from a typedef of X 68447330f729Sjoerg 68457330f729SjoergIn the following example, Bar matches isDerivedFrom(hasName("X")): 68467330f729Sjoerg class Foo; 68477330f729Sjoerg typedef Foo X; 68487330f729Sjoerg class Bar : public Foo {}; // derived from a type that X is a typedef of 68497330f729Sjoerg 68507330f729SjoergIn the following example, Bar matches isDerivedFrom(hasName("NSObject")) 68517330f729Sjoerg @interface NSObject @end 68527330f729Sjoerg @interface Bar : NSObject @end 68537330f729Sjoerg 68547330f729SjoergUsable 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>> 68557330f729Sjoerg</pre></td></tr> 68567330f729Sjoerg 68577330f729Sjoerg 68587330f729Sjoerg<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> 68597330f729Sjoerg<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom0"><pre>Matches C++ or Objective-C classes that are directly derived from a class 68607330f729Sjoergmatching Base. 68617330f729Sjoerg 68627330f729SjoergNote that a class is not considered to be derived from itself. 68637330f729Sjoerg 68647330f729SjoergExample matches Y, C (Base == hasName("X")) 68657330f729Sjoerg class X; 68667330f729Sjoerg class Y : public X {}; // directly derived 68677330f729Sjoerg class Z : public Y {}; // indirectly derived 68687330f729Sjoerg typedef X A; 68697330f729Sjoerg typedef A B; 68707330f729Sjoerg class C : public B {}; // derived from a typedef of X 68717330f729Sjoerg 68727330f729SjoergIn the following example, Bar matches isDerivedFrom(hasName("X")): 68737330f729Sjoerg class Foo; 68747330f729Sjoerg typedef Foo X; 68757330f729Sjoerg class Bar : public Foo {}; // derived from a type that X is a typedef of 68767330f729Sjoerg</pre></td></tr> 68777330f729Sjoerg 68787330f729Sjoerg 68797330f729Sjoerg<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> 68807330f729Sjoerg<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 68817330f729Sjoergmatch Base. 68827330f729Sjoerg</pre></td></tr> 68837330f729Sjoerg 68847330f729Sjoerg 6885*e038c9c4Sjoerg<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> 6886*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasEitherOperand2"><pre>Matches if either the left hand side or the right hand side of a 6887*e038c9c4Sjoergbinary operator matches. 6888*e038c9c4Sjoerg</pre></td></tr> 6889*e038c9c4Sjoerg 6890*e038c9c4Sjoerg 6891*e038c9c4Sjoerg<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> 6892*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasLHS2"><pre>Matches the left hand side of binary operator expressions. 6893*e038c9c4Sjoerg 6894*e038c9c4SjoergExample matches a (matcher = binaryOperator(hasLHS())) 6895*e038c9c4Sjoerg a || b 6896*e038c9c4Sjoerg</pre></td></tr> 6897*e038c9c4Sjoerg 6898*e038c9c4Sjoerg 6899*e038c9c4Sjoerg<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> 6900*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasOperands2"><pre>Matches if both matchers match with opposite sides of the binary operator. 6901*e038c9c4Sjoerg 6902*e038c9c4SjoergExample matcher = binaryOperator(hasOperands(integerLiteral(equals(1), 6903*e038c9c4Sjoerg integerLiteral(equals(2))) 6904*e038c9c4Sjoerg 1 + 2 // Match 6905*e038c9c4Sjoerg 2 + 1 // Match 6906*e038c9c4Sjoerg 1 + 1 // No match 6907*e038c9c4Sjoerg 2 + 2 // No match 6908*e038c9c4Sjoerg</pre></td></tr> 6909*e038c9c4Sjoerg 6910*e038c9c4Sjoerg 6911*e038c9c4Sjoerg<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> 6912*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasRHS2"><pre>Matches the right hand side of binary operator expressions. 6913*e038c9c4Sjoerg 6914*e038c9c4SjoergExample matches b (matcher = binaryOperator(hasRHS())) 6915*e038c9c4Sjoerg a || b 6916*e038c9c4Sjoerg</pre></td></tr> 6917*e038c9c4Sjoerg 6918*e038c9c4Sjoerg 6919*e038c9c4Sjoerg<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> 6920*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc5"><pre>Matches if the type location of a node matches the inner matcher. 6921*e038c9c4Sjoerg 6922*e038c9c4SjoergExamples: 6923*e038c9c4Sjoerg int x; 6924*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 6925*e038c9c4Sjoerg matches int x 6926*e038c9c4Sjoerg 6927*e038c9c4Sjoergauto x = int(3); 6928*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 6929*e038c9c4Sjoerg matches int(3) 6930*e038c9c4Sjoerg 6931*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 6932*e038c9c4Sjoergauto x = Foo(1, 2); 6933*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 6934*e038c9c4Sjoerg matches Foo(1, 2) 6935*e038c9c4Sjoerg 6936*e038c9c4SjoergUsable 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>>, 6937*e038c9c4Sjoerg 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>>, 6938*e038c9c4Sjoerg 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>>, 6939*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 6940*e038c9c4Sjoerg 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>>, 6941*e038c9c4Sjoerg 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>>, 6942*e038c9c4Sjoerg 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>>, 6943*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 6944*e038c9c4Sjoerg</pre></td></tr> 6945*e038c9c4Sjoerg 6946*e038c9c4Sjoerg 69477330f729Sjoerg<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> 69487330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call 69497330f729Sjoergexpression, or an ObjC-message-send expression. 69507330f729Sjoerg 69517330f729SjoergGiven 69527330f729Sjoerg void x(int, int, int) { int y; x(1, y, 42); } 69537330f729SjoergcallExpr(hasAnyArgument(declRefExpr())) 69547330f729Sjoerg matches x(1, y, 42) 69557330f729Sjoergwith hasAnyArgument(...) 69567330f729Sjoerg matching y 69577330f729Sjoerg 69587330f729SjoergFor ObjectiveC, given 69597330f729Sjoerg @interface I - (void) f:(int) y; @end 69607330f729Sjoerg void foo(I *i) { [i f:12]; } 69617330f729SjoergobjcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 69627330f729Sjoerg matches [i f:12] 69637330f729Sjoerg</pre></td></tr> 69647330f729Sjoerg 69657330f729Sjoerg 6966*e038c9c4Sjoerg<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> 6967*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor 6968*e038c9c4Sjoergcall expression. 6969*e038c9c4Sjoerg 6970*e038c9c4SjoergExample matches y in x(y) 6971*e038c9c4Sjoerg (matcher = callExpr(hasArgument(0, declRefExpr()))) 6972*e038c9c4Sjoerg void x(int) { int y; x(y); } 6973*e038c9c4Sjoerg</pre></td></tr> 6974*e038c9c4Sjoerg 6975*e038c9c4Sjoerg 6976*e038c9c4Sjoerg<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> 6977*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc6"><pre>Matches if the type location of a node matches the inner matcher. 6978*e038c9c4Sjoerg 6979*e038c9c4SjoergExamples: 6980*e038c9c4Sjoerg int x; 6981*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 6982*e038c9c4Sjoerg matches int x 6983*e038c9c4Sjoerg 6984*e038c9c4Sjoergauto x = int(3); 6985*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 6986*e038c9c4Sjoerg matches int(3) 6987*e038c9c4Sjoerg 6988*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 6989*e038c9c4Sjoergauto x = Foo(1, 2); 6990*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 6991*e038c9c4Sjoerg matches Foo(1, 2) 6992*e038c9c4Sjoerg 6993*e038c9c4SjoergUsable 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>>, 6994*e038c9c4Sjoerg 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>>, 6995*e038c9c4Sjoerg 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>>, 6996*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 6997*e038c9c4Sjoerg 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>>, 6998*e038c9c4Sjoerg 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>>, 6999*e038c9c4Sjoerg 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>>, 7000*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 7001*e038c9c4Sjoerg</pre></td></tr> 7002*e038c9c4Sjoerg 7003*e038c9c4Sjoerg 70047330f729Sjoerg<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('callee1')"><a name="callee1Anchor">callee</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 70057330f729Sjoerg<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the 70067330f729Sjoerggiven matcher. 70077330f729Sjoerg 70087330f729SjoergExample matches y.x() (matcher = callExpr(callee( 70097330f729Sjoerg cxxMethodDecl(hasName("x"))))) 70107330f729Sjoerg class Y { public: void x(); }; 70117330f729Sjoerg void z() { Y y; y.x(); } 70127330f729Sjoerg</pre></td></tr> 70137330f729Sjoerg 70147330f729Sjoerg 70157330f729Sjoerg<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> 70167330f729Sjoerg<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. 70177330f729Sjoerg 70187330f729SjoergGiven 70197330f729Sjoerg class Y { void x() { this->x(); x(); Y y; y.x(); } }; 70207330f729Sjoerg void f() { f(); } 70217330f729SjoergcallExpr(callee(expr())) 70227330f729Sjoerg matches this->x(), x(), y.x(), f() 70237330f729Sjoergwith callee(...) 70247330f729Sjoerg matching this->x, x, y.x, f respectively 70257330f729Sjoerg 70267330f729SjoergNote: Callee cannot take the more general internal::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> 70277330f729Sjoergbecause this introduces ambiguous overloads with calls to Callee taking a 70287330f729Sjoerginternal::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely 70297330f729Sjoergimplemented in terms of implicit casts. 70307330f729Sjoerg</pre></td></tr> 70317330f729Sjoerg 70327330f729Sjoerg 70337330f729Sjoerg<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> 70347330f729Sjoerg<tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl. 70357330f729Sjoerg 70367330f729SjoergGiven 70377330f729Sjoerg void f(int i); 70387330f729Sjoerg int y; 70397330f729Sjoerg f(y); 70407330f729SjoergcallExpr( 70417330f729Sjoerg forEachArgumentWithParam( 70427330f729Sjoerg declRefExpr(to(varDecl(hasName("y")))), 70437330f729Sjoerg parmVarDecl(hasType(isInteger())) 70447330f729Sjoerg)) 70457330f729Sjoerg matches f(y); 70467330f729Sjoergwith declRefExpr(...) 70477330f729Sjoerg matching int y 70487330f729Sjoergand parmVarDecl(...) 70497330f729Sjoerg matching int i 70507330f729Sjoerg</pre></td></tr> 70517330f729Sjoerg 70527330f729Sjoerg 7053*e038c9c4Sjoerg<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> 7054*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="forEachArgumentWithParamType0"><pre>Matches all arguments and their respective types for a CallExpr or 7055*e038c9c4SjoergCXXConstructExpr. It is very similar to forEachArgumentWithParam but 7056*e038c9c4Sjoergit works on calls through function pointers as well. 7057*e038c9c4Sjoerg 7058*e038c9c4SjoergThe difference is, that function pointers do not provide access to a 7059*e038c9c4SjoergParmVarDecl, but only the QualType for each argument. 7060*e038c9c4Sjoerg 7061*e038c9c4SjoergGiven 7062*e038c9c4Sjoerg void f(int i); 7063*e038c9c4Sjoerg int y; 7064*e038c9c4Sjoerg f(y); 7065*e038c9c4Sjoerg void (*f_ptr)(int) = f; 7066*e038c9c4Sjoerg f_ptr(y); 7067*e038c9c4SjoergcallExpr( 7068*e038c9c4Sjoerg forEachArgumentWithParamType( 7069*e038c9c4Sjoerg declRefExpr(to(varDecl(hasName("y")))), 7070*e038c9c4Sjoerg qualType(isInteger()).bind("type) 7071*e038c9c4Sjoerg)) 7072*e038c9c4Sjoerg matches f(y) and f_ptr(y) 7073*e038c9c4Sjoergwith declRefExpr(...) 7074*e038c9c4Sjoerg matching int y 7075*e038c9c4Sjoergand qualType(...) 7076*e038c9c4Sjoerg matching int 7077*e038c9c4Sjoerg</pre></td></tr> 7078*e038c9c4Sjoerg 7079*e038c9c4Sjoerg 70807330f729Sjoerg<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> 70817330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 70827330f729Sjoergexpression, or an ObjC-message-send expression. 70837330f729Sjoerg 70847330f729SjoergGiven 70857330f729Sjoerg void x(int, int, int) { int y; x(1, y, 42); } 70867330f729SjoergcallExpr(hasAnyArgument(declRefExpr())) 70877330f729Sjoerg matches x(1, y, 42) 70887330f729Sjoergwith hasAnyArgument(...) 70897330f729Sjoerg matching y 70907330f729Sjoerg 70917330f729SjoergFor ObjectiveC, given 70927330f729Sjoerg @interface I - (void) f:(int) y; @end 70937330f729Sjoerg void foo(I *i) { [i f:12]; } 70947330f729SjoergobjcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 70957330f729Sjoerg matches [i f:12] 70967330f729Sjoerg</pre></td></tr> 70977330f729Sjoerg 70987330f729Sjoerg 70997330f729Sjoerg<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> 71007330f729Sjoerg<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 71017330f729Sjoergcall expression. 71027330f729Sjoerg 71037330f729SjoergExample matches y in x(y) 71047330f729Sjoerg (matcher = callExpr(hasArgument(0, declRefExpr()))) 71057330f729Sjoerg void x(int) { int y; x(y); } 71067330f729Sjoerg</pre></td></tr> 71077330f729Sjoerg 71087330f729Sjoerg 7109*e038c9c4Sjoerg<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> 71107330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node 71117330f729Sjoergmatches the given matcher. 71127330f729Sjoerg 71137330f729SjoergThe associated declaration is: 71147330f729Sjoerg- for type nodes, the declaration of the underlying type 71157330f729Sjoerg- for CallExpr, the declaration of the callee 71167330f729Sjoerg- for MemberExpr, the declaration of the referenced member 71177330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 71187330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 71197330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 71207330f729Sjoerg 71217330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 71227330f729Sjoergsugared type. Given 71237330f729Sjoerg class X {}; 71247330f729Sjoerg typedef X Y; 71257330f729Sjoerg Y y; 71267330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 71277330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 71287330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 71297330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 71307330f729Sjoerg recordType(hasDeclaration(decl()))))) 71317330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 71327330f729Sjoerg 71337330f729SjoergUsable 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>>, 71347330f729Sjoerg 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>>, 71357330f729Sjoerg 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>>, 71367330f729Sjoerg 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>>, 71377330f729Sjoerg 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>>, 71387330f729Sjoerg 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>>, 71397330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 71407330f729Sjoerg</pre></td></tr> 71417330f729Sjoerg 71427330f729Sjoerg 71437330f729Sjoerg<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> 71447330f729Sjoerg<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range 71457330f729Sjoergextension, matches the constant given in the statement. 71467330f729Sjoerg 71477330f729SjoergGiven 71487330f729Sjoerg switch (1) { case 1: case 1+1: case 3 ... 4: ; } 71497330f729SjoergcaseStmt(hasCaseConstant(integerLiteral())) 71507330f729Sjoerg matches "case 1:" 71517330f729Sjoerg</pre></td></tr> 71527330f729Sjoerg 71537330f729Sjoerg 71547330f729Sjoerg<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> 71557330f729Sjoerg<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression 71567330f729Sjoergor opaque value's source expression matches the given matcher. 71577330f729Sjoerg 71587330f729SjoergExample 1: matches "a string" 71597330f729Sjoerg(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) 71607330f729Sjoergclass URL { URL(string); }; 71617330f729SjoergURL url = "a string"; 71627330f729Sjoerg 71637330f729SjoergExample 2: matches 'b' (matcher = 71647330f729SjoergopaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) 71657330f729Sjoergint a = b ?: 1; 71667330f729Sjoerg</pre></td></tr> 71677330f729Sjoerg 71687330f729Sjoerg 71697330f729Sjoerg<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> 71707330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and 71717330f729SjoergfunctionDecl that have at least one TemplateArgument matching the given 71727330f729SjoergInnerMatcher. 71737330f729Sjoerg 71747330f729SjoergGiven 71757330f729Sjoerg template<typename T> class A {}; 71767330f729Sjoerg template<> class A<double> {}; 71777330f729Sjoerg A<int> a; 71787330f729Sjoerg 71797330f729Sjoerg template<typename T> f() {}; 71807330f729Sjoerg void func() { f<int>(); }; 71817330f729Sjoerg 71827330f729SjoergclassTemplateSpecializationDecl(hasAnyTemplateArgument( 71837330f729Sjoerg refersToType(asString("int")))) 71847330f729Sjoerg matches the specialization A<int> 71857330f729Sjoerg 71867330f729SjoergfunctionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 71877330f729Sjoerg matches the specialization f<int> 71887330f729Sjoerg</pre></td></tr> 71897330f729Sjoerg 71907330f729Sjoerg 71917330f729Sjoerg<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> 71927330f729Sjoerg<tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration. 71937330f729Sjoerg 71947330f729SjoergGiven 71957330f729Sjoerg template<typename T> class A {}; #1 71967330f729Sjoerg template<> class A<int> {}; #2 71977330f729SjoergclassTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl())) 71987330f729Sjoerg matches '#2' with classTemplateDecl() matching the class template 71997330f729Sjoerg declaration of 'A' at #1. 72007330f729Sjoerg</pre></td></tr> 72017330f729Sjoerg 72027330f729Sjoerg 72037330f729Sjoerg<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> 72047330f729Sjoerg<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and 72057330f729SjoergfunctionDecl where the n'th TemplateArgument matches the given InnerMatcher. 72067330f729Sjoerg 72077330f729SjoergGiven 72087330f729Sjoerg template<typename T, typename U> class A {}; 72097330f729Sjoerg A<bool, int> b; 72107330f729Sjoerg A<int, bool> c; 72117330f729Sjoerg 72127330f729Sjoerg template<typename T> void f() {} 72137330f729Sjoerg void func() { f<int>(); }; 72147330f729SjoergclassTemplateSpecializationDecl(hasTemplateArgument( 72157330f729Sjoerg 1, refersToType(asString("int")))) 72167330f729Sjoerg matches the specialization A<bool, int> 72177330f729Sjoerg 72187330f729SjoergfunctionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 72197330f729Sjoerg matches the specialization f<int> 72207330f729Sjoerg</pre></td></tr> 72217330f729Sjoerg 72227330f729Sjoerg 7223*e038c9c4Sjoerg<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> 7224*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc7"><pre>Matches if the type location of a node matches the inner matcher. 7225*e038c9c4Sjoerg 7226*e038c9c4SjoergExamples: 7227*e038c9c4Sjoerg int x; 7228*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 7229*e038c9c4Sjoerg matches int x 7230*e038c9c4Sjoerg 7231*e038c9c4Sjoergauto x = int(3); 7232*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 7233*e038c9c4Sjoerg matches int(3) 7234*e038c9c4Sjoerg 7235*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 7236*e038c9c4Sjoergauto x = Foo(1, 2); 7237*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 7238*e038c9c4Sjoerg matches Foo(1, 2) 7239*e038c9c4Sjoerg 7240*e038c9c4SjoergUsable 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>>, 7241*e038c9c4Sjoerg 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>>, 7242*e038c9c4Sjoerg 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>>, 7243*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 7244*e038c9c4Sjoerg 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>>, 7245*e038c9c4Sjoerg 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>>, 7246*e038c9c4Sjoerg 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>>, 7247*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 7248*e038c9c4Sjoerg</pre></td></tr> 7249*e038c9c4Sjoerg 7250*e038c9c4Sjoerg 72517330f729Sjoerg<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> 72527330f729Sjoerg<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element 72537330f729Sjoergtype. 72547330f729Sjoerg 72557330f729SjoergGiven 72567330f729Sjoerg struct A {}; 72577330f729Sjoerg A a[7]; 72587330f729Sjoerg int b[7]; 72597330f729SjoergarrayType(hasElementType(builtinType())) 72607330f729Sjoerg matches "int b[7]" 72617330f729Sjoerg 72627330f729SjoergUsable 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>> 72637330f729Sjoerg</pre></td></tr> 72647330f729Sjoerg 72657330f729Sjoerg 7266*e038c9c4Sjoerg<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> 7267*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc8"><pre>Matches if the type location of a node matches the inner matcher. 7268*e038c9c4Sjoerg 7269*e038c9c4SjoergExamples: 7270*e038c9c4Sjoerg int x; 7271*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 7272*e038c9c4Sjoerg matches int x 7273*e038c9c4Sjoerg 7274*e038c9c4Sjoergauto x = int(3); 7275*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 7276*e038c9c4Sjoerg matches int(3) 7277*e038c9c4Sjoerg 7278*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 7279*e038c9c4Sjoergauto x = Foo(1, 2); 7280*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 7281*e038c9c4Sjoerg matches Foo(1, 2) 7282*e038c9c4Sjoerg 7283*e038c9c4SjoergUsable 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>>, 7284*e038c9c4Sjoerg 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>>, 7285*e038c9c4Sjoerg 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>>, 7286*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 7287*e038c9c4Sjoerg 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>>, 7288*e038c9c4Sjoerg 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>>, 7289*e038c9c4Sjoerg 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>>, 7290*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 7291*e038c9c4Sjoerg</pre></td></tr> 7292*e038c9c4Sjoerg 7293*e038c9c4Sjoerg 72947330f729Sjoerg<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> 72957330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 72967330f729Sjoerga given matcher. Also matches StmtExprs that have CompoundStmt as children. 72977330f729Sjoerg 72987330f729SjoergGiven 72997330f729Sjoerg { {}; 1+2; } 73007330f729SjoerghasAnySubstatement(compoundStmt()) 73017330f729Sjoerg matches '{ {}; 1+2; }' 73027330f729Sjoergwith compoundStmt() 73037330f729Sjoerg matching '{}' 73047330f729Sjoerg</pre></td></tr> 73057330f729Sjoerg 73067330f729Sjoerg 73077330f729Sjoerg<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> 7308*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whoes decayed type matches InnerMatcher 73097330f729Sjoerg</pre></td></tr> 73107330f729Sjoerg 73117330f729Sjoerg 7312*e038c9c4Sjoerg<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> 73137330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node 73147330f729Sjoergmatches the given matcher. 73157330f729Sjoerg 73167330f729SjoergThe associated declaration is: 73177330f729Sjoerg- for type nodes, the declaration of the underlying type 73187330f729Sjoerg- for CallExpr, the declaration of the callee 73197330f729Sjoerg- for MemberExpr, the declaration of the referenced member 73207330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 73217330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 73227330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 73237330f729Sjoerg 73247330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 73257330f729Sjoergsugared type. Given 73267330f729Sjoerg class X {}; 73277330f729Sjoerg typedef X Y; 73287330f729Sjoerg Y y; 73297330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 73307330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 73317330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 73327330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 73337330f729Sjoerg recordType(hasDeclaration(decl()))))) 73347330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 73357330f729Sjoerg 73367330f729SjoergUsable 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>>, 73377330f729Sjoerg 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>>, 73387330f729Sjoerg 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>>, 73397330f729Sjoerg 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>>, 73407330f729Sjoerg 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>>, 73417330f729Sjoerg 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>>, 73427330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 73437330f729Sjoerg</pre></td></tr> 73447330f729Sjoerg 73457330f729Sjoerg 73467330f729Sjoerg<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>> InnerMatcher</td></tr> 73477330f729Sjoerg<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a 73487330f729Sjoergspecific using shadow declaration. 73497330f729Sjoerg 73507330f729SjoergGiven 73517330f729Sjoerg namespace a { void f() {} } 73527330f729Sjoerg using a::f; 73537330f729Sjoerg void g() { 73547330f729Sjoerg f(); // Matches this .. 73557330f729Sjoerg a::f(); // .. but not this. 73567330f729Sjoerg } 73577330f729SjoergdeclRefExpr(throughUsingDecl(anything())) 73587330f729Sjoerg matches f() 73597330f729Sjoerg</pre></td></tr> 73607330f729Sjoerg 73617330f729Sjoerg 73627330f729Sjoerg<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> 73637330f729Sjoerg<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 73647330f729Sjoergspecified matcher. 73657330f729Sjoerg 73667330f729SjoergExample matches x in if(x) 73677330f729Sjoerg (matcher = declRefExpr(to(varDecl(hasName("x"))))) 73687330f729Sjoerg bool x; 73697330f729Sjoerg if (x) {} 73707330f729Sjoerg</pre></td></tr> 73717330f729Sjoerg 73727330f729Sjoerg 73737330f729Sjoerg<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> 73747330f729Sjoerg<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 73757330f729Sjoerg 73767330f729SjoergNote that this does not work for global declarations because the AST 73777330f729Sjoergbreaks up multiple-declaration DeclStmt's into multiple single-declaration 73787330f729SjoergDeclStmt's. 73797330f729SjoergExample: Given non-global declarations 73807330f729Sjoerg int a, b = 0; 73817330f729Sjoerg int c; 73827330f729Sjoerg int d = 2, e; 73837330f729SjoergdeclStmt(containsDeclaration( 73847330f729Sjoerg 0, varDecl(hasInitializer(anything())))) 73857330f729Sjoerg matches only 'int d = 2, e;', and 73867330f729SjoergdeclStmt(containsDeclaration(1, varDecl())) 73877330f729Sjoerg matches 'int a, b = 0' as well as 'int d = 2, e;' 73887330f729Sjoerg but 'int c;' is not matched. 73897330f729Sjoerg</pre></td></tr> 73907330f729Sjoerg 73917330f729Sjoerg 73927330f729Sjoerg<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> 73937330f729Sjoerg<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 73947330f729Sjoerg 73957330f729SjoergGiven 73967330f729Sjoerg int a, b; 73977330f729Sjoerg int c; 73987330f729SjoergdeclStmt(hasSingleDecl(anything())) 73997330f729Sjoerg matches 'int c;' but not 'int a, b;'. 74007330f729Sjoerg</pre></td></tr> 74017330f729Sjoerg 74027330f729Sjoerg 7403*e038c9c4Sjoerg<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> 7404*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc9"><pre>Matches if the type location of a node matches the inner matcher. 74057330f729Sjoerg 7406*e038c9c4SjoergExamples: 74077330f729Sjoerg int x; 74087330f729SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 74097330f729Sjoerg matches int x 7410*e038c9c4Sjoerg 7411*e038c9c4Sjoergauto x = int(3); 7412*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 7413*e038c9c4Sjoerg matches int(3) 7414*e038c9c4Sjoerg 7415*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 7416*e038c9c4Sjoergauto x = Foo(1, 2); 7417*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 7418*e038c9c4Sjoerg matches Foo(1, 2) 7419*e038c9c4Sjoerg 7420*e038c9c4SjoergUsable 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>>, 7421*e038c9c4Sjoerg 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>>, 7422*e038c9c4Sjoerg 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>>, 7423*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 7424*e038c9c4Sjoerg 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>>, 7425*e038c9c4Sjoerg 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>>, 7426*e038c9c4Sjoerg 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>>, 7427*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 74287330f729Sjoerg</pre></td></tr> 74297330f729Sjoerg 74307330f729Sjoerg 74317330f729Sjoerg<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> 74327330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a 74337330f729SjoergDecl, matches InnerMatcher. 74347330f729Sjoerg 74357330f729SjoergGiven 74367330f729Sjoerg namespace N { 74377330f729Sjoerg namespace M { 74387330f729Sjoerg class D {}; 74397330f729Sjoerg } 74407330f729Sjoerg } 74417330f729Sjoerg 74427330f729SjoergcxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the 74437330f729Sjoergdeclaration of class D. 74447330f729Sjoerg</pre></td></tr> 74457330f729Sjoerg 74467330f729Sjoerg 74477330f729Sjoerg<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> 74487330f729Sjoerg<tr><td colspan="4" class="doc" id="hasUnderlyingType0"><pre>Matches DecltypeType nodes to find out the underlying type. 74497330f729Sjoerg 74507330f729SjoergGiven 74517330f729Sjoerg decltype(1) a = 1; 74527330f729Sjoerg decltype(2.0) b = 2.0; 74537330f729SjoergdecltypeType(hasUnderlyingType(isInteger())) 74547330f729Sjoerg matches the type of "a" 74557330f729Sjoerg 74567330f729SjoergUsable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>> 74577330f729Sjoerg</pre></td></tr> 74587330f729Sjoerg 74597330f729Sjoerg 7460*e038c9c4Sjoerg<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> 7461*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyBinding0"><pre>Matches any binding of a DecompositionDecl. 74627330f729Sjoerg 7463*e038c9c4SjoergFor example, in: 7464*e038c9c4Sjoergvoid foo() 7465*e038c9c4Sjoerg{ 7466*e038c9c4Sjoerg int arr[3]; 7467*e038c9c4Sjoerg auto &[f, s, t] = arr; 7468*e038c9c4Sjoerg 7469*e038c9c4Sjoerg f = 42; 7470*e038c9c4Sjoerg} 7471*e038c9c4SjoergThe matcher: 7472*e038c9c4Sjoerg decompositionDecl(hasAnyBinding(bindingDecl(hasName("f").bind("fBinding")))) 7473*e038c9c4Sjoergmatches the decomposition decl with 'f' bound to "fBinding". 74747330f729Sjoerg</pre></td></tr> 74757330f729Sjoerg 74767330f729Sjoerg 7477*e038c9c4Sjoerg<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> 7478*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasBinding0"><pre>Matches the Nth binding of a DecompositionDecl. 7479*e038c9c4Sjoerg 7480*e038c9c4SjoergFor example, in: 7481*e038c9c4Sjoergvoid foo() 7482*e038c9c4Sjoerg{ 7483*e038c9c4Sjoerg int arr[3]; 7484*e038c9c4Sjoerg auto &[f, s, t] = arr; 7485*e038c9c4Sjoerg 7486*e038c9c4Sjoerg f = 42; 7487*e038c9c4Sjoerg} 7488*e038c9c4SjoergThe matcher: 7489*e038c9c4Sjoerg decompositionDecl(hasBinding(0, 7490*e038c9c4Sjoerg bindingDecl(hasName("f").bind("fBinding")))) 7491*e038c9c4Sjoergmatches the decomposition decl with 'f' bound to "fBinding". 7492*e038c9c4Sjoerg</pre></td></tr> 7493*e038c9c4Sjoerg 7494*e038c9c4Sjoerg 7495*e038c9c4Sjoerg<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> 7496*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasBody0"><pre></pre></td></tr> 7497*e038c9c4Sjoerg 7498*e038c9c4Sjoerg 74997330f729Sjoerg<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> 75007330f729Sjoerg<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 75017330f729Sjoergswitch statement or conditional operator. 75027330f729Sjoerg 75037330f729SjoergExample matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 75047330f729Sjoerg if (true) {} 75057330f729Sjoerg</pre></td></tr> 75067330f729Sjoerg 75077330f729Sjoerg 75087330f729Sjoerg<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> 75097330f729Sjoerg<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, 75107330f729Sjoergmatches InnerMatcher if the qualifier exists. 75117330f729Sjoerg 75127330f729SjoergGiven 75137330f729Sjoerg namespace N { 75147330f729Sjoerg namespace M { 75157330f729Sjoerg class D {}; 75167330f729Sjoerg } 75177330f729Sjoerg } 75187330f729Sjoerg N::M::D d; 75197330f729Sjoerg 75207330f729SjoergelaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) 75217330f729Sjoergmatches the type of the variable declaration of d. 75227330f729Sjoerg</pre></td></tr> 75237330f729Sjoerg 75247330f729Sjoerg 75257330f729Sjoerg<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> 75267330f729Sjoerg<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. 75277330f729Sjoerg 75287330f729SjoergGiven 75297330f729Sjoerg namespace N { 75307330f729Sjoerg namespace M { 75317330f729Sjoerg class D {}; 75327330f729Sjoerg } 75337330f729Sjoerg } 75347330f729Sjoerg N::M::D d; 75357330f729Sjoerg 75367330f729SjoergelaboratedType(namesType(recordType( 75377330f729SjoerghasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable 75387330f729Sjoergdeclaration of d. 75397330f729Sjoerg</pre></td></tr> 75407330f729Sjoerg 75417330f729Sjoerg 7542*e038c9c4Sjoerg<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> 75437330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node 75447330f729Sjoergmatches the given matcher. 75457330f729Sjoerg 75467330f729SjoergThe associated declaration is: 75477330f729Sjoerg- for type nodes, the declaration of the underlying type 75487330f729Sjoerg- for CallExpr, the declaration of the callee 75497330f729Sjoerg- for MemberExpr, the declaration of the referenced member 75507330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 75517330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 75527330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 75537330f729Sjoerg 75547330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 75557330f729Sjoergsugared type. Given 75567330f729Sjoerg class X {}; 75577330f729Sjoerg typedef X Y; 75587330f729Sjoerg Y y; 75597330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 75607330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 75617330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 75627330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 75637330f729Sjoerg recordType(hasDeclaration(decl()))))) 75647330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 75657330f729Sjoerg 75667330f729SjoergUsable 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>>, 75677330f729Sjoerg 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>>, 75687330f729Sjoerg 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>>, 75697330f729Sjoerg 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>>, 75707330f729Sjoerg 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>>, 75717330f729Sjoerg 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>>, 75727330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 75737330f729Sjoerg</pre></td></tr> 75747330f729Sjoerg 75757330f729Sjoerg 75767330f729Sjoerg<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> 75777330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 75787330f729Sjoerg 75797330f729Sjoerg(Note: Clang's AST refers to other conversions as "casts" too, and calls 75807330f729Sjoergactual casts "explicit" casts.) 75817330f729Sjoerg</pre></td></tr> 75827330f729Sjoerg 75837330f729Sjoerg 7584*e038c9c4Sjoerg<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> 7585*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc10"><pre>Matches if the type location of a node matches the inner matcher. 7586*e038c9c4Sjoerg 7587*e038c9c4SjoergExamples: 7588*e038c9c4Sjoerg int x; 7589*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 7590*e038c9c4Sjoerg matches int x 7591*e038c9c4Sjoerg 7592*e038c9c4Sjoergauto x = int(3); 7593*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 7594*e038c9c4Sjoerg matches int(3) 7595*e038c9c4Sjoerg 7596*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 7597*e038c9c4Sjoergauto x = Foo(1, 2); 7598*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 7599*e038c9c4Sjoerg matches Foo(1, 2) 7600*e038c9c4Sjoerg 7601*e038c9c4SjoergUsable 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>>, 7602*e038c9c4Sjoerg 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>>, 7603*e038c9c4Sjoerg 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>>, 7604*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 7605*e038c9c4Sjoerg 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>>, 7606*e038c9c4Sjoerg 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>>, 7607*e038c9c4Sjoerg 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>>, 7608*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 7609*e038c9c4Sjoerg</pre></td></tr> 7610*e038c9c4Sjoerg 7611*e038c9c4Sjoerg 7612*e038c9c4Sjoerg<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> 7613*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasType5"><pre>Overloaded to match the declaration of the expression's or value 76147330f729Sjoergdeclaration's type. 76157330f729Sjoerg 76167330f729SjoergIn case of a value declaration (for example a variable declaration), 76177330f729Sjoergthis resolves one layer of indirection. For example, in the value 76187330f729Sjoergdeclaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 76197330f729SjoergX, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 76207330f729Sjoergdeclaration of x. 76217330f729Sjoerg 76227330f729SjoergExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 76237330f729Sjoerg and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 76247330f729Sjoerg and friend class X (matcher = friendDecl(hasType("X")) 7625*e038c9c4Sjoerg and public virtual X (matcher = cxxBaseSpecifier(hasType( 7626*e038c9c4Sjoerg cxxRecordDecl(hasName("X")))) 76277330f729Sjoerg class X {}; 76287330f729Sjoerg void y(X &x) { x; X z; } 76297330f729Sjoerg class Y { friend class X; }; 7630*e038c9c4Sjoerg class Z : public virtual X {}; 76317330f729Sjoerg 7632*e038c9c4SjoergExample matches class Derived 7633*e038c9c4Sjoerg(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) 7634*e038c9c4Sjoergclass Base {}; 7635*e038c9c4Sjoergclass Derived : Base {}; 7636*e038c9c4Sjoerg 7637*e038c9c4SjoergUsable 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>>, 7638*e038c9c4SjoergMatcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> 76397330f729Sjoerg</pre></td></tr> 76407330f729Sjoerg 76417330f729Sjoerg 76427330f729Sjoerg<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> 76437330f729Sjoerg<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type 76447330f729Sjoergmatcher. 76457330f729Sjoerg 76467330f729SjoergExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 76477330f729Sjoerg and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 76487330f729Sjoerg and U (matcher = typedefDecl(hasType(asString("int"))) 76497330f729Sjoerg and friend class X (matcher = friendDecl(hasType("X")) 7650*e038c9c4Sjoerg and public virtual X (matcher = cxxBaseSpecifier(hasType( 7651*e038c9c4Sjoerg asString("class X"))) 76527330f729Sjoerg class X {}; 76537330f729Sjoerg void y(X &x) { x; X z; } 76547330f729Sjoerg typedef int U; 76557330f729Sjoerg class Y { friend class X; }; 7656*e038c9c4Sjoerg class Z : public virtual X {}; 76577330f729Sjoerg</pre></td></tr> 76587330f729Sjoerg 76597330f729Sjoerg 76607330f729Sjoerg<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> 76617330f729Sjoerg<tr><td colspan="4" class="doc" id="ignoringElidableConstructorCall0"><pre>Matches expressions that match InnerMatcher that are possibly wrapped in an 76627330f729Sjoergelidable constructor and other corresponding bookkeeping nodes. 76637330f729Sjoerg 76647330f729SjoergIn C++17, elidable copy constructors are no longer being generated in the 76657330f729SjoergAST as it is not permitted by the standard. They are, however, part of the 76667330f729SjoergAST in C++14 and earlier. So, a matcher must abstract over these differences 76677330f729Sjoergto work in all language modes. This matcher skips elidable constructor-call 76687330f729SjoergAST nodes, `ExprWithCleanups` nodes wrapping elidable constructor-calls and 76697330f729Sjoergvarious implicit nodes inside the constructor calls, all of which will not 76707330f729Sjoergappear in the C++17 AST. 76717330f729Sjoerg 76727330f729SjoergGiven 76737330f729Sjoerg 76747330f729Sjoergstruct H {}; 76757330f729SjoergH G(); 76767330f729Sjoergvoid f() { 76777330f729Sjoerg H D = G(); 76787330f729Sjoerg} 76797330f729Sjoerg 76807330f729Sjoerg``varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr())))`` 76817330f729Sjoergmatches ``H D = G()`` in C++11 through C++17 (and beyond). 76827330f729Sjoerg</pre></td></tr> 76837330f729Sjoerg 76847330f729Sjoerg 76857330f729Sjoerg<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> 76867330f729Sjoerg<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 76877330f729Sjoergare stripped off. 76887330f729Sjoerg 76897330f729SjoergParentheses and explicit casts are not discarded. 76907330f729SjoergGiven 76917330f729Sjoerg int arr[5]; 76927330f729Sjoerg int a = 0; 76937330f729Sjoerg char b = 0; 76947330f729Sjoerg const int c = a; 76957330f729Sjoerg int *d = arr; 76967330f729Sjoerg long e = (long) 0l; 76977330f729SjoergThe matchers 76987330f729Sjoerg varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 76997330f729Sjoerg varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 77007330f729Sjoergwould match the declarations for a, b, c, and d, but not e. 77017330f729SjoergWhile 77027330f729Sjoerg varDecl(hasInitializer(integerLiteral())) 77037330f729Sjoerg varDecl(hasInitializer(declRefExpr())) 77047330f729Sjoergonly match the declarations for b, c, and d. 77057330f729Sjoerg</pre></td></tr> 77067330f729Sjoerg 77077330f729Sjoerg 77087330f729Sjoerg<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> 77097330f729Sjoerg<tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST 77107330f729Sjoergnodes are stripped off. 77117330f729Sjoerg 77127330f729SjoergParentheses and explicit casts are not discarded. 77137330f729SjoergGiven 77147330f729Sjoerg class C {}; 77157330f729Sjoerg C a = C(); 77167330f729Sjoerg C b; 77177330f729Sjoerg C c = b; 77187330f729SjoergThe matchers 77197330f729Sjoerg varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr()))) 77207330f729Sjoergwould match the declarations for a, b, and c. 77217330f729SjoergWhile 77227330f729Sjoerg varDecl(hasInitializer(cxxConstructExpr())) 77237330f729Sjoergonly match the declarations for b and c. 77247330f729Sjoerg</pre></td></tr> 77257330f729Sjoerg 77267330f729Sjoerg 77277330f729Sjoerg<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> 77287330f729Sjoerg<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 77297330f729Sjoergcasts are stripped off. 77307330f729Sjoerg 77317330f729SjoergImplicit and non-C Style casts are also discarded. 77327330f729SjoergGiven 77337330f729Sjoerg int a = 0; 77347330f729Sjoerg char b = (0); 77357330f729Sjoerg void* c = reinterpret_cast<char*>(0); 77367330f729Sjoerg char d = char(0); 77377330f729SjoergThe matcher 77387330f729Sjoerg varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 77397330f729Sjoergwould match the declarations for a, b, c, and d. 77407330f729Sjoergwhile 77417330f729Sjoerg varDecl(hasInitializer(integerLiteral())) 77427330f729Sjoergonly match the declaration for a. 77437330f729Sjoerg</pre></td></tr> 77447330f729Sjoerg 77457330f729Sjoerg 77467330f729Sjoerg<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> 77477330f729Sjoerg<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 77487330f729Sjoergparentheses are stripped off. 77497330f729Sjoerg 77507330f729SjoergExplicit casts are not discarded. 77517330f729SjoergGiven 77527330f729Sjoerg int arr[5]; 77537330f729Sjoerg int a = 0; 77547330f729Sjoerg char b = (0); 77557330f729Sjoerg const int c = a; 77567330f729Sjoerg int *d = (arr); 77577330f729Sjoerg long e = ((long) 0l); 77587330f729SjoergThe matchers 77597330f729Sjoerg varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 77607330f729Sjoerg varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 77617330f729Sjoergwould match the declarations for a, b, c, and d, but not e. 77627330f729Sjoergwhile 77637330f729Sjoerg varDecl(hasInitializer(integerLiteral())) 77647330f729Sjoerg varDecl(hasInitializer(declRefExpr())) 77657330f729Sjoergwould only match the declaration for a. 77667330f729Sjoerg</pre></td></tr> 77677330f729Sjoerg 77687330f729Sjoerg 77697330f729Sjoerg<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> 77707330f729Sjoerg<tr><td colspan="4" class="doc" id="ignoringParens1"><pre>Overload ignoringParens for Expr. 77717330f729Sjoerg 77727330f729SjoergGiven 77737330f729Sjoerg const char* str = ("my-string"); 77747330f729SjoergThe matcher 77757330f729Sjoerg implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral()))) 77767330f729Sjoergwould match the implicit cast resulting from the assignment. 77777330f729Sjoerg</pre></td></tr> 77787330f729Sjoerg 77797330f729Sjoerg 77807330f729Sjoerg<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> 77817330f729Sjoerg<tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer. 77827330f729Sjoerg 77837330f729SjoergGiven 77847330f729Sjoerg class C { 77857330f729Sjoerg int a = 2; 77867330f729Sjoerg int b = 3; 77877330f729Sjoerg int c; 77887330f729Sjoerg }; 77897330f729SjoergfieldDecl(hasInClassInitializer(integerLiteral(equals(2)))) 77907330f729Sjoerg matches 'int a;' but not 'int b;'. 77917330f729SjoergfieldDecl(hasInClassInitializer(anything())) 77927330f729Sjoerg matches 'int a;' and 'int b;' but not 'int c;'. 77937330f729Sjoerg</pre></td></tr> 77947330f729Sjoerg 77957330f729Sjoerg 77967330f729Sjoerg<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> 7797*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasBody1"><pre></pre></td></tr> 77987330f729Sjoerg 77997330f729Sjoerg 78007330f729Sjoerg<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> 78017330f729Sjoerg<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 78027330f729Sjoergswitch statement or conditional operator. 78037330f729Sjoerg 78047330f729SjoergExample matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 78057330f729Sjoerg if (true) {} 78067330f729Sjoerg</pre></td></tr> 78077330f729Sjoerg 78087330f729Sjoerg 78097330f729Sjoerg<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> 78107330f729Sjoerg<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 78117330f729Sjoerg 78127330f729SjoergExample: 78137330f729Sjoerg forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 78147330f729Sjoergmatches '++x' in 78157330f729Sjoerg for (x; x < N; ++x) { } 78167330f729Sjoerg</pre></td></tr> 78177330f729Sjoerg 78187330f729Sjoerg 78197330f729Sjoerg<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> 78207330f729Sjoerg<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 78217330f729Sjoerg 78227330f729SjoergExample: 78237330f729Sjoerg forStmt(hasLoopInit(declStmt())) 78247330f729Sjoergmatches 'int x = 0' in 78257330f729Sjoerg for (int x = 0; x < N; ++x) { } 78267330f729Sjoerg</pre></td></tr> 78277330f729Sjoerg 78287330f729Sjoerg 7829*e038c9c4Sjoerg<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> 7830*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasType6"><pre>Overloaded to match the declaration of the expression's or value 78317330f729Sjoergdeclaration's type. 78327330f729Sjoerg 78337330f729SjoergIn case of a value declaration (for example a variable declaration), 78347330f729Sjoergthis resolves one layer of indirection. For example, in the value 78357330f729Sjoergdeclaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 78367330f729SjoergX, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 78377330f729Sjoergdeclaration of x. 78387330f729Sjoerg 78397330f729SjoergExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 78407330f729Sjoerg and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 78417330f729Sjoerg and friend class X (matcher = friendDecl(hasType("X")) 7842*e038c9c4Sjoerg and public virtual X (matcher = cxxBaseSpecifier(hasType( 7843*e038c9c4Sjoerg cxxRecordDecl(hasName("X")))) 78447330f729Sjoerg class X {}; 78457330f729Sjoerg void y(X &x) { x; X z; } 78467330f729Sjoerg class Y { friend class X; }; 7847*e038c9c4Sjoerg class Z : public virtual X {}; 78487330f729Sjoerg 7849*e038c9c4SjoergExample matches class Derived 7850*e038c9c4Sjoerg(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) 7851*e038c9c4Sjoergclass Base {}; 7852*e038c9c4Sjoergclass Derived : Base {}; 7853*e038c9c4Sjoerg 7854*e038c9c4SjoergUsable 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>>, 7855*e038c9c4SjoergMatcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> 78567330f729Sjoerg</pre></td></tr> 78577330f729Sjoerg 78587330f729Sjoerg 78597330f729Sjoerg<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> 78607330f729Sjoerg<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type 78617330f729Sjoergmatcher. 78627330f729Sjoerg 78637330f729SjoergExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 78647330f729Sjoerg and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 78657330f729Sjoerg and U (matcher = typedefDecl(hasType(asString("int"))) 78667330f729Sjoerg and friend class X (matcher = friendDecl(hasType("X")) 7867*e038c9c4Sjoerg and public virtual X (matcher = cxxBaseSpecifier(hasType( 7868*e038c9c4Sjoerg asString("class X"))) 78697330f729Sjoerg class X {}; 78707330f729Sjoerg void y(X &x) { x; X z; } 78717330f729Sjoerg typedef int U; 78727330f729Sjoerg class Y { friend class X; }; 7873*e038c9c4Sjoerg class Z : public virtual X {}; 7874*e038c9c4Sjoerg</pre></td></tr> 7875*e038c9c4Sjoerg 7876*e038c9c4Sjoerg 7877*e038c9c4Sjoerg<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> 7878*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyBody0"><pre>Matches a function declaration that has a given body present in the AST. 7879*e038c9c4SjoergNote that this matcher matches all the declarations of a function whose 7880*e038c9c4Sjoergbody is present in the AST. 7881*e038c9c4Sjoerg 7882*e038c9c4SjoergGiven 7883*e038c9c4Sjoerg void f(); 7884*e038c9c4Sjoerg void f() {} 7885*e038c9c4Sjoerg void g(); 7886*e038c9c4SjoergfunctionDecl(hasAnyBody(compoundStmt())) 7887*e038c9c4Sjoerg matches both 'void f();' 7888*e038c9c4Sjoerg and 'void f() {}' 7889*e038c9c4Sjoergwith compoundStmt() 7890*e038c9c4Sjoerg matching '{}' 7891*e038c9c4Sjoerg but does not match 'void g();' 78927330f729Sjoerg</pre></td></tr> 78937330f729Sjoerg 78947330f729Sjoerg 78957330f729Sjoerg<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> 78967330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a 78977330f729Sjoergblock. 78987330f729Sjoerg 78997330f729SjoergDoes not match the 'this' parameter of a method. 79007330f729Sjoerg 79017330f729SjoergGiven 79027330f729Sjoerg class X { void f(int x, int y, int z) {} }; 79037330f729SjoergcxxMethodDecl(hasAnyParameter(hasName("y"))) 79047330f729Sjoerg matches f(int x, int y, int z) {} 79057330f729Sjoergwith hasAnyParameter(...) 79067330f729Sjoerg matching int y 79077330f729Sjoerg 79087330f729SjoergFor ObjectiveC, given 79097330f729Sjoerg @interface I - (void) f:(int) y; @end 79107330f729Sjoerg 79117330f729Sjoergthe matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 79127330f729Sjoergmatches the declaration of method f with hasParameter 79137330f729Sjoergmatching y. 79147330f729Sjoerg 79157330f729SjoergFor blocks, given 79167330f729Sjoerg b = ^(int y) { printf("%d", y) }; 79177330f729Sjoerg 79187330f729Sjoergthe matcher blockDecl(hasAnyParameter(hasName("y"))) 79197330f729Sjoergmatches the declaration of the block b with hasParameter 79207330f729Sjoergmatching y. 79217330f729Sjoerg</pre></td></tr> 79227330f729Sjoerg 79237330f729Sjoerg 79247330f729Sjoerg<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> 79257330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and 79267330f729SjoergfunctionDecl that have at least one TemplateArgument matching the given 79277330f729SjoergInnerMatcher. 79287330f729Sjoerg 79297330f729SjoergGiven 79307330f729Sjoerg template<typename T> class A {}; 79317330f729Sjoerg template<> class A<double> {}; 79327330f729Sjoerg A<int> a; 79337330f729Sjoerg 79347330f729Sjoerg template<typename T> f() {}; 79357330f729Sjoerg void func() { f<int>(); }; 79367330f729Sjoerg 79377330f729SjoergclassTemplateSpecializationDecl(hasAnyTemplateArgument( 79387330f729Sjoerg refersToType(asString("int")))) 79397330f729Sjoerg matches the specialization A<int> 79407330f729Sjoerg 79417330f729SjoergfunctionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 79427330f729Sjoerg matches the specialization f<int> 79437330f729Sjoerg</pre></td></tr> 79447330f729Sjoerg 79457330f729Sjoerg 79467330f729Sjoerg<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> 7947*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasBody4"><pre></pre></td></tr> 79487330f729Sjoerg 79497330f729Sjoerg 79507330f729Sjoerg<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> 79517330f729Sjoerg<tr><td colspan="4" class="doc" id="hasExplicitSpecifier0"><pre>Matches the expression in an explicit specifier if present in the given 79527330f729Sjoergdeclaration. 79537330f729Sjoerg 79547330f729SjoergGiven 79557330f729Sjoerg template<bool b> 79567330f729Sjoerg struct S { 79577330f729Sjoerg S(int); // #1 79587330f729Sjoerg explicit S(double); // #2 79597330f729Sjoerg operator int(); // #3 79607330f729Sjoerg explicit operator bool(); // #4 79617330f729Sjoerg explicit(false) S(bool) // # 7 79627330f729Sjoerg explicit(true) S(char) // # 8 79637330f729Sjoerg explicit(b) S(S) // # 9 79647330f729Sjoerg }; 79657330f729Sjoerg S(int) -> S<true> // #5 79667330f729Sjoerg explicit S(double) -> S<false> // #6 79677330f729SjoergcxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2. 79687330f729SjoergcxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4. 79697330f729SjoergcxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6. 79707330f729Sjoerg</pre></td></tr> 79717330f729Sjoerg 79727330f729Sjoerg 79737330f729Sjoerg<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> 79747330f729Sjoerg<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method 79757330f729Sjoergdeclaration or a block. 79767330f729Sjoerg 79777330f729SjoergGiven 79787330f729Sjoerg class X { void f(int x) {} }; 79797330f729SjoergcxxMethodDecl(hasParameter(0, hasType(varDecl()))) 79807330f729Sjoerg matches f(int x) {} 79817330f729Sjoergwith hasParameter(...) 79827330f729Sjoerg matching int x 79837330f729Sjoerg 79847330f729SjoergFor ObjectiveC, given 79857330f729Sjoerg @interface I - (void) f:(int) y; @end 79867330f729Sjoerg 79877330f729Sjoergthe matcher objcMethodDecl(hasParameter(0, hasName("y"))) 79887330f729Sjoergmatches the declaration of method f with hasParameter 79897330f729Sjoergmatching y. 79907330f729Sjoerg</pre></td></tr> 79917330f729Sjoerg 79927330f729Sjoerg 79937330f729Sjoerg<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> 79947330f729Sjoerg<tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and 79957330f729SjoergfunctionDecl where the n'th TemplateArgument matches the given InnerMatcher. 79967330f729Sjoerg 79977330f729SjoergGiven 79987330f729Sjoerg template<typename T, typename U> class A {}; 79997330f729Sjoerg A<bool, int> b; 80007330f729Sjoerg A<int, bool> c; 80017330f729Sjoerg 80027330f729Sjoerg template<typename T> void f() {} 80037330f729Sjoerg void func() { f<int>(); }; 80047330f729SjoergclassTemplateSpecializationDecl(hasTemplateArgument( 80057330f729Sjoerg 1, refersToType(asString("int")))) 80067330f729Sjoerg matches the specialization A<bool, int> 80077330f729Sjoerg 80087330f729SjoergfunctionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 80097330f729Sjoerg matches the specialization f<int> 80107330f729Sjoerg</pre></td></tr> 80117330f729Sjoerg 80127330f729Sjoerg 80137330f729Sjoerg<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> 80147330f729Sjoerg<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 80157330f729Sjoerg 80167330f729SjoergGiven: 80177330f729Sjoerg class X { int f() { return 1; } }; 80187330f729SjoergcxxMethodDecl(returns(asString("int"))) 80197330f729Sjoerg matches int f() { return 1; } 80207330f729Sjoerg</pre></td></tr> 80217330f729Sjoerg 80227330f729Sjoerg 80237330f729Sjoerg<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> 80247330f729Sjoerg<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 80257330f729Sjoergswitch statement or conditional operator. 80267330f729Sjoerg 80277330f729SjoergExample matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 80287330f729Sjoerg if (true) {} 80297330f729Sjoerg</pre></td></tr> 80307330f729Sjoerg 80317330f729Sjoerg 80327330f729Sjoerg<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> 80337330f729Sjoerg<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 80347330f729Sjoerg 80357330f729SjoergGiven 80367330f729Sjoerg if (A* a = GetAPointer()) {} 80377330f729SjoerghasConditionVariableStatement(...) 80387330f729Sjoerg matches 'A* a = GetAPointer()'. 80397330f729Sjoerg</pre></td></tr> 80407330f729Sjoerg 80417330f729Sjoerg 80427330f729Sjoerg<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> 80437330f729Sjoerg<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. 80447330f729Sjoerg 80457330f729SjoergExamples matches the if statement 80467330f729Sjoerg (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) 80477330f729Sjoerg if (false) false; else true; 80487330f729Sjoerg</pre></td></tr> 80497330f729Sjoerg 80507330f729Sjoerg 8051*e038c9c4Sjoerg<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> 8052*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasInitStatement0"><pre>Matches selection statements with initializer. 8053*e038c9c4Sjoerg 8054*e038c9c4SjoergGiven: 8055*e038c9c4Sjoerg void foo() { 8056*e038c9c4Sjoerg if (int i = foobar(); i > 0) {} 8057*e038c9c4Sjoerg switch (int i = foobar(); i) {} 8058*e038c9c4Sjoerg for (auto& a = get_range(); auto& x : a) {} 8059*e038c9c4Sjoerg } 8060*e038c9c4Sjoerg void bar() { 8061*e038c9c4Sjoerg if (foobar() > 0) {} 8062*e038c9c4Sjoerg switch (foobar()) {} 8063*e038c9c4Sjoerg for (auto& x : get_range()) {} 8064*e038c9c4Sjoerg } 8065*e038c9c4SjoergifStmt(hasInitStatement(anything())) 8066*e038c9c4Sjoerg matches the if statement in foo but not in bar. 8067*e038c9c4SjoergswitchStmt(hasInitStatement(anything())) 8068*e038c9c4Sjoerg matches the switch statement in foo but not in bar. 8069*e038c9c4SjoergcxxForRangeStmt(hasInitStatement(anything())) 8070*e038c9c4Sjoerg matches the range for statement in foo but not in bar. 8071*e038c9c4Sjoerg</pre></td></tr> 8072*e038c9c4Sjoerg 8073*e038c9c4Sjoerg 80747330f729Sjoerg<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> 80757330f729Sjoerg<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. 80767330f729Sjoerg 80777330f729SjoergExamples matches the if statement 80787330f729Sjoerg (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) 80797330f729Sjoerg if (false) true; else false; 80807330f729Sjoerg</pre></td></tr> 80817330f729Sjoerg 80827330f729Sjoerg 80837330f729Sjoerg<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> 80847330f729Sjoerg<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 80857330f729Sjoergmatcher. 80867330f729Sjoerg 80877330f729SjoergFIXME: Unit test this matcher 80887330f729Sjoerg</pre></td></tr> 80897330f729Sjoerg 80907330f729Sjoerg 80917330f729Sjoerg<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> 80927330f729Sjoerg<tr><td colspan="4" class="doc" id="hasInit0"><pre>Matches the n'th item of an initializer list expression. 80937330f729Sjoerg 80947330f729SjoergExample matches y. 80957330f729Sjoerg (matcher = initListExpr(hasInit(0, expr()))) 80967330f729Sjoerg int x{y}. 80977330f729Sjoerg</pre></td></tr> 80987330f729Sjoerg 80997330f729Sjoerg 81007330f729Sjoerg<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> 81017330f729Sjoerg<tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions 81027330f729Sjoerg(if expression have it). 81037330f729Sjoerg</pre></td></tr> 81047330f729Sjoerg 81057330f729Sjoerg 8106*e038c9c4Sjoerg<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> 81077330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node 81087330f729Sjoergmatches the given matcher. 81097330f729Sjoerg 81107330f729SjoergThe associated declaration is: 81117330f729Sjoerg- for type nodes, the declaration of the underlying type 81127330f729Sjoerg- for CallExpr, the declaration of the callee 81137330f729Sjoerg- for MemberExpr, the declaration of the referenced member 81147330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 81157330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 81167330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 81177330f729Sjoerg 81187330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 81197330f729Sjoergsugared type. Given 81207330f729Sjoerg class X {}; 81217330f729Sjoerg typedef X Y; 81227330f729Sjoerg Y y; 81237330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 81247330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 81257330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 81267330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 81277330f729Sjoerg recordType(hasDeclaration(decl()))))) 81287330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 81297330f729Sjoerg 81307330f729SjoergUsable 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>>, 81317330f729Sjoerg 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>>, 81327330f729Sjoerg 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>>, 81337330f729Sjoerg 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>>, 81347330f729Sjoerg 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>>, 81357330f729Sjoerg 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>>, 81367330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 81377330f729Sjoerg</pre></td></tr> 81387330f729Sjoerg 81397330f729Sjoerg 8140*e038c9c4Sjoerg<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> 81417330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node 81427330f729Sjoergmatches the given matcher. 81437330f729Sjoerg 81447330f729SjoergThe associated declaration is: 81457330f729Sjoerg- for type nodes, the declaration of the underlying type 81467330f729Sjoerg- for CallExpr, the declaration of the callee 81477330f729Sjoerg- for MemberExpr, the declaration of the referenced member 81487330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 81497330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 81507330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 81517330f729Sjoerg 81527330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 81537330f729Sjoergsugared type. Given 81547330f729Sjoerg class X {}; 81557330f729Sjoerg typedef X Y; 81567330f729Sjoerg Y y; 81577330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 81587330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 81597330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 81607330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 81617330f729Sjoerg recordType(hasDeclaration(decl()))))) 81627330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 81637330f729Sjoerg 81647330f729SjoergUsable 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>>, 81657330f729Sjoerg 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>>, 81667330f729Sjoerg 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>>, 81677330f729Sjoerg 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>>, 81687330f729Sjoerg 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>>, 81697330f729Sjoerg 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>>, 81707330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 81717330f729Sjoerg</pre></td></tr> 81727330f729Sjoerg 81737330f729Sjoerg 8174*e038c9c4Sjoerg<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>></td><td class="name" onclick="toggle('hasAnyCapture1')"><a name="hasAnyCapture1Anchor">hasAnyCapture</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>> InnerMatcher</td></tr> 8175*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyCapture1"><pre>Matches any capture of 'this' in a lambda expression. 8176*e038c9c4Sjoerg 8177*e038c9c4SjoergGiven 8178*e038c9c4Sjoerg struct foo { 8179*e038c9c4Sjoerg void bar() { 8180*e038c9c4Sjoerg auto f = [this](){}; 8181*e038c9c4Sjoerg } 8182*e038c9c4Sjoerg } 8183*e038c9c4SjoerglambdaExpr(hasAnyCapture(cxxThisExpr())) 8184*e038c9c4Sjoerg matches [this](){}; 8185*e038c9c4Sjoerg</pre></td></tr> 8186*e038c9c4Sjoerg 8187*e038c9c4Sjoerg 8188*e038c9c4Sjoerg<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_1VarDecl.html">VarDecl</a>> InnerMatcher</td></tr> 8189*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasAnyCapture0"><pre>Matches any capture of a lambda expression. 8190*e038c9c4Sjoerg 8191*e038c9c4SjoergGiven 8192*e038c9c4Sjoerg void foo() { 8193*e038c9c4Sjoerg int x; 8194*e038c9c4Sjoerg auto f = [x](){}; 8195*e038c9c4Sjoerg } 8196*e038c9c4SjoerglambdaExpr(hasAnyCapture(anything())) 8197*e038c9c4Sjoerg matches [x](){}; 8198*e038c9c4Sjoerg</pre></td></tr> 8199*e038c9c4Sjoerg 8200*e038c9c4Sjoerg 8201*e038c9c4Sjoerg<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> 82027330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node 82037330f729Sjoergmatches the given matcher. 82047330f729Sjoerg 82057330f729SjoergThe associated declaration is: 82067330f729Sjoerg- for type nodes, the declaration of the underlying type 82077330f729Sjoerg- for CallExpr, the declaration of the callee 82087330f729Sjoerg- for MemberExpr, the declaration of the referenced member 82097330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 82107330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 82117330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 82127330f729Sjoerg 82137330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 82147330f729Sjoergsugared type. Given 82157330f729Sjoerg class X {}; 82167330f729Sjoerg typedef X Y; 82177330f729Sjoerg Y y; 82187330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 82197330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 82207330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 82217330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 82227330f729Sjoerg recordType(hasDeclaration(decl()))))) 82237330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 82247330f729Sjoerg 82257330f729SjoergUsable 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>>, 82267330f729Sjoerg 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>>, 82277330f729Sjoerg 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>>, 82287330f729Sjoerg 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>>, 82297330f729Sjoerg 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>>, 82307330f729Sjoerg 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>>, 82317330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 82327330f729Sjoerg</pre></td></tr> 82337330f729Sjoerg 82347330f729Sjoerg 82357330f729Sjoerg<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> 82367330f729Sjoerg<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is matched by a 82377330f729Sjoerggiven matcher. Implicit object expressions are included; that is, it matches 82387330f729Sjoerguse of implicit `this`. 82397330f729Sjoerg 82407330f729SjoergGiven 82417330f729Sjoerg struct X { 82427330f729Sjoerg int m; 82437330f729Sjoerg int f(X x) { x.m; return m; } 82447330f729Sjoerg }; 82457330f729SjoergmemberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) 82467330f729Sjoerg matches `x.m`, but not `m`; however, 82477330f729SjoergmemberExpr(hasObjectExpression(hasType(pointsTo( 82487330f729Sjoerg cxxRecordDecl(hasName("X")))))) 82497330f729Sjoerg matches `m` (aka. `this->m`), but not `x.m`. 82507330f729Sjoerg</pre></td></tr> 82517330f729Sjoerg 82527330f729Sjoerg 82537330f729Sjoerg<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> 82547330f729Sjoerg<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 82557330f729Sjoerggiven matcher. 82567330f729Sjoerg 82577330f729SjoergGiven 82587330f729Sjoerg struct { int first, second; } first, second; 82597330f729Sjoerg int i(second.first); 82607330f729Sjoerg int j(first.second); 82617330f729SjoergmemberExpr(member(hasName("first"))) 82627330f729Sjoerg matches second.first 82637330f729Sjoerg but not first.second (because the member name there is "second"). 82647330f729Sjoerg</pre></td></tr> 82657330f729Sjoerg 82667330f729Sjoerg 82677330f729Sjoerg<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> 82687330f729Sjoerg<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the 82697330f729Sjoergpointee matches a given matcher. 82707330f729Sjoerg 82717330f729SjoergGiven 82727330f729Sjoerg int *a; 82737330f729Sjoerg int const *b; 82747330f729Sjoerg float const *f; 82757330f729SjoergpointerType(pointee(isConstQualified(), isInteger())) 82767330f729Sjoerg matches "int const *b" 82777330f729Sjoerg 82787330f729SjoergUsable 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>>, 82797330f729Sjoerg 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>> 82807330f729Sjoerg</pre></td></tr> 82817330f729Sjoerg 82827330f729Sjoerg 82837330f729Sjoerg<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> 82847330f729Sjoerg<tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given 82857330f729Sjoergmatcher. 82867330f729Sjoerg 82877330f729SjoergGiven 82887330f729Sjoerg namespace N { template<class T> void f(T t); } 82897330f729Sjoerg template <class T> void g() { using N::f; f(T()); } 82907330f729SjoergunresolvedLookupExpr(hasAnyDeclaration( 82917330f729Sjoerg namedDecl(hasUnderlyingDecl(hasName("::N::f"))))) 82927330f729Sjoerg matches the use of f in g() . 82937330f729Sjoerg</pre></td></tr> 82947330f729Sjoerg 82957330f729Sjoerg 82967330f729Sjoerg<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> 82977330f729Sjoerg<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 82987330f729Sjoerg 82997330f729SjoergGiven 83007330f729Sjoerg struct A { struct B { struct C {}; }; }; 83017330f729Sjoerg A::B::C c; 83027330f729SjoergnestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 83037330f729Sjoerg matches "A::" 83047330f729Sjoerg</pre></td></tr> 83057330f729Sjoerg 83067330f729Sjoerg 8307*e038c9c4Sjoerg<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> 8308*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner 8309*e038c9c4SjoergNestedNameSpecifier-matcher matches. 8310*e038c9c4Sjoerg</pre></td></tr> 8311*e038c9c4Sjoerg 8312*e038c9c4Sjoerg 83137330f729Sjoerg<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> 83147330f729Sjoerg<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 83157330f729Sjoerggiven TypeLoc. 83167330f729Sjoerg 83177330f729SjoergGiven 83187330f729Sjoerg struct A { struct B { struct C {}; }; }; 83197330f729Sjoerg A::B::C c; 83207330f729SjoergnestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 83217330f729Sjoerg hasDeclaration(cxxRecordDecl(hasName("A"))))))) 83227330f729Sjoerg matches "A::" 83237330f729Sjoerg</pre></td></tr> 83247330f729Sjoerg 83257330f729Sjoerg 83267330f729Sjoerg<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> 83277330f729Sjoerg<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 83287330f729Sjoerg 83297330f729SjoergGiven 83307330f729Sjoerg struct A { struct B { struct C {}; }; }; 83317330f729Sjoerg A::B::C c; 83327330f729SjoergnestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 83337330f729Sjoerg matches "A::" 83347330f729Sjoerg</pre></td></tr> 83357330f729Sjoerg 83367330f729Sjoerg 83377330f729Sjoerg<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> 83387330f729Sjoerg<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 83397330f729Sjoerggiven namespace matcher. 83407330f729Sjoerg 83417330f729SjoergGiven 83427330f729Sjoerg namespace ns { struct A {}; } 83437330f729Sjoerg ns::A a; 83447330f729SjoergnestedNameSpecifier(specifiesNamespace(hasName("ns"))) 83457330f729Sjoerg matches "ns::" 83467330f729Sjoerg</pre></td></tr> 83477330f729Sjoerg 83487330f729Sjoerg 83497330f729Sjoerg<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> 83507330f729Sjoerg<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 83517330f729Sjoerggiven QualType matcher without qualifiers. 83527330f729Sjoerg 83537330f729SjoergGiven 83547330f729Sjoerg struct A { struct B { struct C {}; }; }; 83557330f729Sjoerg A::B::C c; 83567330f729SjoergnestedNameSpecifier(specifiesType( 83577330f729Sjoerg hasDeclaration(cxxRecordDecl(hasName("A"))) 83587330f729Sjoerg)) 83597330f729Sjoerg matches "A::" 83607330f729Sjoerg</pre></td></tr> 83617330f729Sjoerg 83627330f729Sjoerg 83637330f729Sjoerg<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> 83647330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyClause0"><pre>Matches any clause in an OpenMP directive. 83657330f729Sjoerg 83667330f729SjoergGiven 83677330f729Sjoerg 83687330f729Sjoerg #pragma omp parallel 83697330f729Sjoerg #pragma omp parallel default(none) 83707330f729Sjoerg 83717330f729Sjoerg``ompExecutableDirective(hasAnyClause(anything()))`` matches 83727330f729Sjoerg``omp parallel default(none)``. 83737330f729Sjoerg</pre></td></tr> 83747330f729Sjoerg 83757330f729Sjoerg 83767330f729Sjoerg<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> 83777330f729Sjoerg<tr><td colspan="4" class="doc" id="hasStructuredBlock0"><pre>Matches the structured-block of the OpenMP executable directive 83787330f729Sjoerg 83797330f729SjoergPrerequisite: the executable directive must not be standalone directive. 83807330f729SjoergIf it is, it will never match. 83817330f729Sjoerg 83827330f729SjoergGiven 83837330f729Sjoerg 83847330f729Sjoerg #pragma omp parallel 83857330f729Sjoerg ; 83867330f729Sjoerg #pragma omp parallel 83877330f729Sjoerg {} 83887330f729Sjoerg 83897330f729Sjoerg``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;`` 83907330f729Sjoerg</pre></td></tr> 83917330f729Sjoerg 83927330f729Sjoerg 83937330f729Sjoerg<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> 83947330f729Sjoerg<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Matches C++ classes that are directly or indirectly derived from a class 83957330f729Sjoergmatching Base, or Objective-C classes that directly or indirectly 83967330f729Sjoergsubclass a class matching Base. 83977330f729Sjoerg 83987330f729SjoergNote that a class is not considered to be derived from itself. 83997330f729Sjoerg 84007330f729SjoergExample matches Y, Z, C (Base == hasName("X")) 84017330f729Sjoerg class X; 84027330f729Sjoerg class Y : public X {}; // directly derived 84037330f729Sjoerg class Z : public Y {}; // indirectly derived 84047330f729Sjoerg typedef X A; 84057330f729Sjoerg typedef A B; 84067330f729Sjoerg class C : public B {}; // derived from a typedef of X 84077330f729Sjoerg 84087330f729SjoergIn the following example, Bar matches isDerivedFrom(hasName("X")): 84097330f729Sjoerg class Foo; 84107330f729Sjoerg typedef Foo X; 84117330f729Sjoerg class Bar : public Foo {}; // derived from a type that X is a typedef of 84127330f729Sjoerg 84137330f729SjoergIn the following example, Bar matches isDerivedFrom(hasName("NSObject")) 84147330f729Sjoerg @interface NSObject @end 84157330f729Sjoerg @interface Bar : NSObject @end 84167330f729Sjoerg 84177330f729SjoergUsable 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>> 84187330f729Sjoerg</pre></td></tr> 84197330f729Sjoerg 84207330f729Sjoerg 84217330f729Sjoerg<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> 84227330f729Sjoerg<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom1"><pre>Matches C++ or Objective-C classes that are directly derived from a class 84237330f729Sjoergmatching Base. 84247330f729Sjoerg 84257330f729SjoergNote that a class is not considered to be derived from itself. 84267330f729Sjoerg 84277330f729SjoergExample matches Y, C (Base == hasName("X")) 84287330f729Sjoerg class X; 84297330f729Sjoerg class Y : public X {}; // directly derived 84307330f729Sjoerg class Z : public Y {}; // indirectly derived 84317330f729Sjoerg typedef X A; 84327330f729Sjoerg typedef A B; 84337330f729Sjoerg class C : public B {}; // derived from a typedef of X 84347330f729Sjoerg 84357330f729SjoergIn the following example, Bar matches isDerivedFrom(hasName("X")): 84367330f729Sjoerg class Foo; 84377330f729Sjoerg typedef Foo X; 84387330f729Sjoerg class Bar : public Foo {}; // derived from a type that X is a typedef of 84397330f729Sjoerg</pre></td></tr> 84407330f729Sjoerg 84417330f729Sjoerg 84427330f729Sjoerg<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> 84437330f729Sjoerg<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Similar to isDerivedFrom(), but also matches classes that directly 84447330f729Sjoergmatch Base. 84457330f729Sjoerg</pre></td></tr> 84467330f729Sjoerg 84477330f729Sjoerg 84487330f729Sjoerg<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> 84497330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyArgument3"><pre>Matches any argument of a call expression or a constructor call 84507330f729Sjoergexpression, or an ObjC-message-send expression. 84517330f729Sjoerg 84527330f729SjoergGiven 84537330f729Sjoerg void x(int, int, int) { int y; x(1, y, 42); } 84547330f729SjoergcallExpr(hasAnyArgument(declRefExpr())) 84557330f729Sjoerg matches x(1, y, 42) 84567330f729Sjoergwith hasAnyArgument(...) 84577330f729Sjoerg matching y 84587330f729Sjoerg 84597330f729SjoergFor ObjectiveC, given 84607330f729Sjoerg @interface I - (void) f:(int) y; @end 84617330f729Sjoerg void foo(I *i) { [i f:12]; } 84627330f729SjoergobjcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 84637330f729Sjoerg matches [i f:12] 84647330f729Sjoerg</pre></td></tr> 84657330f729Sjoerg 84667330f729Sjoerg 8467*e038c9c4Sjoerg<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> 8468*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasArgument3"><pre>Matches the n'th argument of a call expression or a constructor 84697330f729Sjoergcall expression. 84707330f729Sjoerg 84717330f729SjoergExample matches y in x(y) 84727330f729Sjoerg (matcher = callExpr(hasArgument(0, declRefExpr()))) 84737330f729Sjoerg void x(int) { int y; x(y); } 84747330f729Sjoerg</pre></td></tr> 84757330f729Sjoerg 84767330f729Sjoerg 84777330f729Sjoerg<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> 84787330f729Sjoerg<tr><td colspan="4" class="doc" id="hasReceiver0"><pre>Matches if the Objective-C message is sent to an instance, 84797330f729Sjoergand the inner matcher matches on that instance. 84807330f729Sjoerg 84817330f729SjoergFor example the method call in 84827330f729Sjoerg NSString *x = @"hello"; 84837330f729Sjoerg [x containsString:@"h"]; 84847330f729Sjoergis matched by 84857330f729SjoergobjcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x")))))) 84867330f729Sjoerg</pre></td></tr> 84877330f729Sjoerg 84887330f729Sjoerg 84897330f729Sjoerg<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> 84907330f729Sjoerg<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. 84917330f729Sjoerg 84927330f729SjoergExample 84937330f729Sjoergmatcher = objCMessageExpr(hasReceiverType(asString("UIWebView *"))); 84947330f729Sjoergmatches the [webView ...] message invocation. 84957330f729Sjoerg NSString *webViewJavaScript = ... 84967330f729Sjoerg UIWebView *webView = ... 84977330f729Sjoerg [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; 84987330f729Sjoerg</pre></td></tr> 84997330f729Sjoerg 85007330f729Sjoerg 85017330f729Sjoerg<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> 85027330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a 85037330f729Sjoergblock. 85047330f729Sjoerg 85057330f729SjoergDoes not match the 'this' parameter of a method. 85067330f729Sjoerg 85077330f729SjoergGiven 85087330f729Sjoerg class X { void f(int x, int y, int z) {} }; 85097330f729SjoergcxxMethodDecl(hasAnyParameter(hasName("y"))) 85107330f729Sjoerg matches f(int x, int y, int z) {} 85117330f729Sjoergwith hasAnyParameter(...) 85127330f729Sjoerg matching int y 85137330f729Sjoerg 85147330f729SjoergFor ObjectiveC, given 85157330f729Sjoerg @interface I - (void) f:(int) y; @end 85167330f729Sjoerg 85177330f729Sjoergthe matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 85187330f729Sjoergmatches the declaration of method f with hasParameter 85197330f729Sjoergmatching y. 85207330f729Sjoerg 85217330f729SjoergFor blocks, given 85227330f729Sjoerg b = ^(int y) { printf("%d", y) }; 85237330f729Sjoerg 85247330f729Sjoergthe matcher blockDecl(hasAnyParameter(hasName("y"))) 85257330f729Sjoergmatches the declaration of the block b with hasParameter 85267330f729Sjoergmatching y. 85277330f729Sjoerg</pre></td></tr> 85287330f729Sjoerg 85297330f729Sjoerg 85307330f729Sjoerg<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> 85317330f729Sjoerg<tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method 85327330f729Sjoergdeclaration or a block. 85337330f729Sjoerg 85347330f729SjoergGiven 85357330f729Sjoerg class X { void f(int x) {} }; 85367330f729SjoergcxxMethodDecl(hasParameter(0, hasType(varDecl()))) 85377330f729Sjoerg matches f(int x) {} 85387330f729Sjoergwith hasParameter(...) 85397330f729Sjoerg matching int x 85407330f729Sjoerg 85417330f729SjoergFor ObjectiveC, given 85427330f729Sjoerg @interface I - (void) f:(int) y; @end 85437330f729Sjoerg 85447330f729Sjoergthe matcher objcMethodDecl(hasParameter(0, hasName("y"))) 85457330f729Sjoergmatches the declaration of method f with hasParameter 85467330f729Sjoergmatching y. 85477330f729Sjoerg</pre></td></tr> 85487330f729Sjoerg 85497330f729Sjoerg 8550*e038c9c4Sjoerg<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> 8551*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc11"><pre>Matches if the type location of a node matches the inner matcher. 8552*e038c9c4Sjoerg 8553*e038c9c4SjoergExamples: 8554*e038c9c4Sjoerg int x; 8555*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 8556*e038c9c4Sjoerg matches int x 8557*e038c9c4Sjoerg 8558*e038c9c4Sjoergauto x = int(3); 8559*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 8560*e038c9c4Sjoerg matches int(3) 8561*e038c9c4Sjoerg 8562*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 8563*e038c9c4Sjoergauto x = Foo(1, 2); 8564*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 8565*e038c9c4Sjoerg matches Foo(1, 2) 8566*e038c9c4Sjoerg 8567*e038c9c4SjoergUsable 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>>, 8568*e038c9c4Sjoerg 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>>, 8569*e038c9c4Sjoerg 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>>, 8570*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 8571*e038c9c4Sjoerg 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>>, 8572*e038c9c4Sjoerg 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>>, 8573*e038c9c4Sjoerg 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>>, 8574*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 8575*e038c9c4Sjoerg</pre></td></tr> 8576*e038c9c4Sjoerg 8577*e038c9c4Sjoerg 85787330f729Sjoerg<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> 85797330f729Sjoerg<tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression 85807330f729Sjoergor opaque value's source expression matches the given matcher. 85817330f729Sjoerg 85827330f729SjoergExample 1: matches "a string" 85837330f729Sjoerg(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) 85847330f729Sjoergclass URL { URL(string); }; 85857330f729SjoergURL url = "a string"; 85867330f729Sjoerg 85877330f729SjoergExample 2: matches 'b' (matcher = 85887330f729SjoergopaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) 85897330f729Sjoergint a = b ?: 1; 85907330f729Sjoerg</pre></td></tr> 85917330f729Sjoerg 85927330f729Sjoerg 85937330f729Sjoerg<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> 85947330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of 85957330f729Sjoergoverloads matches the given matcher. 85967330f729Sjoerg 85977330f729SjoergGiven 85987330f729Sjoerg template <typename T> void foo(T); 85997330f729Sjoerg template <typename T> void bar(T); 86007330f729Sjoerg template <typename T> void baz(T t) { 86017330f729Sjoerg foo(t); 86027330f729Sjoerg bar(t); 86037330f729Sjoerg } 86047330f729SjoergunresolvedLookupExpr(hasAnyDeclaration( 86057330f729Sjoerg functionTemplateDecl(hasName("foo")))) 86067330f729Sjoerg matches foo in foo(t); but not bar in bar(t); 86077330f729Sjoerg</pre></td></tr> 86087330f729Sjoerg 86097330f729Sjoerg 86107330f729Sjoerg<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> 86117330f729Sjoerg<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. 86127330f729Sjoerg 86137330f729SjoergGiven 86147330f729Sjoerg int (*ptr_to_array)[4]; 86157330f729Sjoerg int (*ptr_to_func)(int); 86167330f729Sjoerg 86177330f729SjoergvarDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches 86187330f729Sjoergptr_to_func but not ptr_to_array. 86197330f729Sjoerg 86207330f729SjoergUsable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> 86217330f729Sjoerg</pre></td></tr> 86227330f729Sjoerg 86237330f729Sjoerg 86247330f729Sjoerg<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> 86257330f729Sjoerg<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the 86267330f729Sjoergpointee matches a given matcher. 86277330f729Sjoerg 86287330f729SjoergGiven 86297330f729Sjoerg int *a; 86307330f729Sjoerg int const *b; 86317330f729Sjoerg float const *f; 86327330f729SjoergpointerType(pointee(isConstQualified(), isInteger())) 86337330f729Sjoerg matches "int const *b" 86347330f729Sjoerg 86357330f729SjoergUsable 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>>, 86367330f729Sjoerg 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>> 86377330f729Sjoerg</pre></td></tr> 86387330f729Sjoerg 86397330f729Sjoerg 86407330f729Sjoerg<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> 86417330f729Sjoerg<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. 86427330f729Sjoerg 86437330f729SjoergGiven: 86447330f729Sjoerg typedef int &int_ref; 86457330f729Sjoerg int a; 86467330f729Sjoerg int_ref b = a; 86477330f729Sjoerg 86487330f729SjoergvarDecl(hasType(qualType(referenceType()))))) will not match the 86497330f729Sjoergdeclaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. 86507330f729Sjoerg</pre></td></tr> 86517330f729Sjoerg 86527330f729Sjoerg 8653*e038c9c4Sjoerg<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> 86547330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node 86557330f729Sjoergmatches the given matcher. 86567330f729Sjoerg 86577330f729SjoergThe associated declaration is: 86587330f729Sjoerg- for type nodes, the declaration of the underlying type 86597330f729Sjoerg- for CallExpr, the declaration of the callee 86607330f729Sjoerg- for MemberExpr, the declaration of the referenced member 86617330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 86627330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 86637330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 86647330f729Sjoerg 86657330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 86667330f729Sjoergsugared type. Given 86677330f729Sjoerg class X {}; 86687330f729Sjoerg typedef X Y; 86697330f729Sjoerg Y y; 86707330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 86717330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 86727330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 86737330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 86747330f729Sjoerg recordType(hasDeclaration(decl()))))) 86757330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 86767330f729Sjoerg 86777330f729SjoergUsable 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>>, 86787330f729Sjoerg 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>>, 86797330f729Sjoerg 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>>, 86807330f729Sjoerg 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>>, 86817330f729Sjoerg 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>>, 86827330f729Sjoerg 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>>, 86837330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 86847330f729Sjoerg</pre></td></tr> 86857330f729Sjoerg 86867330f729Sjoerg 86877330f729Sjoerg<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> 86887330f729Sjoerg<tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped. 86897330f729Sjoerg 86907330f729SjoergGiven 86917330f729Sjoerg void (*fp)(void); 86927330f729SjoergThe matcher 86937330f729Sjoerg varDecl(hasType(pointerType(pointee(ignoringParens(functionType()))))) 86947330f729Sjoergwould match the declaration for fp. 86957330f729Sjoerg</pre></td></tr> 86967330f729Sjoerg 86977330f729Sjoerg 86987330f729Sjoerg<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> 86997330f729Sjoerg<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 87007330f729Sjoerg</pre></td></tr> 87017330f729Sjoerg 87027330f729Sjoerg 87037330f729Sjoerg<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> 87047330f729Sjoerg<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type 87057330f729Sjoergmatches the specified matcher. 87067330f729Sjoerg 87077330f729SjoergExample matches y->x() 87087330f729Sjoerg (matcher = cxxMemberCallExpr(on(hasType(pointsTo 87097330f729Sjoerg cxxRecordDecl(hasName("Y"))))))) 87107330f729Sjoerg class Y { public: void x(); }; 87117330f729Sjoerg void z() { Y *y; y->x(); } 87127330f729Sjoerg</pre></td></tr> 87137330f729Sjoerg 87147330f729Sjoerg 87157330f729Sjoerg<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> 87167330f729Sjoerg<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 87177330f729Sjoerg</pre></td></tr> 87187330f729Sjoerg 87197330f729Sjoerg 87207330f729Sjoerg<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> 87217330f729Sjoerg<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced 87227330f729Sjoergtype matches the specified matcher. 87237330f729Sjoerg 87247330f729SjoergExample matches X &x and const X &y 87257330f729Sjoerg (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) 87267330f729Sjoerg class X { 87277330f729Sjoerg void a(X b) { 87287330f729Sjoerg X &x = b; 87297330f729Sjoerg const X &y = b; 87307330f729Sjoerg } 87317330f729Sjoerg }; 87327330f729Sjoerg</pre></td></tr> 87337330f729Sjoerg 87347330f729Sjoerg 8735*e038c9c4Sjoerg<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> 87367330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node 87377330f729Sjoergmatches the given matcher. 87387330f729Sjoerg 87397330f729SjoergThe associated declaration is: 87407330f729Sjoerg- for type nodes, the declaration of the underlying type 87417330f729Sjoerg- for CallExpr, the declaration of the callee 87427330f729Sjoerg- for MemberExpr, the declaration of the referenced member 87437330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 87447330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 87457330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 87467330f729Sjoerg 87477330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 87487330f729Sjoergsugared type. Given 87497330f729Sjoerg class X {}; 87507330f729Sjoerg typedef X Y; 87517330f729Sjoerg Y y; 87527330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 87537330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 87547330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 87557330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 87567330f729Sjoerg recordType(hasDeclaration(decl()))))) 87577330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 87587330f729Sjoerg 87597330f729SjoergUsable 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>>, 87607330f729Sjoerg 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>>, 87617330f729Sjoerg 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>>, 87627330f729Sjoerg 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>>, 87637330f729Sjoerg 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>>, 87647330f729Sjoerg 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>>, 87657330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 87667330f729Sjoerg</pre></td></tr> 87677330f729Sjoerg 87687330f729Sjoerg 87697330f729Sjoerg<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> 87707330f729Sjoerg<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the 87717330f729Sjoergpointee matches a given matcher. 87727330f729Sjoerg 87737330f729SjoergGiven 87747330f729Sjoerg int *a; 87757330f729Sjoerg int const *b; 87767330f729Sjoerg float const *f; 87777330f729SjoergpointerType(pointee(isConstQualified(), isInteger())) 87787330f729Sjoerg matches "int const *b" 87797330f729Sjoerg 87807330f729SjoergUsable 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>>, 87817330f729Sjoerg 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>> 87827330f729Sjoerg</pre></td></tr> 87837330f729Sjoerg 87847330f729Sjoerg 87857330f729Sjoerg<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> 87867330f729Sjoerg<tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement 87877330f729Sjoerg 87887330f729SjoergGiven 87897330f729Sjoerg return a + b; 87907330f729SjoerghasReturnValue(binaryOperator()) 87917330f729Sjoerg matches 'return a + b' 87927330f729Sjoergwith binaryOperator() 87937330f729Sjoerg matching 'a + b' 87947330f729Sjoerg</pre></td></tr> 87957330f729Sjoerg 87967330f729Sjoerg 87977330f729Sjoerg<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> 87987330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches 87997330f729Sjoerga given matcher. Also matches StmtExprs that have CompoundStmt as children. 88007330f729Sjoerg 88017330f729SjoergGiven 88027330f729Sjoerg { {}; 1+2; } 88037330f729SjoerghasAnySubstatement(compoundStmt()) 88047330f729Sjoerg matches '{ {}; 1+2; }' 88057330f729Sjoergwith compoundStmt() 88067330f729Sjoerg matching '{}' 88077330f729Sjoerg</pre></td></tr> 88087330f729Sjoerg 88097330f729Sjoerg 8810*e038c9c4Sjoerg<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> 88117330f729Sjoerg<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 88127330f729Sjoergalignof. 88137330f729Sjoerg</pre></td></tr> 88147330f729Sjoerg 88157330f729Sjoerg 8816*e038c9c4Sjoerg<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> 8817*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="forCallable0"><pre>Matches declaration of the function, method, or block the statement 8818*e038c9c4Sjoergbelongs to. 8819*e038c9c4Sjoerg 8820*e038c9c4SjoergGiven: 8821*e038c9c4SjoergF& operator=(const F& o) { 8822*e038c9c4Sjoerg std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); 8823*e038c9c4Sjoerg return *this; 8824*e038c9c4Sjoerg} 8825*e038c9c4SjoergreturnStmt(forCallable(functionDecl(hasName("operator=")))) 8826*e038c9c4Sjoerg matches 'return *this' 8827*e038c9c4Sjoerg but does not match 'return v > 0' 8828*e038c9c4Sjoerg 8829*e038c9c4SjoergGiven: 8830*e038c9c4Sjoerg-(void) foo { 8831*e038c9c4Sjoerg int x = 1; 8832*e038c9c4Sjoerg dispatch_sync(queue, ^{ int y = 2; }); 8833*e038c9c4Sjoerg} 8834*e038c9c4SjoergdeclStmt(forCallable(objcMethodDecl())) 8835*e038c9c4Sjoerg matches 'int x = 1' 8836*e038c9c4Sjoerg but does not match 'int y = 2'. 8837*e038c9c4Sjoergwhereas declStmt(forCallable(blockDecl())) 8838*e038c9c4Sjoerg matches 'int y = 2' 8839*e038c9c4Sjoerg but does not match 'int x = 1'. 8840*e038c9c4Sjoerg</pre></td></tr> 8841*e038c9c4Sjoerg 8842*e038c9c4Sjoerg 88437330f729Sjoerg<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> 8844*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to. 8845*e038c9c4Sjoerg 8846*e038c9c4SjoergDeprecated. Use forCallable() to correctly handle the situation when 8847*e038c9c4Sjoergthe declaration is not a function (but a block or an Objective-C method). 8848*e038c9c4SjoergforFunction() not only fails to take non-functions into account but also 8849*e038c9c4Sjoergmay match the wrong declaration in their presence. 88507330f729Sjoerg 88517330f729SjoergGiven: 88527330f729SjoergF& operator=(const F& o) { 88537330f729Sjoerg std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); 88547330f729Sjoerg return *this; 88557330f729Sjoerg} 88567330f729SjoergreturnStmt(forFunction(hasName("operator="))) 88577330f729Sjoerg matches 'return *this' 88587330f729Sjoerg but does not match 'return v > 0' 88597330f729Sjoerg</pre></td></tr> 88607330f729Sjoerg 88617330f729Sjoerg 8862*e038c9c4Sjoerg<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> 88637330f729Sjoerg<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 88647330f729Sjoergsizeof. 88657330f729Sjoerg</pre></td></tr> 88667330f729Sjoerg 88677330f729Sjoerg 88687330f729Sjoerg<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> 88697330f729Sjoerg<tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement 88707330f729Sjoergtype that matches the provided matcher. 88717330f729Sjoerg 88727330f729SjoergGiven 88737330f729Sjoerg template <typename T> 88747330f729Sjoerg double F(T t); 88757330f729Sjoerg int i; 88767330f729Sjoerg double j = F(i); 88777330f729Sjoerg 88787330f729SjoergsubstTemplateTypeParmType(hasReplacementType(type())) matches int 88797330f729Sjoerg</pre></td></tr> 88807330f729Sjoerg 88817330f729Sjoerg 88827330f729Sjoerg<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> 88837330f729Sjoerg<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch 88847330f729Sjoergstatement. This matcher may produce multiple matches. 88857330f729Sjoerg 88867330f729SjoergGiven 88877330f729Sjoerg switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } 88887330f729SjoergswitchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") 88897330f729Sjoerg matches four times, with "c" binding each of "case 1:", "case 2:", 88907330f729Sjoerg"case 3:" and "case 4:", and "s" respectively binding "switch (1)", 88917330f729Sjoerg"switch (1)", "switch (2)" and "switch (2)". 88927330f729Sjoerg</pre></td></tr> 88937330f729Sjoerg 88947330f729Sjoerg 88957330f729Sjoerg<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> 88967330f729Sjoerg<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 88977330f729Sjoergswitch statement or conditional operator. 88987330f729Sjoerg 88997330f729SjoergExample matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 89007330f729Sjoerg if (true) {} 89017330f729Sjoerg</pre></td></tr> 89027330f729Sjoerg 89037330f729Sjoerg 8904*e038c9c4Sjoerg<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> 8905*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasInitStatement1"><pre>Matches selection statements with initializer. 8906*e038c9c4Sjoerg 8907*e038c9c4SjoergGiven: 8908*e038c9c4Sjoerg void foo() { 8909*e038c9c4Sjoerg if (int i = foobar(); i > 0) {} 8910*e038c9c4Sjoerg switch (int i = foobar(); i) {} 8911*e038c9c4Sjoerg for (auto& a = get_range(); auto& x : a) {} 8912*e038c9c4Sjoerg } 8913*e038c9c4Sjoerg void bar() { 8914*e038c9c4Sjoerg if (foobar() > 0) {} 8915*e038c9c4Sjoerg switch (foobar()) {} 8916*e038c9c4Sjoerg for (auto& x : get_range()) {} 8917*e038c9c4Sjoerg } 8918*e038c9c4SjoergifStmt(hasInitStatement(anything())) 8919*e038c9c4Sjoerg matches the if statement in foo but not in bar. 8920*e038c9c4SjoergswitchStmt(hasInitStatement(anything())) 8921*e038c9c4Sjoerg matches the switch statement in foo but not in bar. 8922*e038c9c4SjoergcxxForRangeStmt(hasInitStatement(anything())) 8923*e038c9c4Sjoerg matches the range for statement in foo but not in bar. 8924*e038c9c4Sjoerg</pre></td></tr> 8925*e038c9c4Sjoerg 8926*e038c9c4Sjoerg 8927*e038c9c4Sjoerg<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> 89287330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node 89297330f729Sjoergmatches the given matcher. 89307330f729Sjoerg 89317330f729SjoergThe associated declaration is: 89327330f729Sjoerg- for type nodes, the declaration of the underlying type 89337330f729Sjoerg- for CallExpr, the declaration of the callee 89347330f729Sjoerg- for MemberExpr, the declaration of the referenced member 89357330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 89367330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 89377330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 89387330f729Sjoerg 89397330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 89407330f729Sjoergsugared type. Given 89417330f729Sjoerg class X {}; 89427330f729Sjoerg typedef X Y; 89437330f729Sjoerg Y y; 89447330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 89457330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 89467330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 89477330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 89487330f729Sjoerg recordType(hasDeclaration(decl()))))) 89497330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 89507330f729Sjoerg 89517330f729SjoergUsable 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>>, 89527330f729Sjoerg 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>>, 89537330f729Sjoerg 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>>, 89547330f729Sjoerg 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>>, 89557330f729Sjoerg 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>>, 89567330f729Sjoerg 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>>, 89577330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 89587330f729Sjoerg</pre></td></tr> 89597330f729Sjoerg 89607330f729Sjoerg 8961*e038c9c4Sjoerg<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> 8962*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc12"><pre>Matches if the type location of a node matches the inner matcher. 8963*e038c9c4Sjoerg 8964*e038c9c4SjoergExamples: 8965*e038c9c4Sjoerg int x; 8966*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 8967*e038c9c4Sjoerg matches int x 8968*e038c9c4Sjoerg 8969*e038c9c4Sjoergauto x = int(3); 8970*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 8971*e038c9c4Sjoerg matches int(3) 8972*e038c9c4Sjoerg 8973*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 8974*e038c9c4Sjoergauto x = Foo(1, 2); 8975*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 8976*e038c9c4Sjoerg matches Foo(1, 2) 8977*e038c9c4Sjoerg 8978*e038c9c4SjoergUsable 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>>, 8979*e038c9c4Sjoerg 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>>, 8980*e038c9c4Sjoerg 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>>, 8981*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 8982*e038c9c4Sjoerg 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>>, 8983*e038c9c4Sjoerg 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>>, 8984*e038c9c4Sjoerg 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>>, 8985*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 8986*e038c9c4Sjoerg</pre></td></tr> 8987*e038c9c4Sjoerg 8988*e038c9c4Sjoerg 89897330f729Sjoerg<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> 89907330f729Sjoerg<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. 89917330f729Sjoerg 89927330f729SjoergGiven 89937330f729Sjoerg struct B { int next; }; 89947330f729Sjoerg template<int(B::*next_ptr)> struct A {}; 89957330f729Sjoerg A<&B::next> a; 89967330f729SjoergtemplateSpecializationType(hasAnyTemplateArgument( 89977330f729Sjoerg isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) 89987330f729Sjoerg matches the specialization A<&B::next> with fieldDecl(...) matching 89997330f729Sjoerg B::next 90007330f729Sjoerg</pre></td></tr> 90017330f729Sjoerg 90027330f729Sjoerg 90037330f729Sjoerg<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> 90047330f729Sjoerg<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain 90057330f729Sjoergdeclaration. 90067330f729Sjoerg 90077330f729SjoergGiven 90087330f729Sjoerg struct B { int next; }; 90097330f729Sjoerg template<int(B::*next_ptr)> struct A {}; 90107330f729Sjoerg A<&B::next> a; 90117330f729SjoergclassTemplateSpecializationDecl(hasAnyTemplateArgument( 90127330f729Sjoerg refersToDeclaration(fieldDecl(hasName("next"))))) 90137330f729Sjoerg matches the specialization A<&B::next> with fieldDecl(...) matching 90147330f729Sjoerg B::next 90157330f729Sjoerg</pre></td></tr> 90167330f729Sjoerg 90177330f729Sjoerg 90187330f729Sjoerg<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> 9019*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that refers to an integral type. 90207330f729Sjoerg 90217330f729SjoergGiven 90227330f729Sjoerg template<int T> struct C {}; 90237330f729Sjoerg C<42> c; 90247330f729SjoergclassTemplateSpecializationDecl( 90257330f729Sjoerg hasAnyTemplateArgument(refersToIntegralType(asString("int")))) 90267330f729Sjoerg matches the implicit instantiation of C in C<42>. 90277330f729Sjoerg</pre></td></tr> 90287330f729Sjoerg 90297330f729Sjoerg 90307330f729Sjoerg<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> 90317330f729Sjoerg<tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template. 90327330f729Sjoerg 90337330f729SjoergGiven 90347330f729Sjoerg template<template <typename> class S> class X {}; 90357330f729Sjoerg template<typename T> class Y {}; 90367330f729Sjoerg X<Y> xi; 90377330f729SjoergclassTemplateSpecializationDecl(hasAnyTemplateArgument( 90387330f729Sjoerg refersToTemplate(templateName()))) 90397330f729Sjoerg matches the specialization X<Y> 90407330f729Sjoerg</pre></td></tr> 90417330f729Sjoerg 90427330f729Sjoerg 90437330f729Sjoerg<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> 90447330f729Sjoerg<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 90457330f729Sjoerg 90467330f729SjoergGiven 90477330f729Sjoerg struct X {}; 90487330f729Sjoerg template<typename T> struct A {}; 90497330f729Sjoerg A<X> a; 90507330f729SjoergclassTemplateSpecializationDecl(hasAnyTemplateArgument( 90517330f729Sjoerg refersToType(class(hasName("X"))))) 90527330f729Sjoerg matches the specialization A<X> 90537330f729Sjoerg</pre></td></tr> 90547330f729Sjoerg 90557330f729Sjoerg 90567330f729Sjoerg<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> 90577330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and 90587330f729SjoergfunctionDecl that have at least one TemplateArgument matching the given 90597330f729SjoergInnerMatcher. 90607330f729Sjoerg 90617330f729SjoergGiven 90627330f729Sjoerg template<typename T> class A {}; 90637330f729Sjoerg template<> class A<double> {}; 90647330f729Sjoerg A<int> a; 90657330f729Sjoerg 90667330f729Sjoerg template<typename T> f() {}; 90677330f729Sjoerg void func() { f<int>(); }; 90687330f729Sjoerg 90697330f729SjoergclassTemplateSpecializationDecl(hasAnyTemplateArgument( 90707330f729Sjoerg refersToType(asString("int")))) 90717330f729Sjoerg matches the specialization A<int> 90727330f729Sjoerg 90737330f729SjoergfunctionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 90747330f729Sjoerg matches the specialization f<int> 90757330f729Sjoerg</pre></td></tr> 90767330f729Sjoerg 90777330f729Sjoerg 9078*e038c9c4Sjoerg<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> 90797330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node 90807330f729Sjoergmatches the given matcher. 90817330f729Sjoerg 90827330f729SjoergThe associated declaration is: 90837330f729Sjoerg- for type nodes, the declaration of the underlying type 90847330f729Sjoerg- for CallExpr, the declaration of the callee 90857330f729Sjoerg- for MemberExpr, the declaration of the referenced member 90867330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 90877330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 90887330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 90897330f729Sjoerg 90907330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 90917330f729Sjoergsugared type. Given 90927330f729Sjoerg class X {}; 90937330f729Sjoerg typedef X Y; 90947330f729Sjoerg Y y; 90957330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 90967330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 90977330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 90987330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 90997330f729Sjoerg recordType(hasDeclaration(decl()))))) 91007330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 91017330f729Sjoerg 91027330f729SjoergUsable 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>>, 91037330f729Sjoerg 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>>, 91047330f729Sjoerg 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>>, 91057330f729Sjoerg 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>>, 91067330f729Sjoerg 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>>, 91077330f729Sjoerg 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>>, 91087330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 91097330f729Sjoerg</pre></td></tr> 91107330f729Sjoerg 91117330f729Sjoerg 91127330f729Sjoerg<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> 91137330f729Sjoerg<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and 91147330f729SjoergfunctionDecl where the n'th TemplateArgument matches the given InnerMatcher. 91157330f729Sjoerg 91167330f729SjoergGiven 91177330f729Sjoerg template<typename T, typename U> class A {}; 91187330f729Sjoerg A<bool, int> b; 91197330f729Sjoerg A<int, bool> c; 91207330f729Sjoerg 91217330f729Sjoerg template<typename T> void f() {} 91227330f729Sjoerg void func() { f<int>(); }; 91237330f729SjoergclassTemplateSpecializationDecl(hasTemplateArgument( 91247330f729Sjoerg 1, refersToType(asString("int")))) 91257330f729Sjoerg matches the specialization A<bool, int> 91267330f729Sjoerg 91277330f729SjoergfunctionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 91287330f729Sjoerg matches the specialization f<int> 91297330f729Sjoerg</pre></td></tr> 91307330f729Sjoerg 91317330f729Sjoerg 9132*e038c9c4Sjoerg<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> 91337330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node 91347330f729Sjoergmatches the given matcher. 91357330f729Sjoerg 91367330f729SjoergThe associated declaration is: 91377330f729Sjoerg- for type nodes, the declaration of the underlying type 91387330f729Sjoerg- for CallExpr, the declaration of the callee 91397330f729Sjoerg- for MemberExpr, the declaration of the referenced member 91407330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 91417330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 91427330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 91437330f729Sjoerg 91447330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 91457330f729Sjoergsugared type. Given 91467330f729Sjoerg class X {}; 91477330f729Sjoerg typedef X Y; 91487330f729Sjoerg Y y; 91497330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 91507330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 91517330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 91527330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 91537330f729Sjoerg recordType(hasDeclaration(decl()))))) 91547330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 91557330f729Sjoerg 91567330f729SjoergUsable 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>>, 91577330f729Sjoerg 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>>, 91587330f729Sjoerg 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>>, 91597330f729Sjoerg 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>>, 91607330f729Sjoerg 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>>, 91617330f729Sjoerg 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>>, 91627330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 91637330f729Sjoerg</pre></td></tr> 91647330f729Sjoerg 91657330f729Sjoerg 9166*e038c9c4Sjoerg<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> 9167*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner 9168*e038c9c4SjoergQualType-matcher matches. 9169*e038c9c4Sjoerg</pre></td></tr> 91707330f729Sjoerg 91717330f729Sjoerg 9172*e038c9c4Sjoerg<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> 9173*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasTypeLoc13"><pre>Matches if the type location of a node matches the inner matcher. 91747330f729Sjoerg 9175*e038c9c4SjoergExamples: 9176*e038c9c4Sjoerg int x; 9177*e038c9c4SjoergdeclaratorDecl(hasTypeLoc(loc(asString("int")))) 9178*e038c9c4Sjoerg matches int x 9179*e038c9c4Sjoerg 9180*e038c9c4Sjoergauto x = int(3); 9181*e038c9c4SjoergcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) 9182*e038c9c4Sjoerg matches int(3) 9183*e038c9c4Sjoerg 9184*e038c9c4Sjoergstruct Foo { Foo(int, int); }; 9185*e038c9c4Sjoergauto x = Foo(1, 2); 9186*e038c9c4SjoergcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) 9187*e038c9c4Sjoerg matches Foo(1, 2) 9188*e038c9c4Sjoerg 9189*e038c9c4SjoergUsable 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>>, 9190*e038c9c4Sjoerg 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>>, 9191*e038c9c4Sjoerg 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>>, 9192*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, 9193*e038c9c4Sjoerg 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>>, 9194*e038c9c4Sjoerg 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>>, 9195*e038c9c4Sjoerg 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>>, 9196*e038c9c4Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> 91977330f729Sjoerg</pre></td></tr> 91987330f729Sjoerg 91997330f729Sjoerg 92007330f729Sjoerg<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> 92017330f729Sjoerg<tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type 92027330f729Sjoergmatcher. 92037330f729Sjoerg 92047330f729SjoergExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 92057330f729Sjoerg and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 92067330f729Sjoerg and U (matcher = typedefDecl(hasType(asString("int"))) 92077330f729Sjoerg and friend class X (matcher = friendDecl(hasType("X")) 9208*e038c9c4Sjoerg and public virtual X (matcher = cxxBaseSpecifier(hasType( 9209*e038c9c4Sjoerg asString("class X"))) 92107330f729Sjoerg class X {}; 92117330f729Sjoerg void y(X &x) { x; X z; } 92127330f729Sjoerg typedef int U; 92137330f729Sjoerg class Y { friend class X; }; 9214*e038c9c4Sjoerg class Z : public virtual X {}; 92157330f729Sjoerg</pre></td></tr> 92167330f729Sjoerg 92177330f729Sjoerg 9218*e038c9c4Sjoerg<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> 92197330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node 92207330f729Sjoergmatches the given matcher. 92217330f729Sjoerg 92227330f729SjoergThe associated declaration is: 92237330f729Sjoerg- for type nodes, the declaration of the underlying type 92247330f729Sjoerg- for CallExpr, the declaration of the callee 92257330f729Sjoerg- for MemberExpr, the declaration of the referenced member 92267330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 92277330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 92287330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 92297330f729Sjoerg 92307330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 92317330f729Sjoergsugared type. Given 92327330f729Sjoerg class X {}; 92337330f729Sjoerg typedef X Y; 92347330f729Sjoerg Y y; 92357330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 92367330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 92377330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 92387330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 92397330f729Sjoerg recordType(hasDeclaration(decl()))))) 92407330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 92417330f729Sjoerg 92427330f729SjoergUsable 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>>, 92437330f729Sjoerg 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>>, 92447330f729Sjoerg 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>>, 92457330f729Sjoerg 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>>, 92467330f729Sjoerg 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>>, 92477330f729Sjoerg 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>>, 92487330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 92497330f729Sjoerg</pre></td></tr> 92507330f729Sjoerg 92517330f729Sjoerg 92527330f729Sjoerg<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> 92537330f729Sjoerg<tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared 92547330f729Sjoergtype of the matched node. 92557330f729Sjoerg 92567330f729SjoergFor example, in: 92577330f729Sjoerg class A {}; 92587330f729Sjoerg using B = A; 92597330f729SjoergThe matcher type(hasUnqualifiedDesugaredType(recordType())) matches 92607330f729Sjoergboth B and A. 92617330f729Sjoerg</pre></td></tr> 92627330f729Sjoerg 92637330f729Sjoerg 92647330f729Sjoerg<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> 92657330f729Sjoerg<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 92667330f729Sjoerg 92677330f729SjoergGiven 92687330f729Sjoerg int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 92697330f729SjoergunaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 92707330f729Sjoerg matches sizeof(a) and alignof(c) 92717330f729Sjoerg</pre></td></tr> 92727330f729Sjoerg 92737330f729Sjoerg 92747330f729Sjoerg<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> 92757330f729Sjoerg<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 92767330f729Sjoerg 92777330f729SjoergExample matches true (matcher = hasUnaryOperand( 92787330f729Sjoerg cxxBoolLiteral(equals(true)))) 92797330f729Sjoerg !true 92807330f729Sjoerg</pre></td></tr> 92817330f729Sjoerg 92827330f729Sjoerg 92837330f729Sjoerg<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> 92847330f729Sjoerg<tr><td colspan="4" class="doc" id="hasObjectExpression1"><pre>Matches a member expression where the object expression is matched by a 92857330f729Sjoerggiven matcher. Implicit object expressions are included; that is, it matches 92867330f729Sjoerguse of implicit `this`. 92877330f729Sjoerg 92887330f729SjoergGiven 92897330f729Sjoerg struct X { 92907330f729Sjoerg int m; 92917330f729Sjoerg int f(X x) { x.m; return m; } 92927330f729Sjoerg }; 92937330f729SjoergmemberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) 92947330f729Sjoerg matches `x.m`, but not `m`; however, 92957330f729SjoergmemberExpr(hasObjectExpression(hasType(pointsTo( 92967330f729Sjoerg cxxRecordDecl(hasName("X")))))) 92977330f729Sjoerg matches `m` (aka. `this->m`), but not `x.m`. 92987330f729Sjoerg</pre></td></tr> 92997330f729Sjoerg 93007330f729Sjoerg 9301*e038c9c4Sjoerg<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> 93027330f729Sjoerg<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node 93037330f729Sjoergmatches the given matcher. 93047330f729Sjoerg 93057330f729SjoergThe associated declaration is: 93067330f729Sjoerg- for type nodes, the declaration of the underlying type 93077330f729Sjoerg- for CallExpr, the declaration of the callee 93087330f729Sjoerg- for MemberExpr, the declaration of the referenced member 93097330f729Sjoerg- for CXXConstructExpr, the declaration of the constructor 93107330f729Sjoerg- for CXXNewExpr, the declaration of the operator new 93117330f729Sjoerg- for ObjCIvarExpr, the declaration of the ivar 93127330f729Sjoerg 93137330f729SjoergFor type nodes, hasDeclaration will generally match the declaration of the 93147330f729Sjoergsugared type. Given 93157330f729Sjoerg class X {}; 93167330f729Sjoerg typedef X Y; 93177330f729Sjoerg Y y; 93187330f729Sjoergin varDecl(hasType(hasDeclaration(decl()))) the decl will match the 93197330f729SjoergtypedefDecl. A common use case is to match the underlying, desugared type. 93207330f729SjoergThis can be achieved by using the hasUnqualifiedDesugaredType matcher: 93217330f729Sjoerg varDecl(hasType(hasUnqualifiedDesugaredType( 93227330f729Sjoerg recordType(hasDeclaration(decl()))))) 93237330f729SjoergIn this matcher, the decl will match the CXXRecordDecl of class X. 93247330f729Sjoerg 93257330f729SjoergUsable 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>>, 93267330f729Sjoerg 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>>, 93277330f729Sjoerg 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>>, 93287330f729Sjoerg 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>>, 93297330f729Sjoerg 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>>, 93307330f729Sjoerg 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>>, 93317330f729Sjoerg Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 93327330f729Sjoerg</pre></td></tr> 93337330f729Sjoerg 93347330f729Sjoerg 93357330f729Sjoerg<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>></td><td class="name" onclick="toggle('hasAnyUsingShadowDecl0')"><a name="hasAnyUsingShadowDecl0Anchor">hasAnyUsingShadowDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>> InnerMatcher</td></tr> 93367330f729Sjoerg<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 93377330f729Sjoerg 93387330f729SjoergGiven 93397330f729Sjoerg namespace X { void b(); } 93407330f729Sjoerg using X::b; 93417330f729SjoergusingDecl(hasAnyUsingShadowDecl(hasName("b")))) 93427330f729Sjoerg matches using X::b </pre></td></tr> 93437330f729Sjoerg 93447330f729Sjoerg 93457330f729Sjoerg<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> 93467330f729Sjoerg<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 93477330f729Sjoergmatched by the given matcher. 93487330f729Sjoerg 93497330f729SjoergGiven 93507330f729Sjoerg namespace X { int a; void b(); } 93517330f729Sjoerg using X::a; 93527330f729Sjoerg using X::b; 93537330f729SjoergusingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 93547330f729Sjoerg matches using X::b but not using X::a </pre></td></tr> 93557330f729Sjoerg 93567330f729Sjoerg 9357*e038c9c4Sjoerg<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> 9358*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasType7"><pre>Overloaded to match the declaration of the expression's or value 93597330f729Sjoergdeclaration's type. 93607330f729Sjoerg 93617330f729SjoergIn case of a value declaration (for example a variable declaration), 93627330f729Sjoergthis resolves one layer of indirection. For example, in the value 93637330f729Sjoergdeclaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 93647330f729SjoergX, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 93657330f729Sjoergdeclaration of x. 93667330f729Sjoerg 93677330f729SjoergExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 93687330f729Sjoerg and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 93697330f729Sjoerg and friend class X (matcher = friendDecl(hasType("X")) 9370*e038c9c4Sjoerg and public virtual X (matcher = cxxBaseSpecifier(hasType( 9371*e038c9c4Sjoerg cxxRecordDecl(hasName("X")))) 93727330f729Sjoerg class X {}; 93737330f729Sjoerg void y(X &x) { x; X z; } 93747330f729Sjoerg class Y { friend class X; }; 9375*e038c9c4Sjoerg class Z : public virtual X {}; 93767330f729Sjoerg 9377*e038c9c4SjoergExample matches class Derived 9378*e038c9c4Sjoerg(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) 9379*e038c9c4Sjoergclass Base {}; 9380*e038c9c4Sjoergclass Derived : Base {}; 9381*e038c9c4Sjoerg 9382*e038c9c4SjoergUsable 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>>, 9383*e038c9c4SjoergMatcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> 93847330f729Sjoerg</pre></td></tr> 93857330f729Sjoerg 93867330f729Sjoerg 93877330f729Sjoerg<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> 93887330f729Sjoerg<tr><td colspan="4" class="doc" id="hasType3"><pre>Matches if the expression's or declaration's type matches a type 93897330f729Sjoergmatcher. 93907330f729Sjoerg 93917330f729SjoergExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 93927330f729Sjoerg and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 93937330f729Sjoerg and U (matcher = typedefDecl(hasType(asString("int"))) 93947330f729Sjoerg and friend class X (matcher = friendDecl(hasType("X")) 9395*e038c9c4Sjoerg and public virtual X (matcher = cxxBaseSpecifier(hasType( 9396*e038c9c4Sjoerg asString("class X"))) 93977330f729Sjoerg class X {}; 93987330f729Sjoerg void y(X &x) { x; X z; } 93997330f729Sjoerg typedef int U; 94007330f729Sjoerg class Y { friend class X; }; 9401*e038c9c4Sjoerg class Z : public virtual X {}; 94027330f729Sjoerg</pre></td></tr> 94037330f729Sjoerg 94047330f729Sjoerg 94057330f729Sjoerg<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> 94067330f729Sjoerg<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 94077330f729Sjoergthat matches the given matcher. 94087330f729Sjoerg 94097330f729SjoergExample matches x (matcher = varDecl(hasInitializer(callExpr()))) 94107330f729Sjoerg bool y() { return true; } 94117330f729Sjoerg bool x = y(); 94127330f729Sjoerg</pre></td></tr> 94137330f729Sjoerg 94147330f729Sjoerg 94157330f729Sjoerg<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> 94167330f729Sjoerg<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 94177330f729Sjoergexpression. 94187330f729Sjoerg 94197330f729SjoergGiven 94207330f729Sjoerg void f(int b) { 94217330f729Sjoerg int a[b]; 94227330f729Sjoerg } 94237330f729SjoergvariableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 94247330f729Sjoerg varDecl(hasName("b"))))))) 94257330f729Sjoerg matches "int a[b]" 94267330f729Sjoerg</pre></td></tr> 94277330f729Sjoerg 94287330f729Sjoerg 94297330f729Sjoerg<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> 9430*e038c9c4Sjoerg<tr><td colspan="4" class="doc" id="hasBody2"><pre></pre></td></tr> 94317330f729Sjoerg 94327330f729Sjoerg 94337330f729Sjoerg<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> 94347330f729Sjoerg<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 94357330f729Sjoergswitch statement or conditional operator. 94367330f729Sjoerg 94377330f729SjoergExample matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 94387330f729Sjoerg if (true) {} 94397330f729Sjoerg</pre></td></tr> 94407330f729Sjoerg 94417330f729Sjoerg<!--END_TRAVERSAL_MATCHERS --> 94427330f729Sjoerg</table> 94437330f729Sjoerg 94447330f729Sjoerg</div> 94457330f729Sjoerg</body> 94467330f729Sjoerg</html> 94477330f729Sjoerg 94487330f729Sjoerg 9449