| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<title>AST Matcher Reference</title> |
| 6 |
<link type="text/css" rel="stylesheet" href="../menu.css" /> |
| 7 |
<link type="text/css" rel="stylesheet" href="../content.css" /> |
| 8 |
<style type="text/css"> |
| 9 |
td { |
| 10 |
padding: .33em; |
| 11 |
} |
| 12 |
td.doc { |
| 13 |
display: none; |
| 14 |
border-bottom: 1px solid black; |
| 15 |
} |
| 16 |
td.name:hover { |
| 17 |
color: blue; |
| 18 |
cursor: pointer; |
| 19 |
} |
| 20 |
span.mono { font-family: monospace; } |
| 21 |
|
| 22 |
.traverse_compare, .traverse_compare td, .traverse_compare th { |
| 23 |
border: 1px solid black; |
| 24 |
border-collapse: collapse; |
| 25 |
} |
| 26 |
</style> |
| 27 |
<script type="text/javascript"> |
| 28 |
function toggle(id) { |
| 29 |
if (!id) return; |
| 30 |
row = document.getElementById(id); |
| 31 |
if (row.style.display != 'table-cell') |
| 32 |
row.style.display = 'table-cell'; |
| 33 |
else |
| 34 |
row.style.display = 'none'; |
| 35 |
} |
| 36 |
</script> |
| 37 |
</head> |
| 38 |
<body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))"> |
| 39 |
|
| 40 |
<!--#include virtual="../menu.html.incl"--> |
| 41 |
|
| 42 |
<div id="content"> |
| 43 |
|
| 44 |
<h1>AST Matcher Reference</h1> |
| 45 |
|
| 46 |
<p>This document shows all currently implemented matchers. The matchers are grouped |
| 47 |
by category and node type they match. You can click on matcher names to show the |
| 48 |
matcher's source documentation.</p> |
| 49 |
|
| 50 |
<p>There are three different basic categories of matchers: |
| 51 |
<ul> |
| 52 |
<li><a href="#decl-matchers">Node Matchers:</a> Matchers that match a specific type of AST node.</li> |
| 53 |
<li><a href="#narrowing-matchers">Narrowing Matchers:</a> Matchers that match attributes on AST nodes.</li> |
| 54 |
<li><a href="#traversal-matchers">Traversal Matchers:</a> Matchers that allow traversal between AST nodes.</li> |
| 55 |
</ul> |
| 56 |
</p> |
| 57 |
|
| 58 |
<p>Within each category the matchers are ordered by node type they match on. |
| 59 |
Note that if a matcher can match multiple node types, it will appear |
| 60 |
multiple times. This means that by searching for Matcher<Stmt> you can |
| 61 |
find all matchers that can be used to match on Stmt nodes.</p> |
| 62 |
|
| 63 |
<p>The exception to that rule are matchers that can match on any node. Those |
| 64 |
are marked with a * and are listed in the beginning of each category.</p> |
| 65 |
|
| 66 |
<p>Note that the categorization of matchers is a great help when you combine |
| 67 |
them into matcher expressions. You will usually want to form matcher expressions |
| 68 |
that read like english sentences by alternating between node matchers and |
| 69 |
narrowing or traversal matchers, like this: |
| 70 |
<pre> |
| 71 |
recordDecl(hasDescendant( |
| 72 |
ifStmt(hasTrueExpression( |
| 73 |
expr(hasDescendant( |
| 74 |
ifStmt())))))) |
| 75 |
</pre> |
| 76 |
</p> |
| 77 |
|
| 78 |
<!-- ======================================================================= --> |
| 79 |
<h2 id="traverse-mode">Traverse Mode</h2> |
| 80 |
<!-- ======================================================================= --> |
| 81 |
|
| 82 |
<p>The default mode of operation of AST Matchers visits all nodes in the AST, |
| 83 |
even if they are not spelled in the source. This is |
| 84 |
<span class="mono">AsIs</span> mode. This mode requires writing AST matchers |
| 85 |
that explicitly traverse or ignore implicit nodes, such as parentheses |
| 86 |
surrounding an expression or expressions with cleanups. These implicit |
| 87 |
nodes are not always obvious from the syntax of the source code, and so this |
| 88 |
mode requires careful consideration and testing to get the desired behavior |
| 89 |
from an AST matcher. |
| 90 |
</p> |
| 91 |
|
| 92 |
<p>In addition, because template instantiations are matched in the default mode, |
| 93 |
transformations can be accidentally made to template declarations. Finally, |
| 94 |
because implicit nodes are matched by default, transformations can be made on |
| 95 |
entirely incorrect places in the code.</p> |
| 96 |
|
| 97 |
<p>For these reasons, it is possible to ignore AST nodes which are not spelled |
| 98 |
in the source using the <span class="mono">IgnoreUnlessSpelledInSource</span> |
| 99 |
mode. This is likely to be far less error-prone for users who are not already |
| 100 |
very familiar with where implicit nodes appear in the AST. It is also likely |
| 101 |
to be less error-prone for experienced AST users, as difficult cases do not |
| 102 |
need to be encountered and matcher expressions adjusted for these cases.</p> |
| 103 |
|
| 104 |
<p>In clang-query, the mode can be changed with |
| 105 |
<pre> |
| 106 |
set traversal IgnoreUnlessSpelledInSource |
| 107 |
</pre> |
| 108 |
</p> |
| 109 |
This affects both matchers and AST dump output in results. |
| 110 |
|
| 111 |
<p>When using the C++ API such as in clang-tidy checks, the |
| 112 |
<span class="mono">traverse()</span> matcher is used to set the mode: |
| 113 |
<pre> |
| 114 |
Finder->addMatcher(traverse(TK_IgnoreUnlessSpelledInSource, |
| 115 |
returnStmt(hasReturnValue(integerLiteral(equals(0)))) |
| 116 |
), this); |
| 117 |
</pre> |
| 118 |
</p> |
| 119 |
<p>The following table compares the <span class="mono">AsIs</span> mode with |
| 120 |
the <span class="mono">IgnoreUnlessSpelledInSource</span> mode:</p> |
| 121 |
|
| 122 |
<table class="traverse_compare"> |
| 123 |
<tr> |
| 124 |
<th></th> |
| 125 |
<th><span class="mono">AsIs</span></th> |
| 126 |
<th><span class="mono">IgnoreUnlessSpelledInSource</span></th> |
| 127 |
</tr> |
| 128 |
<tr> |
| 129 |
<td>AST dump of <span class="mono">func1</span>: |
| 130 |
<pre> |
| 131 |
struct B { |
| 132 |
B(int); |
| 133 |
}; |
| 134 |
|
| 135 |
B func1() { return 42; } |
| 136 |
</pre> |
| 137 |
|
| 138 |
</td> |
| 139 |
<td> |
| 140 |
C++98 dialect: |
| 141 |
<pre> |
| 142 |
FunctionDecl |
| 143 |
`-CompoundStmt |
| 144 |
`-ReturnStmt |
| 145 |
`-ExprWithCleanups |
| 146 |
`-CXXConstructExpr |
| 147 |
`-MaterializeTemporaryExpr |
| 148 |
`-ImplicitCastExpr |
| 149 |
`-ImplicitCastExpr |
| 150 |
`-CXXConstructExpr |
| 151 |
`-IntegerLiteral 'int' 42 |
| 152 |
</pre> |
| 153 |
C++11, C++14 dialect: |
| 154 |
<pre> |
| 155 |
FunctionDecl |
| 156 |
`-CompoundStmt |
| 157 |
`-ReturnStmt |
| 158 |
`-ExprWithCleanups |
| 159 |
`-CXXConstructExpr |
| 160 |
`-MaterializeTemporaryExpr |
| 161 |
`-ImplicitCastExpr |
| 162 |
`-CXXConstructExpr |
| 163 |
`-IntegerLiteral 'int' 42 |
| 164 |
</pre> |
| 165 |
C++17, C++20 dialect: |
| 166 |
<pre> |
| 167 |
FunctionDecl |
| 168 |
`-CompoundStmt |
| 169 |
`-ReturnStmt |
| 170 |
`-ImplicitCastExpr |
| 171 |
`-CXXConstructExpr |
| 172 |
`-IntegerLiteral 'int' 42 |
| 173 |
</pre> |
| 174 |
</td> |
| 175 |
<td> |
| 176 |
All dialects: |
| 177 |
<pre> |
| 178 |
FunctionDecl |
| 179 |
`-CompoundStmt |
| 180 |
`-ReturnStmt |
| 181 |
`-IntegerLiteral 'int' 42 |
| 182 |
</pre></td> |
| 183 |
</tr> |
| 184 |
|
| 185 |
<tr> |
| 186 |
<td>Matcher for returned <span class="mono">42</span>: |
| 187 |
<pre> |
| 188 |
struct B { |
| 189 |
B(int); |
| 190 |
}; |
| 191 |
|
| 192 |
B func1() { return 42; } |
| 193 |
</pre> |
| 194 |
|
| 195 |
</td> |
| 196 |
<td> |
| 197 |
All dialects: |
| 198 |
<pre> |
| 199 |
returnStmt(hasReturnValue( |
| 200 |
ignoringImplicit( |
| 201 |
ignoringElidableConstructorCall( |
| 202 |
ignoringImplicit( |
| 203 |
cxxConstructExpr(hasArgument(0, |
| 204 |
ignoringImplicit( |
| 205 |
integerLiteral().bind("returnVal") |
| 206 |
) |
| 207 |
)) |
| 208 |
) |
| 209 |
) |
| 210 |
) |
| 211 |
)) |
| 212 |
</pre></td> |
| 213 |
<td> |
| 214 |
All dialects: |
| 215 |
<pre> |
| 216 |
returnStmt(hasReturnValue( |
| 217 |
integerLiteral().bind("returnVal") |
| 218 |
)) |
| 219 |
</pre></td> |
| 220 |
</tr> |
| 221 |
<tr> |
| 222 |
<td>Match result for |
| 223 |
<pre>implicitCastExpr()</pre> |
| 224 |
given: |
| 225 |
<pre> |
| 226 |
struct B { |
| 227 |
B(int); |
| 228 |
}; |
| 229 |
|
| 230 |
B func1() { return 42; } |
| 231 |
</pre> |
| 232 |
|
| 233 |
</td> |
| 234 |
<td> |
| 235 |
Match found.</td> |
| 236 |
<td> |
| 237 |
No match.</td> |
| 238 |
</tr> |
| 239 |
<tr> |
| 240 |
<td>Match result for: |
| 241 |
<pre> |
| 242 |
cxxConstructorDecl( |
| 243 |
isCopyConstructor() |
| 244 |
).bind("prepend_explicit") |
| 245 |
</pre> |
| 246 |
given: |
| 247 |
<pre> |
| 248 |
struct Other {}; |
| 249 |
struct Copyable { |
| 250 |
Other m_o; |
| 251 |
Copyable(); |
| 252 |
}; |
| 253 |
</pre> |
| 254 |
</td> |
| 255 |
<td> |
| 256 |
Match found. Insertion produces incorrect output: |
| 257 |
<pre> |
| 258 |
struct Other {}; |
| 259 |
struct explicit Copyable { |
| 260 |
Other m_o; |
| 261 |
Copyable(); |
| 262 |
}; |
| 263 |
</pre> |
| 264 |
</td> |
| 265 |
<td> |
| 266 |
No match found. Incorrect replacement not possible. |
| 267 |
</td> |
| 268 |
</tr> |
| 269 |
<tr> |
| 270 |
<td>Replacement of <span class="mono">begin()</span> |
| 271 |
with <span class="mono">cbegin()</span>: |
| 272 |
<pre> |
| 273 |
cxxMemberCallExpr( |
| 274 |
on(ConstContainerExpr), |
| 275 |
callee(cxxMethodDecl(hasName("begin"))) |
| 276 |
).bind("replace_with_cbegin") |
| 277 |
</pre> |
| 278 |
given: |
| 279 |
<pre> |
| 280 |
void foo() { |
| 281 |
const Container c; |
| 282 |
c.begin(); |
| 283 |
|
| 284 |
for (auto i : c) { |
| 285 |
} |
| 286 |
} |
| 287 |
</pre> |
| 288 |
</td> |
| 289 |
<td> |
| 290 |
2 matches found. Replacement produces incorrect output: |
| 291 |
<pre> |
| 292 |
void foo() { |
| 293 |
const Container c; |
| 294 |
c.cbegin(); |
| 295 |
|
| 296 |
for (auto i :.cbegin() c) { |
| 297 |
} |
| 298 |
} |
| 299 |
</pre> |
| 300 |
</td> |
| 301 |
<td> |
| 302 |
1 match found. Replacement produces correct output: |
| 303 |
<pre> |
| 304 |
void foo() { |
| 305 |
const Container c; |
| 306 |
c.cbegin(); |
| 307 |
|
| 308 |
for (auto i : c) { |
| 309 |
} |
| 310 |
} |
| 311 |
</pre> |
| 312 |
</td> |
| 313 |
</tr> |
| 314 |
<tr> |
| 315 |
<td>Replacement of <span class="mono">int</span> member |
| 316 |
with <span class="mono">safe_int</span>: |
| 317 |
<pre> |
| 318 |
fieldDecl( |
| 319 |
hasType(asString("int")) |
| 320 |
).bind("use_safe_int") |
| 321 |
</pre> |
| 322 |
given: |
| 323 |
<pre> |
| 324 |
struct S { |
| 325 |
int m_i; |
| 326 |
}; |
| 327 |
|
| 328 |
template <typename T> struct TemplStruct { |
| 329 |
TemplStruct() {} |
| 330 |
~TemplStruct() {} |
| 331 |
|
| 332 |
private: |
| 333 |
T m_t; |
| 334 |
}; |
| 335 |
|
| 336 |
void instantiate() { TemplStruct<int> ti; } |
| 337 |
</pre> |
| 338 |
</td> |
| 339 |
<td> |
| 340 |
2 matches found. Replacement produces incorrect output: |
| 341 |
<pre> |
| 342 |
struct S { |
| 343 |
safe_int m_i; |
| 344 |
}; |
| 345 |
|
| 346 |
template <typename T> struct TemplStruct { |
| 347 |
TemplStruct() {} |
| 348 |
~TemplStruct() {} |
| 349 |
|
| 350 |
private: |
| 351 |
safe_int m_t; |
| 352 |
}; |
| 353 |
|
| 354 |
void instantiate() { TemplStruct<int> ti; } |
| 355 |
</pre> |
| 356 |
</td> |
| 357 |
<td> |
| 358 |
1 match found. Replacement produces correct output: |
| 359 |
<pre> |
| 360 |
struct S { |
| 361 |
safe_int m_i; |
| 362 |
}; |
| 363 |
|
| 364 |
template <typename T> struct TemplStruct { |
| 365 |
TemplStruct() {} |
| 366 |
~TemplStruct() {} |
| 367 |
|
| 368 |
private: |
| 369 |
T m_t; |
| 370 |
}; |
| 371 |
|
| 372 |
void instantiate() { TemplStruct<int> ti; } |
| 373 |
</pre> |
| 374 |
</td> |
| 375 |
</tr> |
| 376 |
<tr> |
| 377 |
<td>Add prefix to member initializer |
| 378 |
<pre> |
| 379 |
cxxCtorInitializer( |
| 380 |
forField(fieldDecl()) |
| 381 |
).bind("add_prefix") |
| 382 |
</pre> |
| 383 |
given: |
| 384 |
<pre> |
| 385 |
struct Simple {}; |
| 386 |
|
| 387 |
struct Record { |
| 388 |
Record() : i(42) {} |
| 389 |
private: |
| 390 |
int i; |
| 391 |
Simple s; |
| 392 |
}; |
| 393 |
</pre> |
| 394 |
</td> |
| 395 |
<td> |
| 396 |
2 matches found. Replacement produces incorrect output: |
| 397 |
<pre> |
| 398 |
struct Simple {}; |
| 399 |
|
| 400 |
struct Record { |
| 401 |
m_Record() : m_i(42) {} |
| 402 |
private: |
| 403 |
int i; |
| 404 |
Simple s; |
| 405 |
}; |
| 406 |
</pre> |
| 407 |
</td> |
| 408 |
<td> |
| 409 |
1 match found. Replacement produces correct output: |
| 410 |
<pre> |
| 411 |
struct Simple {}; |
| 412 |
|
| 413 |
struct Record { |
| 414 |
Record() : m_i(42) {} |
| 415 |
private: |
| 416 |
int i; |
| 417 |
Simple s; |
| 418 |
}; |
| 419 |
</pre> |
| 420 |
</td> |
| 421 |
</tr> |
| 422 |
<tr> |
| 423 |
<td>Ignored default arguments |
| 424 |
<pre> |
| 425 |
callExpr( |
| 426 |
callee(functionDecl( |
| 427 |
hasName("hasDefaultArg") |
| 428 |
)), |
| 429 |
argumentCountIs(1) |
| 430 |
).bind("add_prefix") |
| 431 |
</pre> |
| 432 |
given: |
| 433 |
<pre> |
| 434 |
void hasDefaultArg(int i, int j = 0) {} |
| 435 |
void callDefaultArg() { hasDefaultArg(42); } |
| 436 |
</pre> |
| 437 |
</td> |
| 438 |
<td> |
| 439 |
No match. |
| 440 |
</td> |
| 441 |
<td> |
| 442 |
1 match found. |
| 443 |
</td> |
| 444 |
</tr> |
| 445 |
<tr> |
| 446 |
<td>Lambda fields |
| 447 |
<pre> |
| 448 |
fieldDecl( |
| 449 |
hasType(asString("int")) |
| 450 |
).bind("make_safe") |
| 451 |
</pre> |
| 452 |
given: |
| 453 |
<pre> |
| 454 |
struct S { |
| 455 |
int m_i; |
| 456 |
}; |
| 457 |
|
| 458 |
void func() { |
| 459 |
int a = 0; |
| 460 |
int c = 0; |
| 461 |
|
| 462 |
auto l = [a, b = c](int d) { int e = d; }; |
| 463 |
l(43); |
| 464 |
} |
| 465 |
</pre> |
| 466 |
</td> |
| 467 |
<td> |
| 468 |
2 matches found. Replacement produces incorrect output: |
| 469 |
<pre> |
| 470 |
struct S { |
| 471 |
safe_int m_i; |
| 472 |
}; |
| 473 |
|
| 474 |
void func() { |
| 475 |
int a = 0; |
| 476 |
int c = 0; |
| 477 |
|
| 478 |
auto l = [safe_a, safe_b = c](int d) { int e = d; }; |
| 479 |
l(43); |
| 480 |
} |
| 481 |
</pre> |
| 482 |
</td> |
| 483 |
<td> |
| 484 |
1 match found. Replacement produces correct output: |
| 485 |
<pre> |
| 486 |
struct S { |
| 487 |
safe_int m_i; |
| 488 |
}; |
| 489 |
|
| 490 |
void func() { |
| 491 |
int a = 0; |
| 492 |
int c = 0; |
| 493 |
|
| 494 |
auto l = [a, b = c](int d) { int e = d; }; |
| 495 |
l(43); |
| 496 |
} |
| 497 |
</pre> |
| 498 |
</td> |
| 499 |
|
| 500 |
</tr> |
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
<tr> |
| 507 |
<td>Rewritten binary operators |
| 508 |
<pre> |
| 509 |
binaryOperator( |
| 510 |
hasOperatorName("<"), |
| 511 |
hasRHS(hasDescendant(integerLiteral(equals(0)))) |
| 512 |
) |
| 513 |
</pre> |
| 514 |
given: |
| 515 |
<pre> |
| 516 |
#include <compare> |
| 517 |
|
| 518 |
class HasSpaceship { |
| 519 |
public: |
| 520 |
int x; |
| 521 |
bool operator==(const HasSpaceship&) const = default; |
| 522 |
std::strong_ordering operator<=>(const HasSpaceship&) const = default; |
| 523 |
}; |
| 524 |
|
| 525 |
bool isLess(const HasSpaceship& a, const HasSpaceship& b) { |
| 526 |
return a < b; |
| 527 |
} |
| 528 |
</pre> |
| 529 |
</td> |
| 530 |
<td> |
| 531 |
1 match found. |
| 532 |
|
| 533 |
<pre> |
| 534 |
return a < b; |
| 535 |
^~~~~ |
| 536 |
</pre> |
| 537 |
|
| 538 |
</td> |
| 539 |
<td> |
| 540 |
No match found. |
| 541 |
</td> |
| 542 |
</tr> |
| 543 |
</table> |
| 544 |
|
| 545 |
<!-- ======================================================================= --> |
| 546 |
<h2 id="decl-matchers">Node Matchers</h2> |
| 547 |
<!-- ======================================================================= --> |
| 548 |
|
| 549 |
<p>Node matchers are at the core of matcher expressions - they specify the type |
| 550 |
of node that is expected. Every match expression starts with a node matcher, |
| 551 |
which can then be further refined with a narrowing or traversal matcher. All |
| 552 |
traversal matchers take node matchers as their arguments.</p> |
| 553 |
|
| 554 |
<p>For convenience, all node matchers take an arbitrary number of arguments |
| 555 |
and implicitly act as allOf matchers.</p> |
| 556 |
|
| 557 |
<p>Node matchers are the only matchers that support the bind("id") call to |
| 558 |
bind the matched node to the given string, to be later retrieved from the |
| 559 |
match callback.</p> |
| 560 |
|
| 561 |
<p>It is important to remember that the arguments to node matchers are |
| 562 |
predicates on the same node, just with additional information about the type. |
| 563 |
This is often useful to make matcher expression more readable by inlining bind |
| 564 |
calls into redundant node matchers inside another node matcher: |
| 565 |
<pre> |
| 566 |
// This binds the CXXRecordDecl to "id", as the decl() matcher will stay on |
| 567 |
// the same node. |
| 568 |
recordDecl(decl().bind("id"), hasName("::MyClass")) |
| 569 |
</pre> |
| 570 |
</p> |
| 571 |
|
| 572 |
<table> |
| 573 |
<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| 574 |
<!-- START_DECL_MATCHERS --> |
| 575 |
|
| 576 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>></td><td class="name" onclick="toggle('attr0')"><a name="attr0Anchor">attr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>>...</td></tr> |
| 577 |
<tr><td colspan="4" class="doc" id="attr0"><pre>Matches attributes. |
| 578 |
Attributes may be attached with a variety of different syntaxes (including |
| 579 |
keywords, C++11 attributes, GNU ``__attribute``` and MSVC `__declspec``, |
| 580 |
and ``#pragma``s). They may also be implicit. |
| 581 |
|
| 582 |
Given |
| 583 |
struct [[nodiscard]] Foo{}; |
| 584 |
void bar(int * __attribute__((nonnull)) ); |
| 585 |
__declspec(noinline) void baz(); |
| 586 |
|
| 587 |
#pragma omp declare simd |
| 588 |
int min(); |
| 589 |
attr() |
| 590 |
matches "nodiscard", "nonnull", "noinline", and the whole "#pragma" line. |
| 591 |
</pre></td></tr> |
| 592 |
|
| 593 |
|
| 594 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>></td><td class="name" onclick="toggle('cxxBaseSpecifier0')"><a name="cxxBaseSpecifier0Anchor">cxxBaseSpecifier</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>...</td></tr> |
| 595 |
<tr><td colspan="4" class="doc" id="cxxBaseSpecifier0"><pre>Matches class bases. |
| 596 |
|
| 597 |
Examples matches public virtual B. |
| 598 |
class B {}; |
| 599 |
class C : public virtual B {}; |
| 600 |
</pre></td></tr> |
| 601 |
|
| 602 |
|
| 603 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('cxxCtorInitializer0')"><a name="cxxCtorInitializer0Anchor">cxxCtorInitializer</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>...</td></tr> |
| 604 |
<tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers. |
| 605 |
|
| 606 |
Examples matches i(42). |
| 607 |
class C { |
| 608 |
C() : i(42) {} |
| 609 |
int i; |
| 610 |
}; |
| 611 |
</pre></td></tr> |
| 612 |
|
| 613 |
|
| 614 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('accessSpecDecl0')"><a name="accessSpecDecl0Anchor">accessSpecDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AccessSpecDecl.html">AccessSpecDecl</a>>...</td></tr> |
| 615 |
<tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations. |
| 616 |
|
| 617 |
Given |
| 618 |
class C { |
| 619 |
public: |
| 620 |
int a; |
| 621 |
}; |
| 622 |
accessSpecDecl() |
| 623 |
matches 'public:' |
| 624 |
</pre></td></tr> |
| 625 |
|
| 626 |
|
| 627 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('bindingDecl0')"><a name="bindingDecl0Anchor">bindingDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html">BindingDecl</a>>...</td></tr> |
| 628 |
<tr><td colspan="4" class="doc" id="bindingDecl0"><pre>Matches binding declarations |
| 629 |
Example matches foo and bar |
| 630 |
(matcher = bindingDecl() |
| 631 |
|
| 632 |
auto [foo, bar] = std::make_pair{42, 42}; |
| 633 |
</pre></td></tr> |
| 634 |
|
| 635 |
|
| 636 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('blockDecl0')"><a name="blockDecl0Anchor">blockDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>...</td></tr> |
| 637 |
<tr><td colspan="4" class="doc" id="blockDecl0"><pre>Matches block declarations. |
| 638 |
|
| 639 |
Example matches the declaration of the nameless block printing an input |
| 640 |
integer. |
| 641 |
|
| 642 |
myFunc(^(int p) { |
| 643 |
printf("%d", p); |
| 644 |
}) |
| 645 |
</pre></td></tr> |
| 646 |
|
| 647 |
|
| 648 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('classTemplateDecl0')"><a name="classTemplateDecl0Anchor">classTemplateDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>>...</td></tr> |
| 649 |
<tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations. |
| 650 |
|
| 651 |
Example matches Z |
| 652 |
template<class T> class Z {}; |
| 653 |
</pre></td></tr> |
| 654 |
|
| 655 |
|
| 656 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('classTemplatePartialSpecializationDecl0')"><a name="classTemplatePartialSpecializationDecl0Anchor">classTemplatePartialSpecializationDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplatePartialSpecializationDecl.html">ClassTemplatePartialSpecializationDecl</a>>...</td></tr> |
| 657 |
<tr><td colspan="4" class="doc" id="classTemplatePartialSpecializationDecl0"><pre>Matches C++ class template partial specializations. |
| 658 |
|
| 659 |
Given |
| 660 |
template<class T1, class T2, int I> |
| 661 |
class A {}; |
| 662 |
|
| 663 |
template<class T, int I> |
| 664 |
class A<T, T*, I> {}; |
| 665 |
|
| 666 |
template<> |
| 667 |
class A<int, int, 1> {}; |
| 668 |
classTemplatePartialSpecializationDecl() |
| 669 |
matches the specialization A<T,T*,I> but not A<int,int,1> |
| 670 |
</pre></td></tr> |
| 671 |
|
| 672 |
|
| 673 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('classTemplateSpecializationDecl0')"><a name="classTemplateSpecializationDecl0Anchor">classTemplateSpecializationDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>...</td></tr> |
| 674 |
<tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations. |
| 675 |
|
| 676 |
Given |
| 677 |
template<typename T> class A {}; |
| 678 |
template<> class A<double> {}; |
| 679 |
A<int> a; |
| 680 |
classTemplateSpecializationDecl() |
| 681 |
matches the specializations A<int> and A<double> |
| 682 |
</pre></td></tr> |
| 683 |
|
| 684 |
|
| 685 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('conceptDecl0')"><a name="conceptDecl0Anchor">conceptDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ConceptDecl.html">ConceptDecl</a>>...</td></tr> |
| 686 |
<tr><td colspan="4" class="doc" id="conceptDecl0"><pre>Matches concept declarations. |
| 687 |
|
| 688 |
Example matches integral |
| 689 |
template<typename T> |
| 690 |
concept integral = std::is_integral_v<T>; |
| 691 |
</pre></td></tr> |
| 692 |
|
| 693 |
|
| 694 |
<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> |
| 695 |
<tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations. |
| 696 |
|
| 697 |
Example matches Foo::Foo() and Foo::Foo(int) |
| 698 |
class Foo { |
| 699 |
public: |
| 700 |
Foo(); |
| 701 |
Foo(int); |
| 702 |
int DoSomething(); |
| 703 |
}; |
| 704 |
</pre></td></tr> |
| 705 |
|
| 706 |
|
| 707 |
<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> |
| 708 |
<tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations. |
| 709 |
|
| 710 |
Example matches the operator. |
| 711 |
class X { operator int() const; }; |
| 712 |
</pre></td></tr> |
| 713 |
|
| 714 |
|
| 715 |
<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> |
| 716 |
<tr><td colspan="4" class="doc" id="cxxDeductionGuideDecl0"><pre>Matches user-defined and implicitly generated deduction guide. |
| 717 |
|
| 718 |
Example matches the deduction guide. |
| 719 |
template<typename T> |
| 720 |
class X { X(int) }; |
| 721 |
X(int) -> X<int>; |
| 722 |
</pre></td></tr> |
| 723 |
|
| 724 |
|
| 725 |
<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> |
| 726 |
<tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations. |
| 727 |
|
| 728 |
Example matches Foo::~Foo() |
| 729 |
class Foo { |
| 730 |
public: |
| 731 |
virtual ~Foo(); |
| 732 |
}; |
| 733 |
</pre></td></tr> |
| 734 |
|
| 735 |
|
| 736 |
<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> |
| 737 |
<tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations. |
| 738 |
|
| 739 |
Example matches y |
| 740 |
class X { void y(); }; |
| 741 |
</pre></td></tr> |
| 742 |
|
| 743 |
|
| 744 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxRecordDecl0')"><a name="cxxRecordDecl0Anchor">cxxRecordDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>...</td></tr> |
| 745 |
<tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations. |
| 746 |
|
| 747 |
Example matches X, Z |
| 748 |
class X; |
| 749 |
template<class T> class Z {}; |
| 750 |
</pre></td></tr> |
| 751 |
|
| 752 |
|
| 753 |
<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> |
| 754 |
<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. |
| 755 |
|
| 756 |
Examples matches X, C, and the friend declaration inside C; |
| 757 |
void X(); |
| 758 |
class C { |
| 759 |
friend X; |
| 760 |
}; |
| 761 |
</pre></td></tr> |
| 762 |
|
| 763 |
|
| 764 |
<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> |
| 765 |
<tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function |
| 766 |
and non-type template parameter declarations). |
| 767 |
|
| 768 |
Given |
| 769 |
class X { int y; }; |
| 770 |
declaratorDecl() |
| 771 |
matches int y. |
| 772 |
</pre></td></tr> |
| 773 |
|
| 774 |
|
| 775 |
<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> |
| 776 |
<tr><td colspan="4" class="doc" id="decompositionDecl0"><pre>Matches decomposition-declarations. |
| 777 |
|
| 778 |
Examples matches the declaration node with foo and bar, but not |
| 779 |
number. |
| 780 |
(matcher = declStmt(has(decompositionDecl()))) |
| 781 |
|
| 782 |
int number = 42; |
| 783 |
auto [foo, bar] = std::make_pair{42, 42}; |
| 784 |
</pre></td></tr> |
| 785 |
|
| 786 |
|
| 787 |
<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> |
| 788 |
<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. |
| 789 |
|
| 790 |
Example matches A, B, C |
| 791 |
enum X { |
| 792 |
A, B, C |
| 793 |
}; |
| 794 |
</pre></td></tr> |
| 795 |
|
| 796 |
|
| 797 |
<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> |
| 798 |
<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. |
| 799 |
|
| 800 |
Example matches X |
| 801 |
enum X { |
| 802 |
A, B, C |
| 803 |
}; |
| 804 |
</pre></td></tr> |
| 805 |
|
| 806 |
|
| 807 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('exportDecl0')"><a name="exportDecl0Anchor">exportDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExportDecl.html">ExportDecl</a>>...</td></tr> |
| 808 |
<tr><td colspan="4" class="doc" id="exportDecl0"><pre>Matches any export declaration. |
| 809 |
|
| 810 |
Example matches following declarations. |
| 811 |
export void foo(); |
| 812 |
export { void foo(); } |
| 813 |
export namespace { void foo(); } |
| 814 |
export int v; |
| 815 |
</pre></td></tr> |
| 816 |
|
| 817 |
|
| 818 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('fieldDecl0')"><a name="fieldDecl0Anchor">fieldDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>>...</td></tr> |
| 819 |
<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. |
| 820 |
|
| 821 |
Given |
| 822 |
class X { int m; }; |
| 823 |
fieldDecl() |
| 824 |
matches 'm'. |
| 825 |
</pre></td></tr> |
| 826 |
|
| 827 |
|
| 828 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('fileScopeAsmDecl0')"><a name="fileScopeAsmDecl0Anchor">fileScopeAsmDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FileScopeAsmDecl.html">FileScopeAsmDecl</a>>...</td></tr> |
| 829 |
<tr><td colspan="4" class="doc" id="fileScopeAsmDecl0"><pre>Matches top level asm declarations. |
| 830 |
|
| 831 |
Given |
| 832 |
__asm("nop"); |
| 833 |
void f() { |
| 834 |
__asm("mov al, 2"); |
| 835 |
} |
| 836 |
fileScopeAsmDecl() |
| 837 |
matches '__asm("nop")', |
| 838 |
but not '__asm("mov al, 2")'. |
| 839 |
</pre></td></tr> |
| 840 |
|
| 841 |
|
| 842 |
<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> |
| 843 |
<tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations. |
| 844 |
|
| 845 |
Given |
| 846 |
class X { friend void foo(); }; |
| 847 |
friendDecl() |
| 848 |
matches 'friend void foo()'. |
| 849 |
</pre></td></tr> |
| 850 |
|
| 851 |
|
| 852 |
<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> |
| 853 |
<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. |
| 854 |
|
| 855 |
Example matches f |
| 856 |
void f(); |
| 857 |
</pre></td></tr> |
| 858 |
|
| 859 |
|
| 860 |
<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> |
| 861 |
<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. |
| 862 |
|
| 863 |
Example matches f |
| 864 |
template<class T> void f(T t) {} |
| 865 |
</pre></td></tr> |
| 866 |
|
| 867 |
|
| 868 |
<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> |
| 869 |
<tr><td colspan="4" class="doc" id="indirectFieldDecl0"><pre>Matches indirect field declarations. |
| 870 |
|
| 871 |
Given |
| 872 |
struct X { struct { int a; }; }; |
| 873 |
indirectFieldDecl() |
| 874 |
matches 'a'. |
| 875 |
</pre></td></tr> |
| 876 |
|
| 877 |
|
| 878 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('labelDecl0')"><a name="labelDecl0Anchor">labelDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelDecl.html">LabelDecl</a>>...</td></tr> |
| 879 |
<tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label. |
| 880 |
|
| 881 |
Given |
| 882 |
goto FOO; |
| 883 |
FOO: bar(); |
| 884 |
labelDecl() |
| 885 |
matches 'FOO:' |
| 886 |
</pre></td></tr> |
| 887 |
|
| 888 |
|
| 889 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('linkageSpecDecl0')"><a name="linkageSpecDecl0Anchor">linkageSpecDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LinkageSpecDecl.html">LinkageSpecDecl</a>>...</td></tr> |
| 890 |
<tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification. |
| 891 |
|
| 892 |
Given |
| 893 |
extern "C" {} |
| 894 |
linkageSpecDecl() |
| 895 |
matches "extern "C" {}" |
| 896 |
</pre></td></tr> |
| 897 |
|
| 898 |
|
| 899 |
<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> |
| 900 |
<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. |
| 901 |
|
| 902 |
Example matches X, S, the anonymous union type, i, and U; |
| 903 |
typedef int X; |
| 904 |
struct S { |
| 905 |
union { |
| 906 |
int i; |
| 907 |
} U; |
| 908 |
}; |
| 909 |
</pre></td></tr> |
| 910 |
|
| 911 |
|
| 912 |
<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> |
| 913 |
<tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias. |
| 914 |
|
| 915 |
Given |
| 916 |
namespace test {} |
| 917 |
namespace alias = ::test; |
| 918 |
namespaceAliasDecl() |
| 919 |
matches "namespace alias" but not "namespace test" |
| 920 |
</pre></td></tr> |
| 921 |
|
| 922 |
|
| 923 |
<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> |
| 924 |
<tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. |
| 925 |
|
| 926 |
Given |
| 927 |
namespace {} |
| 928 |
namespace test {} |
| 929 |
namespaceDecl() |
| 930 |
matches "namespace {}" and "namespace test {}" |
| 931 |
</pre></td></tr> |
| 932 |
|
| 933 |
|
| 934 |
<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> |
| 935 |
<tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations. |
| 936 |
|
| 937 |
Given |
| 938 |
template <typename T, int N> struct C {}; |
| 939 |
nonTypeTemplateParmDecl() |
| 940 |
matches 'N', but not 'T'. |
| 941 |
</pre></td></tr> |
| 942 |
|
| 943 |
|
| 944 |
<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> |
| 945 |
<tr><td colspan="4" class="doc" id="objcCategoryDecl0"><pre>Matches Objective-C category declarations. |
| 946 |
|
| 947 |
Example matches Foo (Additions) |
| 948 |
@interface Foo (Additions) |
| 949 |
@end |
| 950 |
</pre></td></tr> |
| 951 |
|
| 952 |
|
| 953 |
<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> |
| 954 |
<tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions. |
| 955 |
|
| 956 |
Example matches Foo (Additions) |
| 957 |
@implementation Foo (Additions) |
| 958 |
@end |
| 959 |
</pre></td></tr> |
| 960 |
|
| 961 |
|
| 962 |
<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> |
| 963 |
<tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations. |
| 964 |
|
| 965 |
Example matches Foo |
| 966 |
@implementation Foo |
| 967 |
@end |
| 968 |
</pre></td></tr> |
| 969 |
|
| 970 |
|
| 971 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcInterfaceDecl0')"><a name="objcInterfaceDecl0Anchor">objcInterfaceDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>>...</td></tr> |
| 972 |
<tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations. |
| 973 |
|
| 974 |
Example matches Foo |
| 975 |
@interface Foo |
| 976 |
@end |
| 977 |
</pre></td></tr> |
| 978 |
|
| 979 |
|
| 980 |
<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> |
| 981 |
<tr><td colspan="4" class="doc" id="objcIvarDecl0"><pre>Matches Objective-C instance variable declarations. |
| 982 |
|
| 983 |
Example matches _enabled |
| 984 |
@implementation Foo { |
| 985 |
BOOL _enabled; |
| 986 |
} |
| 987 |
@end |
| 988 |
</pre></td></tr> |
| 989 |
|
| 990 |
|
| 991 |
<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> |
| 992 |
<tr><td colspan="4" class="doc" id="objcMethodDecl0"><pre>Matches Objective-C method declarations. |
| 993 |
|
| 994 |
Example matches both declaration and definition of -[Foo method] |
| 995 |
@interface Foo |
| 996 |
- (void)method; |
| 997 |
@end |
| 998 |
|
| 999 |
@implementation Foo |
| 1000 |
- (void)method {} |
| 1001 |
@end |
| 1002 |
</pre></td></tr> |
| 1003 |
|
| 1004 |
|
| 1005 |
<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> |
| 1006 |
<tr><td colspan="4" class="doc" id="objcPropertyDecl0"><pre>Matches Objective-C property declarations. |
| 1007 |
|
| 1008 |
Example matches enabled |
| 1009 |
@interface Foo |
| 1010 |
@property BOOL enabled; |
| 1011 |
@end |
| 1012 |
</pre></td></tr> |
| 1013 |
|
| 1014 |
|
| 1015 |
<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> |
| 1016 |
<tr><td colspan="4" class="doc" id="objcProtocolDecl0"><pre>Matches Objective-C protocol declarations. |
| 1017 |
|
| 1018 |
Example matches FooDelegate |
| 1019 |
@protocol FooDelegate |
| 1020 |
@end |
| 1021 |
</pre></td></tr> |
| 1022 |
|
| 1023 |
|
| 1024 |
<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> |
| 1025 |
<tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. |
| 1026 |
|
| 1027 |
Given |
| 1028 |
void f(int x); |
| 1029 |
parmVarDecl() |
| 1030 |
matches int x. |
| 1031 |
</pre></td></tr> |
| 1032 |
|
| 1033 |
|
| 1034 |
<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> |
| 1035 |
<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations. |
| 1036 |
|
| 1037 |
Example matches X, Z, U, and S |
| 1038 |
class X; |
| 1039 |
template<class T> class Z {}; |
| 1040 |
struct S {}; |
| 1041 |
union U {}; |
| 1042 |
</pre></td></tr> |
| 1043 |
|
| 1044 |
|
| 1045 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('requiresExprBodyDecl0')"><a name="requiresExprBodyDecl0Anchor">requiresExprBodyDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RequiresExprBodyDecl.html">RequiresExprBodyDecl</a>>...</td></tr> |
| 1046 |
<tr><td colspan="4" class="doc" id="requiresExprBodyDecl0"><pre>Matches concept requirement body declaration. |
| 1047 |
|
| 1048 |
Example matches '{ *p; }' |
| 1049 |
template<typename T> |
| 1050 |
concept dereferencable = requires(T p) { *p; } |
| 1051 |
</pre></td></tr> |
| 1052 |
|
| 1053 |
|
| 1054 |
<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> |
| 1055 |
<tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration. |
| 1056 |
|
| 1057 |
Example: |
| 1058 |
staticAssertDecl() |
| 1059 |
matches |
| 1060 |
static_assert(sizeof(S) == sizeof(int)) |
| 1061 |
in |
| 1062 |
struct S { |
| 1063 |
int x; |
| 1064 |
}; |
| 1065 |
static_assert(sizeof(S) == sizeof(int)); |
| 1066 |
</pre></td></tr> |
| 1067 |
|
| 1068 |
|
| 1069 |
<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> |
| 1070 |
<tr><td colspan="4" class="doc" id="tagDecl0"><pre>Matches tag declarations. |
| 1071 |
|
| 1072 |
Example matches X, Z, U, S, E |
| 1073 |
class X; |
| 1074 |
template<class T> class Z {}; |
| 1075 |
struct S {}; |
| 1076 |
union U {}; |
| 1077 |
enum E { |
| 1078 |
A, B, C |
| 1079 |
}; |
| 1080 |
</pre></td></tr> |
| 1081 |
|
| 1082 |
|
| 1083 |
<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> |
| 1084 |
<tr><td colspan="4" class="doc" id="templateTemplateParmDecl0"><pre>Matches template template parameter declarations. |
| 1085 |
|
| 1086 |
Given |
| 1087 |
template <template <typename> class Z, int N> struct C {}; |
| 1088 |
templateTypeParmDecl() |
| 1089 |
matches 'Z', but not 'N'. |
| 1090 |
</pre></td></tr> |
| 1091 |
|
| 1092 |
|
| 1093 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('templateTypeParmDecl0')"><a name="templateTypeParmDecl0Anchor">templateTypeParmDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmDecl.html">TemplateTypeParmDecl</a>>...</td></tr> |
| 1094 |
<tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations. |
| 1095 |
|
| 1096 |
Given |
| 1097 |
template <typename T, int N> struct C {}; |
| 1098 |
templateTypeParmDecl() |
| 1099 |
matches 'T', but not 'N'. |
| 1100 |
</pre></td></tr> |
| 1101 |
|
| 1102 |
|
| 1103 |
<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> |
| 1104 |
<tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context. |
| 1105 |
|
| 1106 |
Given |
| 1107 |
int X; |
| 1108 |
namespace NS { |
| 1109 |
int Y; |
| 1110 |
} // namespace NS |
| 1111 |
decl(hasDeclContext(translationUnitDecl())) |
| 1112 |
matches "int X", but not "int Y". |
| 1113 |
</pre></td></tr> |
| 1114 |
|
| 1115 |
|
| 1116 |
<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> |
| 1117 |
<tr><td colspan="4" class="doc" id="typeAliasDecl0"><pre>Matches type alias declarations. |
| 1118 |
|
| 1119 |
Given |
| 1120 |
typedef int X; |
| 1121 |
using Y = int; |
| 1122 |
typeAliasDecl() |
| 1123 |
matches "using Y = int", but not "typedef int X" |
| 1124 |
</pre></td></tr> |
| 1125 |
|
| 1126 |
|
| 1127 |
<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> |
| 1128 |
<tr><td colspan="4" class="doc" id="typeAliasTemplateDecl0"><pre>Matches type alias template declarations. |
| 1129 |
|
| 1130 |
typeAliasTemplateDecl() matches |
| 1131 |
template <typename T> |
| 1132 |
using Y = X<T>; |
| 1133 |
</pre></td></tr> |
| 1134 |
|
| 1135 |
|
| 1136 |
<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> |
| 1137 |
<tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations. |
| 1138 |
|
| 1139 |
Given |
| 1140 |
typedef int X; |
| 1141 |
using Y = int; |
| 1142 |
typedefDecl() |
| 1143 |
matches "typedef int X", but not "using Y = int" |
| 1144 |
</pre></td></tr> |
| 1145 |
|
| 1146 |
|
| 1147 |
<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> |
| 1148 |
<tr><td colspan="4" class="doc" id="typedefNameDecl0"><pre>Matches typedef name declarations. |
| 1149 |
|
| 1150 |
Given |
| 1151 |
typedef int X; |
| 1152 |
using Y = int; |
| 1153 |
typedefNameDecl() |
| 1154 |
matches "typedef int X" and "using Y = int" |
| 1155 |
</pre></td></tr> |
| 1156 |
|
| 1157 |
|
| 1158 |
<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> |
| 1159 |
<tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the |
| 1160 |
typename. |
| 1161 |
|
| 1162 |
Given |
| 1163 |
template <typename T> |
| 1164 |
struct Base { typedef T Foo; }; |
| 1165 |
|
| 1166 |
template<typename T> |
| 1167 |
struct S : private Base<T> { |
| 1168 |
using typename Base<T>::Foo; |
| 1169 |
}; |
| 1170 |
unresolvedUsingTypenameDecl() |
| 1171 |
matches using Base<T>::Foo </pre></td></tr> |
| 1172 |
|
| 1173 |
|
| 1174 |
<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> |
| 1175 |
<tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations. |
| 1176 |
|
| 1177 |
Given |
| 1178 |
template<typename X> |
| 1179 |
class C : private X { |
| 1180 |
using X::x; |
| 1181 |
}; |
| 1182 |
unresolvedUsingValueDecl() |
| 1183 |
matches using X::x </pre></td></tr> |
| 1184 |
|
| 1185 |
|
| 1186 |
<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> |
| 1187 |
<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. |
| 1188 |
|
| 1189 |
Given |
| 1190 |
namespace X { int x; } |
| 1191 |
using X::x; |
| 1192 |
usingDecl() |
| 1193 |
matches using X::x </pre></td></tr> |
| 1194 |
|
| 1195 |
|
| 1196 |
<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> |
| 1197 |
<tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations. |
| 1198 |
|
| 1199 |
Given |
| 1200 |
namespace X { int x; } |
| 1201 |
using namespace X; |
| 1202 |
usingDirectiveDecl() |
| 1203 |
matches using namespace X </pre></td></tr> |
| 1204 |
|
| 1205 |
|
| 1206 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('usingEnumDecl0')"><a name="usingEnumDecl0Anchor">usingEnumDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingEnumDecl.html">UsingEnumDecl</a>>...</td></tr> |
| 1207 |
<tr><td colspan="4" class="doc" id="usingEnumDecl0"><pre>Matches using-enum declarations. |
| 1208 |
|
| 1209 |
Given |
| 1210 |
namespace X { enum x {...}; } |
| 1211 |
using enum X::x; |
| 1212 |
usingEnumDecl() |
| 1213 |
matches using enum X::x </pre></td></tr> |
| 1214 |
|
| 1215 |
|
| 1216 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('usingShadowDecl0')"><a name="usingShadowDecl0Anchor">usingShadowDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>>...</td></tr> |
| 1217 |
<tr><td colspan="4" class="doc" id="usingShadowDecl0"><pre>Matches shadow declarations introduced into a scope by a |
| 1218 |
(resolved) using declaration. |
| 1219 |
|
| 1220 |
Given |
| 1221 |
namespace n { int f; } |
| 1222 |
namespace declToImport { using n::f; } |
| 1223 |
usingShadowDecl() |
| 1224 |
matches f </pre></td></tr> |
| 1225 |
|
| 1226 |
|
| 1227 |
<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> |
| 1228 |
<tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration. |
| 1229 |
|
| 1230 |
Example matches A, B, C and F |
| 1231 |
enum X { A, B, C }; |
| 1232 |
void F(); |
| 1233 |
</pre></td></tr> |
| 1234 |
|
| 1235 |
|
| 1236 |
<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> |
| 1237 |
<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. |
| 1238 |
|
| 1239 |
Note: this does not match declarations of member variables, which are |
| 1240 |
"field" declarations in Clang parlance. |
| 1241 |
|
| 1242 |
Example matches a |
| 1243 |
int a; |
| 1244 |
</pre></td></tr> |
| 1245 |
|
| 1246 |
|
| 1247 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('requiresExpr0')"><a name="requiresExpr0Anchor">requiresExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RequiresExpr.html">RequiresExpr</a>>...</td></tr> |
| 1248 |
<tr><td colspan="4" class="doc" id="requiresExpr0"><pre>Matches concept requirement. |
| 1249 |
|
| 1250 |
Example matches 'requires(T p) { *p; }' |
| 1251 |
template<typename T> |
| 1252 |
concept dereferencable = requires(T p) { *p; } |
| 1253 |
</pre></td></tr> |
| 1254 |
|
| 1255 |
|
| 1256 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>></td><td class="name" onclick="toggle('lambdaCapture0')"><a name="lambdaCapture0Anchor">lambdaCapture</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>>...</td></tr> |
| 1257 |
<tr><td colspan="4" class="doc" id="lambdaCapture0"><pre>Matches lambda captures. |
| 1258 |
|
| 1259 |
Given |
| 1260 |
int main() { |
| 1261 |
int x; |
| 1262 |
auto f = [x](){}; |
| 1263 |
auto g = [x = 1](){}; |
| 1264 |
} |
| 1265 |
In the matcher `lambdaExpr(hasAnyCapture(lambdaCapture()))`, |
| 1266 |
`lambdaCapture()` matches `x` and `x=1`. |
| 1267 |
</pre></td></tr> |
| 1268 |
|
| 1269 |
|
| 1270 |
<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> |
| 1271 |
<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. |
| 1272 |
</pre></td></tr> |
| 1273 |
|
| 1274 |
|
| 1275 |
<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> |
| 1276 |
<tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. |
| 1277 |
|
| 1278 |
Given |
| 1279 |
namespace ns { |
| 1280 |
struct A { static void f(); }; |
| 1281 |
void A::f() {} |
| 1282 |
void g() { A::f(); } |
| 1283 |
} |
| 1284 |
ns::A a; |
| 1285 |
nestedNameSpecifier() |
| 1286 |
matches "ns::" and both "A::" |
| 1287 |
</pre></td></tr> |
| 1288 |
|
| 1289 |
|
| 1290 |
<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> |
| 1291 |
<tr><td colspan="4" class="doc" id="ompDefaultClause0"><pre>Matches OpenMP ``default`` clause. |
| 1292 |
|
| 1293 |
Given |
| 1294 |
|
| 1295 |
#pragma omp parallel default(none) |
| 1296 |
#pragma omp parallel default(shared) |
| 1297 |
#pragma omp parallel default(private) |
| 1298 |
#pragma omp parallel default(firstprivate) |
| 1299 |
#pragma omp parallel |
| 1300 |
|
| 1301 |
``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, |
| 1302 |
`` default(private)`` and ``default(firstprivate)`` |
| 1303 |
</pre></td></tr> |
| 1304 |
|
| 1305 |
|
| 1306 |
<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> |
| 1307 |
<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. |
| 1308 |
</pre></td></tr> |
| 1309 |
|
| 1310 |
|
| 1311 |
<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> |
| 1312 |
<tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension). |
| 1313 |
|
| 1314 |
Given |
| 1315 |
FOO: bar(); |
| 1316 |
void *ptr = &&FOO; |
| 1317 |
goto *bar; |
| 1318 |
addrLabelExpr() |
| 1319 |
matches '&&FOO' |
| 1320 |
</pre></td></tr> |
| 1321 |
|
| 1322 |
|
| 1323 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('arrayInitIndexExpr0')"><a name="arrayInitIndexExpr0Anchor">arrayInitIndexExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayInitIndexExpr.html">ArrayInitIndexExpr</a>>...</td></tr> |
| 1324 |
<tr><td colspan="4" class="doc" id="arrayInitIndexExpr0"><pre>The arrayInitIndexExpr consists of two subexpressions: a common expression |
| 1325 |
(the source array) that is evaluated once up-front, and a per-element initializer |
| 1326 |
that runs once for each array element. Within the per-element initializer, |
| 1327 |
the current index may be obtained via an ArrayInitIndexExpr. |
| 1328 |
|
| 1329 |
Given |
| 1330 |
void testStructBinding() { |
| 1331 |
int a[2] = {1, 2}; |
| 1332 |
auto [x, y] = a; |
| 1333 |
} |
| 1334 |
arrayInitIndexExpr() matches the array index that implicitly iterates |
| 1335 |
over the array `a` to copy each element to the anonymous array |
| 1336 |
that backs the structured binding `[x, y]` elements of which are |
| 1337 |
referred to by their aliases `x` and `y`. |
| 1338 |
</pre></td></tr> |
| 1339 |
|
| 1340 |
|
| 1341 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('arrayInitLoopExpr0')"><a name="arrayInitLoopExpr0Anchor">arrayInitLoopExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayInitLoopExpr.html">ArrayInitLoopExpr</a>>...</td></tr> |
| 1342 |
<tr><td colspan="4" class="doc" id="arrayInitLoopExpr0"><pre>Matches a loop initializing the elements of an array in a number of contexts: |
| 1343 |
* in the implicit copy/move constructor for a class with an array member |
| 1344 |
* when a lambda-expression captures an array by value |
| 1345 |
* when a decomposition declaration decomposes an array |
| 1346 |
|
| 1347 |
Given |
| 1348 |
void testLambdaCapture() { |
| 1349 |
int a[10]; |
| 1350 |
auto Lam1 = [a]() { |
| 1351 |
return; |
| 1352 |
}; |
| 1353 |
} |
| 1354 |
arrayInitLoopExpr() matches the implicit loop that initializes each element of |
| 1355 |
the implicit array field inside the lambda object, that represents the array `a` |
| 1356 |
captured by value. |
| 1357 |
</pre></td></tr> |
| 1358 |
|
| 1359 |
|
| 1360 |
<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> |
| 1361 |
<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. |
| 1362 |
|
| 1363 |
Given |
| 1364 |
int i = a[1]; |
| 1365 |
arraySubscriptExpr() |
| 1366 |
matches "a[1]" |
| 1367 |
</pre></td></tr> |
| 1368 |
|
| 1369 |
|
| 1370 |
<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> |
| 1371 |
<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. |
| 1372 |
|
| 1373 |
int i = 100; |
| 1374 |
__asm("mov al, 2"); |
| 1375 |
asmStmt() |
| 1376 |
matches '__asm("mov al, 2")' |
| 1377 |
</pre></td></tr> |
| 1378 |
|
| 1379 |
|
| 1380 |
<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> |
| 1381 |
<tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins. |
| 1382 |
Example matches __atomic_load_n(ptr, 1) |
| 1383 |
void foo() { int *ptr; __atomic_load_n(ptr, 1); } |
| 1384 |
</pre></td></tr> |
| 1385 |
|
| 1386 |
|
| 1387 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('autoreleasePoolStmt0')"><a name="autoreleasePoolStmt0Anchor">autoreleasePoolStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCAutoreleasePoolStmt.html">ObjCAutoreleasePoolStmt</a>>...</td></tr> |
| 1388 |
<tr><td colspan="4" class="doc" id="autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement. |
| 1389 |
|
| 1390 |
Given |
| 1391 |
@autoreleasepool { |
| 1392 |
int x = 0; |
| 1393 |
} |
| 1394 |
autoreleasePoolStmt(stmt()) matches the declaration of "x" |
| 1395 |
inside the autorelease pool. |
| 1396 |
</pre></td></tr> |
| 1397 |
|
| 1398 |
|
| 1399 |
<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> |
| 1400 |
<tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension). |
| 1401 |
|
| 1402 |
Example matches a ?: b |
| 1403 |
(a ?: b) + 42; |
| 1404 |
</pre></td></tr> |
| 1405 |
|
| 1406 |
|
| 1407 |
<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> |
| 1408 |
<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. |
| 1409 |
|
| 1410 |
Example matches a || b |
| 1411 |
!(a || b) |
| 1412 |
See also the binaryOperation() matcher for more-general matching. |
| 1413 |
</pre></td></tr> |
| 1414 |
|
| 1415 |
|
| 1416 |
<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> |
| 1417 |
<tr><td colspan="4" class="doc" id="blockExpr0"><pre>Matches a reference to a block. |
| 1418 |
|
| 1419 |
Example: matches "^{}": |
| 1420 |
void f() { ^{}(); } |
| 1421 |
</pre></td></tr> |
| 1422 |
|
| 1423 |
|
| 1424 |
<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> |
| 1425 |
<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. |
| 1426 |
|
| 1427 |
Given |
| 1428 |
while (true) { break; } |
| 1429 |
breakStmt() |
| 1430 |
matches 'break' |
| 1431 |
</pre></td></tr> |
| 1432 |
|
| 1433 |
|
| 1434 |
<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> |
| 1435 |
<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. |
| 1436 |
|
| 1437 |
Example: Matches (int) 2.2f in |
| 1438 |
int i = (int) 2.2f; |
| 1439 |
</pre></td></tr> |
| 1440 |
|
| 1441 |
|
| 1442 |
<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> |
| 1443 |
<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. |
| 1444 |
|
| 1445 |
Example matches x.y() and y() |
| 1446 |
X x; |
| 1447 |
x.y(); |
| 1448 |
y(); |
| 1449 |
</pre></td></tr> |
| 1450 |
|
| 1451 |
|
| 1452 |
<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> |
| 1453 |
<tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. |
| 1454 |
|
| 1455 |
Given |
| 1456 |
switch(a) { case 42: break; default: break; } |
| 1457 |
caseStmt() |
| 1458 |
matches 'case 42:'. |
| 1459 |
</pre></td></tr> |
| 1460 |
|
| 1461 |
|
| 1462 |
<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> |
| 1463 |
<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. |
| 1464 |
|
| 1465 |
Example: castExpr() matches each of the following: |
| 1466 |
(int) 3; |
| 1467 |
const_cast<Expr *>(SubExpr); |
| 1468 |
char c = 0; |
| 1469 |
but does not match |
| 1470 |
int i = (0); |
| 1471 |
int k = 0; |
| 1472 |
</pre></td></tr> |
| 1473 |
|
| 1474 |
|
| 1475 |
<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> |
| 1476 |
<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). |
| 1477 |
|
| 1478 |
Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), |
| 1479 |
though. |
| 1480 |
|
| 1481 |
Example matches 'a', L'a' |
| 1482 |
char ch = 'a'; |
| 1483 |
wchar_t chw = L'a'; |
| 1484 |
</pre></td></tr> |
| 1485 |
|
| 1486 |
|
| 1487 |
<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> |
| 1488 |
<tr><td colspan="4" class="doc" id="chooseExpr0"><pre>Matches GNU __builtin_choose_expr. |
| 1489 |
</pre></td></tr> |
| 1490 |
|
| 1491 |
|
| 1492 |
<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> |
| 1493 |
<tr><td colspan="4" class="doc" id="coawaitExpr0"><pre>Matches co_await expressions. |
| 1494 |
|
| 1495 |
Given |
| 1496 |
co_await 1; |
| 1497 |
coawaitExpr() |
| 1498 |
matches 'co_await 1' |
| 1499 |
</pre></td></tr> |
| 1500 |
|
| 1501 |
|
| 1502 |
<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> |
| 1503 |
<tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals |
| 1504 |
|
| 1505 |
Example match: {1}, (1, 2) |
| 1506 |
int array[4] = {1}; |
| 1507 |
vector int myvec = (vector int)(1, 2); |
| 1508 |
</pre></td></tr> |
| 1509 |
|
| 1510 |
|
| 1511 |
<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> |
| 1512 |
<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. |
| 1513 |
|
| 1514 |
Example matches '{}' and '{{}}' in 'for (;;) {{}}' |
| 1515 |
for (;;) {{}} |
| 1516 |
</pre></td></tr> |
| 1517 |
|
| 1518 |
|
| 1519 |
<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> |
| 1520 |
<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. |
| 1521 |
|
| 1522 |
Example matches a ? b : c |
| 1523 |
(a ? b : c) + 42 |
| 1524 |
</pre></td></tr> |
| 1525 |
|
| 1526 |
|
| 1527 |
<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> |
| 1528 |
<tr><td colspan="4" class="doc" id="constantExpr0"><pre>Matches a constant expression wrapper. |
| 1529 |
|
| 1530 |
Example matches the constant in the case statement: |
| 1531 |
(matcher = constantExpr()) |
| 1532 |
switch (a) { |
| 1533 |
case 37: break; |
| 1534 |
} |
| 1535 |
</pre></td></tr> |
| 1536 |
|
| 1537 |
|
| 1538 |
<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> |
| 1539 |
<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. |
| 1540 |
|
| 1541 |
Given |
| 1542 |
while (true) { continue; } |
| 1543 |
continueStmt() |
| 1544 |
matches 'continue' |
| 1545 |
</pre></td></tr> |
| 1546 |
|
| 1547 |
|
| 1548 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('convertVectorExpr0')"><a name="convertVectorExpr0Anchor">convertVectorExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ConvertVectorExpr.html">ConvertVectorExpr</a>>...</td></tr> |
| 1549 |
<tr><td colspan="4" class="doc" id="convertVectorExpr0"><pre>Matches builtin function __builtin_convertvector. |
| 1550 |
</pre></td></tr> |
| 1551 |
|
| 1552 |
|
| 1553 |
<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> |
| 1554 |
<tr><td colspan="4" class="doc" id="coreturnStmt0"><pre>Matches co_return statements. |
| 1555 |
|
| 1556 |
Given |
| 1557 |
while (true) { co_return; } |
| 1558 |
coreturnStmt() |
| 1559 |
matches 'co_return' |
| 1560 |
</pre></td></tr> |
| 1561 |
|
| 1562 |
|
| 1563 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('coroutineBodyStmt0')"><a name="coroutineBodyStmt0Anchor">coroutineBodyStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CoroutineBodyStmt.html">CoroutineBodyStmt</a>>...</td></tr> |
| 1564 |
<tr><td colspan="4" class="doc" id="coroutineBodyStmt0"><pre>Matches coroutine body statements. |
| 1565 |
|
| 1566 |
coroutineBodyStmt() matches the coroutine below |
| 1567 |
generator<int> gen() { |
| 1568 |
co_return; |
| 1569 |
} |
| 1570 |
</pre></td></tr> |
| 1571 |
|
| 1572 |
|
| 1573 |
<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> |
| 1574 |
<tr><td colspan="4" class="doc" id="coyieldExpr0"><pre>Matches co_yield expressions. |
| 1575 |
|
| 1576 |
Given |
| 1577 |
co_yield 1; |
| 1578 |
coyieldExpr() |
| 1579 |
matches 'co_yield 1' |
| 1580 |
</pre></td></tr> |
| 1581 |
|
| 1582 |
|
| 1583 |
<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> |
| 1584 |
<tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression. |
| 1585 |
|
| 1586 |
Example matches, |
| 1587 |
kernel<<<i,j>>>(); |
| 1588 |
</pre></td></tr> |
| 1589 |
|
| 1590 |
|
| 1591 |
<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> |
| 1592 |
<tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created. |
| 1593 |
|
| 1594 |
Example matches FunctionTakesString(GetStringByValue()) |
| 1595 |
(matcher = cxxBindTemporaryExpr()) |
| 1596 |
FunctionTakesString(GetStringByValue()); |
| 1597 |
FunctionTakesStringByPointer(GetStringPointer()); |
| 1598 |
</pre></td></tr> |
| 1599 |
|
| 1600 |
|
| 1601 |
<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> |
| 1602 |
<tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals. |
| 1603 |
|
| 1604 |
Example matches true |
| 1605 |
true |
| 1606 |
</pre></td></tr> |
| 1607 |
|
| 1608 |
|
| 1609 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxCatchStmt0')"><a name="cxxCatchStmt0Anchor">cxxCatchStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>>...</td></tr> |
| 1610 |
<tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements. |
| 1611 |
|
| 1612 |
try {} catch(int i) {} |
| 1613 |
cxxCatchStmt() |
| 1614 |
matches 'catch(int i)' |
| 1615 |
</pre></td></tr> |
| 1616 |
|
| 1617 |
|
| 1618 |
<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> |
| 1619 |
<tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression. |
| 1620 |
|
| 1621 |
Example: Matches const_cast<int*>(&r) in |
| 1622 |
int n = 42; |
| 1623 |
const int &r(n); |
| 1624 |
int* p = const_cast<int*>(&r); |
| 1625 |
</pre></td></tr> |
| 1626 |
|
| 1627 |
|
| 1628 |
<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> |
| 1629 |
<tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones). |
| 1630 |
|
| 1631 |
Example matches string(ptr, n) and ptr within arguments of f |
| 1632 |
(matcher = cxxConstructExpr()) |
| 1633 |
void f(const string &a, const string &b); |
| 1634 |
char *ptr; |
| 1635 |
int n; |
| 1636 |
f(string(ptr, n), ptr); |
| 1637 |
</pre></td></tr> |
| 1638 |
|
| 1639 |
|
| 1640 |
<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> |
| 1641 |
<tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site. |
| 1642 |
|
| 1643 |
Example matches the CXXDefaultArgExpr placeholder inserted for the |
| 1644 |
default value of the second parameter in the call expression f(42) |
| 1645 |
(matcher = cxxDefaultArgExpr()) |
| 1646 |
void f(int x, int y = 0); |
| 1647 |
f(42); |
| 1648 |
</pre></td></tr> |
| 1649 |
|
| 1650 |
|
| 1651 |
<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> |
| 1652 |
<tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions. |
| 1653 |
|
| 1654 |
Given |
| 1655 |
delete X; |
| 1656 |
cxxDeleteExpr() |
| 1657 |
matches 'delete X'. |
| 1658 |
</pre></td></tr> |
| 1659 |
|
| 1660 |
|
| 1661 |
<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> |
| 1662 |
<tr><td colspan="4" class="doc" id="cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be |
| 1663 |
resolved because the base expression or the member name was dependent. |
| 1664 |
|
| 1665 |
Given |
| 1666 |
template <class T> void f() { T t; t.g(); } |
| 1667 |
cxxDependentScopeMemberExpr() |
| 1668 |
matches t.g |
| 1669 |
</pre></td></tr> |
| 1670 |
|
| 1671 |
|
| 1672 |
<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> |
| 1673 |
<tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression. |
| 1674 |
|
| 1675 |
Example: |
| 1676 |
cxxDynamicCastExpr() |
| 1677 |
matches |
| 1678 |
dynamic_cast<D*>(&b); |
| 1679 |
in |
| 1680 |
struct B { virtual ~B() {} }; struct D : B {}; |
| 1681 |
B b; |
| 1682 |
D* p = dynamic_cast<D*>(&b); |
| 1683 |
</pre></td></tr> |
| 1684 |
|
| 1685 |
|
| 1686 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxFoldExpr0')"><a name="cxxFoldExpr0Anchor">cxxFoldExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>>...</td></tr> |
| 1687 |
<tr><td colspan="4" class="doc" id="cxxFoldExpr0"><pre>Matches C++17 fold expressions. |
| 1688 |
|
| 1689 |
Example matches `(0 + ... + args)`: |
| 1690 |
template <typename... Args> |
| 1691 |
auto sum(Args... args) { |
| 1692 |
return (0 + ... + args); |
| 1693 |
} |
| 1694 |
</pre></td></tr> |
| 1695 |
|
| 1696 |
|
| 1697 |
<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> |
| 1698 |
<tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements. |
| 1699 |
|
| 1700 |
cxxForRangeStmt() matches 'for (auto a : i)' |
| 1701 |
int i[] = {1, 2, 3}; for (auto a : i); |
| 1702 |
for(int j = 0; j < 5; ++j); |
| 1703 |
</pre></td></tr> |
| 1704 |
|
| 1705 |
|
| 1706 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxFunctionalCastExpr0')"><a name="cxxFunctionalCastExpr0Anchor">cxxFunctionalCastExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>...</td></tr> |
| 1707 |
<tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions |
| 1708 |
|
| 1709 |
Example: Matches Foo(bar); |
| 1710 |
Foo f = bar; |
| 1711 |
Foo g = (Foo) bar; |
| 1712 |
Foo h = Foo(bar); |
| 1713 |
</pre></td></tr> |
| 1714 |
|
| 1715 |
|
| 1716 |
<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> |
| 1717 |
<tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions. |
| 1718 |
|
| 1719 |
Example matches x.y() |
| 1720 |
X x; |
| 1721 |
x.y(); |
| 1722 |
</pre></td></tr> |
| 1723 |
|
| 1724 |
|
| 1725 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxNamedCastExpr0')"><a name="cxxNamedCastExpr0Anchor">cxxNamedCastExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNamedCastExpr.html">CXXNamedCastExpr</a>>...</td></tr> |
| 1726 |
<tr><td colspan="4" class="doc" id="cxxNamedCastExpr0"><pre>Matches any named cast expression. |
| 1727 |
|
| 1728 |
Example: Matches all four of the casts in |
| 1729 |
struct S { virtual void f(); }; |
| 1730 |
S* p = nullptr; |
| 1731 |
S* ptr1 = static_cast<S*>(p); |
| 1732 |
S* ptr2 = reinterpret_cast<S*>(p); |
| 1733 |
S* ptr3 = dynamic_cast<S*>(p); |
| 1734 |
S* ptr4 = const_cast<S*>(p); |
| 1735 |
</pre></td></tr> |
| 1736 |
|
| 1737 |
|
| 1738 |
<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> |
| 1739 |
<tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions. |
| 1740 |
|
| 1741 |
Given |
| 1742 |
new X; |
| 1743 |
cxxNewExpr() |
| 1744 |
matches 'new X'. |
| 1745 |
</pre></td></tr> |
| 1746 |
|
| 1747 |
|
| 1748 |
<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> |
| 1749 |
<tr><td colspan="4" class="doc" id="cxxNoexceptExpr0"><pre>Matches noexcept expressions. |
| 1750 |
|
| 1751 |
Given |
| 1752 |
bool a() noexcept; |
| 1753 |
bool b() noexcept(true); |
| 1754 |
bool c() noexcept(false); |
| 1755 |
bool d() noexcept(noexcept(a())); |
| 1756 |
bool e = noexcept(b()) || noexcept(c()); |
| 1757 |
cxxNoexceptExpr() |
| 1758 |
matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`. |
| 1759 |
doesn't match the noexcept specifier in the declarations a, b, c or d. |
| 1760 |
</pre></td></tr> |
| 1761 |
|
| 1762 |
|
| 1763 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxNullPtrLiteralExpr0')"><a name="cxxNullPtrLiteralExpr0Anchor">cxxNullPtrLiteralExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>>...</td></tr> |
| 1764 |
<tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal. |
| 1765 |
</pre></td></tr> |
| 1766 |
|
| 1767 |
|
| 1768 |
<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> |
| 1769 |
<tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls. |
| 1770 |
|
| 1771 |
Note that if an operator isn't overloaded, it won't match. Instead, use |
| 1772 |
binaryOperator matcher. |
| 1773 |
Currently it does not match operators such as new delete. |
| 1774 |
FIXME: figure out why these do not match? |
| 1775 |
|
| 1776 |
Example matches both operator<<((o << b), c) and operator<<(o, b) |
| 1777 |
(matcher = cxxOperatorCallExpr()) |
| 1778 |
ostream &operator<< (ostream &out, int i) { }; |
| 1779 |
ostream &o; int b = 1, c = 1; |
| 1780 |
o << b << c; |
| 1781 |
See also the binaryOperation() matcher for more-general matching of binary |
| 1782 |
uses of this AST node. |
| 1783 |
</pre></td></tr> |
| 1784 |
|
| 1785 |
|
| 1786 |
<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> |
| 1787 |
<tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. |
| 1788 |
|
| 1789 |
Either the source expression or the destination type can be matched |
| 1790 |
using has(), but hasDestinationType() is more specific and can be |
| 1791 |
more readable. |
| 1792 |
|
| 1793 |
Example matches reinterpret_cast<char*>(&p) in |
| 1794 |
void* p = reinterpret_cast<char*>(&p); |
| 1795 |
</pre></td></tr> |
| 1796 |
|
| 1797 |
|
| 1798 |
<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> |
| 1799 |
<tr><td colspan="4" class="doc" id="cxxRewrittenBinaryOperator0"><pre>Matches rewritten binary operators |
| 1800 |
|
| 1801 |
Example matches use of "<": |
| 1802 |
#include <compare> |
| 1803 |
struct HasSpaceshipMem { |
| 1804 |
int a; |
| 1805 |
constexpr auto operator<=>(const HasSpaceshipMem&) const = default; |
| 1806 |
}; |
| 1807 |
void compare() { |
| 1808 |
HasSpaceshipMem hs1, hs2; |
| 1809 |
if (hs1 < hs2) |
| 1810 |
return; |
| 1811 |
} |
| 1812 |
See also the binaryOperation() matcher for more-general matching |
| 1813 |
of this AST node. |
| 1814 |
</pre></td></tr> |
| 1815 |
|
| 1816 |
|
| 1817 |
<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> |
| 1818 |
<tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression. |
| 1819 |
|
| 1820 |
See also: hasDestinationType |
| 1821 |
See also: reinterpretCast |
| 1822 |
|
| 1823 |
Example: |
| 1824 |
cxxStaticCastExpr() |
| 1825 |
matches |
| 1826 |
static_cast<long>(8) |
| 1827 |
in |
| 1828 |
long eight(static_cast<long>(8)); |
| 1829 |
</pre></td></tr> |
| 1830 |
|
| 1831 |
|
| 1832 |
<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> |
| 1833 |
<tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions. |
| 1834 |
|
| 1835 |
Given |
| 1836 |
std::vector<int> a({ 1, 2, 3 }); |
| 1837 |
std::vector<int> b = { 4, 5 }; |
| 1838 |
int c[] = { 6, 7 }; |
| 1839 |
std::pair<int, int> d = { 8, 9 }; |
| 1840 |
cxxStdInitializerListExpr() |
| 1841 |
matches "{ 1, 2, 3 }" and "{ 4, 5 }" |
| 1842 |
</pre></td></tr> |
| 1843 |
|
| 1844 |
|
| 1845 |
<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> |
| 1846 |
<tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments |
| 1847 |
|
| 1848 |
Example: Matches Foo(bar, bar) |
| 1849 |
Foo h = Foo(bar, bar); |
| 1850 |
</pre></td></tr> |
| 1851 |
|
| 1852 |
|
| 1853 |
<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> |
| 1854 |
<tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions. |
| 1855 |
|
| 1856 |
Example matches the implicit this expression in "return i". |
| 1857 |
(matcher = cxxThisExpr()) |
| 1858 |
struct foo { |
| 1859 |
int i; |
| 1860 |
int f() { return i; } |
| 1861 |
}; |
| 1862 |
</pre></td></tr> |
| 1863 |
|
| 1864 |
|
| 1865 |
<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> |
| 1866 |
<tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions. |
| 1867 |
|
| 1868 |
try { throw 5; } catch(int i) {} |
| 1869 |
cxxThrowExpr() |
| 1870 |
matches 'throw 5' |
| 1871 |
</pre></td></tr> |
| 1872 |
|
| 1873 |
|
| 1874 |
<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> |
| 1875 |
<tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements. |
| 1876 |
|
| 1877 |
try {} catch(int i) {} |
| 1878 |
cxxTryStmt() |
| 1879 |
matches 'try {}' |
| 1880 |
</pre></td></tr> |
| 1881 |
|
| 1882 |
|
| 1883 |
<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> |
| 1884 |
<tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. |
| 1885 |
|
| 1886 |
Example matches T(t) in return statement of f |
| 1887 |
(matcher = cxxUnresolvedConstructExpr()) |
| 1888 |
template <typename T> |
| 1889 |
void f(const T& t) { return T(t); } |
| 1890 |
</pre></td></tr> |
| 1891 |
|
| 1892 |
|
| 1893 |
<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> |
| 1894 |
<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. |
| 1895 |
|
| 1896 |
Example matches x in if (x) |
| 1897 |
bool x; |
| 1898 |
if (x) {} |
| 1899 |
</pre></td></tr> |
| 1900 |
|
| 1901 |
|
| 1902 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('declStmt0')"><a name="declStmt0Anchor">declStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>>...</td></tr> |
| 1903 |
<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. |
| 1904 |
|
| 1905 |
Given |
| 1906 |
int a; |
| 1907 |
declStmt() |
| 1908 |
matches 'int a'. |
| 1909 |
</pre></td></tr> |
| 1910 |
|
| 1911 |
|
| 1912 |
<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> |
| 1913 |
<tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. |
| 1914 |
|
| 1915 |
Given |
| 1916 |
switch(a) { case 42: break; default: break; } |
| 1917 |
defaultStmt() |
| 1918 |
matches 'default:'. |
| 1919 |
</pre></td></tr> |
| 1920 |
|
| 1921 |
|
| 1922 |
<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> |
| 1923 |
<tr><td colspan="4" class="doc" id="dependentCoawaitExpr0"><pre>Matches co_await expressions where the type of the promise is dependent |
| 1924 |
</pre></td></tr> |
| 1925 |
|
| 1926 |
|
| 1927 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('dependentScopeDeclRefExpr0')"><a name="dependentScopeDeclRefExpr0Anchor">dependentScopeDeclRefExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentScopeDeclRefExpr.html">DependentScopeDeclRefExpr</a>>...</td></tr> |
| 1928 |
<tr><td colspan="4" class="doc" id="dependentScopeDeclRefExpr0"><pre>Matches expressions that refer to dependent scope declarations. |
| 1929 |
|
| 1930 |
example matches T::v; |
| 1931 |
template <class T> class X : T { void f() { T::v; } }; |
| 1932 |
</pre></td></tr> |
| 1933 |
|
| 1934 |
|
| 1935 |
<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> |
| 1936 |
<tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8]. |
| 1937 |
|
| 1938 |
Example: Matches { [2].y = 1.0, [0].x = 1.0 } |
| 1939 |
point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; |
| 1940 |
</pre></td></tr> |
| 1941 |
|
| 1942 |
|
| 1943 |
<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> |
| 1944 |
<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. |
| 1945 |
|
| 1946 |
Given |
| 1947 |
do {} while (true); |
| 1948 |
doStmt() |
| 1949 |
matches 'do {} while(true)' |
| 1950 |
</pre></td></tr> |
| 1951 |
|
| 1952 |
|
| 1953 |
<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> |
| 1954 |
<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. |
| 1955 |
|
| 1956 |
Matches any cast expression written in user code, whether it be a |
| 1957 |
C-style cast, a functional-style cast, or a keyword cast. |
| 1958 |
|
| 1959 |
Does not match implicit conversions. |
| 1960 |
|
| 1961 |
Note: the name "explicitCast" is chosen to match Clang's terminology, as |
| 1962 |
Clang uses the term "cast" to apply to implicit conversions as well as to |
| 1963 |
actual cast expressions. |
| 1964 |
|
| 1965 |
See also: hasDestinationType. |
| 1966 |
|
| 1967 |
Example: matches all five of the casts in |
| 1968 |
int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) |
| 1969 |
but does not match the implicit conversion in |
| 1970 |
long ell = 42; |
| 1971 |
</pre></td></tr> |
| 1972 |
|
| 1973 |
|
| 1974 |
<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> |
| 1975 |
<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. |
| 1976 |
|
| 1977 |
Example matches x() |
| 1978 |
void f() { x(); } |
| 1979 |
</pre></td></tr> |
| 1980 |
|
| 1981 |
|
| 1982 |
<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> |
| 1983 |
<tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end |
| 1984 |
of the sub-expression's evaluation. |
| 1985 |
|
| 1986 |
Example matches std::string() |
| 1987 |
const std::string str = std::string(); |
| 1988 |
</pre></td></tr> |
| 1989 |
|
| 1990 |
|
| 1991 |
<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> |
| 1992 |
<tr><td colspan="4" class="doc" id="fixedPointLiteral0"><pre>Matches fixed-point literals eg. |
| 1993 |
0.5r, 0.5hr, 0.5lr, 0.5uhr, 0.5ur, 0.5ulr |
| 1994 |
1.0k, 1.0hk, 1.0lk, 1.0uhk, 1.0uk, 1.0ulk |
| 1995 |
Exponents 1.0e10k |
| 1996 |
Hexadecimal numbers 0x0.2p2r |
| 1997 |
|
| 1998 |
Does not match implicit conversions such as first two lines: |
| 1999 |
short _Accum sa = 2; |
| 2000 |
_Accum a = 12.5; |
| 2001 |
_Accum b = 1.25hk; |
| 2002 |
_Fract c = 0.25hr; |
| 2003 |
_Fract v = 0.35uhr; |
| 2004 |
_Accum g = 1.45uhk; |
| 2005 |
_Accum decexp1 = 1.575e1k; |
| 2006 |
|
| 2007 |
The matcher matches |
| 2008 |
but does not |
| 2009 |
match and from the code block. |
| 2010 |
</pre></td></tr> |
| 2011 |
|
| 2012 |
|
| 2013 |
<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> |
| 2014 |
<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g. |
| 2015 |
1.0, 1.0f, 1.0L and 1e10. |
| 2016 |
|
| 2017 |
Does not match implicit conversions such as |
| 2018 |
float a = 10; |
| 2019 |
</pre></td></tr> |
| 2020 |
|
| 2021 |
|
| 2022 |
<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> |
| 2023 |
<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. |
| 2024 |
|
| 2025 |
Example matches 'for (;;) {}' |
| 2026 |
for (;;) {} |
| 2027 |
int i[] = {1, 2, 3}; for (auto a : i); |
| 2028 |
</pre></td></tr> |
| 2029 |
|
| 2030 |
|
| 2031 |
<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> |
| 2032 |
<tr><td colspan="4" class="doc" id="genericSelectionExpr0"><pre>Matches C11 _Generic expression. |
| 2033 |
</pre></td></tr> |
| 2034 |
|
| 2035 |
|
| 2036 |
<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> |
| 2037 |
<tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. |
| 2038 |
</pre></td></tr> |
| 2039 |
|
| 2040 |
|
| 2041 |
<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> |
| 2042 |
<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. |
| 2043 |
|
| 2044 |
Given |
| 2045 |
goto FOO; |
| 2046 |
FOO: bar(); |
| 2047 |
gotoStmt() |
| 2048 |
matches 'goto FOO' |
| 2049 |
</pre></td></tr> |
| 2050 |
|
| 2051 |
|
| 2052 |
<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> |
| 2053 |
<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. |
| 2054 |
|
| 2055 |
Example matches 'if (x) {}' |
| 2056 |
if (x) {} |
| 2057 |
</pre></td></tr> |
| 2058 |
|
| 2059 |
|
| 2060 |
<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> |
| 2061 |
<tr><td colspan="4" class="doc" id="imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating |
| 2062 |
point literals e.g.: 1i, 1.0i |
| 2063 |
</pre></td></tr> |
| 2064 |
|
| 2065 |
|
| 2066 |
<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> |
| 2067 |
<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. |
| 2068 |
|
| 2069 |
This matches many different places, including function call return value |
| 2070 |
eliding, as well as any type conversions. |
| 2071 |
</pre></td></tr> |
| 2072 |
|
| 2073 |
|
| 2074 |
<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> |
| 2075 |
<tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions. |
| 2076 |
|
| 2077 |
Given |
| 2078 |
point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; |
| 2079 |
implicitValueInitExpr() |
| 2080 |
matches "[0].y" (implicitly) |
| 2081 |
</pre></td></tr> |
| 2082 |
|
| 2083 |
|
| 2084 |
<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> |
| 2085 |
<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. |
| 2086 |
|
| 2087 |
Given |
| 2088 |
int a[] = { 1, 2 }; |
| 2089 |
struct B { int x, y; }; |
| 2090 |
B b = { 5, 6 }; |
| 2091 |
initListExpr() |
| 2092 |
matches "{ 1, 2 }" and "{ 5, 6 }" |
| 2093 |
</pre></td></tr> |
| 2094 |
|
| 2095 |
|
| 2096 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('integerLiteral0')"><a name="integerLiteral0Anchor">integerLiteral</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>...</td></tr> |
| 2097 |
<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g. |
| 2098 |
1, 1L, 0x1 and 1U. |
| 2099 |
|
| 2100 |
Does not match character-encoded integers such as L'a'. |
| 2101 |
</pre></td></tr> |
| 2102 |
|
| 2103 |
|
| 2104 |
<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> |
| 2105 |
<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. |
| 2106 |
|
| 2107 |
Given |
| 2108 |
goto FOO; |
| 2109 |
FOO: bar(); |
| 2110 |
labelStmt() |
| 2111 |
matches 'FOO:' |
| 2112 |
</pre></td></tr> |
| 2113 |
|
| 2114 |
|
| 2115 |
<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> |
| 2116 |
<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. |
| 2117 |
|
| 2118 |
Example matches [&](){return 5;} |
| 2119 |
[&](){return 5;} |
| 2120 |
</pre></td></tr> |
| 2121 |
|
| 2122 |
|
| 2123 |
<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> |
| 2124 |
<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. |
| 2125 |
|
| 2126 |
Example: Given |
| 2127 |
struct T {void func();}; |
| 2128 |
T f(); |
| 2129 |
void g(T); |
| 2130 |
materializeTemporaryExpr() matches 'f()' in these statements |
| 2131 |
T u(f()); |
| 2132 |
g(f()); |
| 2133 |
f().func(); |
| 2134 |
but does not match |
| 2135 |
f(); |
| 2136 |
</pre></td></tr> |
| 2137 |
|
| 2138 |
|
| 2139 |
<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> |
| 2140 |
<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. |
| 2141 |
|
| 2142 |
Given |
| 2143 |
class Y { |
| 2144 |
void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 2145 |
int a; static int b; |
| 2146 |
}; |
| 2147 |
memberExpr() |
| 2148 |
matches this->x, x, y.x, a, this->b |
| 2149 |
</pre></td></tr> |
| 2150 |
|
| 2151 |
|
| 2152 |
<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> |
| 2153 |
<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. |
| 2154 |
|
| 2155 |
foo();; |
| 2156 |
nullStmt() |
| 2157 |
matches the second ';' |
| 2158 |
</pre></td></tr> |
| 2159 |
|
| 2160 |
|
| 2161 |
<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> |
| 2162 |
<tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements. |
| 2163 |
|
| 2164 |
Example matches @catch |
| 2165 |
@try {} |
| 2166 |
@catch (...) {} |
| 2167 |
</pre></td></tr> |
| 2168 |
|
| 2169 |
|
| 2170 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcFinallyStmt0')"><a name="objcFinallyStmt0Anchor">objcFinallyStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtFinallyStmt.html">ObjCAtFinallyStmt</a>>...</td></tr> |
| 2171 |
<tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements. |
| 2172 |
|
| 2173 |
Example matches @finally |
| 2174 |
@try {} |
| 2175 |
@finally {} |
| 2176 |
</pre></td></tr> |
| 2177 |
|
| 2178 |
|
| 2179 |
<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> |
| 2180 |
<tr><td colspan="4" class="doc" id="objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar. |
| 2181 |
|
| 2182 |
Example: matches "a" in "init" method: |
| 2183 |
@implementation A { |
| 2184 |
NSString *a; |
| 2185 |
} |
| 2186 |
- (void) init { |
| 2187 |
a = @"hello"; |
| 2188 |
} |
| 2189 |
</pre></td></tr> |
| 2190 |
|
| 2191 |
|
| 2192 |
<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> |
| 2193 |
<tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions. |
| 2194 |
|
| 2195 |
The innermost message send invokes the "alloc" class method on the |
| 2196 |
NSString class, while the outermost message send invokes the |
| 2197 |
"initWithString" instance method on the object returned from |
| 2198 |
NSString's "alloc". This matcher should match both message sends. |
| 2199 |
[[NSString alloc] initWithString:@"Hello"] |
| 2200 |
</pre></td></tr> |
| 2201 |
|
| 2202 |
|
| 2203 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcStringLiteral0')"><a name="objcStringLiteral0Anchor">objcStringLiteral</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCStringLiteral.html">ObjCStringLiteral</a>>...</td></tr> |
| 2204 |
<tr><td colspan="4" class="doc" id="objcStringLiteral0"><pre>Matches ObjectiveC String literal expressions. |
| 2205 |
|
| 2206 |
Example matches @"abcd" |
| 2207 |
NSString *s = @"abcd"; |
| 2208 |
</pre></td></tr> |
| 2209 |
|
| 2210 |
|
| 2211 |
<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> |
| 2212 |
<tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements. |
| 2213 |
|
| 2214 |
Example matches @throw obj; |
| 2215 |
</pre></td></tr> |
| 2216 |
|
| 2217 |
|
| 2218 |
<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> |
| 2219 |
<tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements. |
| 2220 |
|
| 2221 |
Example matches @try |
| 2222 |
@try {} |
| 2223 |
@catch (...) {} |
| 2224 |
</pre></td></tr> |
| 2225 |
|
| 2226 |
|
| 2227 |
<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<OMPExecutableDirective>...</td></tr> |
| 2228 |
<tr><td colspan="4" class="doc" id="ompExecutableDirective0"><pre>Matches any ``#pragma omp`` executable directive. |
| 2229 |
|
| 2230 |
Given |
| 2231 |
|
| 2232 |
#pragma omp parallel |
| 2233 |
#pragma omp parallel default(none) |
| 2234 |
#pragma omp taskyield |
| 2235 |
|
| 2236 |
``ompExecutableDirective()`` matches ``omp parallel``, |
| 2237 |
``omp parallel default(none)`` and ``omp taskyield``. |
| 2238 |
</pre></td></tr> |
| 2239 |
|
| 2240 |
|
| 2241 |
<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> |
| 2242 |
<tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers |
| 2243 |
to reference another expressions and can be met |
| 2244 |
in BinaryConditionalOperators, for example. |
| 2245 |
|
| 2246 |
Example matches 'a' |
| 2247 |
(a ?: c) + 42; |
| 2248 |
</pre></td></tr> |
| 2249 |
|
| 2250 |
|
| 2251 |
<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> |
| 2252 |
<tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions. |
| 2253 |
|
| 2254 |
Example matches (foo() + 1) |
| 2255 |
int foo() { return 1; } |
| 2256 |
int a = (foo() + 1); |
| 2257 |
</pre></td></tr> |
| 2258 |
|
| 2259 |
|
| 2260 |
<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> |
| 2261 |
<tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions. |
| 2262 |
ParenListExprs don't have a predefined type and are used for late parsing. |
| 2263 |
In the final AST, they can be met in template declarations. |
| 2264 |
|
| 2265 |
Given |
| 2266 |
template<typename T> class X { |
| 2267 |
void f() { |
| 2268 |
X x(*this); |
| 2269 |
int a = 0, b = 1; int i = (a, b); |
| 2270 |
} |
| 2271 |
}; |
| 2272 |
parenListExpr() matches "*this" but NOT matches (a, b) because (a, b) |
| 2273 |
has a predefined type and is a ParenExpr, not a ParenListExpr. |
| 2274 |
</pre></td></tr> |
| 2275 |
|
| 2276 |
|
| 2277 |
<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> |
| 2278 |
<tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2]. |
| 2279 |
|
| 2280 |
Example: Matches __func__ |
| 2281 |
printf("%s", __func__); |
| 2282 |
</pre></td></tr> |
| 2283 |
|
| 2284 |
|
| 2285 |
<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> |
| 2286 |
<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. |
| 2287 |
|
| 2288 |
Given |
| 2289 |
return 1; |
| 2290 |
returnStmt() |
| 2291 |
matches 'return 1' |
| 2292 |
</pre></td></tr> |
| 2293 |
|
| 2294 |
|
| 2295 |
<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> |
| 2296 |
<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. |
| 2297 |
|
| 2298 |
Given |
| 2299 |
{ ++a; } |
| 2300 |
stmt() |
| 2301 |
matches both the compound statement '{ ++a; }' and '++a'. |
| 2302 |
</pre></td></tr> |
| 2303 |
|
| 2304 |
|
| 2305 |
<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> |
| 2306 |
<tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension). |
| 2307 |
|
| 2308 |
Example match: ({ int X = 4; X; }) |
| 2309 |
int C = ({ int X = 4; X; }); |
| 2310 |
</pre></td></tr> |
| 2311 |
|
| 2312 |
|
| 2313 |
<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> |
| 2314 |
<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). |
| 2315 |
|
| 2316 |
Example matches "abcd", L"abcd" |
| 2317 |
char *s = "abcd"; |
| 2318 |
wchar_t *ws = L"abcd"; |
| 2319 |
</pre></td></tr> |
| 2320 |
|
| 2321 |
|
| 2322 |
<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> |
| 2323 |
<tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. |
| 2324 |
|
| 2325 |
Given |
| 2326 |
template <int N> |
| 2327 |
struct A { static const int n = N; }; |
| 2328 |
struct B : public A<42> {}; |
| 2329 |
substNonTypeTemplateParmExpr() |
| 2330 |
matches "N" in the right-hand side of "static const int n = N;" |
| 2331 |
</pre></td></tr> |
| 2332 |
|
| 2333 |
|
| 2334 |
<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> |
| 2335 |
<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. |
| 2336 |
|
| 2337 |
Given |
| 2338 |
switch(a) { case 42: break; default: break; } |
| 2339 |
switchCase() |
| 2340 |
matches 'case 42:' and 'default:'. |
| 2341 |
</pre></td></tr> |
| 2342 |
|
| 2343 |
|
| 2344 |
<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> |
| 2345 |
<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. |
| 2346 |
|
| 2347 |
Given |
| 2348 |
switch(a) { case 42: break; default: break; } |
| 2349 |
switchStmt() |
| 2350 |
matches 'switch(a)'. |
| 2351 |
</pre></td></tr> |
| 2352 |
|
| 2353 |
|
| 2354 |
<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> |
| 2355 |
<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) |
| 2356 |
|
| 2357 |
Given |
| 2358 |
Foo x = bar; |
| 2359 |
int y = sizeof(x) + alignof(x); |
| 2360 |
unaryExprOrTypeTraitExpr() |
| 2361 |
matches sizeof(x) and alignof(x) |
| 2362 |
</pre></td></tr> |
| 2363 |
|
| 2364 |
|
| 2365 |
<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> |
| 2366 |
<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. |
| 2367 |
|
| 2368 |
Example matches !a |
| 2369 |
!a || b |
| 2370 |
</pre></td></tr> |
| 2371 |
|
| 2372 |
|
| 2373 |
<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> |
| 2374 |
<tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing |
| 2375 |
but could not be resolved to a specific declaration. |
| 2376 |
|
| 2377 |
Given |
| 2378 |
template<typename T> |
| 2379 |
T foo() { T a; return a; } |
| 2380 |
template<typename T> |
| 2381 |
void bar() { |
| 2382 |
foo<T>(); |
| 2383 |
} |
| 2384 |
unresolvedLookupExpr() |
| 2385 |
matches foo<T>() </pre></td></tr> |
| 2386 |
|
| 2387 |
|
| 2388 |
<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> |
| 2389 |
<tr><td colspan="4" class="doc" id="unresolvedMemberExpr0"><pre>Matches unresolved member expressions. |
| 2390 |
|
| 2391 |
Given |
| 2392 |
struct X { |
| 2393 |
template <class T> void f(); |
| 2394 |
void g(); |
| 2395 |
}; |
| 2396 |
template <class T> void h() { X x; x.f<T>(); x.g(); } |
| 2397 |
unresolvedMemberExpr() |
| 2398 |
matches x.f<T> |
| 2399 |
</pre></td></tr> |
| 2400 |
|
| 2401 |
|
| 2402 |
<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> |
| 2403 |
<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. |
| 2404 |
|
| 2405 |
Example match: "foo"_suffix |
| 2406 |
</pre></td></tr> |
| 2407 |
|
| 2408 |
|
| 2409 |
<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> |
| 2410 |
<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. |
| 2411 |
|
| 2412 |
Given |
| 2413 |
while (true) {} |
| 2414 |
whileStmt() |
| 2415 |
matches 'while (true) {}'. |
| 2416 |
</pre></td></tr> |
| 2417 |
|
| 2418 |
|
| 2419 |
<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> |
| 2420 |
<tr><td colspan="4" class="doc" id="templateArgumentLoc0"><pre>Matches template arguments (with location info). |
| 2421 |
|
| 2422 |
Given |
| 2423 |
template <typename T> struct C {}; |
| 2424 |
C<int> c; |
| 2425 |
templateArgumentLoc() |
| 2426 |
matches 'int' in C<int>. |
| 2427 |
</pre></td></tr> |
| 2428 |
|
| 2429 |
|
| 2430 |
<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> |
| 2431 |
<tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. |
| 2432 |
|
| 2433 |
Given |
| 2434 |
template <typename T> struct C {}; |
| 2435 |
C<int> c; |
| 2436 |
templateArgument() |
| 2437 |
matches 'int' in C<int>. |
| 2438 |
</pre></td></tr> |
| 2439 |
|
| 2440 |
|
| 2441 |
<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> |
| 2442 |
<tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name. |
| 2443 |
|
| 2444 |
Given |
| 2445 |
template <typename T> class X { }; |
| 2446 |
X<int> xi; |
| 2447 |
templateName() |
| 2448 |
matches 'X' in X<int>. |
| 2449 |
</pre></td></tr> |
| 2450 |
|
| 2451 |
|
| 2452 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('arrayTypeLoc0')"><a name="arrayTypeLoc0Anchor">arrayTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayTypeLoc.html">ArrayTypeLoc</a>>...</td></tr> |
| 2453 |
<tr><td colspan="4" class="doc" id="arrayTypeLoc0"><pre>Matches `ArrayTypeLoc`s. |
| 2454 |
|
| 2455 |
Given |
| 2456 |
int a[] = {1, 2}; |
| 2457 |
int b[3]; |
| 2458 |
void f() { int c[a[0]]; } |
| 2459 |
arrayTypeLoc() |
| 2460 |
matches "int a[]", "int b[3]" and "int c[a[0]]". |
| 2461 |
</pre></td></tr> |
| 2462 |
|
| 2463 |
|
| 2464 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('pointerTypeLoc0')"><a name="pointerTypeLoc0Anchor">pointerTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>>...</td></tr> |
| 2465 |
<tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer `TypeLoc`s. |
| 2466 |
|
| 2467 |
Given |
| 2468 |
int* x; |
| 2469 |
pointerTypeLoc() |
| 2470 |
matches `int*`. |
| 2471 |
</pre></td></tr> |
| 2472 |
|
| 2473 |
|
| 2474 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('qualifiedTypeLoc0')"><a name="qualifiedTypeLoc0Anchor">qualifiedTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualifiedTypeLoc.html">QualifiedTypeLoc</a>>...</td></tr> |
| 2475 |
<tr><td colspan="4" class="doc" id="qualifiedTypeLoc0"><pre>Matches `QualifiedTypeLoc`s in the clang AST. |
| 2476 |
|
| 2477 |
Given |
| 2478 |
const int x = 0; |
| 2479 |
qualifiedTypeLoc() |
| 2480 |
matches `const int`. |
| 2481 |
</pre></td></tr> |
| 2482 |
|
| 2483 |
|
| 2484 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('referenceTypeLoc0')"><a name="referenceTypeLoc0Anchor">referenceTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>>...</td></tr> |
| 2485 |
<tr><td colspan="4" class="doc" id="referenceTypeLoc0"><pre>Matches reference `TypeLoc`s. |
| 2486 |
|
| 2487 |
Given |
| 2488 |
int x = 3; |
| 2489 |
int& l = x; |
| 2490 |
int&& r = 3; |
| 2491 |
referenceTypeLoc() |
| 2492 |
matches `int&` and `int&&`. |
| 2493 |
</pre></td></tr> |
| 2494 |
|
| 2495 |
|
| 2496 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('templateSpecializationTypeLoc0')"><a name="templateSpecializationTypeLoc0Anchor">templateSpecializationTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>>...</td></tr> |
| 2497 |
<tr><td colspan="4" class="doc" id="templateSpecializationTypeLoc0"><pre>Matches template specialization `TypeLoc`s. |
| 2498 |
|
| 2499 |
Given |
| 2500 |
template <typename T> class C {}; |
| 2501 |
C<char> var; |
| 2502 |
varDecl(hasTypeLoc(templateSpecializationTypeLoc(typeLoc()))) |
| 2503 |
matches `C<char> var`. |
| 2504 |
</pre></td></tr> |
| 2505 |
|
| 2506 |
|
| 2507 |
<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> |
| 2508 |
<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. |
| 2509 |
</pre></td></tr> |
| 2510 |
|
| 2511 |
|
| 2512 |
<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> |
| 2513 |
<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. |
| 2514 |
|
| 2515 |
Given |
| 2516 |
int a[] = { 2, 3 }; |
| 2517 |
int b[4]; |
| 2518 |
void f() { int c[a[0]]; } |
| 2519 |
arrayType() |
| 2520 |
matches "int a[]", "int b[4]" and "int c[a[0]]"; |
| 2521 |
</pre></td></tr> |
| 2522 |
|
| 2523 |
|
| 2524 |
<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> |
| 2525 |
<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. |
| 2526 |
|
| 2527 |
Given |
| 2528 |
_Atomic(int) i; |
| 2529 |
atomicType() |
| 2530 |
matches "_Atomic(int) i" |
| 2531 |
</pre></td></tr> |
| 2532 |
|
| 2533 |
|
| 2534 |
<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<AutoType>...</td></tr> |
| 2535 |
<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. |
| 2536 |
|
| 2537 |
Given: |
| 2538 |
auto n = 4; |
| 2539 |
int v[] = { 2, 3 } |
| 2540 |
for (auto i : v) { } |
| 2541 |
autoType() |
| 2542 |
matches "auto n" and "auto i" |
| 2543 |
</pre></td></tr> |
| 2544 |
|
| 2545 |
|
| 2546 |
<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> |
| 2547 |
<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as |
| 2548 |
"void (^)(int)". |
| 2549 |
|
| 2550 |
The pointee is always required to be a FunctionType. |
| 2551 |
</pre></td></tr> |
| 2552 |
|
| 2553 |
|
| 2554 |
<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> |
| 2555 |
<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. |
| 2556 |
|
| 2557 |
Given |
| 2558 |
struct A {}; |
| 2559 |
A a; |
| 2560 |
int b; |
| 2561 |
float c; |
| 2562 |
bool d; |
| 2563 |
builtinType() |
| 2564 |
matches "int b", "float c" and "bool d" |
| 2565 |
</pre></td></tr> |
| 2566 |
|
| 2567 |
|
| 2568 |
<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> |
| 2569 |
<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. |
| 2570 |
|
| 2571 |
Given |
| 2572 |
_Complex float f; |
| 2573 |
complexType() |
| 2574 |
matches "_Complex float f" |
| 2575 |
</pre></td></tr> |
| 2576 |
|
| 2577 |
|
| 2578 |
<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> |
| 2579 |
<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. |
| 2580 |
|
| 2581 |
Given |
| 2582 |
void() { |
| 2583 |
int a[2]; |
| 2584 |
int b[] = { 2, 3 }; |
| 2585 |
int c[b[0]]; |
| 2586 |
} |
| 2587 |
constantArrayType() |
| 2588 |
matches "int a[2]" |
| 2589 |
</pre></td></tr> |
| 2590 |
|
| 2591 |
|
| 2592 |
<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> |
| 2593 |
<tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type |
| 2594 |
Example matches i[] in declaration of f. |
| 2595 |
(matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) |
| 2596 |
Example matches i[1]. |
| 2597 |
(matcher = expr(hasType(decayedType(hasDecayedType(pointerType()))))) |
| 2598 |
void f(int i[]) { |
| 2599 |
i[1] = 0; |
| 2600 |
} |
| 2601 |
</pre></td></tr> |
| 2602 |
|
| 2603 |
|
| 2604 |
<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<DecltypeType>...</td></tr> |
| 2605 |
<tr><td colspan="4" class="doc" id="decltypeType0"><pre>Matches types nodes representing C++11 decltype(<expr>) types. |
| 2606 |
|
| 2607 |
Given: |
| 2608 |
short i = 1; |
| 2609 |
int j = 42; |
| 2610 |
decltype(i + j) result = i + j; |
| 2611 |
decltypeType() |
| 2612 |
matches "decltype(i + j)" |
| 2613 |
</pre></td></tr> |
| 2614 |
|
| 2615 |
|
| 2616 |
<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<DeducedTemplateSpecializationType>...</td></tr> |
| 2617 |
<tr><td colspan="4" class="doc" id="deducedTemplateSpecializationType0"><pre>Matches C++17 deduced template specialization types, e.g. deduced class |
| 2618 |
template types. |
| 2619 |
|
| 2620 |
Given |
| 2621 |
template <typename T> |
| 2622 |
class C { public: C(T); }; |
| 2623 |
|
| 2624 |
C c(123); |
| 2625 |
deducedTemplateSpecializationType() matches the type in the declaration |
| 2626 |
of the variable c. |
| 2627 |
</pre></td></tr> |
| 2628 |
|
| 2629 |
|
| 2630 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('dependentNameType0')"><a name="dependentNameType0Anchor">dependentNameType</a></td><td>Matcher<DependentNameType>...</td></tr> |
| 2631 |
<tr><td colspan="4" class="doc" id="dependentNameType0"><pre>Matches a dependent name type |
| 2632 |
|
| 2633 |
Example matches T::type |
| 2634 |
template <typename T> struct declToImport { |
| 2635 |
typedef typename T::type dependent_name; |
| 2636 |
}; |
| 2637 |
</pre></td></tr> |
| 2638 |
|
| 2639 |
|
| 2640 |
<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> |
| 2641 |
<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. |
| 2642 |
|
| 2643 |
Given |
| 2644 |
template<typename T, int Size> |
| 2645 |
class array { |
| 2646 |
T data[Size]; |
| 2647 |
}; |
| 2648 |
dependentSizedArrayType() |
| 2649 |
matches "T data[Size]" |
| 2650 |
</pre></td></tr> |
| 2651 |
|
| 2652 |
|
| 2653 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('dependentSizedExtVectorType0')"><a name="dependentSizedExtVectorType0Anchor">dependentSizedExtVectorType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentSizedExtVectorType.html">DependentSizedExtVectorType</a>>...</td></tr> |
| 2654 |
<tr><td colspan="4" class="doc" id="dependentSizedExtVectorType0"><pre>Matches C++ extended vector type where either the type or size is |
| 2655 |
dependent. |
| 2656 |
|
| 2657 |
Given |
| 2658 |
template<typename T, int Size> |
| 2659 |
class vector { |
| 2660 |
typedef T __attribute__((ext_vector_type(Size))) type; |
| 2661 |
}; |
| 2662 |
dependentSizedExtVectorType() |
| 2663 |
matches "T __attribute__((ext_vector_type(Size)))" |
| 2664 |
</pre></td></tr> |
| 2665 |
|
| 2666 |
|
| 2667 |
<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<EnumType>...</td></tr> |
| 2668 |
<tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types. |
| 2669 |
|
| 2670 |
Given |
| 2671 |
enum C { Green }; |
| 2672 |
enum class S { Red }; |
| 2673 |
|
| 2674 |
C c; |
| 2675 |
S s; |
| 2676 |
|
| 2677 |
enumType() matches the type of the variable declarations of both c and |
| 2678 |
s. |
| 2679 |
</pre></td></tr> |
| 2680 |
|
| 2681 |
|
| 2682 |
<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> |
| 2683 |
<tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes. |
| 2684 |
|
| 2685 |
Given |
| 2686 |
int (*f)(int); |
| 2687 |
void g(); |
| 2688 |
functionProtoType() |
| 2689 |
matches "int (*f)(int)" and the type of "g" in C++ mode. |
| 2690 |
In C mode, "g" is not matched because it does not contain a prototype. |
| 2691 |
</pre></td></tr> |
| 2692 |
|
| 2693 |
|
| 2694 |
<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> |
| 2695 |
<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. |
| 2696 |
|
| 2697 |
Given |
| 2698 |
int (*f)(int); |
| 2699 |
void g(); |
| 2700 |
functionType() |
| 2701 |
matches "int (*f)(int)" and the type of "g". |
| 2702 |
</pre></td></tr> |
| 2703 |
|
| 2704 |
|
| 2705 |
<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> |
| 2706 |
<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. |
| 2707 |
|
| 2708 |
Given |
| 2709 |
int a[] = { 2, 3 }; |
| 2710 |
int b[42]; |
| 2711 |
void f(int c[]) { int d[a[0]]; }; |
| 2712 |
incompleteArrayType() |
| 2713 |
matches "int a[]" and "int c[]" |
| 2714 |
</pre></td></tr> |
| 2715 |
|
| 2716 |
|
| 2717 |
<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<InjectedClassNameType>...</td></tr> |
| 2718 |
<tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types. |
| 2719 |
|
| 2720 |
Example matches S s, but not S<T> s. |
| 2721 |
(matcher = parmVarDecl(hasType(injectedClassNameType()))) |
| 2722 |
template <typename T> struct S { |
| 2723 |
void f(S s); |
| 2724 |
void g(S<T> s); |
| 2725 |
}; |
| 2726 |
</pre></td></tr> |
| 2727 |
|
| 2728 |
|
| 2729 |
<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> |
| 2730 |
<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. |
| 2731 |
|
| 2732 |
Given: |
| 2733 |
int *a; |
| 2734 |
int &b = *a; |
| 2735 |
int &&c = 1; |
| 2736 |
auto &d = b; |
| 2737 |
auto &&e = c; |
| 2738 |
auto &&f = 2; |
| 2739 |
int g = 5; |
| 2740 |
|
| 2741 |
lValueReferenceType() matches the types of b, d, and e. e is |
| 2742 |
matched since the type is deduced as int& by reference collapsing rules. |
| 2743 |
</pre></td></tr> |
| 2744 |
|
| 2745 |
|
| 2746 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('macroQualifiedType0')"><a name="macroQualifiedType0Anchor">macroQualifiedType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MacroQualifiedType.html">MacroQualifiedType</a>>...</td></tr> |
| 2747 |
<tr><td colspan="4" class="doc" id="macroQualifiedType0"><pre>Matches qualified types when the qualifier is applied via a macro. |
| 2748 |
|
| 2749 |
Given |
| 2750 |
#define CDECL __attribute__((cdecl)) |
| 2751 |
typedef void (CDECL *X)(); |
| 2752 |
typedef void (__attribute__((cdecl)) *Y)(); |
| 2753 |
macroQualifiedType() |
| 2754 |
matches the type of the typedef declaration of X but not Y. |
| 2755 |
</pre></td></tr> |
| 2756 |
|
| 2757 |
|
| 2758 |
<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> |
| 2759 |
<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. |
| 2760 |
Given |
| 2761 |
struct A { int i; } |
| 2762 |
A::* ptr = A::i; |
| 2763 |
memberPointerType() |
| 2764 |
matches "A::* ptr" |
| 2765 |
</pre></td></tr> |
| 2766 |
|
| 2767 |
|
| 2768 |
<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> |
| 2769 |
<tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from |
| 2770 |
a pointer type, despite being syntactically similar. |
| 2771 |
|
| 2772 |
Given |
| 2773 |
int *a; |
| 2774 |
|
| 2775 |
@interface Foo |
| 2776 |
@end |
| 2777 |
Foo *f; |
| 2778 |
pointerType() |
| 2779 |
matches "Foo *f", but does not match "int *a". |
| 2780 |
</pre></td></tr> |
| 2781 |
|
| 2782 |
|
| 2783 |
<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> |
| 2784 |
<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. |
| 2785 |
|
| 2786 |
Given |
| 2787 |
int (*ptr_to_array)[4]; |
| 2788 |
int *array_of_ptrs[4]; |
| 2789 |
|
| 2790 |
varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not |
| 2791 |
array_of_ptrs. |
| 2792 |
</pre></td></tr> |
| 2793 |
|
| 2794 |
|
| 2795 |
<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> |
| 2796 |
<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer |
| 2797 |
types. |
| 2798 |
|
| 2799 |
Given |
| 2800 |
int *a; |
| 2801 |
int &b = *a; |
| 2802 |
int c = 5; |
| 2803 |
|
| 2804 |
@interface Foo |
| 2805 |
@end |
| 2806 |
Foo *f; |
| 2807 |
pointerType() |
| 2808 |
matches "int *a", but does not match "Foo *f". |
| 2809 |
</pre></td></tr> |
| 2810 |
|
| 2811 |
|
| 2812 |
<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> |
| 2813 |
<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. |
| 2814 |
|
| 2815 |
Given: |
| 2816 |
int *a; |
| 2817 |
int &b = *a; |
| 2818 |
int &&c = 1; |
| 2819 |
auto &d = b; |
| 2820 |
auto &&e = c; |
| 2821 |
auto &&f = 2; |
| 2822 |
int g = 5; |
| 2823 |
|
| 2824 |
rValueReferenceType() matches the types of c and f. e is not |
| 2825 |
matched as it is deduced to int& by reference collapsing rules. |
| 2826 |
</pre></td></tr> |
| 2827 |
|
| 2828 |
|
| 2829 |
<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<RecordType>...</td></tr> |
| 2830 |
<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). |
| 2831 |
|
| 2832 |
Given |
| 2833 |
class C {}; |
| 2834 |
struct S {}; |
| 2835 |
|
| 2836 |
C c; |
| 2837 |
S s; |
| 2838 |
|
| 2839 |
recordType() matches the type of the variable declarations of both c |
| 2840 |
and s. |
| 2841 |
</pre></td></tr> |
| 2842 |
|
| 2843 |
|
| 2844 |
<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> |
| 2845 |
<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. |
| 2846 |
|
| 2847 |
Given |
| 2848 |
int *a; |
| 2849 |
int &b = *a; |
| 2850 |
int &&c = 1; |
| 2851 |
auto &d = b; |
| 2852 |
auto &&e = c; |
| 2853 |
auto &&f = 2; |
| 2854 |
int g = 5; |
| 2855 |
|
| 2856 |
referenceType() matches the types of b, c, d, e, and f. |
| 2857 |
</pre></td></tr> |
| 2858 |
|
| 2859 |
|
| 2860 |
<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<SubstTemplateTypeParmType>...</td></tr> |
| 2861 |
<tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a |
| 2862 |
template type parameter. |
| 2863 |
|
| 2864 |
Given |
| 2865 |
template <typename T> |
| 2866 |
void F(T t) { |
| 2867 |
int i = 1 + t; |
| 2868 |
} |
| 2869 |
|
| 2870 |
substTemplateTypeParmType() matches the type of 't' but not '1' |
| 2871 |
</pre></td></tr> |
| 2872 |
|
| 2873 |
|
| 2874 |
<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<TagType>...</td></tr> |
| 2875 |
<tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types). |
| 2876 |
|
| 2877 |
Given |
| 2878 |
enum E {}; |
| 2879 |
class C {}; |
| 2880 |
|
| 2881 |
E e; |
| 2882 |
C c; |
| 2883 |
|
| 2884 |
tagType() matches the type of the variable declarations of both e |
| 2885 |
and c. |
| 2886 |
</pre></td></tr> |
| 2887 |
|
| 2888 |
|
| 2889 |
<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<TemplateSpecializationType>...</td></tr> |
| 2890 |
<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. |
| 2891 |
|
| 2892 |
Given |
| 2893 |
template <typename T> |
| 2894 |
class C { }; |
| 2895 |
|
| 2896 |
template class C<int>; // A |
| 2897 |
C<char> var; // B |
| 2898 |
|
| 2899 |
templateSpecializationType() matches the type of the explicit |
| 2900 |
instantiation in A and the type of the variable declaration in B. |
| 2901 |
</pre></td></tr> |
| 2902 |
|
| 2903 |
|
| 2904 |
<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<TemplateTypeParmType>...</td></tr> |
| 2905 |
<tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types. |
| 2906 |
|
| 2907 |
Example matches T, but not int. |
| 2908 |
(matcher = templateTypeParmType()) |
| 2909 |
template <typename T> void f(int i); |
| 2910 |
</pre></td></tr> |
| 2911 |
|
| 2912 |
|
| 2913 |
<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> |
| 2914 |
<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. |
| 2915 |
</pre></td></tr> |
| 2916 |
|
| 2917 |
|
| 2918 |
<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> |
| 2919 |
<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. |
| 2920 |
|
| 2921 |
Given |
| 2922 |
typedef int X; |
| 2923 |
typedefType() |
| 2924 |
matches "typedef int X" |
| 2925 |
</pre></td></tr> |
| 2926 |
|
| 2927 |
|
| 2928 |
<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<UnaryTransformType>...</td></tr> |
| 2929 |
<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. |
| 2930 |
|
| 2931 |
Given: |
| 2932 |
typedef __underlying_type(T) type; |
| 2933 |
unaryTransformType() |
| 2934 |
matches "__underlying_type(T)" |
| 2935 |
</pre></td></tr> |
| 2936 |
|
| 2937 |
|
| 2938 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('usingType0')"><a name="usingType0Anchor">usingType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>>...</td></tr> |
| 2939 |
<tr><td colspan="4" class="doc" id="usingType0"><pre>Matches types specified through a using declaration. |
| 2940 |
|
| 2941 |
Given |
| 2942 |
namespace a { struct S {}; } |
| 2943 |
using a::S; |
| 2944 |
S s; |
| 2945 |
|
| 2946 |
usingType() matches the type of the variable declaration of s. |
| 2947 |
</pre></td></tr> |
| 2948 |
|
| 2949 |
|
| 2950 |
<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> |
| 2951 |
<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an |
| 2952 |
integer-constant-expression. |
| 2953 |
|
| 2954 |
Given |
| 2955 |
void f() { |
| 2956 |
int a[] = { 2, 3 } |
| 2957 |
int b[42]; |
| 2958 |
int c[a[0]]; |
| 2959 |
} |
| 2960 |
variableArrayType() |
| 2961 |
matches "int c[a[0]]" |
| 2962 |
</pre></td></tr> |
| 2963 |
|
| 2964 |
<!--END_DECL_MATCHERS --> |
| 2965 |
</table> |
| 2966 |
|
| 2967 |
<!-- ======================================================================= --> |
| 2968 |
<h2 id="narrowing-matchers">Narrowing Matchers</h2> |
| 2969 |
<!-- ======================================================================= --> |
| 2970 |
|
| 2971 |
<p>Narrowing matchers match certain attributes on the current node, thus |
| 2972 |
narrowing down the set of nodes of the current type to match on.</p> |
| 2973 |
|
| 2974 |
<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) |
| 2975 |
which allow users to create more powerful match expressions.</p> |
| 2976 |
|
| 2977 |
<table> |
| 2978 |
<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| 2979 |
<!-- START_NARROWING_MATCHERS --> |
| 2980 |
|
| 2981 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 2982 |
<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. |
| 2983 |
|
| 2984 |
Usable as: Any Matcher |
| 2985 |
</pre></td></tr> |
| 2986 |
|
| 2987 |
|
| 2988 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 2989 |
<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. |
| 2990 |
|
| 2991 |
Usable as: Any Matcher |
| 2992 |
</pre></td></tr> |
| 2993 |
|
| 2994 |
|
| 2995 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> |
| 2996 |
<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. |
| 2997 |
|
| 2998 |
Useful when another matcher requires a child matcher, but there's no |
| 2999 |
additional constraint. This will often be used with an explicit conversion |
| 3000 |
to an internal::Matcher<> type such as TypeMatcher. |
| 3001 |
|
| 3002 |
Example: DeclarationMatcher(anything()) matches all declarations, e.g., |
| 3003 |
"int* p" and "void f()" in |
| 3004 |
int* p; |
| 3005 |
void f(); |
| 3006 |
|
| 3007 |
Usable as: Any Matcher |
| 3008 |
</pre></td></tr> |
| 3009 |
|
| 3010 |
|
| 3011 |
<tr><td><em>unspecified</em></td><td class="name" onclick="toggle('mapAnyOf0')"><a name="mapAnyOf0Anchor">mapAnyOf</a></td><td>nodeMatcherFunction...</td></tr> |
| 3012 |
<tr><td colspan="4" class="doc" id="mapAnyOf0"><pre>Matches any of the NodeMatchers with InnerMatchers nested within |
| 3013 |
|
| 3014 |
Given |
| 3015 |
if (true); |
| 3016 |
for (; true; ); |
| 3017 |
with the matcher |
| 3018 |
mapAnyOf(ifStmt, forStmt).with( |
| 3019 |
hasCondition(cxxBoolLiteralExpr(equals(true))) |
| 3020 |
).bind("trueCond") |
| 3021 |
matches the if and the for. It is equivalent to: |
| 3022 |
auto trueCond = hasCondition(cxxBoolLiteralExpr(equals(true))); |
| 3023 |
anyOf( |
| 3024 |
ifStmt(trueCond).bind("trueCond"), |
| 3025 |
forStmt(trueCond).bind("trueCond") |
| 3026 |
); |
| 3027 |
|
| 3028 |
The with() chain-call accepts zero or more matchers which are combined |
| 3029 |
as-if with allOf() in each of the node matchers. |
| 3030 |
Usable as: Any Matcher |
| 3031 |
</pre></td></tr> |
| 3032 |
|
| 3033 |
|
| 3034 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> |
| 3035 |
<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. |
| 3036 |
|
| 3037 |
Example matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) |
| 3038 |
class X {}; |
| 3039 |
class Y {}; |
| 3040 |
|
| 3041 |
Usable as: Any Matcher |
| 3042 |
</pre></td></tr> |
| 3043 |
|
| 3044 |
|
| 3045 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>></td><td class="name" onclick="toggle('isImplicit1')"><a name="isImplicit1Anchor">isImplicit</a></td><td></td></tr> |
| 3046 |
<tr><td colspan="4" class="doc" id="isImplicit1"><pre>Matches an entity that has been implicitly added by the compiler (e.g. |
| 3047 |
implicit default/copy constructors). |
| 3048 |
</pre></td></tr> |
| 3049 |
|
| 3050 |
|
| 3051 |
<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> |
| 3052 |
<tr><td colspan="4" class="doc" id="hasAnyOperatorName0"><pre>Matches operator expressions (binary or unary) that have any of the |
| 3053 |
specified names. |
| 3054 |
|
| 3055 |
hasAnyOperatorName("+", "-") |
| 3056 |
Is equivalent to |
| 3057 |
anyOf(hasOperatorName("+"), hasOperatorName("-")) |
| 3058 |
</pre></td></tr> |
| 3059 |
|
| 3060 |
|
| 3061 |
<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> |
| 3062 |
<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions and fold expressions |
| 3063 |
(binary or unary). |
| 3064 |
|
| 3065 |
Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 3066 |
!(a || b) |
| 3067 |
|
| 3068 |
Example matches `(0 + ... + args)` |
| 3069 |
(matcher = cxxFoldExpr(hasOperatorName("+"))) |
| 3070 |
template <typename... Args> |
| 3071 |
auto sum(Args... args) { |
| 3072 |
return (0 + ... + args); |
| 3073 |
} |
| 3074 |
</pre></td></tr> |
| 3075 |
|
| 3076 |
|
| 3077 |
<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> |
| 3078 |
<tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators. |
| 3079 |
|
| 3080 |
Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) |
| 3081 |
if (a == b) |
| 3082 |
a += b; |
| 3083 |
|
| 3084 |
Example 2: matches s1 = s2 |
| 3085 |
(matcher = cxxOperatorCallExpr(isAssignmentOperator())) |
| 3086 |
struct S { S& operator=(const S&); }; |
| 3087 |
void x() { S s1, s2; s1 = s2; } |
| 3088 |
</pre></td></tr> |
| 3089 |
|
| 3090 |
|
| 3091 |
<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> |
| 3092 |
<tr><td colspan="4" class="doc" id="isComparisonOperator0"><pre>Matches comparison operators. |
| 3093 |
|
| 3094 |
Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator())) |
| 3095 |
if (a == b) |
| 3096 |
a += b; |
| 3097 |
|
| 3098 |
Example 2: matches s1 < s2 |
| 3099 |
(matcher = cxxOperatorCallExpr(isComparisonOperator())) |
| 3100 |
struct S { bool operator<(const S& other); }; |
| 3101 |
void x(S s1, S s2) { bool b1 = s1 < s2; } |
| 3102 |
</pre></td></tr> |
| 3103 |
|
| 3104 |
|
| 3105 |
<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> |
| 3106 |
<tr><td colspan="4" class="doc" id="isPrivate1"><pre>Matches private C++ declarations and C++ base specifiers that specify |
| 3107 |
private inheritance. |
| 3108 |
|
| 3109 |
Examples: |
| 3110 |
class C { |
| 3111 |
public: int a; |
| 3112 |
protected: int b; |
| 3113 |
private: int c; // fieldDecl(isPrivate()) matches 'c' |
| 3114 |
}; |
| 3115 |
|
| 3116 |
struct Base {}; |
| 3117 |
struct Derived1 : private Base {}; // matches 'Base' |
| 3118 |
class Derived2 : Base {}; // matches 'Base' |
| 3119 |
</pre></td></tr> |
| 3120 |
|
| 3121 |
|
| 3122 |
<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> |
| 3123 |
<tr><td colspan="4" class="doc" id="isProtected1"><pre>Matches protected C++ declarations and C++ base specifiers that specify |
| 3124 |
protected inheritance. |
| 3125 |
|
| 3126 |
Examples: |
| 3127 |
class C { |
| 3128 |
public: int a; |
| 3129 |
protected: int b; // fieldDecl(isProtected()) matches 'b' |
| 3130 |
private: int c; |
| 3131 |
}; |
| 3132 |
|
| 3133 |
class Base {}; |
| 3134 |
class Derived : protected Base {}; // matches 'Base' |
| 3135 |
</pre></td></tr> |
| 3136 |
|
| 3137 |
|
| 3138 |
<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> |
| 3139 |
<tr><td colspan="4" class="doc" id="isPublic1"><pre>Matches public C++ declarations and C++ base specifiers that specify public |
| 3140 |
inheritance. |
| 3141 |
|
| 3142 |
Examples: |
| 3143 |
class C { |
| 3144 |
public: int a; // fieldDecl(isPublic()) matches 'a' |
| 3145 |
protected: int b; |
| 3146 |
private: int c; |
| 3147 |
}; |
| 3148 |
|
| 3149 |
class Base {}; |
| 3150 |
class Derived1 : public Base {}; // matches 'Base' |
| 3151 |
struct Derived2 : Base {}; // matches 'Base' |
| 3152 |
</pre></td></tr> |
| 3153 |
|
| 3154 |
|
| 3155 |
<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> |
| 3156 |
<tr><td colspan="4" class="doc" id="isVirtual1"><pre>Matches declarations of virtual methods and C++ base specifiers that specify |
| 3157 |
virtual inheritance. |
| 3158 |
|
| 3159 |
Example: |
| 3160 |
class A { |
| 3161 |
public: |
| 3162 |
virtual void x(); // matches x |
| 3163 |
}; |
| 3164 |
|
| 3165 |
Example: |
| 3166 |
class Base {}; |
| 3167 |
class DirectlyDerived : virtual Base {}; // matches Base |
| 3168 |
class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base |
| 3169 |
|
| 3170 |
Usable 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>> |
| 3171 |
</pre></td></tr> |
| 3172 |
|
| 3173 |
|
| 3174 |
<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> |
| 3175 |
<tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr> |
| 3176 |
|
| 3177 |
|
| 3178 |
<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> |
| 3179 |
<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT. |
| 3180 |
|
| 3181 |
Given |
| 3182 |
f('false, 3.14, 42); |
| 3183 |
characterLiteral(equals(0)) |
| 3184 |
matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| 3185 |
match false |
| 3186 |
floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| 3187 |
match 3.14 |
| 3188 |
integerLiteral(equals(42)) |
| 3189 |
matches 42 |
| 3190 |
|
| 3191 |
Note that you cannot directly match a negative numeric literal because the |
| 3192 |
minus sign is not part of the literal: It is a unary operator whose operand |
| 3193 |
is the positive numeric literal. Instead, you must use a unaryOperator() |
| 3194 |
matcher to match the minus sign: |
| 3195 |
|
| 3196 |
unaryOperator(hasOperatorName("-"), |
| 3197 |
hasUnaryOperand(integerLiteral(equals(13)))) |
| 3198 |
|
| 3199 |
Usable 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>>, |
| 3200 |
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>> |
| 3201 |
</pre></td></tr> |
| 3202 |
|
| 3203 |
|
| 3204 |
<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> |
| 3205 |
<tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr> |
| 3206 |
|
| 3207 |
|
| 3208 |
<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> |
| 3209 |
<tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr> |
| 3210 |
|
| 3211 |
|
| 3212 |
<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> |
| 3213 |
<tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. |
| 3214 |
|
| 3215 |
Given |
| 3216 |
try { |
| 3217 |
// ... |
| 3218 |
} catch (int) { |
| 3219 |
// ... |
| 3220 |
} catch (...) { |
| 3221 |
// ... |
| 3222 |
} |
| 3223 |
cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). |
| 3224 |
</pre></td></tr> |
| 3225 |
|
| 3226 |
|
| 3227 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('argumentCountAtLeast1')"><a name="argumentCountAtLeast1Anchor">argumentCountAtLeast</a></td><td>unsigned N</td></tr> |
| 3228 |
<tr><td colspan="4" class="doc" id="argumentCountAtLeast1"><pre>Checks that a call expression or a constructor call expression has at least |
| 3229 |
the specified number of arguments (including absent default arguments). |
| 3230 |
|
| 3231 |
Example matches f(0, 0) and g(0, 0, 0) |
| 3232 |
(matcher = callExpr(argumentCountAtLeast(2))) |
| 3233 |
void f(int x, int y); |
| 3234 |
void g(int x, int y, int z); |
| 3235 |
f(0, 0); |
| 3236 |
g(0, 0, 0); |
| 3237 |
</pre></td></tr> |
| 3238 |
|
| 3239 |
|
| 3240 |
<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> |
| 3241 |
<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has |
| 3242 |
a specific number of arguments (including absent default arguments). |
| 3243 |
|
| 3244 |
Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 3245 |
void f(int x, int y); |
| 3246 |
f(0, 0); |
| 3247 |
</pre></td></tr> |
| 3248 |
|
| 3249 |
|
| 3250 |
<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> |
| 3251 |
<tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. |
| 3252 |
</pre></td></tr> |
| 3253 |
|
| 3254 |
|
| 3255 |
<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> |
| 3256 |
<tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires |
| 3257 |
zero initialization. |
| 3258 |
|
| 3259 |
Given |
| 3260 |
void foo() { |
| 3261 |
struct point { double x; double y; }; |
| 3262 |
point pt[2] = { { 1.0, 2.0 } }; |
| 3263 |
} |
| 3264 |
initListExpr(has(cxxConstructExpr(requiresZeroInitialization())) |
| 3265 |
will match the implicit array filler for pt[1]. |
| 3266 |
</pre></td></tr> |
| 3267 |
|
| 3268 |
|
| 3269 |
<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> |
| 3270 |
<tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. |
| 3271 |
|
| 3272 |
Given |
| 3273 |
struct S { |
| 3274 |
S(); // #1 |
| 3275 |
S(const S &); // #2 |
| 3276 |
S(S &&); // #3 |
| 3277 |
}; |
| 3278 |
cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. |
| 3279 |
</pre></td></tr> |
| 3280 |
|
| 3281 |
|
| 3282 |
<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> |
| 3283 |
<tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. |
| 3284 |
|
| 3285 |
Given |
| 3286 |
struct S { |
| 3287 |
S(); // #1 |
| 3288 |
S(const S &); // #2 |
| 3289 |
S(S &&); // #3 |
| 3290 |
}; |
| 3291 |
cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. |
| 3292 |
</pre></td></tr> |
| 3293 |
|
| 3294 |
|
| 3295 |
<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> |
| 3296 |
<tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor. |
| 3297 |
|
| 3298 |
Given |
| 3299 |
struct S { |
| 3300 |
S(); // #1 |
| 3301 |
S(int) {} // #2 |
| 3302 |
S(S &&) : S() {} // #3 |
| 3303 |
}; |
| 3304 |
S::S() : S(0) {} // #4 |
| 3305 |
cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not |
| 3306 |
#1 or #2. |
| 3307 |
</pre></td></tr> |
| 3308 |
|
| 3309 |
|
| 3310 |
<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> |
| 3311 |
<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor, conversion function, and deduction guide declarations |
| 3312 |
that have an explicit specifier if this explicit specifier is resolved to |
| 3313 |
true. |
| 3314 |
|
| 3315 |
Given |
| 3316 |
template<bool b> |
| 3317 |
struct S { |
| 3318 |
S(int); // #1 |
| 3319 |
explicit S(double); // #2 |
| 3320 |
operator int(); // #3 |
| 3321 |
explicit operator bool(); // #4 |
| 3322 |
explicit(false) S(bool) // # 7 |
| 3323 |
explicit(true) S(char) // # 8 |
| 3324 |
explicit(b) S(S) // # 9 |
| 3325 |
}; |
| 3326 |
S(int) -> S<true> // #5 |
| 3327 |
explicit S(double) -> S<false> // #6 |
| 3328 |
cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. |
| 3329 |
cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| 3330 |
cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5. |
| 3331 |
</pre></td></tr> |
| 3332 |
|
| 3333 |
|
| 3334 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isInheritingConstructor0')"><a name="isInheritingConstructor0Anchor">isInheritingConstructor</a></td><td></td></tr> |
| 3335 |
<tr><td colspan="4" class="doc" id="isInheritingConstructor0"><pre></pre></td></tr> |
| 3336 |
|
| 3337 |
|
| 3338 |
<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> |
| 3339 |
<tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. |
| 3340 |
|
| 3341 |
Given |
| 3342 |
struct S { |
| 3343 |
S(); // #1 |
| 3344 |
S(const S &); // #2 |
| 3345 |
S(S &&); // #3 |
| 3346 |
}; |
| 3347 |
cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. |
| 3348 |
</pre></td></tr> |
| 3349 |
|
| 3350 |
|
| 3351 |
<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> |
| 3352 |
<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor, conversion function, and deduction guide declarations |
| 3353 |
that have an explicit specifier if this explicit specifier is resolved to |
| 3354 |
true. |
| 3355 |
|
| 3356 |
Given |
| 3357 |
template<bool b> |
| 3358 |
struct S { |
| 3359 |
S(int); // #1 |
| 3360 |
explicit S(double); // #2 |
| 3361 |
operator int(); // #3 |
| 3362 |
explicit operator bool(); // #4 |
| 3363 |
explicit(false) S(bool) // # 7 |
| 3364 |
explicit(true) S(char) // # 8 |
| 3365 |
explicit(b) S(S) // # 9 |
| 3366 |
}; |
| 3367 |
S(int) -> S<true> // #5 |
| 3368 |
explicit S(double) -> S<false> // #6 |
| 3369 |
cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. |
| 3370 |
cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| 3371 |
cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5. |
| 3372 |
</pre></td></tr> |
| 3373 |
|
| 3374 |
|
| 3375 |
<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> |
| 3376 |
<tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as |
| 3377 |
opposed to a member. |
| 3378 |
|
| 3379 |
Given |
| 3380 |
struct B {}; |
| 3381 |
struct D : B { |
| 3382 |
int I; |
| 3383 |
D(int i) : I(i) {} |
| 3384 |
}; |
| 3385 |
struct E : B { |
| 3386 |
E() : B() {} |
| 3387 |
}; |
| 3388 |
cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) |
| 3389 |
will match E(), but not match D(int). |
| 3390 |
</pre></td></tr> |
| 3391 |
|
| 3392 |
|
| 3393 |
<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> |
| 3394 |
<tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as |
| 3395 |
opposed to a base. |
| 3396 |
|
| 3397 |
Given |
| 3398 |
struct B {}; |
| 3399 |
struct D : B { |
| 3400 |
int I; |
| 3401 |
D(int i) : I(i) {} |
| 3402 |
}; |
| 3403 |
struct E : B { |
| 3404 |
E() : B() {} |
| 3405 |
}; |
| 3406 |
cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) |
| 3407 |
will match D(int), but not match E(). |
| 3408 |
</pre></td></tr> |
| 3409 |
|
| 3410 |
|
| 3411 |
<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> |
| 3412 |
<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in |
| 3413 |
code (as opposed to implicitly added by the compiler). |
| 3414 |
|
| 3415 |
Given |
| 3416 |
struct Foo { |
| 3417 |
Foo() { } |
| 3418 |
Foo(int) : foo_("A") { } |
| 3419 |
string foo_; |
| 3420 |
}; |
| 3421 |
cxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) |
| 3422 |
will match Foo(int), but not Foo() |
| 3423 |
</pre></td></tr> |
| 3424 |
|
| 3425 |
|
| 3426 |
<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> |
| 3427 |
<tr><td colspan="4" class="doc" id="isExplicit2"><pre>Matches constructor, conversion function, and deduction guide declarations |
| 3428 |
that have an explicit specifier if this explicit specifier is resolved to |
| 3429 |
true. |
| 3430 |
|
| 3431 |
Given |
| 3432 |
template<bool b> |
| 3433 |
struct S { |
| 3434 |
S(int); // #1 |
| 3435 |
explicit S(double); // #2 |
| 3436 |
operator int(); // #3 |
| 3437 |
explicit operator bool(); // #4 |
| 3438 |
explicit(false) S(bool) // # 7 |
| 3439 |
explicit(true) S(char) // # 8 |
| 3440 |
explicit(b) S(S) // # 9 |
| 3441 |
}; |
| 3442 |
S(int) -> S<true> // #5 |
| 3443 |
explicit S(double) -> S<false> // #6 |
| 3444 |
cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. |
| 3445 |
cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| 3446 |
cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5. |
| 3447 |
</pre></td></tr> |
| 3448 |
|
| 3449 |
|
| 3450 |
<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> |
| 3451 |
<tr><td colspan="4" class="doc" id="hasMemberName0"><pre>Matches template-dependent, but known, member names. |
| 3452 |
|
| 3453 |
In template declarations, dependent members are not resolved and so can |
| 3454 |
not be matched to particular named declarations. |
| 3455 |
|
| 3456 |
This matcher allows to match on the known name of members. |
| 3457 |
|
| 3458 |
Given |
| 3459 |
template <typename T> |
| 3460 |
struct S { |
| 3461 |
void mem(); |
| 3462 |
}; |
| 3463 |
template <typename T> |
| 3464 |
void x() { |
| 3465 |
S<T> s; |
| 3466 |
s.mem(); |
| 3467 |
} |
| 3468 |
cxxDependentScopeMemberExpr(hasMemberName("mem")) matches `s.mem()` |
| 3469 |
</pre></td></tr> |
| 3470 |
|
| 3471 |
|
| 3472 |
<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> |
| 3473 |
<tr><td colspan="4" class="doc" id="isArrow2"><pre>Matches member expressions that are called with '->' as opposed |
| 3474 |
to '.'. |
| 3475 |
|
| 3476 |
Member calls on the implicit this pointer match as called with '->'. |
| 3477 |
|
| 3478 |
Given |
| 3479 |
class Y { |
| 3480 |
void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 3481 |
template <class T> void f() { this->f<T>(); f<T>(); } |
| 3482 |
int a; |
| 3483 |
static int b; |
| 3484 |
}; |
| 3485 |
template <class T> |
| 3486 |
class Z { |
| 3487 |
void x() { this->m; } |
| 3488 |
}; |
| 3489 |
memberExpr(isArrow()) |
| 3490 |
matches this->x, x, y.x, a, this->b |
| 3491 |
cxxDependentScopeMemberExpr(isArrow()) |
| 3492 |
matches this->m |
| 3493 |
unresolvedMemberExpr(isArrow()) |
| 3494 |
matches this->f<T>, f<T> |
| 3495 |
</pre></td></tr> |
| 3496 |
|
| 3497 |
|
| 3498 |
<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> |
| 3499 |
<tr><td colspan="4" class="doc" id="memberHasSameNameAsBoundNode0"><pre>Matches template-dependent, but known, member names against an already-bound |
| 3500 |
node |
| 3501 |
|
| 3502 |
In template declarations, dependent members are not resolved and so can |
| 3503 |
not be matched to particular named declarations. |
| 3504 |
|
| 3505 |
This matcher allows to match on the name of already-bound VarDecl, FieldDecl |
| 3506 |
and CXXMethodDecl nodes. |
| 3507 |
|
| 3508 |
Given |
| 3509 |
template <typename T> |
| 3510 |
struct S { |
| 3511 |
void mem(); |
| 3512 |
}; |
| 3513 |
template <typename T> |
| 3514 |
void x() { |
| 3515 |
S<T> s; |
| 3516 |
s.mem(); |
| 3517 |
} |
| 3518 |
The matcher |
| 3519 |
@code |
| 3520 |
cxxDependentScopeMemberExpr( |
| 3521 |
hasObjectExpression(declRefExpr(hasType(templateSpecializationType( |
| 3522 |
hasDeclaration(classTemplateDecl(has(cxxRecordDecl(has( |
| 3523 |
cxxMethodDecl(hasName("mem")).bind("templMem") |
| 3524 |
))))) |
| 3525 |
)))), |
| 3526 |
memberHasSameNameAsBoundNode("templMem") |
| 3527 |
) |
| 3528 |
@endcode |
| 3529 |
first matches and binds the @c mem member of the @c S template, then |
| 3530 |
compares its name to the usage in @c s.mem() in the @c x function template |
| 3531 |
</pre></td></tr> |
| 3532 |
|
| 3533 |
|
| 3534 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>></td><td class="name" onclick="toggle('hasOperatorName3')"><a name="hasOperatorName3Anchor">hasOperatorName</a></td><td>std::string Name</td></tr> |
| 3535 |
<tr><td colspan="4" class="doc" id="hasOperatorName3"><pre>Matches the operator Name of operator expressions and fold expressions |
| 3536 |
(binary or unary). |
| 3537 |
|
| 3538 |
Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 3539 |
!(a || b) |
| 3540 |
|
| 3541 |
Example matches `(0 + ... + args)` |
| 3542 |
(matcher = cxxFoldExpr(hasOperatorName("+"))) |
| 3543 |
template <typename... Args> |
| 3544 |
auto sum(Args... args) { |
| 3545 |
return (0 + ... + args); |
| 3546 |
} |
| 3547 |
</pre></td></tr> |
| 3548 |
|
| 3549 |
|
| 3550 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>></td><td class="name" onclick="toggle('isBinaryFold0')"><a name="isBinaryFold0Anchor">isBinaryFold</a></td><td></td></tr> |
| 3551 |
<tr><td colspan="4" class="doc" id="isBinaryFold0"><pre>Matches binary fold expressions, i.e. fold expressions with an initializer. |
| 3552 |
|
| 3553 |
Example matches `(0 + ... + args)` |
| 3554 |
(matcher = cxxFoldExpr(isBinaryFold())) |
| 3555 |
template <typename... Args> |
| 3556 |
auto sum(Args... args) { |
| 3557 |
return (0 + ... + args); |
| 3558 |
} |
| 3559 |
|
| 3560 |
template <typename... Args> |
| 3561 |
auto multiply(Args... args) { |
| 3562 |
return (args * ...); |
| 3563 |
} |
| 3564 |
</pre></td></tr> |
| 3565 |
|
| 3566 |
|
| 3567 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>></td><td class="name" onclick="toggle('isLeftFold0')"><a name="isLeftFold0Anchor">isLeftFold</a></td><td></td></tr> |
| 3568 |
<tr><td colspan="4" class="doc" id="isLeftFold0"><pre>Matches left-folding fold expressions. |
| 3569 |
|
| 3570 |
Example matches `(0 + ... + args)` |
| 3571 |
(matcher = cxxFoldExpr(isLeftFold())) |
| 3572 |
template <typename... Args> |
| 3573 |
auto sum(Args... args) { |
| 3574 |
return (0 + ... + args); |
| 3575 |
} |
| 3576 |
|
| 3577 |
template <typename... Args> |
| 3578 |
auto multiply(Args... args) { |
| 3579 |
return (args * ... * 1); |
| 3580 |
} |
| 3581 |
</pre></td></tr> |
| 3582 |
|
| 3583 |
|
| 3584 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>></td><td class="name" onclick="toggle('isRightFold0')"><a name="isRightFold0Anchor">isRightFold</a></td><td></td></tr> |
| 3585 |
<tr><td colspan="4" class="doc" id="isRightFold0"><pre>Matches right-folding fold expressions. |
| 3586 |
|
| 3587 |
Example matches `(args * ... * 1)` |
| 3588 |
(matcher = cxxFoldExpr(isRightFold())) |
| 3589 |
template <typename... Args> |
| 3590 |
auto sum(Args... args) { |
| 3591 |
return (0 + ... + args); |
| 3592 |
} |
| 3593 |
|
| 3594 |
template <typename... Args> |
| 3595 |
auto multiply(Args... args) { |
| 3596 |
return (args * ... * 1); |
| 3597 |
} |
| 3598 |
</pre></td></tr> |
| 3599 |
|
| 3600 |
|
| 3601 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>></td><td class="name" onclick="toggle('isUnaryFold0')"><a name="isUnaryFold0Anchor">isUnaryFold</a></td><td></td></tr> |
| 3602 |
<tr><td colspan="4" class="doc" id="isUnaryFold0"><pre>Matches unary fold expressions, i.e. fold expressions without an |
| 3603 |
initializer. |
| 3604 |
|
| 3605 |
Example matches `(args * ...)` |
| 3606 |
(matcher = cxxFoldExpr(isUnaryFold())) |
| 3607 |
template <typename... Args> |
| 3608 |
auto sum(Args... args) { |
| 3609 |
return (0 + ... + args); |
| 3610 |
} |
| 3611 |
|
| 3612 |
template <typename... Args> |
| 3613 |
auto multiply(Args... args) { |
| 3614 |
return (args * ...); |
| 3615 |
} |
| 3616 |
</pre></td></tr> |
| 3617 |
|
| 3618 |
|
| 3619 |
<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> |
| 3620 |
<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. |
| 3621 |
|
| 3622 |
Given |
| 3623 |
struct A { |
| 3624 |
void foo() const; |
| 3625 |
void bar(); |
| 3626 |
}; |
| 3627 |
|
| 3628 |
cxxMethodDecl(isConst()) matches A::foo() but not A::bar() |
| 3629 |
</pre></td></tr> |
| 3630 |
|
| 3631 |
|
| 3632 |
<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> |
| 3633 |
<tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment |
| 3634 |
operator. |
| 3635 |
|
| 3636 |
Given |
| 3637 |
struct A { |
| 3638 |
A &operator=(const A &); |
| 3639 |
A &operator=(A &&); |
| 3640 |
}; |
| 3641 |
|
| 3642 |
cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not |
| 3643 |
the second one. |
| 3644 |
</pre></td></tr> |
| 3645 |
|
| 3646 |
|
| 3647 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isExplicitObjectMemberFunction0')"><a name="isExplicitObjectMemberFunction0Anchor">isExplicitObjectMemberFunction</a></td><td></td></tr> |
| 3648 |
<tr><td colspan="4" class="doc" id="isExplicitObjectMemberFunction0"><pre>Matches if the given method declaration declares a member function with an |
| 3649 |
explicit object parameter. |
| 3650 |
|
| 3651 |
Given |
| 3652 |
struct A { |
| 3653 |
int operator-(this A, int); |
| 3654 |
void fun(this A &&self); |
| 3655 |
static int operator()(int); |
| 3656 |
int operator+(int); |
| 3657 |
}; |
| 3658 |
|
| 3659 |
cxxMethodDecl(isExplicitObjectMemberFunction()) matches the first two |
| 3660 |
methods but not the last two. |
| 3661 |
</pre></td></tr> |
| 3662 |
|
| 3663 |
|
| 3664 |
<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> |
| 3665 |
<tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. |
| 3666 |
|
| 3667 |
Given: |
| 3668 |
class A final {}; |
| 3669 |
|
| 3670 |
struct B { |
| 3671 |
virtual void f(); |
| 3672 |
}; |
| 3673 |
|
| 3674 |
struct C : B { |
| 3675 |
void f() final; |
| 3676 |
}; |
| 3677 |
matches A and C::f, but not B, C, or B::f |
| 3678 |
</pre></td></tr> |
| 3679 |
|
| 3680 |
|
| 3681 |
<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> |
| 3682 |
<tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment |
| 3683 |
operator. |
| 3684 |
|
| 3685 |
Given |
| 3686 |
struct A { |
| 3687 |
A &operator=(const A &); |
| 3688 |
A &operator=(A &&); |
| 3689 |
}; |
| 3690 |
|
| 3691 |
cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not |
| 3692 |
the first one. |
| 3693 |
</pre></td></tr> |
| 3694 |
|
| 3695 |
|
| 3696 |
<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> |
| 3697 |
<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. |
| 3698 |
|
| 3699 |
Given |
| 3700 |
class A { |
| 3701 |
public: |
| 3702 |
virtual void x(); |
| 3703 |
}; |
| 3704 |
class B : public A { |
| 3705 |
public: |
| 3706 |
virtual void x(); |
| 3707 |
}; |
| 3708 |
matches B::x |
| 3709 |
</pre></td></tr> |
| 3710 |
|
| 3711 |
|
| 3712 |
<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> |
| 3713 |
<tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. |
| 3714 |
|
| 3715 |
Given |
| 3716 |
class A { |
| 3717 |
public: |
| 3718 |
virtual void x() = 0; |
| 3719 |
}; |
| 3720 |
matches A::x |
| 3721 |
</pre></td></tr> |
| 3722 |
|
| 3723 |
|
| 3724 |
<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> |
| 3725 |
<tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided. |
| 3726 |
|
| 3727 |
Given |
| 3728 |
struct S { |
| 3729 |
S(); // #1 |
| 3730 |
S(const S &) = default; // #2 |
| 3731 |
S(S &&) = delete; // #3 |
| 3732 |
}; |
| 3733 |
cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3. |
| 3734 |
</pre></td></tr> |
| 3735 |
|
| 3736 |
|
| 3737 |
<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> |
| 3738 |
<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches declarations of virtual methods and C++ base specifiers that specify |
| 3739 |
virtual inheritance. |
| 3740 |
|
| 3741 |
Example: |
| 3742 |
class A { |
| 3743 |
public: |
| 3744 |
virtual void x(); // matches x |
| 3745 |
}; |
| 3746 |
|
| 3747 |
Example: |
| 3748 |
class Base {}; |
| 3749 |
class DirectlyDerived : virtual Base {}; // matches Base |
| 3750 |
class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base |
| 3751 |
|
| 3752 |
Usable 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>> |
| 3753 |
</pre></td></tr> |
| 3754 |
|
| 3755 |
|
| 3756 |
<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> |
| 3757 |
<tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual". |
| 3758 |
|
| 3759 |
Given |
| 3760 |
class A { |
| 3761 |
public: |
| 3762 |
virtual void x(); |
| 3763 |
}; |
| 3764 |
class B : public A { |
| 3765 |
public: |
| 3766 |
void x(); |
| 3767 |
}; |
| 3768 |
matches A::x but not B::x |
| 3769 |
</pre></td></tr> |
| 3770 |
|
| 3771 |
|
| 3772 |
<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> |
| 3773 |
<tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions. |
| 3774 |
|
| 3775 |
Given: |
| 3776 |
MyClass *p1 = new MyClass[10]; |
| 3777 |
cxxNewExpr(isArray()) |
| 3778 |
matches the expression 'new MyClass[10]'. |
| 3779 |
</pre></td></tr> |
| 3780 |
|
| 3781 |
|
| 3782 |
<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> |
| 3783 |
<tr><td colspan="4" class="doc" id="hasAnyOperatorName1"><pre>Matches operator expressions (binary or unary) that have any of the |
| 3784 |
specified names. |
| 3785 |
|
| 3786 |
hasAnyOperatorName("+", "-") |
| 3787 |
Is equivalent to |
| 3788 |
anyOf(hasOperatorName("+"), hasOperatorName("-")) |
| 3789 |
</pre></td></tr> |
| 3790 |
|
| 3791 |
|
| 3792 |
<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> |
| 3793 |
<tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName0"><pre>Matches overloaded operator names. |
| 3794 |
|
| 3795 |
Matches overloaded operator names specified in strings without the |
| 3796 |
"operator" prefix: e.g. "<<". |
| 3797 |
|
| 3798 |
hasAnyOverloadedOperatorName("+", "-") |
| 3799 |
Is equivalent to |
| 3800 |
anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-")) |
| 3801 |
</pre></td></tr> |
| 3802 |
|
| 3803 |
|
| 3804 |
<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> |
| 3805 |
<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions and fold expressions |
| 3806 |
(binary or unary). |
| 3807 |
|
| 3808 |
Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 3809 |
!(a || b) |
| 3810 |
|
| 3811 |
Example matches `(0 + ... + args)` |
| 3812 |
(matcher = cxxFoldExpr(hasOperatorName("+"))) |
| 3813 |
template <typename... Args> |
| 3814 |
auto sum(Args... args) { |
| 3815 |
return (0 + ... + args); |
| 3816 |
} |
| 3817 |
</pre></td></tr> |
| 3818 |
|
| 3819 |
|
| 3820 |
<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> |
| 3821 |
<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. |
| 3822 |
|
| 3823 |
Matches overloaded operator names specified in strings without the |
| 3824 |
"operator" prefix: e.g. "<<". |
| 3825 |
|
| 3826 |
Given: |
| 3827 |
class A { int operator*(); }; |
| 3828 |
const A &operator<<(const A &a, const A &b); |
| 3829 |
A a; |
| 3830 |
a << a; // <-- This matches |
| 3831 |
|
| 3832 |
cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the |
| 3833 |
specified line and |
| 3834 |
cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) |
| 3835 |
matches the declaration of A. |
| 3836 |
|
| 3837 |
Usable 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>> |
| 3838 |
</pre></td></tr> |
| 3839 |
|
| 3840 |
|
| 3841 |
<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> |
| 3842 |
<tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators. |
| 3843 |
|
| 3844 |
Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) |
| 3845 |
if (a == b) |
| 3846 |
a += b; |
| 3847 |
|
| 3848 |
Example 2: matches s1 = s2 |
| 3849 |
(matcher = cxxOperatorCallExpr(isAssignmentOperator())) |
| 3850 |
struct S { S& operator=(const S&); }; |
| 3851 |
void x() { S s1, s2; s1 = s2; } |
| 3852 |
</pre></td></tr> |
| 3853 |
|
| 3854 |
|
| 3855 |
<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> |
| 3856 |
<tr><td colspan="4" class="doc" id="isComparisonOperator1"><pre>Matches comparison operators. |
| 3857 |
|
| 3858 |
Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator())) |
| 3859 |
if (a == b) |
| 3860 |
a += b; |
| 3861 |
|
| 3862 |
Example 2: matches s1 < s2 |
| 3863 |
(matcher = cxxOperatorCallExpr(isComparisonOperator())) |
| 3864 |
struct S { bool operator<(const S& other); }; |
| 3865 |
void x(S s1, S s2) { bool b1 = s1 < s2; } |
| 3866 |
</pre></td></tr> |
| 3867 |
|
| 3868 |
|
| 3869 |
<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> |
| 3870 |
<tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined. |
| 3871 |
|
| 3872 |
Example matches x (matcher = cxxRecordDecl(hasDefinition())) |
| 3873 |
class x {}; |
| 3874 |
class y; |
| 3875 |
</pre></td></tr> |
| 3876 |
|
| 3877 |
|
| 3878 |
<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> |
| 3879 |
<tr><td colspan="4" class="doc" id="isDerivedFrom2"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). |
| 3880 |
</pre></td></tr> |
| 3881 |
|
| 3882 |
|
| 3883 |
<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> |
| 3884 |
<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom2"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)). |
| 3885 |
</pre></td></tr> |
| 3886 |
|
| 3887 |
|
| 3888 |
<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> |
| 3889 |
<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or |
| 3890 |
static member variable template instantiations. |
| 3891 |
|
| 3892 |
Given |
| 3893 |
template<typename T> void A(T t) { } |
| 3894 |
template<> void A(int N) { } |
| 3895 |
functionDecl(isExplicitTemplateSpecialization()) |
| 3896 |
matches the specialization A<int>(). |
| 3897 |
|
| 3898 |
Usable 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>> |
| 3899 |
</pre></td></tr> |
| 3900 |
|
| 3901 |
|
| 3902 |
<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> |
| 3903 |
<tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. |
| 3904 |
|
| 3905 |
Given: |
| 3906 |
class A final {}; |
| 3907 |
|
| 3908 |
struct B { |
| 3909 |
virtual void f(); |
| 3910 |
}; |
| 3911 |
|
| 3912 |
struct C : B { |
| 3913 |
void f() final; |
| 3914 |
}; |
| 3915 |
matches A and C::f, but not B, C, or B::f |
| 3916 |
</pre></td></tr> |
| 3917 |
|
| 3918 |
|
| 3919 |
<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> |
| 3920 |
<tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions. |
| 3921 |
|
| 3922 |
Given: |
| 3923 |
auto x = []{}; |
| 3924 |
|
| 3925 |
cxxRecordDecl(isLambda()) matches the implicit class declaration of |
| 3926 |
decltype(x) |
| 3927 |
</pre></td></tr> |
| 3928 |
|
| 3929 |
|
| 3930 |
<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> |
| 3931 |
<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom2"><pre>Overloaded method as shortcut for |
| 3932 |
isSameOrDerivedFrom(hasName(...)). |
| 3933 |
</pre></td></tr> |
| 3934 |
|
| 3935 |
|
| 3936 |
<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> |
| 3937 |
<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static |
| 3938 |
member variable template instantiations. |
| 3939 |
|
| 3940 |
Given |
| 3941 |
template <typename T> class X {}; class A {}; X<A> x; |
| 3942 |
or |
| 3943 |
template <typename T> class X {}; class A {}; template class X<A>; |
| 3944 |
or |
| 3945 |
template <typename T> class X {}; class A {}; extern template class X<A>; |
| 3946 |
cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 3947 |
matches the template instantiation of X<A>. |
| 3948 |
|
| 3949 |
But given |
| 3950 |
template <typename T> class X {}; class A {}; |
| 3951 |
template <> class X<A> {}; X<A> x; |
| 3952 |
cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 3953 |
does not match, as X<A> is an explicit template specialization. |
| 3954 |
|
| 3955 |
Usable 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>> |
| 3956 |
</pre></td></tr> |
| 3957 |
|
| 3958 |
|
| 3959 |
<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> |
| 3960 |
<tr><td colspan="4" class="doc" id="hasAnyOperatorName2"><pre>Matches operator expressions (binary or unary) that have any of the |
| 3961 |
specified names. |
| 3962 |
|
| 3963 |
hasAnyOperatorName("+", "-") |
| 3964 |
Is equivalent to |
| 3965 |
anyOf(hasOperatorName("+"), hasOperatorName("-")) |
| 3966 |
</pre></td></tr> |
| 3967 |
|
| 3968 |
|
| 3969 |
<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> |
| 3970 |
<tr><td colspan="4" class="doc" id="hasOperatorName2"><pre>Matches the operator Name of operator expressions and fold expressions |
| 3971 |
(binary or unary). |
| 3972 |
|
| 3973 |
Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 3974 |
!(a || b) |
| 3975 |
|
| 3976 |
Example matches `(0 + ... + args)` |
| 3977 |
(matcher = cxxFoldExpr(hasOperatorName("+"))) |
| 3978 |
template <typename... Args> |
| 3979 |
auto sum(Args... args) { |
| 3980 |
return (0 + ... + args); |
| 3981 |
} |
| 3982 |
</pre></td></tr> |
| 3983 |
|
| 3984 |
|
| 3985 |
<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> |
| 3986 |
<tr><td colspan="4" class="doc" id="isAssignmentOperator2"><pre>Matches all kinds of assignment operators. |
| 3987 |
|
| 3988 |
Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) |
| 3989 |
if (a == b) |
| 3990 |
a += b; |
| 3991 |
|
| 3992 |
Example 2: matches s1 = s2 |
| 3993 |
(matcher = cxxOperatorCallExpr(isAssignmentOperator())) |
| 3994 |
struct S { S& operator=(const S&); }; |
| 3995 |
void x() { S s1, s2; s1 = s2; } |
| 3996 |
</pre></td></tr> |
| 3997 |
|
| 3998 |
|
| 3999 |
<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> |
| 4000 |
<tr><td colspan="4" class="doc" id="isComparisonOperator2"><pre>Matches comparison operators. |
| 4001 |
|
| 4002 |
Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator())) |
| 4003 |
if (a == b) |
| 4004 |
a += b; |
| 4005 |
|
| 4006 |
Example 2: matches s1 < s2 |
| 4007 |
(matcher = cxxOperatorCallExpr(isComparisonOperator())) |
| 4008 |
struct S { bool operator<(const S& other); }; |
| 4009 |
void x(S s1, S s2) { bool b1 = s1 < s2; } |
| 4010 |
</pre></td></tr> |
| 4011 |
|
| 4012 |
|
| 4013 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>></td><td class="name" onclick="toggle('argumentCountAtLeast2')"><a name="argumentCountAtLeast2Anchor">argumentCountAtLeast</a></td><td>unsigned N</td></tr> |
| 4014 |
<tr><td colspan="4" class="doc" id="argumentCountAtLeast2"><pre>Checks that a call expression or a constructor call expression has at least |
| 4015 |
the specified number of arguments (including absent default arguments). |
| 4016 |
|
| 4017 |
Example matches f(0, 0) and g(0, 0, 0) |
| 4018 |
(matcher = callExpr(argumentCountAtLeast(2))) |
| 4019 |
void f(int x, int y); |
| 4020 |
void g(int x, int y, int z); |
| 4021 |
f(0, 0); |
| 4022 |
g(0, 0, 0); |
| 4023 |
</pre></td></tr> |
| 4024 |
|
| 4025 |
|
| 4026 |
<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> |
| 4027 |
<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has |
| 4028 |
a specific number of arguments (including absent default arguments). |
| 4029 |
|
| 4030 |
Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 4031 |
void f(int x, int y); |
| 4032 |
f(0, 0); |
| 4033 |
</pre></td></tr> |
| 4034 |
|
| 4035 |
|
| 4036 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('argumentCountAtLeast0')"><a name="argumentCountAtLeast0Anchor">argumentCountAtLeast</a></td><td>unsigned N</td></tr> |
| 4037 |
<tr><td colspan="4" class="doc" id="argumentCountAtLeast0"><pre>Checks that a call expression or a constructor call expression has at least |
| 4038 |
the specified number of arguments (including absent default arguments). |
| 4039 |
|
| 4040 |
Example matches f(0, 0) and g(0, 0, 0) |
| 4041 |
(matcher = callExpr(argumentCountAtLeast(2))) |
| 4042 |
void f(int x, int y); |
| 4043 |
void g(int x, int y, int z); |
| 4044 |
f(0, 0); |
| 4045 |
g(0, 0, 0); |
| 4046 |
</pre></td></tr> |
| 4047 |
|
| 4048 |
|
| 4049 |
<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> |
| 4050 |
<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has |
| 4051 |
a specific number of arguments (including absent default arguments). |
| 4052 |
|
| 4053 |
Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 4054 |
void f(int x, int y); |
| 4055 |
f(0, 0); |
| 4056 |
</pre></td></tr> |
| 4057 |
|
| 4058 |
|
| 4059 |
<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> |
| 4060 |
<tr><td colspan="4" class="doc" id="usesADL0"><pre>Matches call expressions which were resolved using ADL. |
| 4061 |
|
| 4062 |
Example matches y(x) but not y(42) or NS::y(x). |
| 4063 |
namespace NS { |
| 4064 |
struct X {}; |
| 4065 |
void y(X); |
| 4066 |
} |
| 4067 |
|
| 4068 |
void y(...); |
| 4069 |
|
| 4070 |
void test() { |
| 4071 |
NS::X x; |
| 4072 |
y(x); // Matches |
| 4073 |
NS::y(x); // Doesn't match |
| 4074 |
y(42); // Doesn't match |
| 4075 |
using NS::y; |
| 4076 |
y(x); // Found by both unqualified lookup and ADL, doesn't match |
| 4077 |
} |
| 4078 |
</pre></td></tr> |
| 4079 |
|
| 4080 |
|
| 4081 |
<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> |
| 4082 |
<tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind. |
| 4083 |
|
| 4084 |
Example: matches the implicit cast around 0 |
| 4085 |
(matcher = castExpr(hasCastKind(CK_NullToPointer))) |
| 4086 |
int *p = 0; |
| 4087 |
|
| 4088 |
If the matcher is use from clang-query, CastKind parameter |
| 4089 |
should be passed as a quoted string. e.g., hasCastKind("CK_NullToPointer"). |
| 4090 |
</pre></td></tr> |
| 4091 |
|
| 4092 |
|
| 4093 |
<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> |
| 4094 |
<tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr> |
| 4095 |
|
| 4096 |
|
| 4097 |
<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> |
| 4098 |
<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT. |
| 4099 |
|
| 4100 |
Given |
| 4101 |
f('false, 3.14, 42); |
| 4102 |
characterLiteral(equals(0)) |
| 4103 |
matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| 4104 |
match false |
| 4105 |
floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| 4106 |
match 3.14 |
| 4107 |
integerLiteral(equals(42)) |
| 4108 |
matches 42 |
| 4109 |
|
| 4110 |
Note that you cannot directly match a negative numeric literal because the |
| 4111 |
minus sign is not part of the literal: It is a unary operator whose operand |
| 4112 |
is the positive numeric literal. Instead, you must use a unaryOperator() |
| 4113 |
matcher to match the minus sign: |
| 4114 |
|
| 4115 |
unaryOperator(hasOperatorName("-"), |
| 4116 |
hasUnaryOperand(integerLiteral(equals(13)))) |
| 4117 |
|
| 4118 |
Usable 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>>, |
| 4119 |
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>> |
| 4120 |
</pre></td></tr> |
| 4121 |
|
| 4122 |
|
| 4123 |
<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> |
| 4124 |
<tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr> |
| 4125 |
|
| 4126 |
|
| 4127 |
<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> |
| 4128 |
<tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr> |
| 4129 |
|
| 4130 |
|
| 4131 |
<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> |
| 4132 |
<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. |
| 4133 |
|
| 4134 |
Given |
| 4135 |
template<typename T> struct C {}; |
| 4136 |
C<int> c; |
| 4137 |
template<typename T> void f() {} |
| 4138 |
void func() { f<int>(); }; |
| 4139 |
|
| 4140 |
classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
| 4141 |
matches C<int>. |
| 4142 |
|
| 4143 |
functionDecl(templateArgumentCountIs(1)) |
| 4144 |
matches f<int>(); |
| 4145 |
</pre></td></tr> |
| 4146 |
|
| 4147 |
|
| 4148 |
<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> |
| 4149 |
<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of |
| 4150 |
child statements. |
| 4151 |
|
| 4152 |
Example: Given |
| 4153 |
{ for (;;) {} } |
| 4154 |
compoundStmt(statementCountIs(0))) |
| 4155 |
matches '{}' |
| 4156 |
but does not match the outer compound statement. |
| 4157 |
</pre></td></tr> |
| 4158 |
|
| 4159 |
|
| 4160 |
<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> |
| 4161 |
<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size. |
| 4162 |
|
| 4163 |
Given |
| 4164 |
int a[42]; |
| 4165 |
int b[2 * 21]; |
| 4166 |
int c[41], d[43]; |
| 4167 |
char *s = "abcd"; |
| 4168 |
wchar_t *ws = L"abcd"; |
| 4169 |
char *w = "a"; |
| 4170 |
constantArrayType(hasSize(42)) |
| 4171 |
matches "int a[42]" and "int b[2 * 21]" |
| 4172 |
stringLiteral(hasSize(4)) |
| 4173 |
matches "abcd", L"abcd" |
| 4174 |
</pre></td></tr> |
| 4175 |
|
| 4176 |
|
| 4177 |
<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> |
| 4178 |
<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of |
| 4179 |
declarations. |
| 4180 |
|
| 4181 |
Example: Given |
| 4182 |
int a, b; |
| 4183 |
int c; |
| 4184 |
int d = 2, e; |
| 4185 |
declCountIs(2) |
| 4186 |
matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. |
| 4187 |
</pre></td></tr> |
| 4188 |
|
| 4189 |
|
| 4190 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('declaresSameEntityAsBoundNode0')"><a name="declaresSameEntityAsBoundNode0Anchor">declaresSameEntityAsBoundNode</a></td><td>std::string ID</td></tr> |
| 4191 |
<tr><td colspan="4" class="doc" id="declaresSameEntityAsBoundNode0"><pre>Matches a declaration if it declares the same entity as the node previously |
| 4192 |
bound to ID. |
| 4193 |
</pre></td></tr> |
| 4194 |
|
| 4195 |
|
| 4196 |
<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> |
| 4197 |
<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. |
| 4198 |
|
| 4199 |
Matches a node if it equals the node previously bound to ID. |
| 4200 |
|
| 4201 |
Given |
| 4202 |
class X { int a; int b; }; |
| 4203 |
cxxRecordDecl( |
| 4204 |
has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 4205 |
has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 4206 |
matches the class X, as a and b have the same type. |
| 4207 |
|
| 4208 |
Note that when multiple matches are involved via forEach* matchers, |
| 4209 |
equalsBoundNodes acts as a filter. |
| 4210 |
For example: |
| 4211 |
compoundStmt( |
| 4212 |
forEachDescendant(varDecl().bind("d")), |
| 4213 |
forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 4214 |
will trigger a match for each combination of variable declaration |
| 4215 |
and reference to that variable declaration within a compound statement. |
| 4216 |
</pre></td></tr> |
| 4217 |
|
| 4218 |
|
| 4219 |
<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> |
| 4220 |
<tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node. |
| 4221 |
|
| 4222 |
Decl has pointer identity in the AST. |
| 4223 |
</pre></td></tr> |
| 4224 |
|
| 4225 |
|
| 4226 |
<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> |
| 4227 |
<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. |
| 4228 |
|
| 4229 |
Given |
| 4230 |
__attribute__((device)) void f() { ... } |
| 4231 |
decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of |
| 4232 |
f. If the matcher is used from clang-query, attr::Kind parameter should be |
| 4233 |
passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). |
| 4234 |
</pre></td></tr> |
| 4235 |
|
| 4236 |
|
| 4237 |
<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> |
| 4238 |
<tr><td colspan="4" class="doc" id="isExpandedFromMacro0"><pre>Matches statements that are (transitively) expanded from the named macro. |
| 4239 |
Does not match if only part of the statement is expanded from that macro or |
| 4240 |
if different parts of the statement are expanded from different |
| 4241 |
appearances of the macro. |
| 4242 |
</pre></td></tr> |
| 4243 |
|
| 4244 |
|
| 4245 |
<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> |
| 4246 |
<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is |
| 4247 |
partially matching a given regex. |
| 4248 |
|
| 4249 |
Example matches Y but not X |
| 4250 |
(matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 4251 |
#include "ASTMatcher.h" |
| 4252 |
class X {}; |
| 4253 |
ASTMatcher.h: |
| 4254 |
class Y {}; |
| 4255 |
|
| 4256 |
Usable 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>> |
| 4257 |
|
| 4258 |
If the matcher is used in clang-query, RegexFlags parameter |
| 4259 |
should be passed as a quoted string. e.g: "NoFlags". |
| 4260 |
Flags can be combined with '|' example "IgnoreCase | BasicRegex" |
| 4261 |
</pre></td></tr> |
| 4262 |
|
| 4263 |
|
| 4264 |
<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> |
| 4265 |
<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. |
| 4266 |
|
| 4267 |
Example matches X but not Y |
| 4268 |
(matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 4269 |
#include <Y.h> |
| 4270 |
class X {}; |
| 4271 |
Y.h: |
| 4272 |
class Y {}; |
| 4273 |
|
| 4274 |
Usable 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>> |
| 4275 |
</pre></td></tr> |
| 4276 |
|
| 4277 |
|
| 4278 |
<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> |
| 4279 |
<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. |
| 4280 |
|
| 4281 |
Example matches Y but not X |
| 4282 |
(matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 4283 |
#include <SystemHeader.h> |
| 4284 |
class X {}; |
| 4285 |
SystemHeader.h: |
| 4286 |
class Y {}; |
| 4287 |
|
| 4288 |
Usable 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>> |
| 4289 |
</pre></td></tr> |
| 4290 |
|
| 4291 |
|
| 4292 |
<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> |
| 4293 |
<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches an entity that has been implicitly added by the compiler (e.g. |
| 4294 |
implicit default/copy constructors). |
| 4295 |
</pre></td></tr> |
| 4296 |
|
| 4297 |
|
| 4298 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isInAnonymousNamespace0')"><a name="isInAnonymousNamespace0Anchor">isInAnonymousNamespace</a></td><td></td></tr> |
| 4299 |
<tr><td colspan="4" class="doc" id="isInAnonymousNamespace0"><pre>Matches declarations in an anonymous namespace. |
| 4300 |
|
| 4301 |
Given |
| 4302 |
class vector {}; |
| 4303 |
namespace foo { |
| 4304 |
class vector {}; |
| 4305 |
namespace { |
| 4306 |
class vector {}; // #1 |
| 4307 |
} |
| 4308 |
} |
| 4309 |
namespace { |
| 4310 |
class vector {}; // #2 |
| 4311 |
namespace foo { |
| 4312 |
class vector{}; // #3 |
| 4313 |
} |
| 4314 |
} |
| 4315 |
cxxRecordDecl(hasName("vector"), isInAnonymousNamespace()) will match |
| 4316 |
#1, #2 and #3. |
| 4317 |
</pre></td></tr> |
| 4318 |
|
| 4319 |
|
| 4320 |
<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> |
| 4321 |
<tr><td colspan="4" class="doc" id="isInStdNamespace0"><pre>Matches declarations in the namespace `std`, but not in nested namespaces. |
| 4322 |
|
| 4323 |
Given |
| 4324 |
class vector {}; |
| 4325 |
namespace foo { |
| 4326 |
class vector {}; |
| 4327 |
namespace std { |
| 4328 |
class vector {}; |
| 4329 |
} |
| 4330 |
} |
| 4331 |
namespace std { |
| 4332 |
inline namespace __1 { |
| 4333 |
class vector {}; // #1 |
| 4334 |
namespace experimental { |
| 4335 |
class vector {}; |
| 4336 |
} |
| 4337 |
} |
| 4338 |
} |
| 4339 |
cxxRecordDecl(hasName("vector"), isInStdNamespace()) will match only #1. |
| 4340 |
</pre></td></tr> |
| 4341 |
|
| 4342 |
|
| 4343 |
<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> |
| 4344 |
<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside |
| 4345 |
template instantiations. |
| 4346 |
|
| 4347 |
Given |
| 4348 |
template<typename T> void A(T t) { T i; } |
| 4349 |
A(0); |
| 4350 |
A(0U); |
| 4351 |
functionDecl(isInstantiated()) |
| 4352 |
matches 'A(int) {...};' and 'A(unsigned) {...}'. |
| 4353 |
</pre></td></tr> |
| 4354 |
|
| 4355 |
|
| 4356 |
<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> |
| 4357 |
<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations and C++ base specifiers that specify |
| 4358 |
private inheritance. |
| 4359 |
|
| 4360 |
Examples: |
| 4361 |
class C { |
| 4362 |
public: int a; |
| 4363 |
protected: int b; |
| 4364 |
private: int c; // fieldDecl(isPrivate()) matches 'c' |
| 4365 |
}; |
| 4366 |
|
| 4367 |
struct Base {}; |
| 4368 |
struct Derived1 : private Base {}; // matches 'Base' |
| 4369 |
class Derived2 : Base {}; // matches 'Base' |
| 4370 |
</pre></td></tr> |
| 4371 |
|
| 4372 |
|
| 4373 |
<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> |
| 4374 |
<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations and C++ base specifiers that specify |
| 4375 |
protected inheritance. |
| 4376 |
|
| 4377 |
Examples: |
| 4378 |
class C { |
| 4379 |
public: int a; |
| 4380 |
protected: int b; // fieldDecl(isProtected()) matches 'b' |
| 4381 |
private: int c; |
| 4382 |
}; |
| 4383 |
|
| 4384 |
class Base {}; |
| 4385 |
class Derived : protected Base {}; // matches 'Base' |
| 4386 |
</pre></td></tr> |
| 4387 |
|
| 4388 |
|
| 4389 |
<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> |
| 4390 |
<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations and C++ base specifiers that specify public |
| 4391 |
inheritance. |
| 4392 |
|
| 4393 |
Examples: |
| 4394 |
class C { |
| 4395 |
public: int a; // fieldDecl(isPublic()) matches 'a' |
| 4396 |
protected: int b; |
| 4397 |
private: int c; |
| 4398 |
}; |
| 4399 |
|
| 4400 |
class Base {}; |
| 4401 |
class Derived1 : public Base {}; // matches 'Base' |
| 4402 |
struct Derived2 : Base {}; // matches 'Base' |
| 4403 |
</pre></td></tr> |
| 4404 |
|
| 4405 |
|
| 4406 |
<tr><td>Matcher<DependentNameType></td><td class="name" onclick="toggle('hasDependentName1')"><a name="hasDependentName1Anchor">hasDependentName</a></td><td>std::string N</td></tr> |
| 4407 |
<tr><td colspan="4" class="doc" id="hasDependentName1"><pre>Matches the dependent name of a DependentScopeDeclRefExpr or |
| 4408 |
DependentNameType |
| 4409 |
|
| 4410 |
Given: |
| 4411 |
template <class T> class X : T { void f() { T::v; } }; |
| 4412 |
dependentScopeDeclRefExpr(hasDependentName("v")) matches `T::v` |
| 4413 |
|
| 4414 |
Given: |
| 4415 |
template <typename T> struct declToImport { |
| 4416 |
typedef typename T::type dependent_name; |
| 4417 |
}; |
| 4418 |
dependentNameType(hasDependentName("type")) matches `T::type` |
| 4419 |
</pre></td></tr> |
| 4420 |
|
| 4421 |
|
| 4422 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentScopeDeclRefExpr.html">DependentScopeDeclRefExpr</a>></td><td class="name" onclick="toggle('hasDependentName0')"><a name="hasDependentName0Anchor">hasDependentName</a></td><td>std::string N</td></tr> |
| 4423 |
<tr><td colspan="4" class="doc" id="hasDependentName0"><pre>Matches the dependent name of a DependentScopeDeclRefExpr or |
| 4424 |
DependentNameType |
| 4425 |
|
| 4426 |
Given: |
| 4427 |
template <class T> class X : T { void f() { T::v; } }; |
| 4428 |
dependentScopeDeclRefExpr(hasDependentName("v")) matches `T::v` |
| 4429 |
|
| 4430 |
Given: |
| 4431 |
template <typename T> struct declToImport { |
| 4432 |
typedef typename T::type dependent_name; |
| 4433 |
}; |
| 4434 |
dependentNameType(hasDependentName("type")) matches `T::type` |
| 4435 |
</pre></td></tr> |
| 4436 |
|
| 4437 |
|
| 4438 |
<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> |
| 4439 |
<tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain |
| 4440 |
a specific number of designators. |
| 4441 |
|
| 4442 |
Example: Given |
| 4443 |
point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; |
| 4444 |
point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }; |
| 4445 |
designatorCountIs(2) |
| 4446 |
matches '{ [2].y = 1.0, [0].x = 1.0 }', |
| 4447 |
but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'. |
| 4448 |
</pre></td></tr> |
| 4449 |
|
| 4450 |
|
| 4451 |
<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> |
| 4452 |
<tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration. |
| 4453 |
|
| 4454 |
Example matches Y (matcher = enumDecl(isScoped())) |
| 4455 |
enum X {}; |
| 4456 |
enum class Y {}; |
| 4457 |
</pre></td></tr> |
| 4458 |
|
| 4459 |
|
| 4460 |
<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> |
| 4461 |
<tr><td colspan="4" class="doc" id="isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is |
| 4462 |
neither type- nor value-dependent. |
| 4463 |
|
| 4464 |
In the following example, the expression sizeof(sizeof(T() + T())) |
| 4465 |
is instantiation-dependent (since it involves a template parameter T), |
| 4466 |
but is neither type- nor value-dependent, since the type of the inner |
| 4467 |
sizeof is known (std::size_t) and therefore the size of the outer |
| 4468 |
sizeof is known. |
| 4469 |
template<typename T> |
| 4470 |
void f(T x, T y) { sizeof(sizeof(T() + T()); } |
| 4471 |
expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T()) |
| 4472 |
</pre></td></tr> |
| 4473 |
|
| 4474 |
|
| 4475 |
<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> |
| 4476 |
<tr><td colspan="4" class="doc" id="isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type |
| 4477 |
is not yet instantiated. |
| 4478 |
|
| 4479 |
For example, the expressions "x" and "x + y" are type-dependent in |
| 4480 |
the following code, but "y" is not type-dependent: |
| 4481 |
template<typename T> |
| 4482 |
void add(T x, int y) { |
| 4483 |
x + y; |
| 4484 |
} |
| 4485 |
expr(isTypeDependent()) matches x + y |
| 4486 |
</pre></td></tr> |
| 4487 |
|
| 4488 |
|
| 4489 |
<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> |
| 4490 |
<tr><td colspan="4" class="doc" id="isValueDependent0"><pre>Matches expression that are value-dependent because they contain a |
| 4491 |
non-type template parameter. |
| 4492 |
|
| 4493 |
For example, the array bound of "Chars" in the following example is |
| 4494 |
value-dependent. |
| 4495 |
template<int Size> int f() { return Size; } |
| 4496 |
expr(isValueDependent()) matches return Size |
| 4497 |
</pre></td></tr> |
| 4498 |
|
| 4499 |
|
| 4500 |
<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> |
| 4501 |
<tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as |
| 4502 |
GNU's __null, C++11's nullptr, or C's NULL macro. |
| 4503 |
|
| 4504 |
Given: |
| 4505 |
void *v1 = NULL; |
| 4506 |
void *v2 = nullptr; |
| 4507 |
void *v3 = __null; // GNU extension |
| 4508 |
char *cp = (char *)0; |
| 4509 |
int *ip = 0; |
| 4510 |
int i = 0; |
| 4511 |
expr(nullPointerConstant()) |
| 4512 |
matches the initializer for v1, v2, v3, cp, and ip. Does not match the |
| 4513 |
initializer for i. |
| 4514 |
</pre></td></tr> |
| 4515 |
|
| 4516 |
|
| 4517 |
<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> |
| 4518 |
<tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified |
| 4519 |
bit width. |
| 4520 |
|
| 4521 |
Given |
| 4522 |
class C { |
| 4523 |
int a : 2; |
| 4524 |
int b : 4; |
| 4525 |
int c : 2; |
| 4526 |
}; |
| 4527 |
fieldDecl(hasBitWidth(2)) |
| 4528 |
matches 'int a;' and 'int c;' but not 'int b;'. |
| 4529 |
</pre></td></tr> |
| 4530 |
|
| 4531 |
|
| 4532 |
<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> |
| 4533 |
<tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields. |
| 4534 |
|
| 4535 |
Given |
| 4536 |
class C { |
| 4537 |
int a : 2; |
| 4538 |
int b; |
| 4539 |
}; |
| 4540 |
fieldDecl(isBitField()) |
| 4541 |
matches 'int a;' but not 'int b;'. |
| 4542 |
</pre></td></tr> |
| 4543 |
|
| 4544 |
|
| 4545 |
<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> |
| 4546 |
<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT. |
| 4547 |
|
| 4548 |
Given |
| 4549 |
f('false, 3.14, 42); |
| 4550 |
characterLiteral(equals(0)) |
| 4551 |
matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| 4552 |
match false |
| 4553 |
floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| 4554 |
match 3.14 |
| 4555 |
integerLiteral(equals(42)) |
| 4556 |
matches 42 |
| 4557 |
|
| 4558 |
Note that you cannot directly match a negative numeric literal because the |
| 4559 |
minus sign is not part of the literal: It is a unary operator whose operand |
| 4560 |
is the positive numeric literal. Instead, you must use a unaryOperator() |
| 4561 |
matcher to match the minus sign: |
| 4562 |
|
| 4563 |
unaryOperator(hasOperatorName("-"), |
| 4564 |
hasUnaryOperand(integerLiteral(equals(13)))) |
| 4565 |
|
| 4566 |
Usable 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>>, |
| 4567 |
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>> |
| 4568 |
</pre></td></tr> |
| 4569 |
|
| 4570 |
|
| 4571 |
<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> |
| 4572 |
<tr><td colspan="4" class="doc" id="equals12"><pre></pre></td></tr> |
| 4573 |
|
| 4574 |
|
| 4575 |
<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> |
| 4576 |
<tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName1"><pre>Matches overloaded operator names. |
| 4577 |
|
| 4578 |
Matches overloaded operator names specified in strings without the |
| 4579 |
"operator" prefix: e.g. "<<". |
| 4580 |
|
| 4581 |
hasAnyOverloadedOperatorName("+", "-") |
| 4582 |
Is equivalent to |
| 4583 |
anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-")) |
| 4584 |
</pre></td></tr> |
| 4585 |
|
| 4586 |
|
| 4587 |
<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> |
| 4588 |
<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification. |
| 4589 |
|
| 4590 |
Given: |
| 4591 |
void f(); |
| 4592 |
void g() noexcept; |
| 4593 |
void h() noexcept(true); |
| 4594 |
void i() noexcept(false); |
| 4595 |
void j() throw(); |
| 4596 |
void k() throw(int); |
| 4597 |
void l() throw(...); |
| 4598 |
functionDecl(hasDynamicExceptionSpec()) and |
| 4599 |
functionProtoType(hasDynamicExceptionSpec()) |
| 4600 |
match the declarations of j, k, and l, but not f, g, h, or i. |
| 4601 |
</pre></td></tr> |
| 4602 |
|
| 4603 |
|
| 4604 |
<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> |
| 4605 |
<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. |
| 4606 |
|
| 4607 |
Matches overloaded operator names specified in strings without the |
| 4608 |
"operator" prefix: e.g. "<<". |
| 4609 |
|
| 4610 |
Given: |
| 4611 |
class A { int operator*(); }; |
| 4612 |
const A &operator<<(const A &a, const A &b); |
| 4613 |
A a; |
| 4614 |
a << a; // <-- This matches |
| 4615 |
|
| 4616 |
cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the |
| 4617 |
specified line and |
| 4618 |
cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) |
| 4619 |
matches the declaration of A. |
| 4620 |
|
| 4621 |
Usable 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>> |
| 4622 |
</pre></td></tr> |
| 4623 |
|
| 4624 |
|
| 4625 |
<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> |
| 4626 |
<tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type. |
| 4627 |
|
| 4628 |
Example matches Y (matcher = functionDecl(hasTrailingReturn())) |
| 4629 |
int X() {} |
| 4630 |
auto Y() -> int {} |
| 4631 |
</pre></td></tr> |
| 4632 |
|
| 4633 |
|
| 4634 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isConsteval0')"><a name="isConsteval0Anchor">isConsteval</a></td><td></td></tr> |
| 4635 |
<tr><td colspan="4" class="doc" id="isConsteval0"><pre>Matches consteval function declarations and if consteval/if ! consteval |
| 4636 |
statements. |
| 4637 |
|
| 4638 |
Given: |
| 4639 |
consteval int a(); |
| 4640 |
void b() { if consteval {} } |
| 4641 |
void c() { if ! consteval {} } |
| 4642 |
void d() { if ! consteval {} else {} } |
| 4643 |
functionDecl(isConsteval()) |
| 4644 |
matches the declaration of "int a()". |
| 4645 |
ifStmt(isConsteval()) |
| 4646 |
matches the if statement in "void b()", "void c()", "void d()". |
| 4647 |
</pre></td></tr> |
| 4648 |
|
| 4649 |
|
| 4650 |
<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> |
| 4651 |
<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations, |
| 4652 |
and if constexpr. |
| 4653 |
|
| 4654 |
Given: |
| 4655 |
constexpr int foo = 42; |
| 4656 |
constexpr int bar(); |
| 4657 |
void baz() { if constexpr(1 > 0) {} } |
| 4658 |
varDecl(isConstexpr()) |
| 4659 |
matches the declaration of foo. |
| 4660 |
functionDecl(isConstexpr()) |
| 4661 |
matches the declaration of bar. |
| 4662 |
ifStmt(isConstexpr()) |
| 4663 |
matches the if statement in baz. |
| 4664 |
</pre></td></tr> |
| 4665 |
|
| 4666 |
|
| 4667 |
<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> |
| 4668 |
<tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations. |
| 4669 |
|
| 4670 |
Given: |
| 4671 |
class A { ~A(); }; |
| 4672 |
class B { ~B() = default; }; |
| 4673 |
functionDecl(isDefaulted()) |
| 4674 |
matches the declaration of ~B, but not ~A. |
| 4675 |
</pre></td></tr> |
| 4676 |
|
| 4677 |
|
| 4678 |
<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> |
| 4679 |
<tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached. |
| 4680 |
|
| 4681 |
Example matches A, va, fa |
| 4682 |
class A {}; |
| 4683 |
class B; // Doesn't match, as it has no body. |
| 4684 |
int va; |
| 4685 |
extern int vb; // Doesn't match, as it doesn't define the variable. |
| 4686 |
void fa() {} |
| 4687 |
void fb(); // Doesn't match, as it has no body. |
| 4688 |
@interface X |
| 4689 |
- (void)ma; // Doesn't match, interface is declaration. |
| 4690 |
@end |
| 4691 |
@implementation X |
| 4692 |
- (void)ma {} |
| 4693 |
@end |
| 4694 |
|
| 4695 |
Usable 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>>, |
| 4696 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> |
| 4697 |
</pre></td></tr> |
| 4698 |
|
| 4699 |
|
| 4700 |
<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> |
| 4701 |
<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. |
| 4702 |
|
| 4703 |
Given: |
| 4704 |
void Func(); |
| 4705 |
void DeletedFunc() = delete; |
| 4706 |
functionDecl(isDeleted()) |
| 4707 |
matches the declaration of DeletedFunc, but not Func. |
| 4708 |
</pre></td></tr> |
| 4709 |
|
| 4710 |
|
| 4711 |
<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> |
| 4712 |
<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or |
| 4713 |
static member variable template instantiations. |
| 4714 |
|
| 4715 |
Given |
| 4716 |
template<typename T> void A(T t) { } |
| 4717 |
template<> void A(int N) { } |
| 4718 |
functionDecl(isExplicitTemplateSpecialization()) |
| 4719 |
matches the specialization A<int>(). |
| 4720 |
|
| 4721 |
Usable 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>> |
| 4722 |
</pre></td></tr> |
| 4723 |
|
| 4724 |
|
| 4725 |
<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> |
| 4726 |
<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations. |
| 4727 |
|
| 4728 |
Given: |
| 4729 |
extern "C" void f() {} |
| 4730 |
extern "C" { void g() {} } |
| 4731 |
void h() {} |
| 4732 |
extern "C" int x = 1; |
| 4733 |
extern "C" int y = 2; |
| 4734 |
int z = 3; |
| 4735 |
functionDecl(isExternC()) |
| 4736 |
matches the declaration of f and g, but not the declaration of h. |
| 4737 |
varDecl(isExternC()) |
| 4738 |
matches the declaration of x and y, but not the declaration of z. |
| 4739 |
</pre></td></tr> |
| 4740 |
|
| 4741 |
|
| 4742 |
<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> |
| 4743 |
<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches functions, variables and namespace declarations that are marked with |
| 4744 |
the inline keyword. |
| 4745 |
|
| 4746 |
Given |
| 4747 |
inline void f(); |
| 4748 |
void g(); |
| 4749 |
namespace n { |
| 4750 |
inline namespace m {} |
| 4751 |
} |
| 4752 |
inline int Foo = 5; |
| 4753 |
functionDecl(isInline()) will match ::f(). |
| 4754 |
namespaceDecl(isInline()) will match n::m. |
| 4755 |
varDecl(isInline()) will match Foo; |
| 4756 |
</pre></td></tr> |
| 4757 |
|
| 4758 |
|
| 4759 |
<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> |
| 4760 |
<tr><td colspan="4" class="doc" id="isMain0"><pre>Determines whether the function is "main", which is the entry point |
| 4761 |
into an executable program. |
| 4762 |
</pre></td></tr> |
| 4763 |
|
| 4764 |
|
| 4765 |
<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> |
| 4766 |
<tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute. |
| 4767 |
|
| 4768 |
Given |
| 4769 |
void nope(); |
| 4770 |
[[noreturn]] void a(); |
| 4771 |
__attribute__((noreturn)) void b(); |
| 4772 |
struct c { [[noreturn]] c(); }; |
| 4773 |
functionDecl(isNoReturn()) |
| 4774 |
matches all of those except |
| 4775 |
void nope(); |
| 4776 |
</pre></td></tr> |
| 4777 |
|
| 4778 |
|
| 4779 |
<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> |
| 4780 |
<tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification. |
| 4781 |
|
| 4782 |
Given: |
| 4783 |
void f(); |
| 4784 |
void g() noexcept; |
| 4785 |
void h() throw(); |
| 4786 |
void i() throw(int); |
| 4787 |
void j() noexcept(false); |
| 4788 |
functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) |
| 4789 |
match the declarations of g, and h, but not f, i or j. |
| 4790 |
</pre></td></tr> |
| 4791 |
|
| 4792 |
|
| 4793 |
<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> |
| 4794 |
<tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variable/function declarations that have "static" storage |
| 4795 |
class specifier ("static" keyword) written in the source. |
| 4796 |
|
| 4797 |
Given: |
| 4798 |
static void f() {} |
| 4799 |
static int i = 0; |
| 4800 |
extern int j; |
| 4801 |
int k; |
| 4802 |
functionDecl(isStaticStorageClass()) |
| 4803 |
matches the function declaration f. |
| 4804 |
varDecl(isStaticStorageClass()) |
| 4805 |
matches the variable declaration i. |
| 4806 |
</pre></td></tr> |
| 4807 |
|
| 4808 |
|
| 4809 |
<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> |
| 4810 |
<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static |
| 4811 |
member variable template instantiations. |
| 4812 |
|
| 4813 |
Given |
| 4814 |
template <typename T> class X {}; class A {}; X<A> x; |
| 4815 |
or |
| 4816 |
template <typename T> class X {}; class A {}; template class X<A>; |
| 4817 |
or |
| 4818 |
template <typename T> class X {}; class A {}; extern template class X<A>; |
| 4819 |
cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 4820 |
matches the template instantiation of X<A>. |
| 4821 |
|
| 4822 |
But given |
| 4823 |
template <typename T> class X {}; class A {}; |
| 4824 |
template <> class X<A> {}; X<A> x; |
| 4825 |
cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 4826 |
does not match, as X<A> is an explicit template specialization. |
| 4827 |
|
| 4828 |
Usable 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>> |
| 4829 |
</pre></td></tr> |
| 4830 |
|
| 4831 |
|
| 4832 |
<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> |
| 4833 |
<tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. |
| 4834 |
|
| 4835 |
Example matches f, but not g or h. The function i will not match, even when |
| 4836 |
compiled in C mode. |
| 4837 |
void f(...); |
| 4838 |
void g(int); |
| 4839 |
template <typename... Ts> void h(Ts...); |
| 4840 |
void i(); |
| 4841 |
</pre></td></tr> |
| 4842 |
|
| 4843 |
|
| 4844 |
<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> |
| 4845 |
<tr><td colspan="4" class="doc" id="isWeak0"><pre>Matches weak function declarations. |
| 4846 |
|
| 4847 |
Given: |
| 4848 |
void foo() __attribute__((__weakref__("__foo"))); |
| 4849 |
void bar(); |
| 4850 |
functionDecl(isWeak()) |
| 4851 |
matches the weak declaration "foo", but not "bar". |
| 4852 |
</pre></td></tr> |
| 4853 |
|
| 4854 |
|
| 4855 |
<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> |
| 4856 |
<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a |
| 4857 |
specific parameter count. |
| 4858 |
|
| 4859 |
Given |
| 4860 |
void f(int i) {} |
| 4861 |
void g(int i, int j) {} |
| 4862 |
void h(int i, int j); |
| 4863 |
void j(int i); |
| 4864 |
void k(int x, int y, int z, ...); |
| 4865 |
functionDecl(parameterCountIs(2)) |
| 4866 |
matches g and h |
| 4867 |
functionProtoType(parameterCountIs(2)) |
| 4868 |
matches g and h |
| 4869 |
functionProtoType(parameterCountIs(3)) |
| 4870 |
matches k |
| 4871 |
</pre></td></tr> |
| 4872 |
|
| 4873 |
|
| 4874 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('templateArgumentCountIs2')"><a name="templateArgumentCountIs2Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> |
| 4875 |
<tr><td colspan="4" class="doc" id="templateArgumentCountIs2"><pre>Matches if the number of template arguments equals N. |
| 4876 |
|
| 4877 |
Given |
| 4878 |
template<typename T> struct C {}; |
| 4879 |
C<int> c; |
| 4880 |
template<typename T> void f() {} |
| 4881 |
void func() { f<int>(); }; |
| 4882 |
|
| 4883 |
classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
| 4884 |
matches C<int>. |
| 4885 |
|
| 4886 |
functionDecl(templateArgumentCountIs(1)) |
| 4887 |
matches f<int>(); |
| 4888 |
</pre></td></tr> |
| 4889 |
|
| 4890 |
|
| 4891 |
<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> |
| 4892 |
<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification. |
| 4893 |
|
| 4894 |
Given: |
| 4895 |
void f(); |
| 4896 |
void g() noexcept; |
| 4897 |
void h() noexcept(true); |
| 4898 |
void i() noexcept(false); |
| 4899 |
void j() throw(); |
| 4900 |
void k() throw(int); |
| 4901 |
void l() throw(...); |
| 4902 |
functionDecl(hasDynamicExceptionSpec()) and |
| 4903 |
functionProtoType(hasDynamicExceptionSpec()) |
| 4904 |
match the declarations of j, k, and l, but not f, g, h, or i. |
| 4905 |
</pre></td></tr> |
| 4906 |
|
| 4907 |
|
| 4908 |
<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> |
| 4909 |
<tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification. |
| 4910 |
|
| 4911 |
Given: |
| 4912 |
void f(); |
| 4913 |
void g() noexcept; |
| 4914 |
void h() throw(); |
| 4915 |
void i() throw(int); |
| 4916 |
void j() noexcept(false); |
| 4917 |
functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) |
| 4918 |
match the declarations of g, and h, but not f, i or j. |
| 4919 |
</pre></td></tr> |
| 4920 |
|
| 4921 |
|
| 4922 |
<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> |
| 4923 |
<tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a |
| 4924 |
specific parameter count. |
| 4925 |
|
| 4926 |
Given |
| 4927 |
void f(int i) {} |
| 4928 |
void g(int i, int j) {} |
| 4929 |
void h(int i, int j); |
| 4930 |
void j(int i); |
| 4931 |
void k(int x, int y, int z, ...); |
| 4932 |
functionDecl(parameterCountIs(2)) |
| 4933 |
matches g and h |
| 4934 |
functionProtoType(parameterCountIs(2)) |
| 4935 |
matches g and h |
| 4936 |
functionProtoType(parameterCountIs(3)) |
| 4937 |
matches k |
| 4938 |
</pre></td></tr> |
| 4939 |
|
| 4940 |
|
| 4941 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('isConsteval1')"><a name="isConsteval1Anchor">isConsteval</a></td><td></td></tr> |
| 4942 |
<tr><td colspan="4" class="doc" id="isConsteval1"><pre>Matches consteval function declarations and if consteval/if ! consteval |
| 4943 |
statements. |
| 4944 |
|
| 4945 |
Given: |
| 4946 |
consteval int a(); |
| 4947 |
void b() { if consteval {} } |
| 4948 |
void c() { if ! consteval {} } |
| 4949 |
void d() { if ! consteval {} else {} } |
| 4950 |
functionDecl(isConsteval()) |
| 4951 |
matches the declaration of "int a()". |
| 4952 |
ifStmt(isConsteval()) |
| 4953 |
matches the if statement in "void b()", "void c()", "void d()". |
| 4954 |
</pre></td></tr> |
| 4955 |
|
| 4956 |
|
| 4957 |
<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> |
| 4958 |
<tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations, |
| 4959 |
and if constexpr. |
| 4960 |
|
| 4961 |
Given: |
| 4962 |
constexpr int foo = 42; |
| 4963 |
constexpr int bar(); |
| 4964 |
void baz() { if constexpr(1 > 0) {} } |
| 4965 |
varDecl(isConstexpr()) |
| 4966 |
matches the declaration of foo. |
| 4967 |
functionDecl(isConstexpr()) |
| 4968 |
matches the declaration of bar. |
| 4969 |
ifStmt(isConstexpr()) |
| 4970 |
matches the if statement in baz. |
| 4971 |
</pre></td></tr> |
| 4972 |
|
| 4973 |
|
| 4974 |
<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> |
| 4975 |
<tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr> |
| 4976 |
|
| 4977 |
|
| 4978 |
<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> |
| 4979 |
<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT. |
| 4980 |
|
| 4981 |
Given |
| 4982 |
f('false, 3.14, 42); |
| 4983 |
characterLiteral(equals(0)) |
| 4984 |
matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| 4985 |
match false |
| 4986 |
floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| 4987 |
match 3.14 |
| 4988 |
integerLiteral(equals(42)) |
| 4989 |
matches 42 |
| 4990 |
|
| 4991 |
Note that you cannot directly match a negative numeric literal because the |
| 4992 |
minus sign is not part of the literal: It is a unary operator whose operand |
| 4993 |
is the positive numeric literal. Instead, you must use a unaryOperator() |
| 4994 |
matcher to match the minus sign: |
| 4995 |
|
| 4996 |
unaryOperator(hasOperatorName("-"), |
| 4997 |
hasUnaryOperand(integerLiteral(equals(13)))) |
| 4998 |
|
| 4999 |
Usable 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>>, |
| 5000 |
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>> |
| 5001 |
</pre></td></tr> |
| 5002 |
|
| 5003 |
|
| 5004 |
<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> |
| 5005 |
<tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr> |
| 5006 |
|
| 5007 |
|
| 5008 |
<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> |
| 5009 |
<tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr> |
| 5010 |
|
| 5011 |
|
| 5012 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>></td><td class="name" onclick="toggle('capturesThis0')"><a name="capturesThis0Anchor">capturesThis</a></td><td></td></tr> |
| 5013 |
<tr><td colspan="4" class="doc" id="capturesThis0"><pre>Matches a `LambdaCapture` that refers to 'this'. |
| 5014 |
|
| 5015 |
Given |
| 5016 |
class C { |
| 5017 |
int cc; |
| 5018 |
int f() { |
| 5019 |
auto l = [this]() { return cc; }; |
| 5020 |
return l(); |
| 5021 |
} |
| 5022 |
}; |
| 5023 |
lambdaExpr(hasAnyCapture(lambdaCapture(capturesThis()))) |
| 5024 |
matches `[this]() { return cc; }`. |
| 5025 |
</pre></td></tr> |
| 5026 |
|
| 5027 |
|
| 5028 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>></td><td class="name" onclick="toggle('isImplicit2')"><a name="isImplicit2Anchor">isImplicit</a></td><td></td></tr> |
| 5029 |
<tr><td colspan="4" class="doc" id="isImplicit2"><pre>Matches an entity that has been implicitly added by the compiler (e.g. |
| 5030 |
implicit default/copy constructors). |
| 5031 |
</pre></td></tr> |
| 5032 |
|
| 5033 |
|
| 5034 |
<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> |
| 5035 |
<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed |
| 5036 |
to '.'. |
| 5037 |
|
| 5038 |
Member calls on the implicit this pointer match as called with '->'. |
| 5039 |
|
| 5040 |
Given |
| 5041 |
class Y { |
| 5042 |
void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 5043 |
template <class T> void f() { this->f<T>(); f<T>(); } |
| 5044 |
int a; |
| 5045 |
static int b; |
| 5046 |
}; |
| 5047 |
template <class T> |
| 5048 |
class Z { |
| 5049 |
void x() { this->m; } |
| 5050 |
}; |
| 5051 |
memberExpr(isArrow()) |
| 5052 |
matches this->x, x, y.x, a, this->b |
| 5053 |
cxxDependentScopeMemberExpr(isArrow()) |
| 5054 |
matches this->m |
| 5055 |
unresolvedMemberExpr(isArrow()) |
| 5056 |
matches this->f<T>, f<T> |
| 5057 |
</pre></td></tr> |
| 5058 |
|
| 5059 |
|
| 5060 |
<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> |
| 5061 |
<tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names. |
| 5062 |
|
| 5063 |
This matcher is only provided as a performance optimization of hasName. |
| 5064 |
hasAnyName(a, b, c) |
| 5065 |
is equivalent to, but faster than |
| 5066 |
anyOf(hasName(a), hasName(b), hasName(c)) |
| 5067 |
</pre></td></tr> |
| 5068 |
|
| 5069 |
|
| 5070 |
<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> |
| 5071 |
<tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage. |
| 5072 |
|
| 5073 |
Example matches only z (matcher = varDecl(hasExternalFormalLinkage())) |
| 5074 |
void f() { |
| 5075 |
int x; |
| 5076 |
static int y; |
| 5077 |
} |
| 5078 |
int z; |
| 5079 |
|
| 5080 |
Example matches f() because it has external formal linkage despite being |
| 5081 |
unique to the translation unit as though it has internal linkage |
| 5082 |
(matcher = functionDecl(hasExternalFormalLinkage())) |
| 5083 |
|
| 5084 |
namespace { |
| 5085 |
void f() {} |
| 5086 |
} |
| 5087 |
</pre></td></tr> |
| 5088 |
|
| 5089 |
|
| 5090 |
<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> |
| 5091 |
<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. |
| 5092 |
|
| 5093 |
Supports specifying enclosing namespaces or classes by prefixing the name |
| 5094 |
with '<enclosing>::'. |
| 5095 |
Does not match typedefs of an underlying type with the given name. |
| 5096 |
|
| 5097 |
Example matches X (Name == "X") |
| 5098 |
class X; |
| 5099 |
|
| 5100 |
Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") |
| 5101 |
namespace a { namespace b { class X; } } |
| 5102 |
</pre></td></tr> |
| 5103 |
|
| 5104 |
|
| 5105 |
<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> |
| 5106 |
<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain |
| 5107 |
a substring matched by the given RegExp. |
| 5108 |
|
| 5109 |
Supports specifying enclosing namespaces or classes by |
| 5110 |
prefixing the name with '<enclosing>::'. Does not match typedefs |
| 5111 |
of an underlying type with the given name. |
| 5112 |
|
| 5113 |
Example matches X (regexp == "::X") |
| 5114 |
class X; |
| 5115 |
|
| 5116 |
Example matches X (regexp is one of "::X", "^foo::.*X", among others) |
| 5117 |
namespace foo { namespace bar { class X; } } |
| 5118 |
|
| 5119 |
If the matcher is used in clang-query, RegexFlags parameter |
| 5120 |
should be passed as a quoted string. e.g: "NoFlags". |
| 5121 |
Flags can be combined with '|' example "IgnoreCase | BasicRegex" |
| 5122 |
</pre></td></tr> |
| 5123 |
|
| 5124 |
|
| 5125 |
<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> |
| 5126 |
<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. |
| 5127 |
|
| 5128 |
Given |
| 5129 |
namespace n { |
| 5130 |
namespace {} // #1 |
| 5131 |
} |
| 5132 |
namespaceDecl(isAnonymous()) will match #1 but not ::n. |
| 5133 |
</pre></td></tr> |
| 5134 |
|
| 5135 |
|
| 5136 |
<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> |
| 5137 |
<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches functions, variables and namespace declarations that are marked with |
| 5138 |
the inline keyword. |
| 5139 |
|
| 5140 |
Given |
| 5141 |
inline void f(); |
| 5142 |
void g(); |
| 5143 |
namespace n { |
| 5144 |
inline namespace m {} |
| 5145 |
} |
| 5146 |
inline int Foo = 5; |
| 5147 |
functionDecl(isInline()) will match ::f(). |
| 5148 |
namespaceDecl(isInline()) will match n::m. |
| 5149 |
varDecl(isInline()) will match Foo; |
| 5150 |
</pre></td></tr> |
| 5151 |
|
| 5152 |
|
| 5153 |
<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> |
| 5154 |
<tr><td colspan="4" class="doc" id="isFirstPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``firstprivate`` kind |
| 5155 |
specified. |
| 5156 |
|
| 5157 |
Given |
| 5158 |
|
| 5159 |
#pragma omp parallel |
| 5160 |
#pragma omp parallel default(none) |
| 5161 |
#pragma omp parallel default(shared) |
| 5162 |
#pragma omp parallel default(private) |
| 5163 |
#pragma omp parallel default(firstprivate) |
| 5164 |
|
| 5165 |
``ompDefaultClause(isFirstPrivateKind())`` matches only |
| 5166 |
``default(firstprivate)``. |
| 5167 |
</pre></td></tr> |
| 5168 |
|
| 5169 |
|
| 5170 |
<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> |
| 5171 |
<tr><td colspan="4" class="doc" id="isNoneKind0"><pre>Matches if the OpenMP ``default`` clause has ``none`` kind specified. |
| 5172 |
|
| 5173 |
Given |
| 5174 |
|
| 5175 |
#pragma omp parallel |
| 5176 |
#pragma omp parallel default(none) |
| 5177 |
#pragma omp parallel default(shared) |
| 5178 |
#pragma omp parallel default(private) |
| 5179 |
#pragma omp parallel default(firstprivate) |
| 5180 |
|
| 5181 |
``ompDefaultClause(isNoneKind())`` matches only ``default(none)``. |
| 5182 |
</pre></td></tr> |
| 5183 |
|
| 5184 |
|
| 5185 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>></td><td class="name" onclick="toggle('isPrivateKind0')"><a name="isPrivateKind0Anchor">isPrivateKind</a></td><td></td></tr> |
| 5186 |
<tr><td colspan="4" class="doc" id="isPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``private`` kind |
| 5187 |
specified. |
| 5188 |
|
| 5189 |
Given |
| 5190 |
|
| 5191 |
#pragma omp parallel |
| 5192 |
#pragma omp parallel default(none) |
| 5193 |
#pragma omp parallel default(shared) |
| 5194 |
#pragma omp parallel default(private) |
| 5195 |
#pragma omp parallel default(firstprivate) |
| 5196 |
|
| 5197 |
``ompDefaultClause(isPrivateKind())`` matches only |
| 5198 |
``default(private)``. |
| 5199 |
</pre></td></tr> |
| 5200 |
|
| 5201 |
|
| 5202 |
<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> |
| 5203 |
<tr><td colspan="4" class="doc" id="isSharedKind0"><pre>Matches if the OpenMP ``default`` clause has ``shared`` kind specified. |
| 5204 |
|
| 5205 |
Given |
| 5206 |
|
| 5207 |
#pragma omp parallel |
| 5208 |
#pragma omp parallel default(none) |
| 5209 |
#pragma omp parallel default(shared) |
| 5210 |
#pragma omp parallel default(private) |
| 5211 |
#pragma omp parallel default(firstprivate) |
| 5212 |
|
| 5213 |
``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``. |
| 5214 |
</pre></td></tr> |
| 5215 |
|
| 5216 |
|
| 5217 |
<tr><td>Matcher<OMPExecutableDirective></td><td class="name" onclick="toggle('isAllowedToContainClauseKind0')"><a name="isAllowedToContainClauseKind0Anchor">isAllowedToContainClauseKind</a></td><td>OpenMPClauseKind CKind</td></tr> |
| 5218 |
<tr><td colspan="4" class="doc" id="isAllowedToContainClauseKind0"><pre>Matches if the OpenMP directive is allowed to contain the specified OpenMP |
| 5219 |
clause kind. |
| 5220 |
|
| 5221 |
Given |
| 5222 |
|
| 5223 |
#pragma omp parallel |
| 5224 |
#pragma omp parallel for |
| 5225 |
#pragma omp for |
| 5226 |
|
| 5227 |
``ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches |
| 5228 |
``omp parallel`` and ``omp parallel for``. |
| 5229 |
|
| 5230 |
If the matcher is use from clang-query, ``OpenMPClauseKind`` parameter |
| 5231 |
should be passed as a quoted string. e.g., |
| 5232 |
``isAllowedToContainClauseKind("OMPC_default").`` |
| 5233 |
</pre></td></tr> |
| 5234 |
|
| 5235 |
|
| 5236 |
<tr><td>Matcher<OMPExecutableDirective></td><td class="name" onclick="toggle('isStandaloneDirective0')"><a name="isStandaloneDirective0Anchor">isStandaloneDirective</a></td><td></td></tr> |
| 5237 |
<tr><td colspan="4" class="doc" id="isStandaloneDirective0"><pre>Matches standalone OpenMP directives, |
| 5238 |
i.e., directives that can't have a structured block. |
| 5239 |
|
| 5240 |
Given |
| 5241 |
|
| 5242 |
#pragma omp parallel |
| 5243 |
{} |
| 5244 |
#pragma omp taskyield |
| 5245 |
|
| 5246 |
``ompExecutableDirective(isStandaloneDirective()))`` matches |
| 5247 |
``omp taskyield``. |
| 5248 |
</pre></td></tr> |
| 5249 |
|
| 5250 |
|
| 5251 |
<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> |
| 5252 |
<tr><td colspan="4" class="doc" id="isDerivedFrom3"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). |
| 5253 |
</pre></td></tr> |
| 5254 |
|
| 5255 |
|
| 5256 |
<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> |
| 5257 |
<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom3"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)). |
| 5258 |
</pre></td></tr> |
| 5259 |
|
| 5260 |
|
| 5261 |
<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> |
| 5262 |
<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom3"><pre>Overloaded method as shortcut for |
| 5263 |
isSameOrDerivedFrom(hasName(...)). |
| 5264 |
</pre></td></tr> |
| 5265 |
|
| 5266 |
|
| 5267 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('argumentCountAtLeast3')"><a name="argumentCountAtLeast3Anchor">argumentCountAtLeast</a></td><td>unsigned N</td></tr> |
| 5268 |
<tr><td colspan="4" class="doc" id="argumentCountAtLeast3"><pre>Checks that a call expression or a constructor call expression has at least |
| 5269 |
the specified number of arguments (including absent default arguments). |
| 5270 |
|
| 5271 |
Example matches f(0, 0) and g(0, 0, 0) |
| 5272 |
(matcher = callExpr(argumentCountAtLeast(2))) |
| 5273 |
void f(int x, int y); |
| 5274 |
void g(int x, int y, int z); |
| 5275 |
f(0, 0); |
| 5276 |
g(0, 0, 0); |
| 5277 |
</pre></td></tr> |
| 5278 |
|
| 5279 |
|
| 5280 |
<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> |
| 5281 |
<tr><td colspan="4" class="doc" id="argumentCountIs3"><pre>Checks that a call expression or a constructor call expression has |
| 5282 |
a specific number of arguments (including absent default arguments). |
| 5283 |
|
| 5284 |
Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 5285 |
void f(int x, int y); |
| 5286 |
f(0, 0); |
| 5287 |
</pre></td></tr> |
| 5288 |
|
| 5289 |
|
| 5290 |
<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> |
| 5291 |
<tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the |
| 5292 |
Selector.getAsString() |
| 5293 |
|
| 5294 |
matcher = objCMessageExpr(hasSelector("methodA:", "methodB:")); |
| 5295 |
matches both of the expressions below: |
| 5296 |
[myObj methodA:argA]; |
| 5297 |
[myObj methodB:argB]; |
| 5298 |
</pre></td></tr> |
| 5299 |
|
| 5300 |
|
| 5301 |
<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> |
| 5302 |
<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector |
| 5303 |
|
| 5304 |
objCMessageExpr(hasKeywordSelector()) matches the generated setFrame |
| 5305 |
message expression in |
| 5306 |
|
| 5307 |
UIWebView *webView = ...; |
| 5308 |
CGRect bodyFrame = webView.frame; |
| 5309 |
bodyFrame.size.height = self.bodyContentHeight; |
| 5310 |
webView.frame = bodyFrame; |
| 5311 |
// ^---- matches here |
| 5312 |
</pre></td></tr> |
| 5313 |
|
| 5314 |
|
| 5315 |
<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> |
| 5316 |
<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector |
| 5317 |
|
| 5318 |
Matches only when the selector of the objCMessageExpr is NULL. This may |
| 5319 |
represent an error condition in the tree! |
| 5320 |
</pre></td></tr> |
| 5321 |
|
| 5322 |
|
| 5323 |
<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> |
| 5324 |
<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() |
| 5325 |
|
| 5326 |
matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); |
| 5327 |
matches the outer message expr in the code below, but NOT the message |
| 5328 |
invocation for self.bodyView. |
| 5329 |
[self.bodyView loadHTMLString:html baseURL:NULL]; |
| 5330 |
</pre></td></tr> |
| 5331 |
|
| 5332 |
|
| 5333 |
<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> |
| 5334 |
<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector |
| 5335 |
|
| 5336 |
matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); |
| 5337 |
matches self.bodyView in the code below, but NOT the outer message |
| 5338 |
invocation of "loadHTMLString:baseURL:". |
| 5339 |
[self.bodyView loadHTMLString:html baseURL:NULL]; |
| 5340 |
</pre></td></tr> |
| 5341 |
|
| 5342 |
|
| 5343 |
<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> |
| 5344 |
<tr><td colspan="4" class="doc" id="isClassMessage0"><pre>Returns true when the Objective-C message is sent to a class. |
| 5345 |
|
| 5346 |
Example |
| 5347 |
matcher = objcMessageExpr(isClassMessage()) |
| 5348 |
matches |
| 5349 |
[NSString stringWithFormat:@"format"]; |
| 5350 |
but not |
| 5351 |
NSString *x = @"hello"; |
| 5352 |
[x containsString:@"h"]; |
| 5353 |
</pre></td></tr> |
| 5354 |
|
| 5355 |
|
| 5356 |
<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> |
| 5357 |
<tr><td colspan="4" class="doc" id="isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance. |
| 5358 |
|
| 5359 |
Example |
| 5360 |
matcher = objcMessageExpr(isInstanceMessage()) |
| 5361 |
matches |
| 5362 |
NSString *x = @"hello"; |
| 5363 |
[x containsString:@"h"]; |
| 5364 |
but not |
| 5365 |
[NSString stringWithFormat:@"format"]; |
| 5366 |
</pre></td></tr> |
| 5367 |
|
| 5368 |
|
| 5369 |
<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> |
| 5370 |
<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains |
| 5371 |
a substring matched by the given RegExp. |
| 5372 |
matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message |
| 5373 |
invocation for self.bodyView. |
| 5374 |
[self.bodyView loadHTMLString:html baseURL:NULL]; |
| 5375 |
|
| 5376 |
If the matcher is used in clang-query, RegexFlags parameter |
| 5377 |
should be passed as a quoted string. e.g: "NoFlags". |
| 5378 |
Flags can be combined with '|' example "IgnoreCase | BasicRegex" |
| 5379 |
</pre></td></tr> |
| 5380 |
|
| 5381 |
|
| 5382 |
<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> |
| 5383 |
<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments |
| 5384 |
|
| 5385 |
matcher = objCMessageExpr(numSelectorArgs(0)); |
| 5386 |
matches self.bodyView in the code below |
| 5387 |
|
| 5388 |
matcher = objCMessageExpr(numSelectorArgs(2)); |
| 5389 |
matches the invocation of "loadHTMLString:baseURL:" but not that |
| 5390 |
of self.bodyView |
| 5391 |
[self.bodyView loadHTMLString:html baseURL:NULL]; |
| 5392 |
</pre></td></tr> |
| 5393 |
|
| 5394 |
|
| 5395 |
<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> |
| 5396 |
<tr><td colspan="4" class="doc" id="isClassMethod0"><pre>Returns true when the Objective-C method declaration is a class method. |
| 5397 |
|
| 5398 |
Example |
| 5399 |
matcher = objcMethodDecl(isClassMethod()) |
| 5400 |
matches |
| 5401 |
@interface I + (void)foo; @end |
| 5402 |
but not |
| 5403 |
@interface I - (void)bar; @end |
| 5404 |
</pre></td></tr> |
| 5405 |
|
| 5406 |
|
| 5407 |
<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> |
| 5408 |
<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. |
| 5409 |
|
| 5410 |
Example matches A, va, fa |
| 5411 |
class A {}; |
| 5412 |
class B; // Doesn't match, as it has no body. |
| 5413 |
int va; |
| 5414 |
extern int vb; // Doesn't match, as it doesn't define the variable. |
| 5415 |
void fa() {} |
| 5416 |
void fb(); // Doesn't match, as it has no body. |
| 5417 |
@interface X |
| 5418 |
- (void)ma; // Doesn't match, interface is declaration. |
| 5419 |
@end |
| 5420 |
@implementation X |
| 5421 |
- (void)ma {} |
| 5422 |
@end |
| 5423 |
|
| 5424 |
Usable 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>>, |
| 5425 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> |
| 5426 |
</pre></td></tr> |
| 5427 |
|
| 5428 |
|
| 5429 |
<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> |
| 5430 |
<tr><td colspan="4" class="doc" id="isInstanceMethod0"><pre>Returns true when the Objective-C method declaration is an instance method. |
| 5431 |
|
| 5432 |
Example |
| 5433 |
matcher = objcMethodDecl(isInstanceMethod()) |
| 5434 |
matches |
| 5435 |
@interface I - (void)bar; @end |
| 5436 |
but not |
| 5437 |
@interface I + (void)foo; @end |
| 5438 |
</pre></td></tr> |
| 5439 |
|
| 5440 |
|
| 5441 |
<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> |
| 5442 |
<tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments. |
| 5443 |
|
| 5444 |
Example matches y (matcher = parmVarDecl(hasDefaultArgument())) |
| 5445 |
void x(int val) {} |
| 5446 |
void y(int val = 0) {} |
| 5447 |
|
| 5448 |
Deprecated. Use hasInitializer() instead to be able to |
| 5449 |
match on the contents of the default argument. For example: |
| 5450 |
|
| 5451 |
void x(int val = 7) {} |
| 5452 |
void y(int val = 42) {} |
| 5453 |
parmVarDecl(hasInitializer(integerLiteral(equals(42)))) |
| 5454 |
matches the parameter of y |
| 5455 |
|
| 5456 |
A matcher such as |
| 5457 |
parmVarDecl(hasInitializer(anything())) |
| 5458 |
is equivalent to parmVarDecl(hasDefaultArgument()). |
| 5459 |
</pre></td></tr> |
| 5460 |
|
| 5461 |
|
| 5462 |
<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> |
| 5463 |
<tr><td colspan="4" class="doc" id="isAtPosition0"><pre>Matches the ParmVarDecl nodes that are at the N'th position in the parameter |
| 5464 |
list. The parameter list could be that of either a block, function, or |
| 5465 |
objc-method. |
| 5466 |
|
| 5467 |
|
| 5468 |
Given |
| 5469 |
|
| 5470 |
void f(int a, int b, int c) { |
| 5471 |
} |
| 5472 |
|
| 5473 |
``parmVarDecl(isAtPosition(0))`` matches ``int a``. |
| 5474 |
|
| 5475 |
``parmVarDecl(isAtPosition(1))`` matches ``int b``. |
| 5476 |
</pre></td></tr> |
| 5477 |
|
| 5478 |
|
| 5479 |
<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> |
| 5480 |
<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. |
| 5481 |
|
| 5482 |
Given |
| 5483 |
class Y { public: void x(); }; |
| 5484 |
void z() { Y* y; y->x(); } |
| 5485 |
cxxMemberCallExpr(on(hasType(asString("class Y *")))) |
| 5486 |
matches y->x() |
| 5487 |
</pre></td></tr> |
| 5488 |
|
| 5489 |
|
| 5490 |
<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> |
| 5491 |
<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. |
| 5492 |
|
| 5493 |
Matches a node if it equals the node previously bound to ID. |
| 5494 |
|
| 5495 |
Given |
| 5496 |
class X { int a; int b; }; |
| 5497 |
cxxRecordDecl( |
| 5498 |
has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 5499 |
has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 5500 |
matches the class X, as a and b have the same type. |
| 5501 |
|
| 5502 |
Note that when multiple matches are involved via forEach* matchers, |
| 5503 |
equalsBoundNodes acts as a filter. |
| 5504 |
For example: |
| 5505 |
compoundStmt( |
| 5506 |
forEachDescendant(varDecl().bind("d")), |
| 5507 |
forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 5508 |
will trigger a match for each combination of variable declaration |
| 5509 |
and reference to that variable declaration within a compound statement. |
| 5510 |
</pre></td></tr> |
| 5511 |
|
| 5512 |
|
| 5513 |
<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> |
| 5514 |
<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to |
| 5515 |
the node, not hidden within a typedef. |
| 5516 |
|
| 5517 |
Given |
| 5518 |
typedef const int const_int; |
| 5519 |
const_int i; |
| 5520 |
int *const j; |
| 5521 |
int *volatile k; |
| 5522 |
int m; |
| 5523 |
varDecl(hasType(hasLocalQualifiers())) matches only j and k. |
| 5524 |
i is const-qualified but the qualifier is not local. |
| 5525 |
</pre></td></tr> |
| 5526 |
|
| 5527 |
|
| 5528 |
<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> |
| 5529 |
<tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type. |
| 5530 |
|
| 5531 |
Given |
| 5532 |
void a(char); |
| 5533 |
void b(wchar_t); |
| 5534 |
void c(double); |
| 5535 |
functionDecl(hasAnyParameter(hasType(isAnyCharacter()))) |
| 5536 |
matches "a(char)", "b(wchar_t)", but not "c(double)". |
| 5537 |
</pre></td></tr> |
| 5538 |
|
| 5539 |
|
| 5540 |
<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> |
| 5541 |
<tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes |
| 5542 |
the Objective-C object pointer type, which is different despite being |
| 5543 |
syntactically similar. |
| 5544 |
|
| 5545 |
Given |
| 5546 |
int *i = nullptr; |
| 5547 |
|
| 5548 |
@interface Foo |
| 5549 |
@end |
| 5550 |
Foo *f; |
| 5551 |
|
| 5552 |
int j; |
| 5553 |
varDecl(hasType(isAnyPointer())) |
| 5554 |
matches "int *i" and "Foo *f", but not "int j". |
| 5555 |
</pre></td></tr> |
| 5556 |
|
| 5557 |
|
| 5558 |
<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> |
| 5559 |
<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that |
| 5560 |
include "top-level" const. |
| 5561 |
|
| 5562 |
Given |
| 5563 |
void a(int); |
| 5564 |
void b(int const); |
| 5565 |
void c(const int); |
| 5566 |
void d(const int*); |
| 5567 |
void e(int const) {}; |
| 5568 |
functionDecl(hasAnyParameter(hasType(isConstQualified()))) |
| 5569 |
matches "void b(int const)", "void c(const int)" and |
| 5570 |
"void e(int const) {}". It does not match d as there |
| 5571 |
is no top-level const on the parameter type "const int *". |
| 5572 |
</pre></td></tr> |
| 5573 |
|
| 5574 |
|
| 5575 |
<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> |
| 5576 |
<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. |
| 5577 |
|
| 5578 |
Given |
| 5579 |
void a(int); |
| 5580 |
void b(unsigned long); |
| 5581 |
void c(double); |
| 5582 |
functionDecl(hasAnyParameter(hasType(isInteger()))) |
| 5583 |
matches "a(int)", "b(unsigned long)", but not "c(double)". |
| 5584 |
</pre></td></tr> |
| 5585 |
|
| 5586 |
|
| 5587 |
<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> |
| 5588 |
<tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type. |
| 5589 |
|
| 5590 |
Given |
| 5591 |
void a(int); |
| 5592 |
void b(unsigned long); |
| 5593 |
void c(double); |
| 5594 |
functionDecl(hasAnyParameter(hasType(isSignedInteger()))) |
| 5595 |
matches "a(int)", but not "b(unsigned long)" and "c(double)". |
| 5596 |
</pre></td></tr> |
| 5597 |
|
| 5598 |
|
| 5599 |
<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> |
| 5600 |
<tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type. |
| 5601 |
|
| 5602 |
Given |
| 5603 |
void a(int); |
| 5604 |
void b(unsigned long); |
| 5605 |
void c(double); |
| 5606 |
functionDecl(hasAnyParameter(hasType(isUnsignedInteger()))) |
| 5607 |
matches "b(unsigned long)", but not "a(int)" and "c(double)". |
| 5608 |
</pre></td></tr> |
| 5609 |
|
| 5610 |
|
| 5611 |
<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> |
| 5612 |
<tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that |
| 5613 |
include "top-level" volatile. |
| 5614 |
|
| 5615 |
Given |
| 5616 |
void a(int); |
| 5617 |
void b(int volatile); |
| 5618 |
void c(volatile int); |
| 5619 |
void d(volatile int*); |
| 5620 |
void e(int volatile) {}; |
| 5621 |
functionDecl(hasAnyParameter(hasType(isVolatileQualified()))) |
| 5622 |
matches "void b(int volatile)", "void c(volatile int)" and |
| 5623 |
"void e(int volatile) {}". It does not match d as there |
| 5624 |
is no top-level volatile on the parameter type "volatile int *". |
| 5625 |
</pre></td></tr> |
| 5626 |
|
| 5627 |
|
| 5628 |
<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> |
| 5629 |
<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. |
| 5630 |
|
| 5631 |
Matches a node if it equals the node previously bound to ID. |
| 5632 |
|
| 5633 |
Given |
| 5634 |
class X { int a; int b; }; |
| 5635 |
cxxRecordDecl( |
| 5636 |
has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 5637 |
has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 5638 |
matches the class X, as a and b have the same type. |
| 5639 |
|
| 5640 |
Note that when multiple matches are involved via forEach* matchers, |
| 5641 |
equalsBoundNodes acts as a filter. |
| 5642 |
For example: |
| 5643 |
compoundStmt( |
| 5644 |
forEachDescendant(varDecl().bind("d")), |
| 5645 |
forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 5646 |
will trigger a match for each combination of variable declaration |
| 5647 |
and reference to that variable declaration within a compound statement. |
| 5648 |
</pre></td></tr> |
| 5649 |
|
| 5650 |
|
| 5651 |
<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> |
| 5652 |
<tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. |
| 5653 |
|
| 5654 |
Stmt has pointer identity in the AST. |
| 5655 |
</pre></td></tr> |
| 5656 |
|
| 5657 |
|
| 5658 |
<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> |
| 5659 |
<tr><td colspan="4" class="doc" id="isExpandedFromMacro1"><pre>Matches statements that are (transitively) expanded from the named macro. |
| 5660 |
Does not match if only part of the statement is expanded from that macro or |
| 5661 |
if different parts of the statement are expanded from different |
| 5662 |
appearances of the macro. |
| 5663 |
</pre></td></tr> |
| 5664 |
|
| 5665 |
|
| 5666 |
<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> |
| 5667 |
<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is |
| 5668 |
partially matching a given regex. |
| 5669 |
|
| 5670 |
Example matches Y but not X |
| 5671 |
(matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 5672 |
#include "ASTMatcher.h" |
| 5673 |
class X {}; |
| 5674 |
ASTMatcher.h: |
| 5675 |
class Y {}; |
| 5676 |
|
| 5677 |
Usable 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>> |
| 5678 |
|
| 5679 |
If the matcher is used in clang-query, RegexFlags parameter |
| 5680 |
should be passed as a quoted string. e.g: "NoFlags". |
| 5681 |
Flags can be combined with '|' example "IgnoreCase | BasicRegex" |
| 5682 |
</pre></td></tr> |
| 5683 |
|
| 5684 |
|
| 5685 |
<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> |
| 5686 |
<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. |
| 5687 |
|
| 5688 |
Example matches X but not Y |
| 5689 |
(matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 5690 |
#include <Y.h> |
| 5691 |
class X {}; |
| 5692 |
Y.h: |
| 5693 |
class Y {}; |
| 5694 |
|
| 5695 |
Usable 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>> |
| 5696 |
</pre></td></tr> |
| 5697 |
|
| 5698 |
|
| 5699 |
<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> |
| 5700 |
<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. |
| 5701 |
|
| 5702 |
Example matches Y but not X |
| 5703 |
(matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 5704 |
#include <SystemHeader.h> |
| 5705 |
class X {}; |
| 5706 |
SystemHeader.h: |
| 5707 |
class Y {}; |
| 5708 |
|
| 5709 |
Usable 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>> |
| 5710 |
</pre></td></tr> |
| 5711 |
|
| 5712 |
|
| 5713 |
<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> |
| 5714 |
<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. |
| 5715 |
|
| 5716 |
Given |
| 5717 |
int j; |
| 5718 |
template<typename T> void A(T t) { T i; j += 42;} |
| 5719 |
A(0); |
| 5720 |
A(0U); |
| 5721 |
declStmt(isInTemplateInstantiation()) |
| 5722 |
matches 'int i;' and 'unsigned i'. |
| 5723 |
unless(stmt(isInTemplateInstantiation())) |
| 5724 |
will NOT match j += 42; as it's shared between the template definition and |
| 5725 |
instantiation. |
| 5726 |
</pre></td></tr> |
| 5727 |
|
| 5728 |
|
| 5729 |
<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> |
| 5730 |
<tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size. |
| 5731 |
|
| 5732 |
Given |
| 5733 |
int a[42]; |
| 5734 |
int b[2 * 21]; |
| 5735 |
int c[41], d[43]; |
| 5736 |
char *s = "abcd"; |
| 5737 |
wchar_t *ws = L"abcd"; |
| 5738 |
char *w = "a"; |
| 5739 |
constantArrayType(hasSize(42)) |
| 5740 |
matches "int a[42]" and "int b[2 * 21]" |
| 5741 |
stringLiteral(hasSize(4)) |
| 5742 |
matches "abcd", L"abcd" |
| 5743 |
</pre></td></tr> |
| 5744 |
|
| 5745 |
|
| 5746 |
<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> |
| 5747 |
<tr><td colspan="4" class="doc" id="isClass0"><pre>Matches TagDecl object that are spelled with "class." |
| 5748 |
|
| 5749 |
Example matches C, but not S, U or E. |
| 5750 |
struct S {}; |
| 5751 |
class C {}; |
| 5752 |
union U {}; |
| 5753 |
enum E {}; |
| 5754 |
</pre></td></tr> |
| 5755 |
|
| 5756 |
|
| 5757 |
<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> |
| 5758 |
<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. |
| 5759 |
|
| 5760 |
Example matches A, va, fa |
| 5761 |
class A {}; |
| 5762 |
class B; // Doesn't match, as it has no body. |
| 5763 |
int va; |
| 5764 |
extern int vb; // Doesn't match, as it doesn't define the variable. |
| 5765 |
void fa() {} |
| 5766 |
void fb(); // Doesn't match, as it has no body. |
| 5767 |
@interface X |
| 5768 |
- (void)ma; // Doesn't match, interface is declaration. |
| 5769 |
@end |
| 5770 |
@implementation X |
| 5771 |
- (void)ma {} |
| 5772 |
@end |
| 5773 |
|
| 5774 |
Usable 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>>, |
| 5775 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> |
| 5776 |
</pre></td></tr> |
| 5777 |
|
| 5778 |
|
| 5779 |
<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> |
| 5780 |
<tr><td colspan="4" class="doc" id="isEnum0"><pre>Matches TagDecl object that are spelled with "enum." |
| 5781 |
|
| 5782 |
Example matches E, but not C, S or U. |
| 5783 |
struct S {}; |
| 5784 |
class C {}; |
| 5785 |
union U {}; |
| 5786 |
enum E {}; |
| 5787 |
</pre></td></tr> |
| 5788 |
|
| 5789 |
|
| 5790 |
<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> |
| 5791 |
<tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches TagDecl object that are spelled with "struct." |
| 5792 |
|
| 5793 |
Example matches S, but not C, U or E. |
| 5794 |
struct S {}; |
| 5795 |
class C {}; |
| 5796 |
union U {}; |
| 5797 |
enum E {}; |
| 5798 |
</pre></td></tr> |
| 5799 |
|
| 5800 |
|
| 5801 |
<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> |
| 5802 |
<tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches TagDecl object that are spelled with "union." |
| 5803 |
|
| 5804 |
Example matches U, but not C, S or E. |
| 5805 |
struct S {}; |
| 5806 |
class C {}; |
| 5807 |
union U {}; |
| 5808 |
enum E {}; |
| 5809 |
</pre></td></tr> |
| 5810 |
|
| 5811 |
|
| 5812 |
<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> |
| 5813 |
<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. |
| 5814 |
|
| 5815 |
Note that 'Value' is a string as the template argument's value is |
| 5816 |
an arbitrary precision integer. 'Value' must be equal to the canonical |
| 5817 |
representation of that integral value in base 10. |
| 5818 |
|
| 5819 |
Given |
| 5820 |
template<int T> struct C {}; |
| 5821 |
C<42> c; |
| 5822 |
classTemplateSpecializationDecl( |
| 5823 |
hasAnyTemplateArgument(equalsIntegralValue("42"))) |
| 5824 |
matches the implicit instantiation of C in C<42>. |
| 5825 |
</pre></td></tr> |
| 5826 |
|
| 5827 |
|
| 5828 |
<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> |
| 5829 |
<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. |
| 5830 |
|
| 5831 |
Given |
| 5832 |
template<int T> struct C {}; |
| 5833 |
C<42> c; |
| 5834 |
classTemplateSpecializationDecl( |
| 5835 |
hasAnyTemplateArgument(isIntegral())) |
| 5836 |
matches the implicit instantiation of C in C<42> |
| 5837 |
with isIntegral() matching 42. |
| 5838 |
</pre></td></tr> |
| 5839 |
|
| 5840 |
|
| 5841 |
<tr><td>Matcher<TemplateSpecializationType></td><td class="name" onclick="toggle('templateArgumentCountIs3')"><a name="templateArgumentCountIs3Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> |
| 5842 |
<tr><td colspan="4" class="doc" id="templateArgumentCountIs3"><pre>Matches if the number of template arguments equals N. |
| 5843 |
|
| 5844 |
Given |
| 5845 |
template<typename T> struct C {}; |
| 5846 |
C<int> c; |
| 5847 |
template<typename T> void f() {} |
| 5848 |
void func() { f<int>(); }; |
| 5849 |
|
| 5850 |
classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
| 5851 |
matches C<int>. |
| 5852 |
|
| 5853 |
functionDecl(templateArgumentCountIs(1)) |
| 5854 |
matches f<int>(); |
| 5855 |
</pre></td></tr> |
| 5856 |
|
| 5857 |
|
| 5858 |
<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> |
| 5859 |
<tr><td colspan="4" class="doc" id="isExpandedFromMacro2"><pre>Matches statements that are (transitively) expanded from the named macro. |
| 5860 |
Does not match if only part of the statement is expanded from that macro or |
| 5861 |
if different parts of the statement are expanded from different |
| 5862 |
appearances of the macro. |
| 5863 |
</pre></td></tr> |
| 5864 |
|
| 5865 |
|
| 5866 |
<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> |
| 5867 |
<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is |
| 5868 |
partially matching a given regex. |
| 5869 |
|
| 5870 |
Example matches Y but not X |
| 5871 |
(matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 5872 |
#include "ASTMatcher.h" |
| 5873 |
class X {}; |
| 5874 |
ASTMatcher.h: |
| 5875 |
class Y {}; |
| 5876 |
|
| 5877 |
Usable 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>> |
| 5878 |
|
| 5879 |
If the matcher is used in clang-query, RegexFlags parameter |
| 5880 |
should be passed as a quoted string. e.g: "NoFlags". |
| 5881 |
Flags can be combined with '|' example "IgnoreCase | BasicRegex" |
| 5882 |
</pre></td></tr> |
| 5883 |
|
| 5884 |
|
| 5885 |
<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> |
| 5886 |
<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. |
| 5887 |
|
| 5888 |
Example matches X but not Y |
| 5889 |
(matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 5890 |
#include <Y.h> |
| 5891 |
class X {}; |
| 5892 |
Y.h: |
| 5893 |
class Y {}; |
| 5894 |
|
| 5895 |
Usable 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>> |
| 5896 |
</pre></td></tr> |
| 5897 |
|
| 5898 |
|
| 5899 |
<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> |
| 5900 |
<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. |
| 5901 |
|
| 5902 |
Example matches Y but not X |
| 5903 |
(matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 5904 |
#include <SystemHeader.h> |
| 5905 |
class X {}; |
| 5906 |
SystemHeader.h: |
| 5907 |
class Y {}; |
| 5908 |
|
| 5909 |
Usable 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>> |
| 5910 |
</pre></td></tr> |
| 5911 |
|
| 5912 |
|
| 5913 |
<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> |
| 5914 |
<tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool. |
| 5915 |
|
| 5916 |
Given |
| 5917 |
struct S { bool func(); }; |
| 5918 |
functionDecl(returns(booleanType())) |
| 5919 |
matches "bool func();" |
| 5920 |
</pre></td></tr> |
| 5921 |
|
| 5922 |
|
| 5923 |
<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> |
| 5924 |
<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. |
| 5925 |
|
| 5926 |
Matches a node if it equals the node previously bound to ID. |
| 5927 |
|
| 5928 |
Given |
| 5929 |
class X { int a; int b; }; |
| 5930 |
cxxRecordDecl( |
| 5931 |
has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 5932 |
has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 5933 |
matches the class X, as a and b have the same type. |
| 5934 |
|
| 5935 |
Note that when multiple matches are involved via forEach* matchers, |
| 5936 |
equalsBoundNodes acts as a filter. |
| 5937 |
For example: |
| 5938 |
compoundStmt( |
| 5939 |
forEachDescendant(varDecl().bind("d")), |
| 5940 |
forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 5941 |
will trigger a match for each combination of variable declaration |
| 5942 |
and reference to that variable declaration within a compound statement. |
| 5943 |
</pre></td></tr> |
| 5944 |
|
| 5945 |
|
| 5946 |
<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> |
| 5947 |
<tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node. |
| 5948 |
|
| 5949 |
Type has pointer identity in the AST. |
| 5950 |
</pre></td></tr> |
| 5951 |
|
| 5952 |
|
| 5953 |
<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> |
| 5954 |
<tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double). |
| 5955 |
|
| 5956 |
Given |
| 5957 |
int i; |
| 5958 |
float f; |
| 5959 |
realFloatingPointType() |
| 5960 |
matches "float f" but not "int i" |
| 5961 |
</pre></td></tr> |
| 5962 |
|
| 5963 |
|
| 5964 |
<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> |
| 5965 |
<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. |
| 5966 |
|
| 5967 |
Given |
| 5968 |
struct S { void func(); }; |
| 5969 |
functionDecl(returns(voidType())) |
| 5970 |
matches "void func();" |
| 5971 |
</pre></td></tr> |
| 5972 |
|
| 5973 |
|
| 5974 |
<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> |
| 5975 |
<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. |
| 5976 |
|
| 5977 |
Given |
| 5978 |
int x; |
| 5979 |
int s = sizeof(x) + alignof(x) |
| 5980 |
unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) |
| 5981 |
matches sizeof(x) |
| 5982 |
|
| 5983 |
If the matcher is use from clang-query, UnaryExprOrTypeTrait parameter |
| 5984 |
should be passed as a quoted string. e.g., ofKind("UETT_SizeOf"). |
| 5985 |
</pre></td></tr> |
| 5986 |
|
| 5987 |
|
| 5988 |
<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> |
| 5989 |
<tr><td colspan="4" class="doc" id="hasAnyOperatorName3"><pre>Matches operator expressions (binary or unary) that have any of the |
| 5990 |
specified names. |
| 5991 |
|
| 5992 |
hasAnyOperatorName("+", "-") |
| 5993 |
Is equivalent to |
| 5994 |
anyOf(hasOperatorName("+"), hasOperatorName("-")) |
| 5995 |
</pre></td></tr> |
| 5996 |
|
| 5997 |
|
| 5998 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>></td><td class="name" onclick="toggle('hasOperatorName4')"><a name="hasOperatorName4Anchor">hasOperatorName</a></td><td>std::string Name</td></tr> |
| 5999 |
<tr><td colspan="4" class="doc" id="hasOperatorName4"><pre>Matches the operator Name of operator expressions and fold expressions |
| 6000 |
(binary or unary). |
| 6001 |
|
| 6002 |
Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 6003 |
!(a || b) |
| 6004 |
|
| 6005 |
Example matches `(0 + ... + args)` |
| 6006 |
(matcher = cxxFoldExpr(hasOperatorName("+"))) |
| 6007 |
template <typename... Args> |
| 6008 |
auto sum(Args... args) { |
| 6009 |
return (0 + ... + args); |
| 6010 |
} |
| 6011 |
</pre></td></tr> |
| 6012 |
|
| 6013 |
|
| 6014 |
<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> |
| 6015 |
<tr><td colspan="4" class="doc" id="isArrow1"><pre>Matches member expressions that are called with '->' as opposed |
| 6016 |
to '.'. |
| 6017 |
|
| 6018 |
Member calls on the implicit this pointer match as called with '->'. |
| 6019 |
|
| 6020 |
Given |
| 6021 |
class Y { |
| 6022 |
void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 6023 |
template <class T> void f() { this->f<T>(); f<T>(); } |
| 6024 |
int a; |
| 6025 |
static int b; |
| 6026 |
}; |
| 6027 |
template <class T> |
| 6028 |
class Z { |
| 6029 |
void x() { this->m; } |
| 6030 |
}; |
| 6031 |
memberExpr(isArrow()) |
| 6032 |
matches this->x, x, y.x, a, this->b |
| 6033 |
cxxDependentScopeMemberExpr(isArrow()) |
| 6034 |
matches this->m |
| 6035 |
unresolvedMemberExpr(isArrow()) |
| 6036 |
matches this->f<T>, f<T> |
| 6037 |
</pre></td></tr> |
| 6038 |
|
| 6039 |
|
| 6040 |
<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> |
| 6041 |
<tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration. |
| 6042 |
|
| 6043 |
Example matches x, but not y, z, or a. |
| 6044 |
(matcher = varDecl(hasAutomaticStorageDuration()) |
| 6045 |
void f() { |
| 6046 |
int x; |
| 6047 |
static int y; |
| 6048 |
thread_local int z; |
| 6049 |
} |
| 6050 |
int a; |
| 6051 |
</pre></td></tr> |
| 6052 |
|
| 6053 |
|
| 6054 |
<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> |
| 6055 |
<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. |
| 6056 |
|
| 6057 |
Example matches y and z (matcher = varDecl(hasGlobalStorage()) |
| 6058 |
void f() { |
| 6059 |
int x; |
| 6060 |
static int y; |
| 6061 |
} |
| 6062 |
int z; |
| 6063 |
</pre></td></tr> |
| 6064 |
|
| 6065 |
|
| 6066 |
<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> |
| 6067 |
<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a |
| 6068 |
non-static local variable. |
| 6069 |
|
| 6070 |
Example matches x (matcher = varDecl(hasLocalStorage()) |
| 6071 |
void f() { |
| 6072 |
int x; |
| 6073 |
static int y; |
| 6074 |
} |
| 6075 |
int z; |
| 6076 |
</pre></td></tr> |
| 6077 |
|
| 6078 |
|
| 6079 |
<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> |
| 6080 |
<tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration. |
| 6081 |
It includes the variable declared at namespace scope and those declared |
| 6082 |
with "static" and "extern" storage class specifiers. |
| 6083 |
|
| 6084 |
void f() { |
| 6085 |
int x; |
| 6086 |
static int y; |
| 6087 |
thread_local int z; |
| 6088 |
} |
| 6089 |
int a; |
| 6090 |
static int b; |
| 6091 |
extern int c; |
| 6092 |
varDecl(hasStaticStorageDuration()) |
| 6093 |
matches the function declaration y, a, b and c. |
| 6094 |
</pre></td></tr> |
| 6095 |
|
| 6096 |
|
| 6097 |
<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> |
| 6098 |
<tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration. |
| 6099 |
|
| 6100 |
Example matches z, but not x, z, or a. |
| 6101 |
(matcher = varDecl(hasThreadStorageDuration()) |
| 6102 |
void f() { |
| 6103 |
int x; |
| 6104 |
static int y; |
| 6105 |
thread_local int z; |
| 6106 |
} |
| 6107 |
int a; |
| 6108 |
</pre></td></tr> |
| 6109 |
|
| 6110 |
|
| 6111 |
<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> |
| 6112 |
<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations, |
| 6113 |
and if constexpr. |
| 6114 |
|
| 6115 |
Given: |
| 6116 |
constexpr int foo = 42; |
| 6117 |
constexpr int bar(); |
| 6118 |
void baz() { if constexpr(1 > 0) {} } |
| 6119 |
varDecl(isConstexpr()) |
| 6120 |
matches the declaration of foo. |
| 6121 |
functionDecl(isConstexpr()) |
| 6122 |
matches the declaration of bar. |
| 6123 |
ifStmt(isConstexpr()) |
| 6124 |
matches the if statement in baz. |
| 6125 |
</pre></td></tr> |
| 6126 |
|
| 6127 |
|
| 6128 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isConstinit0')"><a name="isConstinit0Anchor">isConstinit</a></td><td></td></tr> |
| 6129 |
<tr><td colspan="4" class="doc" id="isConstinit0"><pre>Matches constinit variable declarations. |
| 6130 |
|
| 6131 |
Given: |
| 6132 |
constinit int foo = 42; |
| 6133 |
constinit const char* bar = "bar"; |
| 6134 |
int baz = 42; |
| 6135 |
[[clang::require_constant_initialization]] int xyz = 42; |
| 6136 |
varDecl(isConstinit()) |
| 6137 |
matches the declaration of `foo` and `bar`, but not `baz` and `xyz`. |
| 6138 |
</pre></td></tr> |
| 6139 |
|
| 6140 |
|
| 6141 |
<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> |
| 6142 |
<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. |
| 6143 |
|
| 6144 |
Example matches A, va, fa |
| 6145 |
class A {}; |
| 6146 |
class B; // Doesn't match, as it has no body. |
| 6147 |
int va; |
| 6148 |
extern int vb; // Doesn't match, as it doesn't define the variable. |
| 6149 |
void fa() {} |
| 6150 |
void fb(); // Doesn't match, as it has no body. |
| 6151 |
@interface X |
| 6152 |
- (void)ma; // Doesn't match, interface is declaration. |
| 6153 |
@end |
| 6154 |
@implementation X |
| 6155 |
- (void)ma {} |
| 6156 |
@end |
| 6157 |
|
| 6158 |
Usable 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>>, |
| 6159 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> |
| 6160 |
</pre></td></tr> |
| 6161 |
|
| 6162 |
|
| 6163 |
<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> |
| 6164 |
<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from |
| 6165 |
a C++ catch block, or an Objective-C statement. |
| 6166 |
|
| 6167 |
Example matches x (matcher = varDecl(isExceptionVariable()) |
| 6168 |
void f(int y) { |
| 6169 |
try { |
| 6170 |
} catch (int x) { |
| 6171 |
} |
| 6172 |
} |
| 6173 |
</pre></td></tr> |
| 6174 |
|
| 6175 |
|
| 6176 |
<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> |
| 6177 |
<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or |
| 6178 |
static member variable template instantiations. |
| 6179 |
|
| 6180 |
Given |
| 6181 |
template<typename T> void A(T t) { } |
| 6182 |
template<> void A(int N) { } |
| 6183 |
functionDecl(isExplicitTemplateSpecialization()) |
| 6184 |
matches the specialization A<int>(). |
| 6185 |
|
| 6186 |
Usable 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>> |
| 6187 |
</pre></td></tr> |
| 6188 |
|
| 6189 |
|
| 6190 |
<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> |
| 6191 |
<tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations. |
| 6192 |
|
| 6193 |
Given: |
| 6194 |
extern "C" void f() {} |
| 6195 |
extern "C" { void g() {} } |
| 6196 |
void h() {} |
| 6197 |
extern "C" int x = 1; |
| 6198 |
extern "C" int y = 2; |
| 6199 |
int z = 3; |
| 6200 |
functionDecl(isExternC()) |
| 6201 |
matches the declaration of f and g, but not the declaration of h. |
| 6202 |
varDecl(isExternC()) |
| 6203 |
matches the declaration of x and y, but not the declaration of z. |
| 6204 |
</pre></td></tr> |
| 6205 |
|
| 6206 |
|
| 6207 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isInitCapture0')"><a name="isInitCapture0Anchor">isInitCapture</a></td><td></td></tr> |
| 6208 |
<tr><td colspan="4" class="doc" id="isInitCapture0"><pre>Matches a variable serving as the implicit variable for a lambda init- |
| 6209 |
capture. |
| 6210 |
|
| 6211 |
Example matches x (matcher = varDecl(isInitCapture())) |
| 6212 |
auto f = [x=3]() { return x; }; |
| 6213 |
</pre></td></tr> |
| 6214 |
|
| 6215 |
|
| 6216 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isInline2')"><a name="isInline2Anchor">isInline</a></td><td></td></tr> |
| 6217 |
<tr><td colspan="4" class="doc" id="isInline2"><pre>Matches functions, variables and namespace declarations that are marked with |
| 6218 |
the inline keyword. |
| 6219 |
|
| 6220 |
Given |
| 6221 |
inline void f(); |
| 6222 |
void g(); |
| 6223 |
namespace n { |
| 6224 |
inline namespace m {} |
| 6225 |
} |
| 6226 |
inline int Foo = 5; |
| 6227 |
functionDecl(isInline()) will match ::f(). |
| 6228 |
namespaceDecl(isInline()) will match n::m. |
| 6229 |
varDecl(isInline()) will match Foo; |
| 6230 |
</pre></td></tr> |
| 6231 |
|
| 6232 |
|
| 6233 |
<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> |
| 6234 |
<tr><td colspan="4" class="doc" id="isStaticLocal0"><pre>Matches a static variable with local scope. |
| 6235 |
|
| 6236 |
Example matches y (matcher = varDecl(isStaticLocal())) |
| 6237 |
void f() { |
| 6238 |
int x; |
| 6239 |
static int y; |
| 6240 |
} |
| 6241 |
static int z; |
| 6242 |
</pre></td></tr> |
| 6243 |
|
| 6244 |
|
| 6245 |
<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> |
| 6246 |
<tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variable/function declarations that have "static" storage |
| 6247 |
class specifier ("static" keyword) written in the source. |
| 6248 |
|
| 6249 |
Given: |
| 6250 |
static void f() {} |
| 6251 |
static int i = 0; |
| 6252 |
extern int j; |
| 6253 |
int k; |
| 6254 |
functionDecl(isStaticStorageClass()) |
| 6255 |
matches the function declaration f. |
| 6256 |
varDecl(isStaticStorageClass()) |
| 6257 |
matches the variable declaration i. |
| 6258 |
</pre></td></tr> |
| 6259 |
|
| 6260 |
|
| 6261 |
<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> |
| 6262 |
<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static |
| 6263 |
member variable template instantiations. |
| 6264 |
|
| 6265 |
Given |
| 6266 |
template <typename T> class X {}; class A {}; X<A> x; |
| 6267 |
or |
| 6268 |
template <typename T> class X {}; class A {}; template class X<A>; |
| 6269 |
or |
| 6270 |
template <typename T> class X {}; class A {}; extern template class X<A>; |
| 6271 |
cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 6272 |
matches the template instantiation of X<A>. |
| 6273 |
|
| 6274 |
But given |
| 6275 |
template <typename T> class X {}; class A {}; |
| 6276 |
template <> class X<A> {}; X<A> x; |
| 6277 |
cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 6278 |
does not match, as X<A> is an explicit template specialization. |
| 6279 |
|
| 6280 |
Usable 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>> |
| 6281 |
</pre></td></tr> |
| 6282 |
|
| 6283 |
|
| 6284 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarTemplateSpecializationDecl.html">VarTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('templateArgumentCountIs1')"><a name="templateArgumentCountIs1Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> |
| 6285 |
<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. |
| 6286 |
|
| 6287 |
Given |
| 6288 |
template<typename T> struct C {}; |
| 6289 |
C<int> c; |
| 6290 |
template<typename T> void f() {} |
| 6291 |
void func() { f<int>(); }; |
| 6292 |
|
| 6293 |
classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
| 6294 |
matches C<int>. |
| 6295 |
|
| 6296 |
functionDecl(templateArgumentCountIs(1)) |
| 6297 |
matches f<int>(); |
| 6298 |
</pre></td></tr> |
| 6299 |
|
| 6300 |
<!--END_NARROWING_MATCHERS --> |
| 6301 |
</table> |
| 6302 |
|
| 6303 |
<!-- ======================================================================= --> |
| 6304 |
<h2 id="traversal-matchers">AST Traversal Matchers</h2> |
| 6305 |
<!-- ======================================================================= --> |
| 6306 |
|
| 6307 |
<p>Traversal matchers specify the relationship to other nodes that are |
| 6308 |
reachable from the current node.</p> |
| 6309 |
|
| 6310 |
<p>Note that there are special traversal matchers (has, hasDescendant, forEach and |
| 6311 |
forEachDescendant) which work on all nodes and allow users to write more generic |
| 6312 |
match expressions.</p> |
| 6313 |
|
| 6314 |
<table> |
| 6315 |
<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| 6316 |
<!-- START_TRAVERSAL_MATCHERS --> |
| 6317 |
|
| 6318 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('binaryOperation0')"><a name="binaryOperation0Anchor">binaryOperation</a></td><td>Matcher<*>...Matcher<*></td></tr> |
| 6319 |
<tr><td colspan="4" class="doc" id="binaryOperation0"><pre>Matches nodes which can be used with binary operators. |
| 6320 |
|
| 6321 |
The code |
| 6322 |
var1 != var2; |
| 6323 |
might be represented in the clang AST as a binaryOperator, a |
| 6324 |
cxxOperatorCallExpr or a cxxRewrittenBinaryOperator, depending on |
| 6325 |
|
| 6326 |
* whether the types of var1 and var2 are fundamental (binaryOperator) or at |
| 6327 |
least one is a class type (cxxOperatorCallExpr) |
| 6328 |
* whether the code appears in a template declaration, if at least one of the |
| 6329 |
vars is a dependent-type (binaryOperator) |
| 6330 |
* whether the code relies on a rewritten binary operator, such as a |
| 6331 |
spaceship operator or an inverted equality operator |
| 6332 |
(cxxRewrittenBinaryOperator) |
| 6333 |
|
| 6334 |
This matcher elides details in places where the matchers for the nodes are |
| 6335 |
compatible. |
| 6336 |
|
| 6337 |
Given |
| 6338 |
binaryOperation( |
| 6339 |
hasOperatorName("!="), |
| 6340 |
hasLHS(expr().bind("lhs")), |
| 6341 |
hasRHS(expr().bind("rhs")) |
| 6342 |
) |
| 6343 |
matches each use of "!=" in: |
| 6344 |
struct S{ |
| 6345 |
bool operator!=(const S&) const; |
| 6346 |
}; |
| 6347 |
|
| 6348 |
void foo() |
| 6349 |
{ |
| 6350 |
1 != 2; |
| 6351 |
S() != S(); |
| 6352 |
} |
| 6353 |
|
| 6354 |
template<typename T> |
| 6355 |
void templ() |
| 6356 |
{ |
| 6357 |
1 != 2; |
| 6358 |
T() != S(); |
| 6359 |
} |
| 6360 |
struct HasOpEq |
| 6361 |
{ |
| 6362 |
bool operator==(const HasOpEq &) const; |
| 6363 |
}; |
| 6364 |
|
| 6365 |
void inverse() |
| 6366 |
{ |
| 6367 |
HasOpEq s1; |
| 6368 |
HasOpEq s2; |
| 6369 |
if (s1 != s2) |
| 6370 |
return; |
| 6371 |
} |
| 6372 |
|
| 6373 |
struct HasSpaceship |
| 6374 |
{ |
| 6375 |
bool operator<=>(const HasOpEq &) const; |
| 6376 |
}; |
| 6377 |
|
| 6378 |
void use_spaceship() |
| 6379 |
{ |
| 6380 |
HasSpaceship s1; |
| 6381 |
HasSpaceship s2; |
| 6382 |
if (s1 != s2) |
| 6383 |
return; |
| 6384 |
} |
| 6385 |
</pre></td></tr> |
| 6386 |
|
| 6387 |
|
| 6388 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 6389 |
<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. |
| 6390 |
|
| 6391 |
Unlike anyOf, eachOf will generate a match result for each |
| 6392 |
matching submatcher. |
| 6393 |
|
| 6394 |
For example, in: |
| 6395 |
class A { int a; int b; }; |
| 6396 |
The matcher: |
| 6397 |
cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), |
| 6398 |
has(fieldDecl(hasName("b")).bind("v")))) |
| 6399 |
will generate two results binding "v", the first of which binds |
| 6400 |
the field declaration of a, the second the field declaration of |
| 6401 |
b. |
| 6402 |
|
| 6403 |
Usable as: Any Matcher |
| 6404 |
</pre></td></tr> |
| 6405 |
|
| 6406 |
|
| 6407 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<*> Matcher</td></tr> |
| 6408 |
<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. |
| 6409 |
|
| 6410 |
Generates results for each match. |
| 6411 |
|
| 6412 |
For example, in: |
| 6413 |
class A { class B {}; class C {}; }; |
| 6414 |
The matcher: |
| 6415 |
cxxRecordDecl(hasName("::A"), |
| 6416 |
findAll(cxxRecordDecl(isDefinition()).bind("m"))) |
| 6417 |
will generate results for A, B and C. |
| 6418 |
|
| 6419 |
Usable as: Any Matcher |
| 6420 |
</pre></td></tr> |
| 6421 |
|
| 6422 |
|
| 6423 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> |
| 6424 |
<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 6425 |
provided matcher. |
| 6426 |
|
| 6427 |
Example matches X, A, A::X, B, B::C, B::C::X |
| 6428 |
(matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) |
| 6429 |
class X {}; |
| 6430 |
class A { class X {}; }; // Matches A, because A::X is a class of name |
| 6431 |
// X inside A. |
| 6432 |
class B { class C { class X {}; }; }; |
| 6433 |
|
| 6434 |
DescendantT must be an AST base type. |
| 6435 |
|
| 6436 |
As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for |
| 6437 |
each result that matches instead of only on the first one. |
| 6438 |
|
| 6439 |
Note: Recursively combined ForEachDescendant can cause many matches: |
| 6440 |
cxxRecordDecl(forEachDescendant(cxxRecordDecl( |
| 6441 |
forEachDescendant(cxxRecordDecl()) |
| 6442 |
))) |
| 6443 |
will match 10 times (plus injected class name matches) on: |
| 6444 |
class A { class B { class C { class D { class E {}; }; }; }; }; |
| 6445 |
|
| 6446 |
Usable as: Any Matcher |
| 6447 |
</pre></td></tr> |
| 6448 |
|
| 6449 |
|
| 6450 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> |
| 6451 |
<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the |
| 6452 |
provided matcher. |
| 6453 |
|
| 6454 |
Example matches X, Y, Y::X, Z::Y, Z::Y::X |
| 6455 |
(matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) |
| 6456 |
class X {}; |
| 6457 |
class Y { class X {}; }; // Matches Y, because Y::X is a class of name X |
| 6458 |
// inside Y. |
| 6459 |
class Z { class Y { class X {}; }; }; // Does not match Z. |
| 6460 |
|
| 6461 |
ChildT must be an AST base type. |
| 6462 |
|
| 6463 |
As opposed to 'has', 'forEach' will cause a match for each result that |
| 6464 |
matches instead of only on the first one. |
| 6465 |
|
| 6466 |
Usable as: Any Matcher |
| 6467 |
</pre></td></tr> |
| 6468 |
|
| 6469 |
|
| 6470 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> |
| 6471 |
<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided |
| 6472 |
matcher. |
| 6473 |
|
| 6474 |
Given |
| 6475 |
void f() { if (true) { int x = 42; } } |
| 6476 |
void g() { for (;;) { int x = 43; } } |
| 6477 |
expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. |
| 6478 |
|
| 6479 |
Usable as: Any Matcher |
| 6480 |
</pre></td></tr> |
| 6481 |
|
| 6482 |
|
| 6483 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> |
| 6484 |
<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 6485 |
provided matcher. |
| 6486 |
|
| 6487 |
Example matches X, Y, Z |
| 6488 |
(matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) |
| 6489 |
class X {}; // Matches X, because X::X is a class of name X inside X. |
| 6490 |
class Y { class X {}; }; |
| 6491 |
class Z { class Y { class X {}; }; }; |
| 6492 |
|
| 6493 |
DescendantT must be an AST base type. |
| 6494 |
|
| 6495 |
Usable as: Any Matcher |
| 6496 |
</pre></td></tr> |
| 6497 |
|
| 6498 |
|
| 6499 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> |
| 6500 |
<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the |
| 6501 |
provided matcher. |
| 6502 |
|
| 6503 |
Example matches X, Y |
| 6504 |
(matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) |
| 6505 |
class X {}; // Matches X, because X::X is a class of name X inside X. |
| 6506 |
class Y { class X {}; }; |
| 6507 |
class Z { class Y { class X {}; }; }; // Does not match Z. |
| 6508 |
|
| 6509 |
ChildT must be an AST base type. |
| 6510 |
|
| 6511 |
Usable as: Any Matcher |
| 6512 |
Note that has is direct matcher, so it also matches things like implicit |
| 6513 |
casts and paren casts. If you are matching with expr then you should |
| 6514 |
probably consider using ignoringParenImpCasts like: |
| 6515 |
has(ignoringParenImpCasts(expr())). |
| 6516 |
</pre></td></tr> |
| 6517 |
|
| 6518 |
|
| 6519 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> |
| 6520 |
<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided |
| 6521 |
matcher. |
| 6522 |
|
| 6523 |
Given |
| 6524 |
void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } |
| 6525 |
compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". |
| 6526 |
|
| 6527 |
Usable as: Any Matcher |
| 6528 |
</pre></td></tr> |
| 6529 |
|
| 6530 |
|
| 6531 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('invocation0')"><a name="invocation0Anchor">invocation</a></td><td>Matcher<*>...Matcher<*></td></tr> |
| 6532 |
<tr><td colspan="4" class="doc" id="invocation0"><pre>Matches function calls and constructor calls |
| 6533 |
|
| 6534 |
Because CallExpr and CXXConstructExpr do not share a common |
| 6535 |
base class with API accessing arguments etc, AST Matchers for code |
| 6536 |
which should match both are typically duplicated. This matcher |
| 6537 |
removes the need for duplication. |
| 6538 |
|
| 6539 |
Given code |
| 6540 |
struct ConstructorTakesInt |
| 6541 |
{ |
| 6542 |
ConstructorTakesInt(int i) {} |
| 6543 |
}; |
| 6544 |
|
| 6545 |
void callTakesInt(int i) |
| 6546 |
{ |
| 6547 |
} |
| 6548 |
|
| 6549 |
void doCall() |
| 6550 |
{ |
| 6551 |
callTakesInt(42); |
| 6552 |
} |
| 6553 |
|
| 6554 |
void doConstruct() |
| 6555 |
{ |
| 6556 |
ConstructorTakesInt cti(42); |
| 6557 |
} |
| 6558 |
|
| 6559 |
The matcher |
| 6560 |
invocation(hasArgument(0, integerLiteral(equals(42)))) |
| 6561 |
matches the expression in both doCall and doConstruct |
| 6562 |
</pre></td></tr> |
| 6563 |
|
| 6564 |
|
| 6565 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('optionally0')"><a name="optionally0Anchor">optionally</a></td><td>Matcher<*></td></tr> |
| 6566 |
<tr><td colspan="4" class="doc" id="optionally0"><pre>Matches any node regardless of the submatcher. |
| 6567 |
|
| 6568 |
However, optionally will retain any bindings generated by the submatcher. |
| 6569 |
Useful when additional information which may or may not present about a main |
| 6570 |
matching node is desired. |
| 6571 |
|
| 6572 |
For example, in: |
| 6573 |
class Foo { |
| 6574 |
int bar; |
| 6575 |
} |
| 6576 |
The matcher: |
| 6577 |
cxxRecordDecl( |
| 6578 |
optionally(has( |
| 6579 |
fieldDecl(hasName("bar")).bind("var") |
| 6580 |
))).bind("record") |
| 6581 |
will produce a result binding for both "record" and "var". |
| 6582 |
The matcher will produce a "record" binding for even if there is no data |
| 6583 |
member named "bar" in that class. |
| 6584 |
|
| 6585 |
Usable as: Any Matcher |
| 6586 |
</pre></td></tr> |
| 6587 |
|
| 6588 |
|
| 6589 |
<tr><td>Matcher<*></td><td class="name" onclick="toggle('traverse0')"><a name="traverse0Anchor">traverse</a></td><td>TraversalKind TK, Matcher<*> InnerMatcher</td></tr> |
| 6590 |
<tr><td colspan="4" class="doc" id="traverse0"><pre>Causes all nested matchers to be matched with the specified traversal kind. |
| 6591 |
|
| 6592 |
Given |
| 6593 |
void foo() |
| 6594 |
{ |
| 6595 |
int i = 3.0; |
| 6596 |
} |
| 6597 |
The matcher |
| 6598 |
traverse(TK_IgnoreUnlessSpelledInSource, |
| 6599 |
varDecl(hasInitializer(floatLiteral().bind("init"))) |
| 6600 |
) |
| 6601 |
matches the variable declaration with "init" bound to the "3.0". |
| 6602 |
</pre></td></tr> |
| 6603 |
|
| 6604 |
|
| 6605 |
<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> |
| 6606 |
<tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop, while loop, |
| 6607 |
do-while loop, switch statement or conditional operator. |
| 6608 |
|
| 6609 |
Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 6610 |
if (true) {} |
| 6611 |
</pre></td></tr> |
| 6612 |
|
| 6613 |
|
| 6614 |
<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> |
| 6615 |
<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator |
| 6616 |
(binary or ternary). |
| 6617 |
|
| 6618 |
Example matches b |
| 6619 |
condition ? a : b |
| 6620 |
condition ?: b |
| 6621 |
</pre></td></tr> |
| 6622 |
|
| 6623 |
|
| 6624 |
<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> |
| 6625 |
<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. |
| 6626 |
|
| 6627 |
Example 1 (conditional ternary operator): matches a |
| 6628 |
condition ? a : b |
| 6629 |
|
| 6630 |
Example 2 (conditional binary operator): matches opaqueValueExpr(condition) |
| 6631 |
condition ?: b |
| 6632 |
</pre></td></tr> |
| 6633 |
|
| 6634 |
|
| 6635 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>></td><td class="name" onclick="toggle('hasDeclaration16')"><a name="hasDeclaration16Anchor">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 6636 |
<tr><td colspan="4" class="doc" id="hasDeclaration16"><pre>Matches a node if the declaration associated with that node |
| 6637 |
matches the given matcher. |
| 6638 |
|
| 6639 |
The associated declaration is: |
| 6640 |
- for type nodes, the declaration of the underlying type |
| 6641 |
- for CallExpr, the declaration of the callee |
| 6642 |
- for MemberExpr, the declaration of the referenced member |
| 6643 |
- for CXXConstructExpr, the declaration of the constructor |
| 6644 |
- for CXXNewExpr, the declaration of the operator new |
| 6645 |
- for ObjCIvarExpr, the declaration of the ivar |
| 6646 |
|
| 6647 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 6648 |
sugared type. Given |
| 6649 |
class X {}; |
| 6650 |
typedef X Y; |
| 6651 |
Y y; |
| 6652 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6653 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 6654 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6655 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6656 |
recordType(hasDeclaration(decl()))))) |
| 6657 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 6658 |
|
| 6659 |
Usable 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>>, |
| 6660 |
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>>, |
| 6661 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 6662 |
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<RecordType>, |
| 6663 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 6664 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 6665 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 6666 |
</pre></td></tr> |
| 6667 |
|
| 6668 |
|
| 6669 |
<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> |
| 6670 |
<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. |
| 6671 |
|
| 6672 |
Given |
| 6673 |
int i[5]; |
| 6674 |
void f() { i[1] = 42; } |
| 6675 |
arraySubscriptExpression(hasBase(implicitCastExpr( |
| 6676 |
hasSourceExpression(declRefExpr())))) |
| 6677 |
matches i[1] with the declRefExpr() matching i |
| 6678 |
</pre></td></tr> |
| 6679 |
|
| 6680 |
|
| 6681 |
<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> |
| 6682 |
<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. |
| 6683 |
|
| 6684 |
Given |
| 6685 |
int i[5]; |
| 6686 |
void f() { i[1] = 42; } |
| 6687 |
arraySubscriptExpression(hasIndex(integerLiteral())) |
| 6688 |
matches i[1] with the integerLiteral() matching 1 |
| 6689 |
</pre></td></tr> |
| 6690 |
|
| 6691 |
|
| 6692 |
<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> |
| 6693 |
<tr><td colspan="4" class="doc" id="hasLHS3"><pre>Matches the left hand side of binary operator expressions. |
| 6694 |
|
| 6695 |
Example matches a (matcher = binaryOperator(hasLHS())) |
| 6696 |
a || b |
| 6697 |
</pre></td></tr> |
| 6698 |
|
| 6699 |
|
| 6700 |
<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> |
| 6701 |
<tr><td colspan="4" class="doc" id="hasRHS3"><pre>Matches the right hand side of binary operator expressions. |
| 6702 |
|
| 6703 |
Example matches b (matcher = binaryOperator(hasRHS())) |
| 6704 |
a || b |
| 6705 |
</pre></td></tr> |
| 6706 |
|
| 6707 |
|
| 6708 |
<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> |
| 6709 |
<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element |
| 6710 |
type. |
| 6711 |
|
| 6712 |
Given |
| 6713 |
struct A {}; |
| 6714 |
A a[7]; |
| 6715 |
int b[7]; |
| 6716 |
arrayType(hasElementType(builtinType())) |
| 6717 |
matches "int b[7]" |
| 6718 |
|
| 6719 |
Usable 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>> |
| 6720 |
</pre></td></tr> |
| 6721 |
|
| 6722 |
|
| 6723 |
<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> |
| 6724 |
<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. |
| 6725 |
|
| 6726 |
Given |
| 6727 |
_Atomic(int) i; |
| 6728 |
_Atomic(float) f; |
| 6729 |
atomicType(hasValueType(isInteger())) |
| 6730 |
matches "_Atomic(int) i" |
| 6731 |
|
| 6732 |
Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> |
| 6733 |
</pre></td></tr> |
| 6734 |
|
| 6735 |
|
| 6736 |
<tr><td>Matcher<AutoType></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> |
| 6737 |
<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. |
| 6738 |
|
| 6739 |
Note: There is no TypeLoc for the deduced type and thus no |
| 6740 |
getDeducedLoc() matcher. |
| 6741 |
|
| 6742 |
Given |
| 6743 |
auto a = 1; |
| 6744 |
auto b = 2.0; |
| 6745 |
autoType(hasDeducedType(isInteger())) |
| 6746 |
matches "auto a" |
| 6747 |
|
| 6748 |
Usable as: Matcher<AutoType> |
| 6749 |
</pre></td></tr> |
| 6750 |
|
| 6751 |
|
| 6752 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BaseUsingDecl.html">BaseUsingDecl</a>></td><td class="name" onclick="toggle('hasAnyUsingShadowDecl0')"><a name="hasAnyUsingShadowDecl0Anchor">hasAnyUsingShadowDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>> InnerMatcher</td></tr> |
| 6753 |
<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. |
| 6754 |
|
| 6755 |
Given |
| 6756 |
namespace X { void b(); } |
| 6757 |
using X::b; |
| 6758 |
usingDecl(hasAnyUsingShadowDecl(hasName("b")))) |
| 6759 |
matches using X::b </pre></td></tr> |
| 6760 |
|
| 6761 |
|
| 6762 |
<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> |
| 6763 |
<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a |
| 6764 |
binary operator or fold expression matches. |
| 6765 |
</pre></td></tr> |
| 6766 |
|
| 6767 |
|
| 6768 |
<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> |
| 6769 |
<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. |
| 6770 |
|
| 6771 |
Example matches a (matcher = binaryOperator(hasLHS())) |
| 6772 |
a || b |
| 6773 |
</pre></td></tr> |
| 6774 |
|
| 6775 |
|
| 6776 |
<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> |
| 6777 |
<tr><td colspan="4" class="doc" id="hasOperands0"><pre>Matches if both matchers match with opposite sides of the binary operator |
| 6778 |
or fold expression. |
| 6779 |
|
| 6780 |
Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1), |
| 6781 |
integerLiteral(equals(2))) |
| 6782 |
1 + 2 // Match |
| 6783 |
2 + 1 // Match |
| 6784 |
1 + 1 // No match |
| 6785 |
2 + 2 // No match |
| 6786 |
</pre></td></tr> |
| 6787 |
|
| 6788 |
|
| 6789 |
<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> |
| 6790 |
<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. |
| 6791 |
|
| 6792 |
Example matches b (matcher = binaryOperator(hasRHS())) |
| 6793 |
a || b |
| 6794 |
</pre></td></tr> |
| 6795 |
|
| 6796 |
|
| 6797 |
<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> |
| 6798 |
<tr><td colspan="4" class="doc" id="forDecomposition0"><pre>Matches the DecompositionDecl the binding belongs to. |
| 6799 |
|
| 6800 |
For example, in: |
| 6801 |
void foo() |
| 6802 |
{ |
| 6803 |
int arr[3]; |
| 6804 |
auto &[f, s, t] = arr; |
| 6805 |
|
| 6806 |
f = 42; |
| 6807 |
} |
| 6808 |
The matcher: |
| 6809 |
bindingDecl(hasName("f"), |
| 6810 |
forDecomposition(decompositionDecl()) |
| 6811 |
matches 'f' in 'auto &[f, s, t]'. |
| 6812 |
</pre></td></tr> |
| 6813 |
|
| 6814 |
|
| 6815 |
<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> |
| 6816 |
<tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a |
| 6817 |
block. |
| 6818 |
|
| 6819 |
Does not match the 'this' parameter of a method. |
| 6820 |
|
| 6821 |
Given |
| 6822 |
class X { void f(int x, int y, int z) {} }; |
| 6823 |
cxxMethodDecl(hasAnyParameter(hasName("y"))) |
| 6824 |
matches f(int x, int y, int z) {} |
| 6825 |
with hasAnyParameter(...) |
| 6826 |
matching int y |
| 6827 |
|
| 6828 |
For ObjectiveC, given |
| 6829 |
@interface I - (void) f:(int) y; @end |
| 6830 |
|
| 6831 |
the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) |
| 6832 |
matches the declaration of method f with hasParameter |
| 6833 |
matching y. |
| 6834 |
|
| 6835 |
For blocks, given |
| 6836 |
b = ^(int y) { printf("%d", y) }; |
| 6837 |
|
| 6838 |
the matcher blockDecl(hasAnyParameter(hasName("y"))) |
| 6839 |
matches the declaration of the block b with hasParameter |
| 6840 |
matching y. |
| 6841 |
</pre></td></tr> |
| 6842 |
|
| 6843 |
|
| 6844 |
<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> |
| 6845 |
<tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method |
| 6846 |
declaration or a block. |
| 6847 |
|
| 6848 |
Given |
| 6849 |
class X { void f(int x) {} }; |
| 6850 |
cxxMethodDecl(hasParameter(0, hasType(varDecl()))) |
| 6851 |
matches f(int x) {} |
| 6852 |
with hasParameter(...) |
| 6853 |
matching int x |
| 6854 |
|
| 6855 |
For ObjectiveC, given |
| 6856 |
@interface I - (void) f:(int) y; @end |
| 6857 |
|
| 6858 |
the matcher objcMethodDecl(hasParameter(0, hasName("y"))) |
| 6859 |
matches the declaration of method f with hasParameter |
| 6860 |
matching y. |
| 6861 |
</pre></td></tr> |
| 6862 |
|
| 6863 |
|
| 6864 |
<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> |
| 6865 |
<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of a node matches the inner matcher. |
| 6866 |
|
| 6867 |
Examples: |
| 6868 |
int x; |
| 6869 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 6870 |
matches int x |
| 6871 |
|
| 6872 |
auto x = int(3); |
| 6873 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 6874 |
matches int(3) |
| 6875 |
|
| 6876 |
struct Foo { Foo(int, int); }; |
| 6877 |
auto x = Foo(1, 2); |
| 6878 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 6879 |
matches Foo(1, 2) |
| 6880 |
|
| 6881 |
Usable 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>>, |
| 6882 |
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>>, |
| 6883 |
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>>, |
| 6884 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 6885 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 6886 |
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>>, |
| 6887 |
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>>, |
| 6888 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 6889 |
</pre></td></tr> |
| 6890 |
|
| 6891 |
|
| 6892 |
<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> |
| 6893 |
<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the |
| 6894 |
pointee matches a given matcher. |
| 6895 |
|
| 6896 |
Given |
| 6897 |
int *a; |
| 6898 |
int const *b; |
| 6899 |
float const *f; |
| 6900 |
pointerType(pointee(isConstQualified(), isInteger())) |
| 6901 |
matches "int const *b" |
| 6902 |
|
| 6903 |
Usable 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>>, |
| 6904 |
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>>, |
| 6905 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>> |
| 6906 |
</pre></td></tr> |
| 6907 |
|
| 6908 |
|
| 6909 |
<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> |
| 6910 |
<tr><td colspan="4" class="doc" id="hasTypeLoc1"><pre>Matches if the type location of a node matches the inner matcher. |
| 6911 |
|
| 6912 |
Examples: |
| 6913 |
int x; |
| 6914 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 6915 |
matches int x |
| 6916 |
|
| 6917 |
auto x = int(3); |
| 6918 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 6919 |
matches int(3) |
| 6920 |
|
| 6921 |
struct Foo { Foo(int, int); }; |
| 6922 |
auto x = Foo(1, 2); |
| 6923 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 6924 |
matches Foo(1, 2) |
| 6925 |
|
| 6926 |
Usable 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>>, |
| 6927 |
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>>, |
| 6928 |
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>>, |
| 6929 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 6930 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 6931 |
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>>, |
| 6932 |
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>>, |
| 6933 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 6934 |
</pre></td></tr> |
| 6935 |
|
| 6936 |
|
| 6937 |
<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> |
| 6938 |
<tr><td colspan="4" class="doc" id="hasType8"><pre>Overloaded to match the declaration of the expression's or value |
| 6939 |
declaration's type. |
| 6940 |
|
| 6941 |
In case of a value declaration (for example a variable declaration), |
| 6942 |
this resolves one layer of indirection. For example, in the value |
| 6943 |
declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 6944 |
X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 6945 |
declaration of x. |
| 6946 |
|
| 6947 |
Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 6948 |
and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 6949 |
and friend class X (matcher = friendDecl(hasType("X")) |
| 6950 |
and public virtual X (matcher = cxxBaseSpecifier(hasType( |
| 6951 |
cxxRecordDecl(hasName("X")))) |
| 6952 |
class X {}; |
| 6953 |
void y(X &x) { x; X z; } |
| 6954 |
class Y { friend class X; }; |
| 6955 |
class Z : public virtual X {}; |
| 6956 |
|
| 6957 |
Example matches class Derived |
| 6958 |
(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) |
| 6959 |
class Base {}; |
| 6960 |
class Derived : Base {}; |
| 6961 |
|
| 6962 |
Usable 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>>, |
| 6963 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> |
| 6964 |
</pre></td></tr> |
| 6965 |
|
| 6966 |
|
| 6967 |
<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> |
| 6968 |
<tr><td colspan="4" class="doc" id="hasType4"><pre>Matches if the expression's or declaration's type matches a type |
| 6969 |
matcher. |
| 6970 |
|
| 6971 |
Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 6972 |
and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 6973 |
and U (matcher = typedefDecl(hasType(asString("int"))) |
| 6974 |
and friend class X (matcher = friendDecl(hasType("X")) |
| 6975 |
and public virtual X (matcher = cxxBaseSpecifier(hasType( |
| 6976 |
asString("class X"))) |
| 6977 |
class X {}; |
| 6978 |
void y(X &x) { x; X z; } |
| 6979 |
typedef int U; |
| 6980 |
class Y { friend class X; }; |
| 6981 |
class Z : public virtual X {}; |
| 6982 |
</pre></td></tr> |
| 6983 |
|
| 6984 |
|
| 6985 |
<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> |
| 6986 |
<tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl. |
| 6987 |
|
| 6988 |
Given |
| 6989 |
void f(int i); |
| 6990 |
int y; |
| 6991 |
f(y); |
| 6992 |
callExpr( |
| 6993 |
forEachArgumentWithParam( |
| 6994 |
declRefExpr(to(varDecl(hasName("y")))), |
| 6995 |
parmVarDecl(hasType(isInteger())) |
| 6996 |
)) |
| 6997 |
matches f(y); |
| 6998 |
with declRefExpr(...) |
| 6999 |
matching int y |
| 7000 |
and parmVarDecl(...) |
| 7001 |
matching int i |
| 7002 |
</pre></td></tr> |
| 7003 |
|
| 7004 |
|
| 7005 |
<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> |
| 7006 |
<tr><td colspan="4" class="doc" id="forEachArgumentWithParamType1"><pre>Matches all arguments and their respective types for a CallExpr or |
| 7007 |
CXXConstructExpr. It is very similar to forEachArgumentWithParam but |
| 7008 |
it works on calls through function pointers as well. |
| 7009 |
|
| 7010 |
The difference is, that function pointers do not provide access to a |
| 7011 |
ParmVarDecl, but only the QualType for each argument. |
| 7012 |
|
| 7013 |
Given |
| 7014 |
void f(int i); |
| 7015 |
int y; |
| 7016 |
f(y); |
| 7017 |
void (*f_ptr)(int) = f; |
| 7018 |
f_ptr(y); |
| 7019 |
callExpr( |
| 7020 |
forEachArgumentWithParamType( |
| 7021 |
declRefExpr(to(varDecl(hasName("y")))), |
| 7022 |
qualType(isInteger()).bind("type) |
| 7023 |
)) |
| 7024 |
matches f(y) and f_ptr(y) |
| 7025 |
with declRefExpr(...) |
| 7026 |
matching int y |
| 7027 |
and qualType(...) |
| 7028 |
matching int |
| 7029 |
</pre></td></tr> |
| 7030 |
|
| 7031 |
|
| 7032 |
<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> |
| 7033 |
<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call |
| 7034 |
expression, or an ObjC-message-send expression. |
| 7035 |
|
| 7036 |
Given |
| 7037 |
void x(int, int, int) { int y; x(1, y, 42); } |
| 7038 |
callExpr(hasAnyArgument(declRefExpr())) |
| 7039 |
matches x(1, y, 42) |
| 7040 |
with hasAnyArgument(...) |
| 7041 |
matching y |
| 7042 |
|
| 7043 |
For ObjectiveC, given |
| 7044 |
@interface I - (void) f:(int) y; @end |
| 7045 |
void foo(I *i) { [i f:12]; } |
| 7046 |
objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) |
| 7047 |
matches [i f:12] |
| 7048 |
</pre></td></tr> |
| 7049 |
|
| 7050 |
|
| 7051 |
<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> |
| 7052 |
<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor |
| 7053 |
call expression. |
| 7054 |
|
| 7055 |
Example matches y in x(y) |
| 7056 |
(matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 7057 |
void x(int) { int y; x(y); } |
| 7058 |
</pre></td></tr> |
| 7059 |
|
| 7060 |
|
| 7061 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</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> |
| 7062 |
<tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node |
| 7063 |
matches the given matcher. |
| 7064 |
|
| 7065 |
The associated declaration is: |
| 7066 |
- for type nodes, the declaration of the underlying type |
| 7067 |
- for CallExpr, the declaration of the callee |
| 7068 |
- for MemberExpr, the declaration of the referenced member |
| 7069 |
- for CXXConstructExpr, the declaration of the constructor |
| 7070 |
- for CXXNewExpr, the declaration of the operator new |
| 7071 |
- for ObjCIvarExpr, the declaration of the ivar |
| 7072 |
|
| 7073 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 7074 |
sugared type. Given |
| 7075 |
class X {}; |
| 7076 |
typedef X Y; |
| 7077 |
Y y; |
| 7078 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 7079 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 7080 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 7081 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 7082 |
recordType(hasDeclaration(decl()))))) |
| 7083 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 7084 |
|
| 7085 |
Usable 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>>, |
| 7086 |
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>>, |
| 7087 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 7088 |
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<RecordType>, |
| 7089 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 7090 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 7091 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 7092 |
</pre></td></tr> |
| 7093 |
|
| 7094 |
|
| 7095 |
<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> |
| 7096 |
<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. |
| 7097 |
|
| 7098 |
Given |
| 7099 |
class A { A() : i(42), j(42) {} int i; int j; }; |
| 7100 |
cxxConstructorDecl(forEachConstructorInitializer( |
| 7101 |
forField(decl().bind("x")) |
| 7102 |
)) |
| 7103 |
will trigger two matches, binding for 'i' and 'j' respectively. |
| 7104 |
</pre></td></tr> |
| 7105 |
|
| 7106 |
|
| 7107 |
<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> |
| 7108 |
<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. |
| 7109 |
|
| 7110 |
Given |
| 7111 |
struct Foo { |
| 7112 |
Foo() : foo_(1) { } |
| 7113 |
int foo_; |
| 7114 |
}; |
| 7115 |
cxxRecordDecl(has(cxxConstructorDecl( |
| 7116 |
hasAnyConstructorInitializer(anything()) |
| 7117 |
))) |
| 7118 |
record matches Foo, hasAnyConstructorInitializer matches foo_(1) |
| 7119 |
</pre></td></tr> |
| 7120 |
|
| 7121 |
|
| 7122 |
<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> |
| 7123 |
<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. |
| 7124 |
|
| 7125 |
Given |
| 7126 |
struct Foo { |
| 7127 |
Foo() : foo_(1) { } |
| 7128 |
int foo_; |
| 7129 |
}; |
| 7130 |
cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( |
| 7131 |
forField(hasName("foo_")))))) |
| 7132 |
matches Foo |
| 7133 |
with forField matching foo_ |
| 7134 |
</pre></td></tr> |
| 7135 |
|
| 7136 |
|
| 7137 |
<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> |
| 7138 |
<tr><td colspan="4" class="doc" id="hasTypeLoc2"><pre>Matches if the type location of a node matches the inner matcher. |
| 7139 |
|
| 7140 |
Examples: |
| 7141 |
int x; |
| 7142 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 7143 |
matches int x |
| 7144 |
|
| 7145 |
auto x = int(3); |
| 7146 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 7147 |
matches int(3) |
| 7148 |
|
| 7149 |
struct Foo { Foo(int, int); }; |
| 7150 |
auto x = Foo(1, 2); |
| 7151 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 7152 |
matches Foo(1, 2) |
| 7153 |
|
| 7154 |
Usable 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>>, |
| 7155 |
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>>, |
| 7156 |
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>>, |
| 7157 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 7158 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 7159 |
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>>, |
| 7160 |
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>>, |
| 7161 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 7162 |
</pre></td></tr> |
| 7163 |
|
| 7164 |
|
| 7165 |
<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> |
| 7166 |
<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. |
| 7167 |
|
| 7168 |
Given |
| 7169 |
struct Foo { |
| 7170 |
Foo() : foo_(1) { } |
| 7171 |
int foo_; |
| 7172 |
}; |
| 7173 |
cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( |
| 7174 |
withInitializer(integerLiteral(equals(1))))))) |
| 7175 |
matches Foo |
| 7176 |
with withInitializer matching (1) |
| 7177 |
</pre></td></tr> |
| 7178 |
|
| 7179 |
|
| 7180 |
<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> |
| 7181 |
<tr><td colspan="4" class="doc" id="hasObjectExpression2"><pre>Matches a member expression where the object expression is matched by a |
| 7182 |
given matcher. Implicit object expressions are included; that is, it matches |
| 7183 |
use of implicit `this`. |
| 7184 |
|
| 7185 |
Given |
| 7186 |
struct X { |
| 7187 |
int m; |
| 7188 |
int f(X x) { x.m; return m; } |
| 7189 |
}; |
| 7190 |
memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) |
| 7191 |
matches `x.m`, but not `m`; however, |
| 7192 |
memberExpr(hasObjectExpression(hasType(pointsTo( |
| 7193 |
cxxRecordDecl(hasName("X")))))) |
| 7194 |
matches `m` (aka. `this->m`), but not `x.m`. |
| 7195 |
</pre></td></tr> |
| 7196 |
|
| 7197 |
|
| 7198 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</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_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> |
| 7199 |
<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call or fold expression's callee expression matches. |
| 7200 |
|
| 7201 |
Given |
| 7202 |
class Y { void x() { this->x(); x(); Y y; y.x(); } }; |
| 7203 |
void f() { f(); } |
| 7204 |
callExpr(callee(expr())) |
| 7205 |
matches this->x(), x(), y.x(), f() |
| 7206 |
with callee(...) |
| 7207 |
matching this->x, x, y.x, f respectively |
| 7208 |
|
| 7209 |
Given |
| 7210 |
template <typename... Args> |
| 7211 |
auto sum(Args... args) { |
| 7212 |
return (0 + ... + args); |
| 7213 |
} |
| 7214 |
|
| 7215 |
template <typename... Args> |
| 7216 |
auto multiply(Args... args) { |
| 7217 |
return (args * ... * 1); |
| 7218 |
} |
| 7219 |
cxxFoldExpr(callee(expr())) |
| 7220 |
matches (args * ... * 1) |
| 7221 |
with callee(...) |
| 7222 |
matching * |
| 7223 |
|
| 7224 |
Note: Callee cannot take the more general internal::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> |
| 7225 |
because this introduces ambiguous overloads with calls to Callee taking a |
| 7226 |
internal::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely |
| 7227 |
implemented in terms of implicit casts. |
| 7228 |
</pre></td></tr> |
| 7229 |
|
| 7230 |
|
| 7231 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</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> |
| 7232 |
<tr><td colspan="4" class="doc" id="hasEitherOperand2"><pre>Matches if either the left hand side or the right hand side of a |
| 7233 |
binary operator or fold expression matches. |
| 7234 |
</pre></td></tr> |
| 7235 |
|
| 7236 |
|
| 7237 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>></td><td class="name" onclick="toggle('hasFoldInit0')"><a name="hasFoldInit0Anchor">hasFoldInit</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMacher</td></tr> |
| 7238 |
<tr><td colspan="4" class="doc" id="hasFoldInit0"><pre>Matches the operand that does not contain the parameter pack. |
| 7239 |
|
| 7240 |
Example matches `(0 + ... + args)` and `(args * ... * 1)` |
| 7241 |
(matcher = cxxFoldExpr(hasFoldInit(expr()))) |
| 7242 |
with hasFoldInit(...) |
| 7243 |
matching `0` and `1` respectively |
| 7244 |
template <typename... Args> |
| 7245 |
auto sum(Args... args) { |
| 7246 |
return (0 + ... + args); |
| 7247 |
} |
| 7248 |
|
| 7249 |
template <typename... Args> |
| 7250 |
auto multiply(Args... args) { |
| 7251 |
return (args * ... * 1); |
| 7252 |
} |
| 7253 |
</pre></td></tr> |
| 7254 |
|
| 7255 |
|
| 7256 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>></td><td class="name" onclick="toggle('hasLHS4')"><a name="hasLHS4Anchor">hasLHS</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 7257 |
<tr><td colspan="4" class="doc" id="hasLHS4"><pre>Matches the left hand side of binary operator expressions. |
| 7258 |
|
| 7259 |
Example matches a (matcher = binaryOperator(hasLHS())) |
| 7260 |
a || b |
| 7261 |
</pre></td></tr> |
| 7262 |
|
| 7263 |
|
| 7264 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</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> |
| 7265 |
<tr><td colspan="4" class="doc" id="hasOperands2"><pre>Matches if both matchers match with opposite sides of the binary operator |
| 7266 |
or fold expression. |
| 7267 |
|
| 7268 |
Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1), |
| 7269 |
integerLiteral(equals(2))) |
| 7270 |
1 + 2 // Match |
| 7271 |
2 + 1 // Match |
| 7272 |
1 + 1 // No match |
| 7273 |
2 + 2 // No match |
| 7274 |
</pre></td></tr> |
| 7275 |
|
| 7276 |
|
| 7277 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>></td><td class="name" onclick="toggle('hasPattern0')"><a name="hasPattern0Anchor">hasPattern</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMacher</td></tr> |
| 7278 |
<tr><td colspan="4" class="doc" id="hasPattern0"><pre>Matches the operand that contains the parameter pack. |
| 7279 |
|
| 7280 |
Example matches `(0 + ... + args)` |
| 7281 |
(matcher = cxxFoldExpr(hasPattern(expr()))) |
| 7282 |
with hasPattern(...) |
| 7283 |
matching `args` |
| 7284 |
template <typename... Args> |
| 7285 |
auto sum(Args... args) { |
| 7286 |
return (0 + ... + args); |
| 7287 |
} |
| 7288 |
|
| 7289 |
template <typename... Args> |
| 7290 |
auto multiply(Args... args) { |
| 7291 |
return (args * ... * 1); |
| 7292 |
} |
| 7293 |
</pre></td></tr> |
| 7294 |
|
| 7295 |
|
| 7296 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>></td><td class="name" onclick="toggle('hasRHS4')"><a name="hasRHS4Anchor">hasRHS</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 7297 |
<tr><td colspan="4" class="doc" id="hasRHS4"><pre>Matches the right hand side of binary operator expressions. |
| 7298 |
|
| 7299 |
Example matches b (matcher = binaryOperator(hasRHS())) |
| 7300 |
a || b |
| 7301 |
</pre></td></tr> |
| 7302 |
|
| 7303 |
|
| 7304 |
<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> |
| 7305 |
<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine |
| 7306 |
definition that has a given body. Note that in case of functions or |
| 7307 |
coroutines this matcher only matches the definition itself and not the |
| 7308 |
other declarations of the same function or coroutine. |
| 7309 |
|
| 7310 |
Given |
| 7311 |
for (;;) {} |
| 7312 |
forStmt(hasBody(compoundStmt())) |
| 7313 |
matches 'for (;;) {}' |
| 7314 |
with compoundStmt() |
| 7315 |
matching '{}' |
| 7316 |
|
| 7317 |
Given |
| 7318 |
void f(); |
| 7319 |
void f() {} |
| 7320 |
functionDecl(hasBody(compoundStmt())) |
| 7321 |
matches 'void f() {}' |
| 7322 |
with compoundStmt() |
| 7323 |
matching '{}' |
| 7324 |
but does not match 'void f();' |
| 7325 |
</pre></td></tr> |
| 7326 |
|
| 7327 |
|
| 7328 |
<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> |
| 7329 |
<tr><td colspan="4" class="doc" id="hasInitStatement2"><pre>Matches selection statements with initializer. |
| 7330 |
|
| 7331 |
Given: |
| 7332 |
void foo() { |
| 7333 |
if (int i = foobar(); i > 0) {} |
| 7334 |
switch (int i = foobar(); i) {} |
| 7335 |
for (auto& a = get_range(); auto& x : a) {} |
| 7336 |
} |
| 7337 |
void bar() { |
| 7338 |
if (foobar() > 0) {} |
| 7339 |
switch (foobar()) {} |
| 7340 |
for (auto& x : get_range()) {} |
| 7341 |
} |
| 7342 |
ifStmt(hasInitStatement(anything())) |
| 7343 |
matches the if statement in foo but not in bar. |
| 7344 |
switchStmt(hasInitStatement(anything())) |
| 7345 |
matches the switch statement in foo but not in bar. |
| 7346 |
cxxForRangeStmt(hasInitStatement(anything())) |
| 7347 |
matches the range for statement in foo but not in bar. |
| 7348 |
</pre></td></tr> |
| 7349 |
|
| 7350 |
|
| 7351 |
<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> |
| 7352 |
<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. |
| 7353 |
|
| 7354 |
Example: |
| 7355 |
forStmt(hasLoopVariable(anything())) |
| 7356 |
matches 'int x' in |
| 7357 |
for (int x : a) { } |
| 7358 |
</pre></td></tr> |
| 7359 |
|
| 7360 |
|
| 7361 |
<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> |
| 7362 |
<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. |
| 7363 |
|
| 7364 |
Example: |
| 7365 |
forStmt(hasRangeInit(anything())) |
| 7366 |
matches 'a' in |
| 7367 |
for (int x : a) { } |
| 7368 |
</pre></td></tr> |
| 7369 |
|
| 7370 |
|
| 7371 |
<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> |
| 7372 |
<tr><td colspan="4" class="doc" id="hasTypeLoc3"><pre>Matches if the type location of a node matches the inner matcher. |
| 7373 |
|
| 7374 |
Examples: |
| 7375 |
int x; |
| 7376 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 7377 |
matches int x |
| 7378 |
|
| 7379 |
auto x = int(3); |
| 7380 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 7381 |
matches int(3) |
| 7382 |
|
| 7383 |
struct Foo { Foo(int, int); }; |
| 7384 |
auto x = Foo(1, 2); |
| 7385 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 7386 |
matches Foo(1, 2) |
| 7387 |
|
| 7388 |
Usable 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>>, |
| 7389 |
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>>, |
| 7390 |
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>>, |
| 7391 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 7392 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 7393 |
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>>, |
| 7394 |
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>>, |
| 7395 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 7396 |
</pre></td></tr> |
| 7397 |
|
| 7398 |
|
| 7399 |
<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> |
| 7400 |
<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre>Matches on the implicit object argument of a member call expression. Unlike |
| 7401 |
`on`, matches the argument directly without stripping away anything. |
| 7402 |
|
| 7403 |
Given |
| 7404 |
class Y { public: void m(); }; |
| 7405 |
Y g(); |
| 7406 |
class X : public Y { void g(); }; |
| 7407 |
void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); } |
| 7408 |
cxxMemberCallExpr(onImplicitObjectArgument(hasType( |
| 7409 |
cxxRecordDecl(hasName("Y"))))) |
| 7410 |
matches `y.m()`, `x.m()` and (`g()).m()`, but not `x.g()`). |
| 7411 |
cxxMemberCallExpr(on(callExpr())) |
| 7412 |
only matches `(g()).m()` (the parens are ignored). |
| 7413 |
|
| 7414 |
FIXME: Overload to allow directly matching types? |
| 7415 |
</pre></td></tr> |
| 7416 |
|
| 7417 |
|
| 7418 |
<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> |
| 7419 |
<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression, after |
| 7420 |
stripping off any parentheses or implicit casts. |
| 7421 |
|
| 7422 |
Given |
| 7423 |
class Y { public: void m(); }; |
| 7424 |
Y g(); |
| 7425 |
class X : public Y {}; |
| 7426 |
void z(Y y, X x) { y.m(); (g()).m(); x.m(); } |
| 7427 |
cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))))) |
| 7428 |
matches `y.m()` and `(g()).m()`. |
| 7429 |
cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X"))))) |
| 7430 |
matches `x.m()`. |
| 7431 |
cxxMemberCallExpr(on(callExpr())) |
| 7432 |
matches `(g()).m()`. |
| 7433 |
|
| 7434 |
FIXME: Overload to allow directly matching types? |
| 7435 |
</pre></td></tr> |
| 7436 |
|
| 7437 |
|
| 7438 |
<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> |
| 7439 |
<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. |
| 7440 |
</pre></td></tr> |
| 7441 |
|
| 7442 |
|
| 7443 |
<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> |
| 7444 |
<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the type of the expression's implicit object argument either |
| 7445 |
matches the InnerMatcher, or is a pointer to a type that matches the |
| 7446 |
InnerMatcher. |
| 7447 |
|
| 7448 |
Given |
| 7449 |
class Y { public: void m(); }; |
| 7450 |
class X : public Y { void g(); }; |
| 7451 |
void z() { Y y; y.m(); Y *p; p->m(); X x; x.m(); x.g(); } |
| 7452 |
cxxMemberCallExpr(thisPointerType(hasDeclaration( |
| 7453 |
cxxRecordDecl(hasName("Y"))))) |
| 7454 |
matches `y.m()`, `p->m()` and `x.m()`. |
| 7455 |
cxxMemberCallExpr(thisPointerType(hasDeclaration( |
| 7456 |
cxxRecordDecl(hasName("X"))))) |
| 7457 |
matches `x.g()`. |
| 7458 |
</pre></td></tr> |
| 7459 |
|
| 7460 |
|
| 7461 |
<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> |
| 7462 |
<tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may |
| 7463 |
produce multiple matches. |
| 7464 |
|
| 7465 |
Given |
| 7466 |
class A { virtual void f(); }; |
| 7467 |
class B : public A { void f(); }; |
| 7468 |
class C : public B { void f(); }; |
| 7469 |
cxxMethodDecl(ofClass(hasName("C")), |
| 7470 |
forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") |
| 7471 |
matches once, with "b" binding "A::f" and "d" binding "C::f" (Note |
| 7472 |
that B::f is not overridden by C::f). |
| 7473 |
|
| 7474 |
The check can produce multiple matches in case of multiple inheritance, e.g. |
| 7475 |
class A1 { virtual void f(); }; |
| 7476 |
class A2 { virtual void f(); }; |
| 7477 |
class C : public A1, public A2 { void f(); }; |
| 7478 |
cxxMethodDecl(ofClass(hasName("C")), |
| 7479 |
forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") |
| 7480 |
matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and |
| 7481 |
once with "b" binding "A2::f" and "d" binding "C::f". |
| 7482 |
</pre></td></tr> |
| 7483 |
|
| 7484 |
|
| 7485 |
<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> |
| 7486 |
<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration |
| 7487 |
belongs to. |
| 7488 |
|
| 7489 |
FIXME: Generalize this for other kinds of declarations. |
| 7490 |
FIXME: What other kind of declarations would we need to generalize |
| 7491 |
this to? |
| 7492 |
|
| 7493 |
Example matches A() in the last line |
| 7494 |
(matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( |
| 7495 |
ofClass(hasName("A")))))) |
| 7496 |
class A { |
| 7497 |
public: |
| 7498 |
A(); |
| 7499 |
}; |
| 7500 |
A a = A(); |
| 7501 |
</pre></td></tr> |
| 7502 |
|
| 7503 |
|
| 7504 |
<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> |
| 7505 |
<tr><td colspan="4" class="doc" id="hasAnyPlacementArg0"><pre>Matches any placement new expression arguments. |
| 7506 |
|
| 7507 |
Given: |
| 7508 |
MyClass *p1 = new (Storage) MyClass(); |
| 7509 |
cxxNewExpr(hasAnyPlacementArg(anything())) |
| 7510 |
matches the expression 'new (Storage, 16) MyClass()'. |
| 7511 |
</pre></td></tr> |
| 7512 |
|
| 7513 |
|
| 7514 |
<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> |
| 7515 |
<tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size. |
| 7516 |
|
| 7517 |
Given: |
| 7518 |
MyClass *p1 = new MyClass[10]; |
| 7519 |
cxxNewExpr(hasArraySize(integerLiteral(equals(10)))) |
| 7520 |
matches the expression 'new MyClass[10]'. |
| 7521 |
</pre></td></tr> |
| 7522 |
|
| 7523 |
|
| 7524 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</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> |
| 7525 |
<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node |
| 7526 |
matches the given matcher. |
| 7527 |
|
| 7528 |
The associated declaration is: |
| 7529 |
- for type nodes, the declaration of the underlying type |
| 7530 |
- for CallExpr, the declaration of the callee |
| 7531 |
- for MemberExpr, the declaration of the referenced member |
| 7532 |
- for CXXConstructExpr, the declaration of the constructor |
| 7533 |
- for CXXNewExpr, the declaration of the operator new |
| 7534 |
- for ObjCIvarExpr, the declaration of the ivar |
| 7535 |
|
| 7536 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 7537 |
sugared type. Given |
| 7538 |
class X {}; |
| 7539 |
typedef X Y; |
| 7540 |
Y y; |
| 7541 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 7542 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 7543 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 7544 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 7545 |
recordType(hasDeclaration(decl()))))) |
| 7546 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 7547 |
|
| 7548 |
Usable 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>>, |
| 7549 |
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>>, |
| 7550 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 7551 |
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<RecordType>, |
| 7552 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 7553 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 7554 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 7555 |
</pre></td></tr> |
| 7556 |
|
| 7557 |
|
| 7558 |
<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> |
| 7559 |
<tr><td colspan="4" class="doc" id="hasPlacementArg0"><pre>Matches placement new expression arguments. |
| 7560 |
|
| 7561 |
Given: |
| 7562 |
MyClass *p1 = new (Storage, 16) MyClass(); |
| 7563 |
cxxNewExpr(hasPlacementArg(1, integerLiteral(equals(16)))) |
| 7564 |
matches the expression 'new (Storage, 16) MyClass()'. |
| 7565 |
</pre></td></tr> |
| 7566 |
|
| 7567 |
|
| 7568 |
<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> |
| 7569 |
<tr><td colspan="4" class="doc" id="hasTypeLoc4"><pre>Matches if the type location of a node matches the inner matcher. |
| 7570 |
|
| 7571 |
Examples: |
| 7572 |
int x; |
| 7573 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 7574 |
matches int x |
| 7575 |
|
| 7576 |
auto x = int(3); |
| 7577 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 7578 |
matches int(3) |
| 7579 |
|
| 7580 |
struct Foo { Foo(int, int); }; |
| 7581 |
auto x = Foo(1, 2); |
| 7582 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 7583 |
matches Foo(1, 2) |
| 7584 |
|
| 7585 |
Usable 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>>, |
| 7586 |
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>>, |
| 7587 |
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>>, |
| 7588 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 7589 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 7590 |
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>>, |
| 7591 |
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>>, |
| 7592 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 7593 |
</pre></td></tr> |
| 7594 |
|
| 7595 |
|
| 7596 |
<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> |
| 7597 |
<tr><td colspan="4" class="doc" id="hasEitherOperand1"><pre>Matches if either the left hand side or the right hand side of a |
| 7598 |
binary operator or fold expression matches. |
| 7599 |
</pre></td></tr> |
| 7600 |
|
| 7601 |
|
| 7602 |
<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> |
| 7603 |
<tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions. |
| 7604 |
|
| 7605 |
Example matches a (matcher = binaryOperator(hasLHS())) |
| 7606 |
a || b |
| 7607 |
</pre></td></tr> |
| 7608 |
|
| 7609 |
|
| 7610 |
<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> |
| 7611 |
<tr><td colspan="4" class="doc" id="hasOperands1"><pre>Matches if both matchers match with opposite sides of the binary operator |
| 7612 |
or fold expression. |
| 7613 |
|
| 7614 |
Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1), |
| 7615 |
integerLiteral(equals(2))) |
| 7616 |
1 + 2 // Match |
| 7617 |
2 + 1 // Match |
| 7618 |
1 + 1 // No match |
| 7619 |
2 + 2 // No match |
| 7620 |
</pre></td></tr> |
| 7621 |
|
| 7622 |
|
| 7623 |
<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> |
| 7624 |
<tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions. |
| 7625 |
|
| 7626 |
Example matches b (matcher = binaryOperator(hasRHS())) |
| 7627 |
a || b |
| 7628 |
</pre></td></tr> |
| 7629 |
|
| 7630 |
|
| 7631 |
<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> |
| 7632 |
<tr><td colspan="4" class="doc" id="hasUnaryOperand1"><pre>Matches if the operand of a unary operator matches. |
| 7633 |
|
| 7634 |
Example matches true (matcher = hasUnaryOperand( |
| 7635 |
cxxBoolLiteral(equals(true)))) |
| 7636 |
!true |
| 7637 |
</pre></td></tr> |
| 7638 |
|
| 7639 |
|
| 7640 |
<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> |
| 7641 |
<tr><td colspan="4" class="doc" id="hasAnyBase0"><pre>Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher. |
| 7642 |
|
| 7643 |
Example: |
| 7644 |
matcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase")))) |
| 7645 |
class Foo; |
| 7646 |
class Bar : Foo {}; |
| 7647 |
class Baz : Bar {}; |
| 7648 |
class SpecialBase; |
| 7649 |
class Proxy : SpecialBase {}; // matches Proxy |
| 7650 |
class IndirectlyDerived : Proxy {}; //matches IndirectlyDerived |
| 7651 |
|
| 7652 |
FIXME: Refactor this and isDerivedFrom to reuse implementation. |
| 7653 |
</pre></td></tr> |
| 7654 |
|
| 7655 |
|
| 7656 |
<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> |
| 7657 |
<tr><td colspan="4" class="doc" id="hasDirectBase0"><pre>Matches C++ classes that have a direct base matching BaseSpecMatcher. |
| 7658 |
|
| 7659 |
Example: |
| 7660 |
matcher hasDirectBase(hasType(cxxRecordDecl(hasName("SpecialBase")))) |
| 7661 |
class Foo; |
| 7662 |
class Bar : Foo {}; |
| 7663 |
class Baz : Bar {}; |
| 7664 |
class SpecialBase; |
| 7665 |
class Proxy : SpecialBase {}; // matches Proxy |
| 7666 |
class IndirectlyDerived : Proxy {}; // doesn't match |
| 7667 |
</pre></td></tr> |
| 7668 |
|
| 7669 |
|
| 7670 |
<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> |
| 7671 |
<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. |
| 7672 |
|
| 7673 |
Given: |
| 7674 |
class A { void func(); }; |
| 7675 |
class B { void member(); }; |
| 7676 |
|
| 7677 |
cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of |
| 7678 |
A but not B. |
| 7679 |
</pre></td></tr> |
| 7680 |
|
| 7681 |
|
| 7682 |
<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> |
| 7683 |
<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from a class |
| 7684 |
matching Base, or Objective-C classes that directly or indirectly |
| 7685 |
subclass a class matching Base. |
| 7686 |
|
| 7687 |
Note that a class is not considered to be derived from itself. |
| 7688 |
|
| 7689 |
Example matches Y, Z, C (Base == hasName("X")) |
| 7690 |
class X; |
| 7691 |
class Y : public X {}; // directly derived |
| 7692 |
class Z : public Y {}; // indirectly derived |
| 7693 |
typedef X A; |
| 7694 |
typedef A B; |
| 7695 |
class C : public B {}; // derived from a typedef of X |
| 7696 |
|
| 7697 |
In the following example, Bar matches isDerivedFrom(hasName("X")): |
| 7698 |
class Foo; |
| 7699 |
typedef Foo X; |
| 7700 |
class Bar : public Foo {}; // derived from a type that X is a typedef of |
| 7701 |
|
| 7702 |
In the following example, Bar matches isDerivedFrom(hasName("NSObject")) |
| 7703 |
@interface NSObject @end |
| 7704 |
@interface Bar : NSObject @end |
| 7705 |
|
| 7706 |
Usable 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>> |
| 7707 |
</pre></td></tr> |
| 7708 |
|
| 7709 |
|
| 7710 |
<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> |
| 7711 |
<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom0"><pre>Matches C++ or Objective-C classes that are directly derived from a class |
| 7712 |
matching Base. |
| 7713 |
|
| 7714 |
Note that a class is not considered to be derived from itself. |
| 7715 |
|
| 7716 |
Example matches Y, C (Base == hasName("X")) |
| 7717 |
class X; |
| 7718 |
class Y : public X {}; // directly derived |
| 7719 |
class Z : public Y {}; // indirectly derived |
| 7720 |
typedef X A; |
| 7721 |
typedef A B; |
| 7722 |
class C : public B {}; // derived from a typedef of X |
| 7723 |
|
| 7724 |
In the following example, Bar matches isDerivedFrom(hasName("X")): |
| 7725 |
class Foo; |
| 7726 |
typedef Foo X; |
| 7727 |
class Bar : public Foo {}; // derived from a type that X is a typedef of |
| 7728 |
</pre></td></tr> |
| 7729 |
|
| 7730 |
|
| 7731 |
<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> |
| 7732 |
<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly |
| 7733 |
match Base. |
| 7734 |
</pre></td></tr> |
| 7735 |
|
| 7736 |
|
| 7737 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>></td><td class="name" onclick="toggle('hasEitherOperand3')"><a name="hasEitherOperand3Anchor">hasEitherOperand</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 7738 |
<tr><td colspan="4" class="doc" id="hasEitherOperand3"><pre>Matches if either the left hand side or the right hand side of a |
| 7739 |
binary operator or fold expression matches. |
| 7740 |
</pre></td></tr> |
| 7741 |
|
| 7742 |
|
| 7743 |
<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> |
| 7744 |
<tr><td colspan="4" class="doc" id="hasLHS2"><pre>Matches the left hand side of binary operator expressions. |
| 7745 |
|
| 7746 |
Example matches a (matcher = binaryOperator(hasLHS())) |
| 7747 |
a || b |
| 7748 |
</pre></td></tr> |
| 7749 |
|
| 7750 |
|
| 7751 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>></td><td class="name" onclick="toggle('hasOperands3')"><a name="hasOperands3Anchor">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> |
| 7752 |
<tr><td colspan="4" class="doc" id="hasOperands3"><pre>Matches if both matchers match with opposite sides of the binary operator |
| 7753 |
or fold expression. |
| 7754 |
|
| 7755 |
Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1), |
| 7756 |
integerLiteral(equals(2))) |
| 7757 |
1 + 2 // Match |
| 7758 |
2 + 1 // Match |
| 7759 |
1 + 1 // No match |
| 7760 |
2 + 2 // No match |
| 7761 |
</pre></td></tr> |
| 7762 |
|
| 7763 |
|
| 7764 |
<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> |
| 7765 |
<tr><td colspan="4" class="doc" id="hasRHS2"><pre>Matches the right hand side of binary operator expressions. |
| 7766 |
|
| 7767 |
Example matches b (matcher = binaryOperator(hasRHS())) |
| 7768 |
a || b |
| 7769 |
</pre></td></tr> |
| 7770 |
|
| 7771 |
|
| 7772 |
<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> |
| 7773 |
<tr><td colspan="4" class="doc" id="hasTypeLoc5"><pre>Matches if the type location of a node matches the inner matcher. |
| 7774 |
|
| 7775 |
Examples: |
| 7776 |
int x; |
| 7777 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 7778 |
matches int x |
| 7779 |
|
| 7780 |
auto x = int(3); |
| 7781 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 7782 |
matches int(3) |
| 7783 |
|
| 7784 |
struct Foo { Foo(int, int); }; |
| 7785 |
auto x = Foo(1, 2); |
| 7786 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 7787 |
matches Foo(1, 2) |
| 7788 |
|
| 7789 |
Usable 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>>, |
| 7790 |
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>>, |
| 7791 |
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>>, |
| 7792 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 7793 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 7794 |
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>>, |
| 7795 |
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>>, |
| 7796 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 7797 |
</pre></td></tr> |
| 7798 |
|
| 7799 |
|
| 7800 |
<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> |
| 7801 |
<tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call |
| 7802 |
expression, or an ObjC-message-send expression. |
| 7803 |
|
| 7804 |
Given |
| 7805 |
void x(int, int, int) { int y; x(1, y, 42); } |
| 7806 |
callExpr(hasAnyArgument(declRefExpr())) |
| 7807 |
matches x(1, y, 42) |
| 7808 |
with hasAnyArgument(...) |
| 7809 |
matching y |
| 7810 |
|
| 7811 |
For ObjectiveC, given |
| 7812 |
@interface I - (void) f:(int) y; @end |
| 7813 |
void foo(I *i) { [i f:12]; } |
| 7814 |
objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) |
| 7815 |
matches [i f:12] |
| 7816 |
</pre></td></tr> |
| 7817 |
|
| 7818 |
|
| 7819 |
<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> |
| 7820 |
<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor |
| 7821 |
call expression. |
| 7822 |
|
| 7823 |
Example matches y in x(y) |
| 7824 |
(matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 7825 |
void x(int) { int y; x(y); } |
| 7826 |
</pre></td></tr> |
| 7827 |
|
| 7828 |
|
| 7829 |
<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> |
| 7830 |
<tr><td colspan="4" class="doc" id="hasTypeLoc6"><pre>Matches if the type location of a node matches the inner matcher. |
| 7831 |
|
| 7832 |
Examples: |
| 7833 |
int x; |
| 7834 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 7835 |
matches int x |
| 7836 |
|
| 7837 |
auto x = int(3); |
| 7838 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 7839 |
matches int(3) |
| 7840 |
|
| 7841 |
struct Foo { Foo(int, int); }; |
| 7842 |
auto x = Foo(1, 2); |
| 7843 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 7844 |
matches Foo(1, 2) |
| 7845 |
|
| 7846 |
Usable 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>>, |
| 7847 |
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>>, |
| 7848 |
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>>, |
| 7849 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 7850 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 7851 |
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>>, |
| 7852 |
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>>, |
| 7853 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 7854 |
</pre></td></tr> |
| 7855 |
|
| 7856 |
|
| 7857 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('callee3')"><a name="callee3Anchor">callee</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 7858 |
<tr><td colspan="4" class="doc" id="callee3"><pre>Matches 1) if the call expression's callee's declaration matches the |
| 7859 |
given matcher; or 2) if the Obj-C message expression's callee's method |
| 7860 |
declaration matches the given matcher. |
| 7861 |
|
| 7862 |
Example matches y.x() (matcher = callExpr(callee( |
| 7863 |
cxxMethodDecl(hasName("x"))))) |
| 7864 |
class Y { public: void x(); }; |
| 7865 |
void z() { Y y; y.x(); } |
| 7866 |
|
| 7867 |
Example 2. Matches [I foo] with |
| 7868 |
objcMessageExpr(callee(objcMethodDecl(hasName("foo")))) |
| 7869 |
|
| 7870 |
@interface I: NSObject |
| 7871 |
+(void)foo; |
| 7872 |
@end |
| 7873 |
... |
| 7874 |
[I foo] |
| 7875 |
</pre></td></tr> |
| 7876 |
|
| 7877 |
|
| 7878 |
<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> |
| 7879 |
<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call or fold expression's callee expression matches. |
| 7880 |
|
| 7881 |
Given |
| 7882 |
class Y { void x() { this->x(); x(); Y y; y.x(); } }; |
| 7883 |
void f() { f(); } |
| 7884 |
callExpr(callee(expr())) |
| 7885 |
matches this->x(), x(), y.x(), f() |
| 7886 |
with callee(...) |
| 7887 |
matching this->x, x, y.x, f respectively |
| 7888 |
|
| 7889 |
Given |
| 7890 |
template <typename... Args> |
| 7891 |
auto sum(Args... args) { |
| 7892 |
return (0 + ... + args); |
| 7893 |
} |
| 7894 |
|
| 7895 |
template <typename... Args> |
| 7896 |
auto multiply(Args... args) { |
| 7897 |
return (args * ... * 1); |
| 7898 |
} |
| 7899 |
cxxFoldExpr(callee(expr())) |
| 7900 |
matches (args * ... * 1) |
| 7901 |
with callee(...) |
| 7902 |
matching * |
| 7903 |
|
| 7904 |
Note: Callee cannot take the more general internal::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> |
| 7905 |
because this introduces ambiguous overloads with calls to Callee taking a |
| 7906 |
internal::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely |
| 7907 |
implemented in terms of implicit casts. |
| 7908 |
</pre></td></tr> |
| 7909 |
|
| 7910 |
|
| 7911 |
<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> |
| 7912 |
<tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl. |
| 7913 |
|
| 7914 |
Given |
| 7915 |
void f(int i); |
| 7916 |
int y; |
| 7917 |
f(y); |
| 7918 |
callExpr( |
| 7919 |
forEachArgumentWithParam( |
| 7920 |
declRefExpr(to(varDecl(hasName("y")))), |
| 7921 |
parmVarDecl(hasType(isInteger())) |
| 7922 |
)) |
| 7923 |
matches f(y); |
| 7924 |
with declRefExpr(...) |
| 7925 |
matching int y |
| 7926 |
and parmVarDecl(...) |
| 7927 |
matching int i |
| 7928 |
</pre></td></tr> |
| 7929 |
|
| 7930 |
|
| 7931 |
<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> |
| 7932 |
<tr><td colspan="4" class="doc" id="forEachArgumentWithParamType0"><pre>Matches all arguments and their respective types for a CallExpr or |
| 7933 |
CXXConstructExpr. It is very similar to forEachArgumentWithParam but |
| 7934 |
it works on calls through function pointers as well. |
| 7935 |
|
| 7936 |
The difference is, that function pointers do not provide access to a |
| 7937 |
ParmVarDecl, but only the QualType for each argument. |
| 7938 |
|
| 7939 |
Given |
| 7940 |
void f(int i); |
| 7941 |
int y; |
| 7942 |
f(y); |
| 7943 |
void (*f_ptr)(int) = f; |
| 7944 |
f_ptr(y); |
| 7945 |
callExpr( |
| 7946 |
forEachArgumentWithParamType( |
| 7947 |
declRefExpr(to(varDecl(hasName("y")))), |
| 7948 |
qualType(isInteger()).bind("type) |
| 7949 |
)) |
| 7950 |
matches f(y) and f_ptr(y) |
| 7951 |
with declRefExpr(...) |
| 7952 |
matching int y |
| 7953 |
and qualType(...) |
| 7954 |
matching int |
| 7955 |
</pre></td></tr> |
| 7956 |
|
| 7957 |
|
| 7958 |
<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> |
| 7959 |
<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call |
| 7960 |
expression, or an ObjC-message-send expression. |
| 7961 |
|
| 7962 |
Given |
| 7963 |
void x(int, int, int) { int y; x(1, y, 42); } |
| 7964 |
callExpr(hasAnyArgument(declRefExpr())) |
| 7965 |
matches x(1, y, 42) |
| 7966 |
with hasAnyArgument(...) |
| 7967 |
matching y |
| 7968 |
|
| 7969 |
For ObjectiveC, given |
| 7970 |
@interface I - (void) f:(int) y; @end |
| 7971 |
void foo(I *i) { [i f:12]; } |
| 7972 |
objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) |
| 7973 |
matches [i f:12] |
| 7974 |
</pre></td></tr> |
| 7975 |
|
| 7976 |
|
| 7977 |
<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> |
| 7978 |
<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor |
| 7979 |
call expression. |
| 7980 |
|
| 7981 |
Example matches y in x(y) |
| 7982 |
(matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 7983 |
void x(int) { int y; x(y); } |
| 7984 |
</pre></td></tr> |
| 7985 |
|
| 7986 |
|
| 7987 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</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> |
| 7988 |
<tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node |
| 7989 |
matches the given matcher. |
| 7990 |
|
| 7991 |
The associated declaration is: |
| 7992 |
- for type nodes, the declaration of the underlying type |
| 7993 |
- for CallExpr, the declaration of the callee |
| 7994 |
- for MemberExpr, the declaration of the referenced member |
| 7995 |
- for CXXConstructExpr, the declaration of the constructor |
| 7996 |
- for CXXNewExpr, the declaration of the operator new |
| 7997 |
- for ObjCIvarExpr, the declaration of the ivar |
| 7998 |
|
| 7999 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 8000 |
sugared type. Given |
| 8001 |
class X {}; |
| 8002 |
typedef X Y; |
| 8003 |
Y y; |
| 8004 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 8005 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 8006 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 8007 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 8008 |
recordType(hasDeclaration(decl()))))) |
| 8009 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 8010 |
|
| 8011 |
Usable 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>>, |
| 8012 |
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>>, |
| 8013 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 8014 |
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<RecordType>, |
| 8015 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 8016 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 8017 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 8018 |
</pre></td></tr> |
| 8019 |
|
| 8020 |
|
| 8021 |
<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> |
| 8022 |
<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range |
| 8023 |
extension, matches the constant given in the statement. |
| 8024 |
|
| 8025 |
Given |
| 8026 |
switch (1) { case 1: case 1+1: case 3 ... 4: ; } |
| 8027 |
caseStmt(hasCaseConstant(integerLiteral())) |
| 8028 |
matches "case 1:" |
| 8029 |
</pre></td></tr> |
| 8030 |
|
| 8031 |
|
| 8032 |
<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> |
| 8033 |
<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression |
| 8034 |
or opaque value's source expression matches the given matcher. |
| 8035 |
|
| 8036 |
Example 1: matches "a string" |
| 8037 |
(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) |
| 8038 |
class URL { URL(string); }; |
| 8039 |
URL url = "a string"; |
| 8040 |
|
| 8041 |
Example 2: matches 'b' (matcher = |
| 8042 |
opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) |
| 8043 |
int a = b ?: 1; |
| 8044 |
</pre></td></tr> |
| 8045 |
|
| 8046 |
|
| 8047 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('forEachTemplateArgument0')"><a name="forEachTemplateArgument0Anchor">forEachTemplateArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> |
| 8048 |
<tr><td colspan="4" class="doc" id="forEachTemplateArgument0"><pre>Matches templateSpecializationType, class template specialization, |
| 8049 |
variable template specialization, and function template specialization |
| 8050 |
nodes where the template argument matches the inner matcher. This matcher |
| 8051 |
may produce multiple matches. |
| 8052 |
|
| 8053 |
Given |
| 8054 |
template <typename T, unsigned N, unsigned M> |
| 8055 |
struct Matrix {}; |
| 8056 |
|
| 8057 |
constexpr unsigned R = 2; |
| 8058 |
Matrix<int, R * 2, R * 4> M; |
| 8059 |
|
| 8060 |
template <typename T, typename U> |
| 8061 |
void f(T&& t, U&& u) {} |
| 8062 |
|
| 8063 |
bool B = false; |
| 8064 |
f(R, B); |
| 8065 |
templateSpecializationType(forEachTemplateArgument(isExpr(expr()))) |
| 8066 |
matches twice, with expr() matching 'R * 2' and 'R * 4' |
| 8067 |
functionDecl(forEachTemplateArgument(refersToType(builtinType()))) |
| 8068 |
matches the specialization f<unsigned, bool> twice, for 'unsigned' |
| 8069 |
and 'bool' |
| 8070 |
</pre></td></tr> |
| 8071 |
|
| 8072 |
|
| 8073 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgumentLoc0')"><a name="hasAnyTemplateArgumentLoc0Anchor">hasAnyTemplateArgumentLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> |
| 8074 |
<tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc0"><pre>Matches template specialization `TypeLoc`s, class template specializations, |
| 8075 |
variable template specializations, and function template specializations |
| 8076 |
that have at least one `TemplateArgumentLoc` matching the given |
| 8077 |
`InnerMatcher`. |
| 8078 |
|
| 8079 |
Given |
| 8080 |
template<typename T> class A {}; |
| 8081 |
A<int> a; |
| 8082 |
varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc( |
| 8083 |
hasTypeLoc(loc(asString("int"))))))) |
| 8084 |
matches `A<int> a`. |
| 8085 |
</pre></td></tr> |
| 8086 |
|
| 8087 |
|
| 8088 |
<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> |
| 8089 |
<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches templateSpecializationTypes, class template specializations, |
| 8090 |
variable template specializations, and function template specializations |
| 8091 |
that have at least one TemplateArgument matching the given InnerMatcher. |
| 8092 |
|
| 8093 |
Given |
| 8094 |
template<typename T> class A {}; |
| 8095 |
template<> class A<double> {}; |
| 8096 |
A<int> a; |
| 8097 |
|
| 8098 |
template<typename T> f() {}; |
| 8099 |
void func() { f<int>(); }; |
| 8100 |
|
| 8101 |
classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 8102 |
refersToType(asString("int")))) |
| 8103 |
matches the specialization A<int> |
| 8104 |
|
| 8105 |
functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) |
| 8106 |
matches the specialization f<int> |
| 8107 |
</pre></td></tr> |
| 8108 |
|
| 8109 |
|
| 8110 |
<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> |
| 8111 |
<tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration. |
| 8112 |
|
| 8113 |
Given |
| 8114 |
template<typename T> class A {}; #1 |
| 8115 |
template<> class A<int> {}; #2 |
| 8116 |
classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl())) |
| 8117 |
matches '#2' with classTemplateDecl() matching the class template |
| 8118 |
declaration of 'A' at #1. |
| 8119 |
</pre></td></tr> |
| 8120 |
|
| 8121 |
|
| 8122 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('hasTemplateArgumentLoc0')"><a name="hasTemplateArgumentLoc0Anchor">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> |
| 8123 |
<tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc0"><pre>Matches template specialization `TypeLoc`s, class template specializations, |
| 8124 |
variable template specializations, and function template specializations |
| 8125 |
where the n'th `TemplateArgumentLoc` matches the given `InnerMatcher`. |
| 8126 |
|
| 8127 |
Given |
| 8128 |
template<typename T, typename U> class A {}; |
| 8129 |
A<double, int> b; |
| 8130 |
A<int, double> c; |
| 8131 |
varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0, |
| 8132 |
hasTypeLoc(loc(asString("double"))))))) |
| 8133 |
matches `A<double, int> b`, but not `A<int, double> c`. |
| 8134 |
</pre></td></tr> |
| 8135 |
|
| 8136 |
|
| 8137 |
<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> |
| 8138 |
<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches templateSpecializationType, class template specializations, |
| 8139 |
variable template specializations, and function template specializations |
| 8140 |
where the n'th TemplateArgument matches the given InnerMatcher. |
| 8141 |
|
| 8142 |
Given |
| 8143 |
template<typename T, typename U> class A {}; |
| 8144 |
A<bool, int> b; |
| 8145 |
A<int, bool> c; |
| 8146 |
|
| 8147 |
template<typename T> void f() {} |
| 8148 |
void func() { f<int>(); }; |
| 8149 |
classTemplateSpecializationDecl(hasTemplateArgument( |
| 8150 |
1, refersToType(asString("int")))) |
| 8151 |
matches the specialization A<bool, int> |
| 8152 |
|
| 8153 |
functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) |
| 8154 |
matches the specialization f<int> |
| 8155 |
</pre></td></tr> |
| 8156 |
|
| 8157 |
|
| 8158 |
<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> |
| 8159 |
<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element |
| 8160 |
type. |
| 8161 |
|
| 8162 |
Given |
| 8163 |
struct A {}; |
| 8164 |
A a[7]; |
| 8165 |
int b[7]; |
| 8166 |
arrayType(hasElementType(builtinType())) |
| 8167 |
matches "int b[7]" |
| 8168 |
|
| 8169 |
Usable 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>> |
| 8170 |
</pre></td></tr> |
| 8171 |
|
| 8172 |
|
| 8173 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</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> |
| 8174 |
<tr><td colspan="4" class="doc" id="hasTypeLoc7"><pre>Matches if the type location of a node matches the inner matcher. |
| 8175 |
|
| 8176 |
Examples: |
| 8177 |
int x; |
| 8178 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 8179 |
matches int x |
| 8180 |
|
| 8181 |
auto x = int(3); |
| 8182 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 8183 |
matches int(3) |
| 8184 |
|
| 8185 |
struct Foo { Foo(int, int); }; |
| 8186 |
auto x = Foo(1, 2); |
| 8187 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 8188 |
matches Foo(1, 2) |
| 8189 |
|
| 8190 |
Usable 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>>, |
| 8191 |
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>>, |
| 8192 |
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>>, |
| 8193 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 8194 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 8195 |
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>>, |
| 8196 |
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>>, |
| 8197 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 8198 |
</pre></td></tr> |
| 8199 |
|
| 8200 |
|
| 8201 |
<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> |
| 8202 |
<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches |
| 8203 |
a given matcher. Also matches StmtExprs that have CompoundStmt as children. |
| 8204 |
|
| 8205 |
Given |
| 8206 |
{ {}; 1+2; } |
| 8207 |
hasAnySubstatement(compoundStmt()) |
| 8208 |
matches '{ {}; 1+2; }' |
| 8209 |
with compoundStmt() |
| 8210 |
matching '{}' |
| 8211 |
</pre></td></tr> |
| 8212 |
|
| 8213 |
|
| 8214 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CoroutineBodyStmt.html">CoroutineBodyStmt</a>></td><td class="name" onclick="toggle('hasBody5')"><a name="hasBody5Anchor">hasBody</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> |
| 8215 |
<tr><td colspan="4" class="doc" id="hasBody5"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine |
| 8216 |
definition that has a given body. Note that in case of functions or |
| 8217 |
coroutines this matcher only matches the definition itself and not the |
| 8218 |
other declarations of the same function or coroutine. |
| 8219 |
|
| 8220 |
Given |
| 8221 |
for (;;) {} |
| 8222 |
forStmt(hasBody(compoundStmt())) |
| 8223 |
matches 'for (;;) {}' |
| 8224 |
with compoundStmt() |
| 8225 |
matching '{}' |
| 8226 |
|
| 8227 |
Given |
| 8228 |
void f(); |
| 8229 |
void f() {} |
| 8230 |
functionDecl(hasBody(compoundStmt())) |
| 8231 |
matches 'void f() {}' |
| 8232 |
with compoundStmt() |
| 8233 |
matching '{}' |
| 8234 |
but does not match 'void f();' |
| 8235 |
</pre></td></tr> |
| 8236 |
|
| 8237 |
|
| 8238 |
<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> |
| 8239 |
<tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whose decayed type matches InnerMatcher |
| 8240 |
</pre></td></tr> |
| 8241 |
|
| 8242 |
|
| 8243 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgumentLoc3')"><a name="hasAnyTemplateArgumentLoc3Anchor">hasAnyTemplateArgumentLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> |
| 8244 |
<tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc3"><pre>Matches template specialization `TypeLoc`s, class template specializations, |
| 8245 |
variable template specializations, and function template specializations |
| 8246 |
that have at least one `TemplateArgumentLoc` matching the given |
| 8247 |
`InnerMatcher`. |
| 8248 |
|
| 8249 |
Given |
| 8250 |
template<typename T> class A {}; |
| 8251 |
A<int> a; |
| 8252 |
varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc( |
| 8253 |
hasTypeLoc(loc(asString("int"))))))) |
| 8254 |
matches `A<int> a`. |
| 8255 |
</pre></td></tr> |
| 8256 |
|
| 8257 |
|
| 8258 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</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> |
| 8259 |
<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node |
| 8260 |
matches the given matcher. |
| 8261 |
|
| 8262 |
The associated declaration is: |
| 8263 |
- for type nodes, the declaration of the underlying type |
| 8264 |
- for CallExpr, the declaration of the callee |
| 8265 |
- for MemberExpr, the declaration of the referenced member |
| 8266 |
- for CXXConstructExpr, the declaration of the constructor |
| 8267 |
- for CXXNewExpr, the declaration of the operator new |
| 8268 |
- for ObjCIvarExpr, the declaration of the ivar |
| 8269 |
|
| 8270 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 8271 |
sugared type. Given |
| 8272 |
class X {}; |
| 8273 |
typedef X Y; |
| 8274 |
Y y; |
| 8275 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 8276 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 8277 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 8278 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 8279 |
recordType(hasDeclaration(decl()))))) |
| 8280 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 8281 |
|
| 8282 |
Usable 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>>, |
| 8283 |
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>>, |
| 8284 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 8285 |
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<RecordType>, |
| 8286 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 8287 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 8288 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 8289 |
</pre></td></tr> |
| 8290 |
|
| 8291 |
|
| 8292 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('hasTemplateArgumentLoc3')"><a name="hasTemplateArgumentLoc3Anchor">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> |
| 8293 |
<tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc3"><pre>Matches template specialization `TypeLoc`s, class template specializations, |
| 8294 |
variable template specializations, and function template specializations |
| 8295 |
where the n'th `TemplateArgumentLoc` matches the given `InnerMatcher`. |
| 8296 |
|
| 8297 |
Given |
| 8298 |
template<typename T, typename U> class A {}; |
| 8299 |
A<double, int> b; |
| 8300 |
A<int, double> c; |
| 8301 |
varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0, |
| 8302 |
hasTypeLoc(loc(asString("double"))))))) |
| 8303 |
matches `A<double, int> b`, but not `A<int, double> c`. |
| 8304 |
</pre></td></tr> |
| 8305 |
|
| 8306 |
|
| 8307 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('throughUsingDecl0')"><a name="throughUsingDecl0Anchor">throughUsingDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>> Inner</td></tr> |
| 8308 |
<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches if a node refers to a declaration through a specific |
| 8309 |
using shadow declaration. |
| 8310 |
|
| 8311 |
Examples: |
| 8312 |
namespace a { int f(); } |
| 8313 |
using a::f; |
| 8314 |
int x = f(); |
| 8315 |
declRefExpr(throughUsingDecl(anything())) |
| 8316 |
matches f |
| 8317 |
|
| 8318 |
namespace a { class X{}; } |
| 8319 |
using a::X; |
| 8320 |
X x; |
| 8321 |
typeLoc(loc(usingType(throughUsingDecl(anything())))) |
| 8322 |
matches X |
| 8323 |
|
| 8324 |
Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 8325 |
</pre></td></tr> |
| 8326 |
|
| 8327 |
|
| 8328 |
<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> |
| 8329 |
<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the |
| 8330 |
specified matcher. |
| 8331 |
|
| 8332 |
Example matches x in if(x) |
| 8333 |
(matcher = declRefExpr(to(varDecl(hasName("x"))))) |
| 8334 |
bool x; |
| 8335 |
if (x) {} |
| 8336 |
</pre></td></tr> |
| 8337 |
|
| 8338 |
|
| 8339 |
<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> |
| 8340 |
<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. |
| 8341 |
|
| 8342 |
Note that this does not work for global declarations because the AST |
| 8343 |
breaks up multiple-declaration DeclStmt's into multiple single-declaration |
| 8344 |
DeclStmt's. |
| 8345 |
Example: Given non-global declarations |
| 8346 |
int a, b = 0; |
| 8347 |
int c; |
| 8348 |
int d = 2, e; |
| 8349 |
declStmt(containsDeclaration( |
| 8350 |
0, varDecl(hasInitializer(anything())))) |
| 8351 |
matches only 'int d = 2, e;', and |
| 8352 |
declStmt(containsDeclaration(1, varDecl())) |
| 8353 |
matches 'int a, b = 0' as well as 'int d = 2, e;' |
| 8354 |
but 'int c;' is not matched. |
| 8355 |
</pre></td></tr> |
| 8356 |
|
| 8357 |
|
| 8358 |
<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> |
| 8359 |
<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. |
| 8360 |
|
| 8361 |
Given |
| 8362 |
int a, b; |
| 8363 |
int c; |
| 8364 |
declStmt(hasSingleDecl(anything())) |
| 8365 |
matches 'int c;' but not 'int a, b;'. |
| 8366 |
</pre></td></tr> |
| 8367 |
|
| 8368 |
|
| 8369 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</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> |
| 8370 |
<tr><td colspan="4" class="doc" id="hasTypeLoc8"><pre>Matches if the type location of a node matches the inner matcher. |
| 8371 |
|
| 8372 |
Examples: |
| 8373 |
int x; |
| 8374 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 8375 |
matches int x |
| 8376 |
|
| 8377 |
auto x = int(3); |
| 8378 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 8379 |
matches int(3) |
| 8380 |
|
| 8381 |
struct Foo { Foo(int, int); }; |
| 8382 |
auto x = Foo(1, 2); |
| 8383 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 8384 |
matches Foo(1, 2) |
| 8385 |
|
| 8386 |
Usable 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>>, |
| 8387 |
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>>, |
| 8388 |
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>>, |
| 8389 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 8390 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 8391 |
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>>, |
| 8392 |
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>>, |
| 8393 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 8394 |
</pre></td></tr> |
| 8395 |
|
| 8396 |
|
| 8397 |
<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> |
| 8398 |
<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a |
| 8399 |
Decl, matches InnerMatcher. |
| 8400 |
|
| 8401 |
Given |
| 8402 |
namespace N { |
| 8403 |
namespace M { |
| 8404 |
class D {}; |
| 8405 |
} |
| 8406 |
} |
| 8407 |
|
| 8408 |
cxxRecordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the |
| 8409 |
declaration of class D. |
| 8410 |
</pre></td></tr> |
| 8411 |
|
| 8412 |
|
| 8413 |
<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> |
| 8414 |
<tr><td colspan="4" class="doc" id="hasAnyBinding0"><pre>Matches any binding of a DecompositionDecl. |
| 8415 |
|
| 8416 |
For example, in: |
| 8417 |
void foo() |
| 8418 |
{ |
| 8419 |
int arr[3]; |
| 8420 |
auto &[f, s, t] = arr; |
| 8421 |
|
| 8422 |
f = 42; |
| 8423 |
} |
| 8424 |
The matcher: |
| 8425 |
decompositionDecl(hasAnyBinding(bindingDecl(hasName("f").bind("fBinding")))) |
| 8426 |
matches the decomposition decl with 'f' bound to "fBinding". |
| 8427 |
</pre></td></tr> |
| 8428 |
|
| 8429 |
|
| 8430 |
<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> |
| 8431 |
<tr><td colspan="4" class="doc" id="hasBinding0"><pre>Matches the Nth binding of a DecompositionDecl. |
| 8432 |
|
| 8433 |
For example, in: |
| 8434 |
void foo() |
| 8435 |
{ |
| 8436 |
int arr[3]; |
| 8437 |
auto &[f, s, t] = arr; |
| 8438 |
|
| 8439 |
f = 42; |
| 8440 |
} |
| 8441 |
The matcher: |
| 8442 |
decompositionDecl(hasBinding(0, |
| 8443 |
bindingDecl(hasName("f").bind("fBinding")))) |
| 8444 |
matches the decomposition decl with 'f' bound to "fBinding". |
| 8445 |
</pre></td></tr> |
| 8446 |
|
| 8447 |
|
| 8448 |
<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> |
| 8449 |
<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine |
| 8450 |
definition that has a given body. Note that in case of functions or |
| 8451 |
coroutines this matcher only matches the definition itself and not the |
| 8452 |
other declarations of the same function or coroutine. |
| 8453 |
|
| 8454 |
Given |
| 8455 |
for (;;) {} |
| 8456 |
forStmt(hasBody(compoundStmt())) |
| 8457 |
matches 'for (;;) {}' |
| 8458 |
with compoundStmt() |
| 8459 |
matching '{}' |
| 8460 |
|
| 8461 |
Given |
| 8462 |
void f(); |
| 8463 |
void f() {} |
| 8464 |
functionDecl(hasBody(compoundStmt())) |
| 8465 |
matches 'void f() {}' |
| 8466 |
with compoundStmt() |
| 8467 |
matching '{}' |
| 8468 |
but does not match 'void f();' |
| 8469 |
</pre></td></tr> |
| 8470 |
|
| 8471 |
|
| 8472 |
<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> |
| 8473 |
<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, while loop, |
| 8474 |
do-while loop, switch statement or conditional operator. |
| 8475 |
|
| 8476 |
Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 8477 |
if (true) {} |
| 8478 |
</pre></td></tr> |
| 8479 |
|
| 8480 |
|
| 8481 |
<tr><td>Matcher<EnumType></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> |
| 8482 |
<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node |
| 8483 |
matches the given matcher. |
| 8484 |
|
| 8485 |
The associated declaration is: |
| 8486 |
- for type nodes, the declaration of the underlying type |
| 8487 |
- for CallExpr, the declaration of the callee |
| 8488 |
- for MemberExpr, the declaration of the referenced member |
| 8489 |
- for CXXConstructExpr, the declaration of the constructor |
| 8490 |
- for CXXNewExpr, the declaration of the operator new |
| 8491 |
- for ObjCIvarExpr, the declaration of the ivar |
| 8492 |
|
| 8493 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 8494 |
sugared type. Given |
| 8495 |
class X {}; |
| 8496 |
typedef X Y; |
| 8497 |
Y y; |
| 8498 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 8499 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 8500 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 8501 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 8502 |
recordType(hasDeclaration(decl()))))) |
| 8503 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 8504 |
|
| 8505 |
Usable 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>>, |
| 8506 |
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>>, |
| 8507 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 8508 |
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<RecordType>, |
| 8509 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 8510 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 8511 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 8512 |
</pre></td></tr> |
| 8513 |
|
| 8514 |
|
| 8515 |
<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> |
| 8516 |
<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. |
| 8517 |
|
| 8518 |
(Note: Clang's AST refers to other conversions as "casts" too, and calls |
| 8519 |
actual casts "explicit" casts.) |
| 8520 |
</pre></td></tr> |
| 8521 |
|
| 8522 |
|
| 8523 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</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> |
| 8524 |
<tr><td colspan="4" class="doc" id="hasTypeLoc9"><pre>Matches if the type location of a node matches the inner matcher. |
| 8525 |
|
| 8526 |
Examples: |
| 8527 |
int x; |
| 8528 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 8529 |
matches int x |
| 8530 |
|
| 8531 |
auto x = int(3); |
| 8532 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 8533 |
matches int(3) |
| 8534 |
|
| 8535 |
struct Foo { Foo(int, int); }; |
| 8536 |
auto x = Foo(1, 2); |
| 8537 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 8538 |
matches Foo(1, 2) |
| 8539 |
|
| 8540 |
Usable 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>>, |
| 8541 |
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>>, |
| 8542 |
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>>, |
| 8543 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 8544 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 8545 |
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>>, |
| 8546 |
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>>, |
| 8547 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 8548 |
</pre></td></tr> |
| 8549 |
|
| 8550 |
|
| 8551 |
<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> |
| 8552 |
<tr><td colspan="4" class="doc" id="hasType5"><pre>Overloaded to match the declaration of the expression's or value |
| 8553 |
declaration's type. |
| 8554 |
|
| 8555 |
In case of a value declaration (for example a variable declaration), |
| 8556 |
this resolves one layer of indirection. For example, in the value |
| 8557 |
declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 8558 |
X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 8559 |
declaration of x. |
| 8560 |
|
| 8561 |
Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 8562 |
and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 8563 |
and friend class X (matcher = friendDecl(hasType("X")) |
| 8564 |
and public virtual X (matcher = cxxBaseSpecifier(hasType( |
| 8565 |
cxxRecordDecl(hasName("X")))) |
| 8566 |
class X {}; |
| 8567 |
void y(X &x) { x; X z; } |
| 8568 |
class Y { friend class X; }; |
| 8569 |
class Z : public virtual X {}; |
| 8570 |
|
| 8571 |
Example matches class Derived |
| 8572 |
(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) |
| 8573 |
class Base {}; |
| 8574 |
class Derived : Base {}; |
| 8575 |
|
| 8576 |
Usable 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>>, |
| 8577 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> |
| 8578 |
</pre></td></tr> |
| 8579 |
|
| 8580 |
|
| 8581 |
<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> |
| 8582 |
<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type |
| 8583 |
matcher. |
| 8584 |
|
| 8585 |
Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 8586 |
and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 8587 |
and U (matcher = typedefDecl(hasType(asString("int"))) |
| 8588 |
and friend class X (matcher = friendDecl(hasType("X")) |
| 8589 |
and public virtual X (matcher = cxxBaseSpecifier(hasType( |
| 8590 |
asString("class X"))) |
| 8591 |
class X {}; |
| 8592 |
void y(X &x) { x; X z; } |
| 8593 |
typedef int U; |
| 8594 |
class Y { friend class X; }; |
| 8595 |
class Z : public virtual X {}; |
| 8596 |
</pre></td></tr> |
| 8597 |
|
| 8598 |
|
| 8599 |
<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>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 8600 |
<tr><td colspan="4" class="doc" id="ignoringElidableConstructorCall0"><pre>Matches expressions that match InnerMatcher that are possibly wrapped in an |
| 8601 |
elidable constructor and other corresponding bookkeeping nodes. |
| 8602 |
|
| 8603 |
In C++17, elidable copy constructors are no longer being generated in the |
| 8604 |
AST as it is not permitted by the standard. They are, however, part of the |
| 8605 |
AST in C++14 and earlier. So, a matcher must abstract over these differences |
| 8606 |
to work in all language modes. This matcher skips elidable constructor-call |
| 8607 |
AST nodes, `ExprWithCleanups` nodes wrapping elidable constructor-calls and |
| 8608 |
various implicit nodes inside the constructor calls, all of which will not |
| 8609 |
appear in the C++17 AST. |
| 8610 |
|
| 8611 |
Given |
| 8612 |
|
| 8613 |
struct H {}; |
| 8614 |
H G(); |
| 8615 |
void f() { |
| 8616 |
H D = G(); |
| 8617 |
} |
| 8618 |
|
| 8619 |
``varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr())))`` |
| 8620 |
matches ``H D = G()`` in C++11 through C++17 (and beyond). |
| 8621 |
</pre></td></tr> |
| 8622 |
|
| 8623 |
|
| 8624 |
<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> |
| 8625 |
<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts |
| 8626 |
are stripped off. |
| 8627 |
|
| 8628 |
Parentheses and explicit casts are not discarded. |
| 8629 |
Given |
| 8630 |
int arr[5]; |
| 8631 |
int a = 0; |
| 8632 |
char b = 0; |
| 8633 |
const int c = a; |
| 8634 |
int *d = arr; |
| 8635 |
long e = (long) 0l; |
| 8636 |
The matchers |
| 8637 |
varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) |
| 8638 |
varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) |
| 8639 |
would match the declarations for a, b, c, and d, but not e. |
| 8640 |
While |
| 8641 |
varDecl(hasInitializer(integerLiteral())) |
| 8642 |
varDecl(hasInitializer(declRefExpr())) |
| 8643 |
only match the declarations for a. |
| 8644 |
</pre></td></tr> |
| 8645 |
|
| 8646 |
|
| 8647 |
<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> |
| 8648 |
<tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST |
| 8649 |
nodes are stripped off. |
| 8650 |
|
| 8651 |
Parentheses and explicit casts are not discarded. |
| 8652 |
Given |
| 8653 |
class C {}; |
| 8654 |
C a = C(); |
| 8655 |
C b; |
| 8656 |
C c = b; |
| 8657 |
The matchers |
| 8658 |
varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr()))) |
| 8659 |
would match the declarations for a, b, and c. |
| 8660 |
While |
| 8661 |
varDecl(hasInitializer(cxxConstructExpr())) |
| 8662 |
only match the declarations for b and c. |
| 8663 |
</pre></td></tr> |
| 8664 |
|
| 8665 |
|
| 8666 |
<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> |
| 8667 |
<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and |
| 8668 |
casts are stripped off. |
| 8669 |
|
| 8670 |
Implicit and non-C Style casts are also discarded. |
| 8671 |
Given |
| 8672 |
int a = 0; |
| 8673 |
char b = (0); |
| 8674 |
void* c = reinterpret_cast<char*>(0); |
| 8675 |
char d = char(0); |
| 8676 |
The matcher |
| 8677 |
varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) |
| 8678 |
would match the declarations for a, b, c, and d. |
| 8679 |
while |
| 8680 |
varDecl(hasInitializer(integerLiteral())) |
| 8681 |
only match the declaration for a. |
| 8682 |
</pre></td></tr> |
| 8683 |
|
| 8684 |
|
| 8685 |
<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> |
| 8686 |
<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and |
| 8687 |
parentheses are stripped off. |
| 8688 |
|
| 8689 |
Explicit casts are not discarded. |
| 8690 |
Given |
| 8691 |
int arr[5]; |
| 8692 |
int a = 0; |
| 8693 |
char b = (0); |
| 8694 |
const int c = a; |
| 8695 |
int *d = (arr); |
| 8696 |
long e = ((long) 0l); |
| 8697 |
The matchers |
| 8698 |
varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) |
| 8699 |
varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) |
| 8700 |
would match the declarations for a, b, c, and d, but not e. |
| 8701 |
while |
| 8702 |
varDecl(hasInitializer(integerLiteral())) |
| 8703 |
varDecl(hasInitializer(declRefExpr())) |
| 8704 |
would only match the declaration for a. |
| 8705 |
</pre></td></tr> |
| 8706 |
|
| 8707 |
|
| 8708 |
<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> |
| 8709 |
<tr><td colspan="4" class="doc" id="ignoringParens1"><pre>Overload ignoringParens for Expr. |
| 8710 |
|
| 8711 |
Given |
| 8712 |
const char* str = ("my-string"); |
| 8713 |
The matcher |
| 8714 |
implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral()))) |
| 8715 |
would match the implicit cast resulting from the assignment. |
| 8716 |
</pre></td></tr> |
| 8717 |
|
| 8718 |
|
| 8719 |
<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> |
| 8720 |
<tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer. |
| 8721 |
|
| 8722 |
Given |
| 8723 |
class C { |
| 8724 |
int a = 2; |
| 8725 |
int b = 3; |
| 8726 |
int c; |
| 8727 |
}; |
| 8728 |
fieldDecl(hasInClassInitializer(integerLiteral(equals(2)))) |
| 8729 |
matches 'int a;' but not 'int b;'. |
| 8730 |
fieldDecl(hasInClassInitializer(anything())) |
| 8731 |
matches 'int a;' and 'int b;' but not 'int c;'. |
| 8732 |
</pre></td></tr> |
| 8733 |
|
| 8734 |
|
| 8735 |
<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> |
| 8736 |
<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine |
| 8737 |
definition that has a given body. Note that in case of functions or |
| 8738 |
coroutines this matcher only matches the definition itself and not the |
| 8739 |
other declarations of the same function or coroutine. |
| 8740 |
|
| 8741 |
Given |
| 8742 |
for (;;) {} |
| 8743 |
forStmt(hasBody(compoundStmt())) |
| 8744 |
matches 'for (;;) {}' |
| 8745 |
with compoundStmt() |
| 8746 |
matching '{}' |
| 8747 |
|
| 8748 |
Given |
| 8749 |
void f(); |
| 8750 |
void f() {} |
| 8751 |
functionDecl(hasBody(compoundStmt())) |
| 8752 |
matches 'void f() {}' |
| 8753 |
with compoundStmt() |
| 8754 |
matching '{}' |
| 8755 |
but does not match 'void f();' |
| 8756 |
</pre></td></tr> |
| 8757 |
|
| 8758 |
|
| 8759 |
<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> |
| 8760 |
<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, while loop, |
| 8761 |
do-while loop, switch statement or conditional operator. |
| 8762 |
|
| 8763 |
Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 8764 |
if (true) {} |
| 8765 |
</pre></td></tr> |
| 8766 |
|
| 8767 |
|
| 8768 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>></td><td class="name" onclick="toggle('hasConditionVariableStatement1')"><a name="hasConditionVariableStatement1Anchor">hasConditionVariableStatement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>> InnerMatcher</td></tr> |
| 8769 |
<tr><td colspan="4" class="doc" id="hasConditionVariableStatement1"><pre>Matches the condition variable statement in an if statement, for loop, |
| 8770 |
while loop or switch statement. |
| 8771 |
|
| 8772 |
Given |
| 8773 |
if (A* a = GetAPointer()) {} |
| 8774 |
for (; A* a = GetAPointer(); ) {} |
| 8775 |
hasConditionVariableStatement(...) |
| 8776 |
matches both 'A* a = GetAPointer()'. |
| 8777 |
</pre></td></tr> |
| 8778 |
|
| 8779 |
|
| 8780 |
<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> |
| 8781 |
<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. |
| 8782 |
|
| 8783 |
Example: |
| 8784 |
forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) |
| 8785 |
matches '++x' in |
| 8786 |
for (x; x < N; ++x) { } |
| 8787 |
</pre></td></tr> |
| 8788 |
|
| 8789 |
|
| 8790 |
<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> |
| 8791 |
<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. |
| 8792 |
|
| 8793 |
Example: |
| 8794 |
forStmt(hasLoopInit(declStmt())) |
| 8795 |
matches 'int x = 0' in |
| 8796 |
for (int x = 0; x < N; ++x) { } |
| 8797 |
</pre></td></tr> |
| 8798 |
|
| 8799 |
|
| 8800 |
<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> |
| 8801 |
<tr><td colspan="4" class="doc" id="hasType6"><pre>Overloaded to match the declaration of the expression's or value |
| 8802 |
declaration's type. |
| 8803 |
|
| 8804 |
In case of a value declaration (for example a variable declaration), |
| 8805 |
this resolves one layer of indirection. For example, in the value |
| 8806 |
declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 8807 |
X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 8808 |
declaration of x. |
| 8809 |
|
| 8810 |
Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 8811 |
and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 8812 |
and friend class X (matcher = friendDecl(hasType("X")) |
| 8813 |
and public virtual X (matcher = cxxBaseSpecifier(hasType( |
| 8814 |
cxxRecordDecl(hasName("X")))) |
| 8815 |
class X {}; |
| 8816 |
void y(X &x) { x; X z; } |
| 8817 |
class Y { friend class X; }; |
| 8818 |
class Z : public virtual X {}; |
| 8819 |
|
| 8820 |
Example matches class Derived |
| 8821 |
(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) |
| 8822 |
class Base {}; |
| 8823 |
class Derived : Base {}; |
| 8824 |
|
| 8825 |
Usable 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>>, |
| 8826 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> |
| 8827 |
</pre></td></tr> |
| 8828 |
|
| 8829 |
|
| 8830 |
<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> |
| 8831 |
<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type |
| 8832 |
matcher. |
| 8833 |
|
| 8834 |
Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 8835 |
and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 8836 |
and U (matcher = typedefDecl(hasType(asString("int"))) |
| 8837 |
and friend class X (matcher = friendDecl(hasType("X")) |
| 8838 |
and public virtual X (matcher = cxxBaseSpecifier(hasType( |
| 8839 |
asString("class X"))) |
| 8840 |
class X {}; |
| 8841 |
void y(X &x) { x; X z; } |
| 8842 |
typedef int U; |
| 8843 |
class Y { friend class X; }; |
| 8844 |
class Z : public virtual X {}; |
| 8845 |
</pre></td></tr> |
| 8846 |
|
| 8847 |
|
| 8848 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('forEachTemplateArgument2')"><a name="forEachTemplateArgument2Anchor">forEachTemplateArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> |
| 8849 |
<tr><td colspan="4" class="doc" id="forEachTemplateArgument2"><pre>Matches templateSpecializationType, class template specialization, |
| 8850 |
variable template specialization, and function template specialization |
| 8851 |
nodes where the template argument matches the inner matcher. This matcher |
| 8852 |
may produce multiple matches. |
| 8853 |
|
| 8854 |
Given |
| 8855 |
template <typename T, unsigned N, unsigned M> |
| 8856 |
struct Matrix {}; |
| 8857 |
|
| 8858 |
constexpr unsigned R = 2; |
| 8859 |
Matrix<int, R * 2, R * 4> M; |
| 8860 |
|
| 8861 |
template <typename T, typename U> |
| 8862 |
void f(T&& t, U&& u) {} |
| 8863 |
|
| 8864 |
bool B = false; |
| 8865 |
f(R, B); |
| 8866 |
templateSpecializationType(forEachTemplateArgument(isExpr(expr()))) |
| 8867 |
matches twice, with expr() matching 'R * 2' and 'R * 4' |
| 8868 |
functionDecl(forEachTemplateArgument(refersToType(builtinType()))) |
| 8869 |
matches the specialization f<unsigned, bool> twice, for 'unsigned' |
| 8870 |
and 'bool' |
| 8871 |
</pre></td></tr> |
| 8872 |
|
| 8873 |
|
| 8874 |
<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> |
| 8875 |
<tr><td colspan="4" class="doc" id="hasAnyBody0"><pre>Matches a function declaration that has a given body present in the AST. |
| 8876 |
Note that this matcher matches all the declarations of a function whose |
| 8877 |
body is present in the AST. |
| 8878 |
|
| 8879 |
Given |
| 8880 |
void f(); |
| 8881 |
void f() {} |
| 8882 |
void g(); |
| 8883 |
functionDecl(hasAnyBody(compoundStmt())) |
| 8884 |
matches both 'void f();' |
| 8885 |
and 'void f() {}' |
| 8886 |
with compoundStmt() |
| 8887 |
matching '{}' |
| 8888 |
but does not match 'void g();' |
| 8889 |
</pre></td></tr> |
| 8890 |
|
| 8891 |
|
| 8892 |
<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> |
| 8893 |
<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a |
| 8894 |
block. |
| 8895 |
|
| 8896 |
Does not match the 'this' parameter of a method. |
| 8897 |
|
| 8898 |
Given |
| 8899 |
class X { void f(int x, int y, int z) {} }; |
| 8900 |
cxxMethodDecl(hasAnyParameter(hasName("y"))) |
| 8901 |
matches f(int x, int y, int z) {} |
| 8902 |
with hasAnyParameter(...) |
| 8903 |
matching int y |
| 8904 |
|
| 8905 |
For ObjectiveC, given |
| 8906 |
@interface I - (void) f:(int) y; @end |
| 8907 |
|
| 8908 |
the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) |
| 8909 |
matches the declaration of method f with hasParameter |
| 8910 |
matching y. |
| 8911 |
|
| 8912 |
For blocks, given |
| 8913 |
b = ^(int y) { printf("%d", y) }; |
| 8914 |
|
| 8915 |
the matcher blockDecl(hasAnyParameter(hasName("y"))) |
| 8916 |
matches the declaration of the block b with hasParameter |
| 8917 |
matching y. |
| 8918 |
</pre></td></tr> |
| 8919 |
|
| 8920 |
|
| 8921 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgumentLoc2')"><a name="hasAnyTemplateArgumentLoc2Anchor">hasAnyTemplateArgumentLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> |
| 8922 |
<tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc2"><pre>Matches template specialization `TypeLoc`s, class template specializations, |
| 8923 |
variable template specializations, and function template specializations |
| 8924 |
that have at least one `TemplateArgumentLoc` matching the given |
| 8925 |
`InnerMatcher`. |
| 8926 |
|
| 8927 |
Given |
| 8928 |
template<typename T> class A {}; |
| 8929 |
A<int> a; |
| 8930 |
varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc( |
| 8931 |
hasTypeLoc(loc(asString("int"))))))) |
| 8932 |
matches `A<int> a`. |
| 8933 |
</pre></td></tr> |
| 8934 |
|
| 8935 |
|
| 8936 |
<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> |
| 8937 |
<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches templateSpecializationTypes, class template specializations, |
| 8938 |
variable template specializations, and function template specializations |
| 8939 |
that have at least one TemplateArgument matching the given InnerMatcher. |
| 8940 |
|
| 8941 |
Given |
| 8942 |
template<typename T> class A {}; |
| 8943 |
template<> class A<double> {}; |
| 8944 |
A<int> a; |
| 8945 |
|
| 8946 |
template<typename T> f() {}; |
| 8947 |
void func() { f<int>(); }; |
| 8948 |
|
| 8949 |
classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 8950 |
refersToType(asString("int")))) |
| 8951 |
matches the specialization A<int> |
| 8952 |
|
| 8953 |
functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) |
| 8954 |
matches the specialization f<int> |
| 8955 |
</pre></td></tr> |
| 8956 |
|
| 8957 |
|
| 8958 |
<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> |
| 8959 |
<tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine |
| 8960 |
definition that has a given body. Note that in case of functions or |
| 8961 |
coroutines this matcher only matches the definition itself and not the |
| 8962 |
other declarations of the same function or coroutine. |
| 8963 |
|
| 8964 |
Given |
| 8965 |
for (;;) {} |
| 8966 |
forStmt(hasBody(compoundStmt())) |
| 8967 |
matches 'for (;;) {}' |
| 8968 |
with compoundStmt() |
| 8969 |
matching '{}' |
| 8970 |
|
| 8971 |
Given |
| 8972 |
void f(); |
| 8973 |
void f() {} |
| 8974 |
functionDecl(hasBody(compoundStmt())) |
| 8975 |
matches 'void f() {}' |
| 8976 |
with compoundStmt() |
| 8977 |
matching '{}' |
| 8978 |
but does not match 'void f();' |
| 8979 |
</pre></td></tr> |
| 8980 |
|
| 8981 |
|
| 8982 |
<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> |
| 8983 |
<tr><td colspan="4" class="doc" id="hasExplicitSpecifier0"><pre>Matches the expression in an explicit specifier if present in the given |
| 8984 |
declaration. |
| 8985 |
|
| 8986 |
Given |
| 8987 |
template<bool b> |
| 8988 |
struct S { |
| 8989 |
S(int); // #1 |
| 8990 |
explicit S(double); // #2 |
| 8991 |
operator int(); // #3 |
| 8992 |
explicit operator bool(); // #4 |
| 8993 |
explicit(false) S(bool) // # 7 |
| 8994 |
explicit(true) S(char) // # 8 |
| 8995 |
explicit(b) S(S) // # 9 |
| 8996 |
}; |
| 8997 |
S(int) -> S<true> // #5 |
| 8998 |
explicit S(double) -> S<false> // #6 |
| 8999 |
cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2. |
| 9000 |
cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4. |
| 9001 |
cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6. |
| 9002 |
</pre></td></tr> |
| 9003 |
|
| 9004 |
|
| 9005 |
<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> |
| 9006 |
<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method |
| 9007 |
declaration or a block. |
| 9008 |
|
| 9009 |
Given |
| 9010 |
class X { void f(int x) {} }; |
| 9011 |
cxxMethodDecl(hasParameter(0, hasType(varDecl()))) |
| 9012 |
matches f(int x) {} |
| 9013 |
with hasParameter(...) |
| 9014 |
matching int x |
| 9015 |
|
| 9016 |
For ObjectiveC, given |
| 9017 |
@interface I - (void) f:(int) y; @end |
| 9018 |
|
| 9019 |
the matcher objcMethodDecl(hasParameter(0, hasName("y"))) |
| 9020 |
matches the declaration of method f with hasParameter |
| 9021 |
matching y. |
| 9022 |
</pre></td></tr> |
| 9023 |
|
| 9024 |
|
| 9025 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasReturnTypeLoc0')"><a name="hasReturnTypeLoc0Anchor">hasReturnTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> ReturnMatcher</td></tr> |
| 9026 |
<tr><td colspan="4" class="doc" id="hasReturnTypeLoc0"><pre>Matches a function declared with the specified return `TypeLoc`. |
| 9027 |
|
| 9028 |
Given |
| 9029 |
int f() { return 5; } |
| 9030 |
void g() {} |
| 9031 |
functionDecl(hasReturnTypeLoc(loc(asString("int")))) |
| 9032 |
matches the declaration of `f`, but not `g`. |
| 9033 |
</pre></td></tr> |
| 9034 |
|
| 9035 |
|
| 9036 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasTemplateArgumentLoc2')"><a name="hasTemplateArgumentLoc2Anchor">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> |
| 9037 |
<tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc2"><pre>Matches template specialization `TypeLoc`s, class template specializations, |
| 9038 |
variable template specializations, and function template specializations |
| 9039 |
where the n'th `TemplateArgumentLoc` matches the given `InnerMatcher`. |
| 9040 |
|
| 9041 |
Given |
| 9042 |
template<typename T, typename U> class A {}; |
| 9043 |
A<double, int> b; |
| 9044 |
A<int, double> c; |
| 9045 |
varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0, |
| 9046 |
hasTypeLoc(loc(asString("double"))))))) |
| 9047 |
matches `A<double, int> b`, but not `A<int, double> c`. |
| 9048 |
</pre></td></tr> |
| 9049 |
|
| 9050 |
|
| 9051 |
<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> |
| 9052 |
<tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches templateSpecializationType, class template specializations, |
| 9053 |
variable template specializations, and function template specializations |
| 9054 |
where the n'th TemplateArgument matches the given InnerMatcher. |
| 9055 |
|
| 9056 |
Given |
| 9057 |
template<typename T, typename U> class A {}; |
| 9058 |
A<bool, int> b; |
| 9059 |
A<int, bool> c; |
| 9060 |
|
| 9061 |
template<typename T> void f() {} |
| 9062 |
void func() { f<int>(); }; |
| 9063 |
classTemplateSpecializationDecl(hasTemplateArgument( |
| 9064 |
1, refersToType(asString("int")))) |
| 9065 |
matches the specialization A<bool, int> |
| 9066 |
|
| 9067 |
functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) |
| 9068 |
matches the specialization f<int> |
| 9069 |
</pre></td></tr> |
| 9070 |
|
| 9071 |
|
| 9072 |
<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> |
| 9073 |
<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. |
| 9074 |
|
| 9075 |
Given: |
| 9076 |
class X { int f() { return 1; } }; |
| 9077 |
cxxMethodDecl(returns(asString("int"))) |
| 9078 |
matches int f() { return 1; } |
| 9079 |
</pre></td></tr> |
| 9080 |
|
| 9081 |
|
| 9082 |
<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> |
| 9083 |
<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, while loop, |
| 9084 |
do-while loop, switch statement or conditional operator. |
| 9085 |
|
| 9086 |
Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 9087 |
if (true) {} |
| 9088 |
</pre></td></tr> |
| 9089 |
|
| 9090 |
|
| 9091 |
<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> |
| 9092 |
<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement, for loop, |
| 9093 |
while loop or switch statement. |
| 9094 |
|
| 9095 |
Given |
| 9096 |
if (A* a = GetAPointer()) {} |
| 9097 |
for (; A* a = GetAPointer(); ) {} |
| 9098 |
hasConditionVariableStatement(...) |
| 9099 |
matches both 'A* a = GetAPointer()'. |
| 9100 |
</pre></td></tr> |
| 9101 |
|
| 9102 |
|
| 9103 |
<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> |
| 9104 |
<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. |
| 9105 |
|
| 9106 |
Examples matches the if statement |
| 9107 |
(matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) |
| 9108 |
if (false) false; else true; |
| 9109 |
</pre></td></tr> |
| 9110 |
|
| 9111 |
|
| 9112 |
<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> |
| 9113 |
<tr><td colspan="4" class="doc" id="hasInitStatement0"><pre>Matches selection statements with initializer. |
| 9114 |
|
| 9115 |
Given: |
| 9116 |
void foo() { |
| 9117 |
if (int i = foobar(); i > 0) {} |
| 9118 |
switch (int i = foobar(); i) {} |
| 9119 |
for (auto& a = get_range(); auto& x : a) {} |
| 9120 |
} |
| 9121 |
void bar() { |
| 9122 |
if (foobar() > 0) {} |
| 9123 |
switch (foobar()) {} |
| 9124 |
for (auto& x : get_range()) {} |
| 9125 |
} |
| 9126 |
ifStmt(hasInitStatement(anything())) |
| 9127 |
matches the if statement in foo but not in bar. |
| 9128 |
switchStmt(hasInitStatement(anything())) |
| 9129 |
matches the switch statement in foo but not in bar. |
| 9130 |
cxxForRangeStmt(hasInitStatement(anything())) |
| 9131 |
matches the range for statement in foo but not in bar. |
| 9132 |
</pre></td></tr> |
| 9133 |
|
| 9134 |
|
| 9135 |
<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> |
| 9136 |
<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. |
| 9137 |
|
| 9138 |
Examples matches the if statement |
| 9139 |
(matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) |
| 9140 |
if (false) true; else false; |
| 9141 |
</pre></td></tr> |
| 9142 |
|
| 9143 |
|
| 9144 |
<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> |
| 9145 |
<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given |
| 9146 |
matcher. |
| 9147 |
</pre></td></tr> |
| 9148 |
|
| 9149 |
|
| 9150 |
<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, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 9151 |
<tr><td colspan="4" class="doc" id="hasInit0"><pre>Matches the n'th item of an initializer list expression. |
| 9152 |
|
| 9153 |
Example matches y. |
| 9154 |
(matcher = initListExpr(hasInit(0, expr()))) |
| 9155 |
int x{y}. |
| 9156 |
</pre></td></tr> |
| 9157 |
|
| 9158 |
|
| 9159 |
<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> |
| 9160 |
<tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions |
| 9161 |
(if expression have it). |
| 9162 |
</pre></td></tr> |
| 9163 |
|
| 9164 |
|
| 9165 |
<tr><td>Matcher<InjectedClassNameType></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> |
| 9166 |
<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node |
| 9167 |
matches the given matcher. |
| 9168 |
|
| 9169 |
The associated declaration is: |
| 9170 |
- for type nodes, the declaration of the underlying type |
| 9171 |
- for CallExpr, the declaration of the callee |
| 9172 |
- for MemberExpr, the declaration of the referenced member |
| 9173 |
- for CXXConstructExpr, the declaration of the constructor |
| 9174 |
- for CXXNewExpr, the declaration of the operator new |
| 9175 |
- for ObjCIvarExpr, the declaration of the ivar |
| 9176 |
|
| 9177 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 9178 |
sugared type. Given |
| 9179 |
class X {}; |
| 9180 |
typedef X Y; |
| 9181 |
Y y; |
| 9182 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 9183 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 9184 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 9185 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 9186 |
recordType(hasDeclaration(decl()))))) |
| 9187 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 9188 |
|
| 9189 |
Usable 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>>, |
| 9190 |
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>>, |
| 9191 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 9192 |
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<RecordType>, |
| 9193 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 9194 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 9195 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 9196 |
</pre></td></tr> |
| 9197 |
|
| 9198 |
|
| 9199 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</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> |
| 9200 |
<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node |
| 9201 |
matches the given matcher. |
| 9202 |
|
| 9203 |
The associated declaration is: |
| 9204 |
- for type nodes, the declaration of the underlying type |
| 9205 |
- for CallExpr, the declaration of the callee |
| 9206 |
- for MemberExpr, the declaration of the referenced member |
| 9207 |
- for CXXConstructExpr, the declaration of the constructor |
| 9208 |
- for CXXNewExpr, the declaration of the operator new |
| 9209 |
- for ObjCIvarExpr, the declaration of the ivar |
| 9210 |
|
| 9211 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 9212 |
sugared type. Given |
| 9213 |
class X {}; |
| 9214 |
typedef X Y; |
| 9215 |
Y y; |
| 9216 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 9217 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 9218 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 9219 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 9220 |
recordType(hasDeclaration(decl()))))) |
| 9221 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 9222 |
|
| 9223 |
Usable 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>>, |
| 9224 |
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>>, |
| 9225 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 9226 |
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<RecordType>, |
| 9227 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 9228 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 9229 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 9230 |
</pre></td></tr> |
| 9231 |
|
| 9232 |
|
| 9233 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>></td><td class="name" onclick="toggle('capturesVar0')"><a name="capturesVar0Anchor">capturesVar</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>> InnerMatcher</td></tr> |
| 9234 |
<tr><td colspan="4" class="doc" id="capturesVar0"><pre>Matches a `LambdaCapture` that refers to the specified `VarDecl`. The |
| 9235 |
`VarDecl` can be a separate variable that is captured by value or |
| 9236 |
reference, or a synthesized variable if the capture has an initializer. |
| 9237 |
|
| 9238 |
Given |
| 9239 |
void foo() { |
| 9240 |
int x; |
| 9241 |
auto f = [x](){}; |
| 9242 |
auto g = [x = 1](){}; |
| 9243 |
} |
| 9244 |
In the matcher |
| 9245 |
lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(hasName("x")))), |
| 9246 |
capturesVar(hasName("x")) matches `x` and `x = 1`. |
| 9247 |
</pre></td></tr> |
| 9248 |
|
| 9249 |
|
| 9250 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>></td><td class="name" onclick="toggle('forEachLambdaCapture0')"><a name="forEachLambdaCapture0Anchor">forEachLambdaCapture</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>> InnerMatcher</td></tr> |
| 9251 |
<tr><td colspan="4" class="doc" id="forEachLambdaCapture0"><pre>Matches each lambda capture in a lambda expression. |
| 9252 |
|
| 9253 |
Given |
| 9254 |
int main() { |
| 9255 |
int x, y; |
| 9256 |
float z; |
| 9257 |
auto f = [=]() { return x + y + z; }; |
| 9258 |
} |
| 9259 |
lambdaExpr(forEachLambdaCapture( |
| 9260 |
lambdaCapture(capturesVar(varDecl(hasType(isInteger())))))) |
| 9261 |
will trigger two matches, binding for 'x' and 'y' respectively. |
| 9262 |
</pre></td></tr> |
| 9263 |
|
| 9264 |
|
| 9265 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>></td><td class="name" onclick="toggle('hasAnyCapture0')"><a name="hasAnyCapture0Anchor">hasAnyCapture</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>> InnerMatcher</td></tr> |
| 9266 |
<tr><td colspan="4" class="doc" id="hasAnyCapture0"><pre>Matches any capture in a lambda expression. |
| 9267 |
|
| 9268 |
Given |
| 9269 |
void foo() { |
| 9270 |
int t = 5; |
| 9271 |
auto f = [=](){ return t; }; |
| 9272 |
} |
| 9273 |
lambdaExpr(hasAnyCapture(lambdaCapture())) and |
| 9274 |
lambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("t"))))) |
| 9275 |
both match `[=](){ return t; }`. |
| 9276 |
</pre></td></tr> |
| 9277 |
|
| 9278 |
|
| 9279 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</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> |
| 9280 |
<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node |
| 9281 |
matches the given matcher. |
| 9282 |
|
| 9283 |
The associated declaration is: |
| 9284 |
- for type nodes, the declaration of the underlying type |
| 9285 |
- for CallExpr, the declaration of the callee |
| 9286 |
- for MemberExpr, the declaration of the referenced member |
| 9287 |
- for CXXConstructExpr, the declaration of the constructor |
| 9288 |
- for CXXNewExpr, the declaration of the operator new |
| 9289 |
- for ObjCIvarExpr, the declaration of the ivar |
| 9290 |
|
| 9291 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 9292 |
sugared type. Given |
| 9293 |
class X {}; |
| 9294 |
typedef X Y; |
| 9295 |
Y y; |
| 9296 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 9297 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 9298 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 9299 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 9300 |
recordType(hasDeclaration(decl()))))) |
| 9301 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 9302 |
|
| 9303 |
Usable 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>>, |
| 9304 |
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>>, |
| 9305 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 9306 |
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<RecordType>, |
| 9307 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 9308 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 9309 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 9310 |
</pre></td></tr> |
| 9311 |
|
| 9312 |
|
| 9313 |
<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> |
| 9314 |
<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is matched by a |
| 9315 |
given matcher. Implicit object expressions are included; that is, it matches |
| 9316 |
use of implicit `this`. |
| 9317 |
|
| 9318 |
Given |
| 9319 |
struct X { |
| 9320 |
int m; |
| 9321 |
int f(X x) { x.m; return m; } |
| 9322 |
}; |
| 9323 |
memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) |
| 9324 |
matches `x.m`, but not `m`; however, |
| 9325 |
memberExpr(hasObjectExpression(hasType(pointsTo( |
| 9326 |
cxxRecordDecl(hasName("X")))))) |
| 9327 |
matches `m` (aka. `this->m`), but not `x.m`. |
| 9328 |
</pre></td></tr> |
| 9329 |
|
| 9330 |
|
| 9331 |
<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> |
| 9332 |
<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a |
| 9333 |
given matcher. |
| 9334 |
|
| 9335 |
Given |
| 9336 |
struct { int first, second; } first, second; |
| 9337 |
int i(second.first); |
| 9338 |
int j(first.second); |
| 9339 |
memberExpr(member(hasName("first"))) |
| 9340 |
matches second.first |
| 9341 |
but not first.second (because the member name there is "second"). |
| 9342 |
</pre></td></tr> |
| 9343 |
|
| 9344 |
|
| 9345 |
<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> |
| 9346 |
<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the |
| 9347 |
pointee matches a given matcher. |
| 9348 |
|
| 9349 |
Given |
| 9350 |
int *a; |
| 9351 |
int const *b; |
| 9352 |
float const *f; |
| 9353 |
pointerType(pointee(isConstQualified(), isInteger())) |
| 9354 |
matches "int const *b" |
| 9355 |
|
| 9356 |
Usable 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>>, |
| 9357 |
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>>, |
| 9358 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>> |
| 9359 |
</pre></td></tr> |
| 9360 |
|
| 9361 |
|
| 9362 |
<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> |
| 9363 |
<tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given |
| 9364 |
matcher. |
| 9365 |
|
| 9366 |
Given |
| 9367 |
namespace N { template<class T> void f(T t); } |
| 9368 |
template <class T> void g() { using N::f; f(T()); } |
| 9369 |
unresolvedLookupExpr(hasAnyDeclaration( |
| 9370 |
namedDecl(hasUnderlyingDecl(hasName("::N::f"))))) |
| 9371 |
matches the use of f in g() . |
| 9372 |
</pre></td></tr> |
| 9373 |
|
| 9374 |
|
| 9375 |
<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> |
| 9376 |
<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. |
| 9377 |
|
| 9378 |
Given |
| 9379 |
struct A { struct B { struct C {}; }; }; |
| 9380 |
A::B::C c; |
| 9381 |
nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) |
| 9382 |
matches "A::" |
| 9383 |
</pre></td></tr> |
| 9384 |
|
| 9385 |
|
| 9386 |
<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> |
| 9387 |
<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner |
| 9388 |
NestedNameSpecifier-matcher matches. |
| 9389 |
</pre></td></tr> |
| 9390 |
|
| 9391 |
|
| 9392 |
<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> |
| 9393 |
<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the |
| 9394 |
given TypeLoc. |
| 9395 |
|
| 9396 |
Given |
| 9397 |
struct A { struct B { struct C {}; }; }; |
| 9398 |
A::B::C c; |
| 9399 |
nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( |
| 9400 |
hasDeclaration(cxxRecordDecl(hasName("A"))))))) |
| 9401 |
matches "A::" |
| 9402 |
</pre></td></tr> |
| 9403 |
|
| 9404 |
|
| 9405 |
<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> |
| 9406 |
<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. |
| 9407 |
|
| 9408 |
Given |
| 9409 |
struct A { struct B { struct C {}; }; }; |
| 9410 |
A::B::C c; |
| 9411 |
nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and |
| 9412 |
matches "A::" |
| 9413 |
</pre></td></tr> |
| 9414 |
|
| 9415 |
|
| 9416 |
<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> |
| 9417 |
<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the |
| 9418 |
given namespace matcher. |
| 9419 |
|
| 9420 |
Given |
| 9421 |
namespace ns { struct A {}; } |
| 9422 |
ns::A a; |
| 9423 |
nestedNameSpecifier(specifiesNamespace(hasName("ns"))) |
| 9424 |
matches "ns::" |
| 9425 |
</pre></td></tr> |
| 9426 |
|
| 9427 |
|
| 9428 |
<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> |
| 9429 |
<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the |
| 9430 |
given QualType matcher without qualifiers. |
| 9431 |
|
| 9432 |
Given |
| 9433 |
struct A { struct B { struct C {}; }; }; |
| 9434 |
A::B::C c; |
| 9435 |
nestedNameSpecifier(specifiesType( |
| 9436 |
hasDeclaration(cxxRecordDecl(hasName("A"))) |
| 9437 |
)) |
| 9438 |
matches "A::" |
| 9439 |
</pre></td></tr> |
| 9440 |
|
| 9441 |
|
| 9442 |
<tr><td>Matcher<OMPExecutableDirective></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> |
| 9443 |
<tr><td colspan="4" class="doc" id="hasAnyClause0"><pre>Matches any clause in an OpenMP directive. |
| 9444 |
|
| 9445 |
Given |
| 9446 |
|
| 9447 |
#pragma omp parallel |
| 9448 |
#pragma omp parallel default(none) |
| 9449 |
|
| 9450 |
``ompExecutableDirective(hasAnyClause(anything()))`` matches |
| 9451 |
``omp parallel default(none)``. |
| 9452 |
</pre></td></tr> |
| 9453 |
|
| 9454 |
|
| 9455 |
<tr><td>Matcher<OMPExecutableDirective></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> |
| 9456 |
<tr><td colspan="4" class="doc" id="hasStructuredBlock0"><pre>Matches the structured-block of the OpenMP executable directive |
| 9457 |
|
| 9458 |
Prerequisite: the executable directive must not be standalone directive. |
| 9459 |
If it is, it will never match. |
| 9460 |
|
| 9461 |
Given |
| 9462 |
|
| 9463 |
#pragma omp parallel |
| 9464 |
; |
| 9465 |
#pragma omp parallel |
| 9466 |
{} |
| 9467 |
|
| 9468 |
``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;`` |
| 9469 |
</pre></td></tr> |
| 9470 |
|
| 9471 |
|
| 9472 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>></td><td class="name" onclick="toggle('hasType9')"><a name="hasType9Anchor">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 9473 |
<tr><td colspan="4" class="doc" id="hasType9"><pre>Overloaded to match the declaration of the expression's or value |
| 9474 |
declaration's type. |
| 9475 |
|
| 9476 |
In case of a value declaration (for example a variable declaration), |
| 9477 |
this resolves one layer of indirection. For example, in the value |
| 9478 |
declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 9479 |
X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 9480 |
declaration of x. |
| 9481 |
|
| 9482 |
Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 9483 |
and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 9484 |
and friend class X (matcher = friendDecl(hasType("X")) |
| 9485 |
and public virtual X (matcher = cxxBaseSpecifier(hasType( |
| 9486 |
cxxRecordDecl(hasName("X")))) |
| 9487 |
class X {}; |
| 9488 |
void y(X &x) { x; X z; } |
| 9489 |
class Y { friend class X; }; |
| 9490 |
class Z : public virtual X {}; |
| 9491 |
|
| 9492 |
Example matches class Derived |
| 9493 |
(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) |
| 9494 |
class Base {}; |
| 9495 |
class Derived : Base {}; |
| 9496 |
|
| 9497 |
Usable 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>>, |
| 9498 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> |
| 9499 |
</pre></td></tr> |
| 9500 |
|
| 9501 |
|
| 9502 |
<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> |
| 9503 |
<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Matches C++ classes that are directly or indirectly derived from a class |
| 9504 |
matching Base, or Objective-C classes that directly or indirectly |
| 9505 |
subclass a class matching Base. |
| 9506 |
|
| 9507 |
Note that a class is not considered to be derived from itself. |
| 9508 |
|
| 9509 |
Example matches Y, Z, C (Base == hasName("X")) |
| 9510 |
class X; |
| 9511 |
class Y : public X {}; // directly derived |
| 9512 |
class Z : public Y {}; // indirectly derived |
| 9513 |
typedef X A; |
| 9514 |
typedef A B; |
| 9515 |
class C : public B {}; // derived from a typedef of X |
| 9516 |
|
| 9517 |
In the following example, Bar matches isDerivedFrom(hasName("X")): |
| 9518 |
class Foo; |
| 9519 |
typedef Foo X; |
| 9520 |
class Bar : public Foo {}; // derived from a type that X is a typedef of |
| 9521 |
|
| 9522 |
In the following example, Bar matches isDerivedFrom(hasName("NSObject")) |
| 9523 |
@interface NSObject @end |
| 9524 |
@interface Bar : NSObject @end |
| 9525 |
|
| 9526 |
Usable 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>> |
| 9527 |
</pre></td></tr> |
| 9528 |
|
| 9529 |
|
| 9530 |
<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> |
| 9531 |
<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom1"><pre>Matches C++ or Objective-C classes that are directly derived from a class |
| 9532 |
matching Base. |
| 9533 |
|
| 9534 |
Note that a class is not considered to be derived from itself. |
| 9535 |
|
| 9536 |
Example matches Y, C (Base == hasName("X")) |
| 9537 |
class X; |
| 9538 |
class Y : public X {}; // directly derived |
| 9539 |
class Z : public Y {}; // indirectly derived |
| 9540 |
typedef X A; |
| 9541 |
typedef A B; |
| 9542 |
class C : public B {}; // derived from a typedef of X |
| 9543 |
|
| 9544 |
In the following example, Bar matches isDerivedFrom(hasName("X")): |
| 9545 |
class Foo; |
| 9546 |
typedef Foo X; |
| 9547 |
class Bar : public Foo {}; // derived from a type that X is a typedef of |
| 9548 |
</pre></td></tr> |
| 9549 |
|
| 9550 |
|
| 9551 |
<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> |
| 9552 |
<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Similar to isDerivedFrom(), but also matches classes that directly |
| 9553 |
match Base. |
| 9554 |
</pre></td></tr> |
| 9555 |
|
| 9556 |
|
| 9557 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('callee2')"><a name="callee2Anchor">callee</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 9558 |
<tr><td colspan="4" class="doc" id="callee2"><pre>Matches 1) if the call expression's callee's declaration matches the |
| 9559 |
given matcher; or 2) if the Obj-C message expression's callee's method |
| 9560 |
declaration matches the given matcher. |
| 9561 |
|
| 9562 |
Example matches y.x() (matcher = callExpr(callee( |
| 9563 |
cxxMethodDecl(hasName("x"))))) |
| 9564 |
class Y { public: void x(); }; |
| 9565 |
void z() { Y y; y.x(); } |
| 9566 |
|
| 9567 |
Example 2. Matches [I foo] with |
| 9568 |
objcMessageExpr(callee(objcMethodDecl(hasName("foo")))) |
| 9569 |
|
| 9570 |
@interface I: NSObject |
| 9571 |
+(void)foo; |
| 9572 |
@end |
| 9573 |
... |
| 9574 |
[I foo] |
| 9575 |
</pre></td></tr> |
| 9576 |
|
| 9577 |
|
| 9578 |
<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> |
| 9579 |
<tr><td colspan="4" class="doc" id="hasAnyArgument3"><pre>Matches any argument of a call expression or a constructor call |
| 9580 |
expression, or an ObjC-message-send expression. |
| 9581 |
|
| 9582 |
Given |
| 9583 |
void x(int, int, int) { int y; x(1, y, 42); } |
| 9584 |
callExpr(hasAnyArgument(declRefExpr())) |
| 9585 |
matches x(1, y, 42) |
| 9586 |
with hasAnyArgument(...) |
| 9587 |
matching y |
| 9588 |
|
| 9589 |
For ObjectiveC, given |
| 9590 |
@interface I - (void) f:(int) y; @end |
| 9591 |
void foo(I *i) { [i f:12]; } |
| 9592 |
objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) |
| 9593 |
matches [i f:12] |
| 9594 |
</pre></td></tr> |
| 9595 |
|
| 9596 |
|
| 9597 |
<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> |
| 9598 |
<tr><td colspan="4" class="doc" id="hasArgument3"><pre>Matches the n'th argument of a call expression or a constructor |
| 9599 |
call expression. |
| 9600 |
|
| 9601 |
Example matches y in x(y) |
| 9602 |
(matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 9603 |
void x(int) { int y; x(y); } |
| 9604 |
</pre></td></tr> |
| 9605 |
|
| 9606 |
|
| 9607 |
<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> |
| 9608 |
<tr><td colspan="4" class="doc" id="hasReceiver0"><pre>Matches if the Objective-C message is sent to an instance, |
| 9609 |
and the inner matcher matches on that instance. |
| 9610 |
|
| 9611 |
For example the method call in |
| 9612 |
NSString *x = @"hello"; |
| 9613 |
[x containsString:@"h"]; |
| 9614 |
is matched by |
| 9615 |
objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x")))))) |
| 9616 |
</pre></td></tr> |
| 9617 |
|
| 9618 |
|
| 9619 |
<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> |
| 9620 |
<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. |
| 9621 |
|
| 9622 |
Example |
| 9623 |
matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *"))); |
| 9624 |
matches the [webView ...] message invocation. |
| 9625 |
NSString *webViewJavaScript = ... |
| 9626 |
UIWebView *webView = ... |
| 9627 |
[webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; |
| 9628 |
</pre></td></tr> |
| 9629 |
|
| 9630 |
|
| 9631 |
<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> |
| 9632 |
<tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a |
| 9633 |
block. |
| 9634 |
|
| 9635 |
Does not match the 'this' parameter of a method. |
| 9636 |
|
| 9637 |
Given |
| 9638 |
class X { void f(int x, int y, int z) {} }; |
| 9639 |
cxxMethodDecl(hasAnyParameter(hasName("y"))) |
| 9640 |
matches f(int x, int y, int z) {} |
| 9641 |
with hasAnyParameter(...) |
| 9642 |
matching int y |
| 9643 |
|
| 9644 |
For ObjectiveC, given |
| 9645 |
@interface I - (void) f:(int) y; @end |
| 9646 |
|
| 9647 |
the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) |
| 9648 |
matches the declaration of method f with hasParameter |
| 9649 |
matching y. |
| 9650 |
|
| 9651 |
For blocks, given |
| 9652 |
b = ^(int y) { printf("%d", y) }; |
| 9653 |
|
| 9654 |
the matcher blockDecl(hasAnyParameter(hasName("y"))) |
| 9655 |
matches the declaration of the block b with hasParameter |
| 9656 |
matching y. |
| 9657 |
</pre></td></tr> |
| 9658 |
|
| 9659 |
|
| 9660 |
<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> |
| 9661 |
<tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method |
| 9662 |
declaration or a block. |
| 9663 |
|
| 9664 |
Given |
| 9665 |
class X { void f(int x) {} }; |
| 9666 |
cxxMethodDecl(hasParameter(0, hasType(varDecl()))) |
| 9667 |
matches f(int x) {} |
| 9668 |
with hasParameter(...) |
| 9669 |
matching int x |
| 9670 |
|
| 9671 |
For ObjectiveC, given |
| 9672 |
@interface I - (void) f:(int) y; @end |
| 9673 |
|
| 9674 |
the matcher objcMethodDecl(hasParameter(0, hasName("y"))) |
| 9675 |
matches the declaration of method f with hasParameter |
| 9676 |
matching y. |
| 9677 |
</pre></td></tr> |
| 9678 |
|
| 9679 |
|
| 9680 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>></td><td class="name" onclick="toggle('pointee4')"><a name="pointee4Anchor">pointee</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> |
| 9681 |
<tr><td colspan="4" class="doc" id="pointee4"><pre>Narrows PointerType (and similar) matchers to those where the |
| 9682 |
pointee matches a given matcher. |
| 9683 |
|
| 9684 |
Given |
| 9685 |
int *a; |
| 9686 |
int const *b; |
| 9687 |
float const *f; |
| 9688 |
pointerType(pointee(isConstQualified(), isInteger())) |
| 9689 |
matches "int const *b" |
| 9690 |
|
| 9691 |
Usable 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>>, |
| 9692 |
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>>, |
| 9693 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>> |
| 9694 |
</pre></td></tr> |
| 9695 |
|
| 9696 |
|
| 9697 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</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> |
| 9698 |
<tr><td colspan="4" class="doc" id="hasTypeLoc10"><pre>Matches if the type location of a node matches the inner matcher. |
| 9699 |
|
| 9700 |
Examples: |
| 9701 |
int x; |
| 9702 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 9703 |
matches int x |
| 9704 |
|
| 9705 |
auto x = int(3); |
| 9706 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 9707 |
matches int(3) |
| 9708 |
|
| 9709 |
struct Foo { Foo(int, int); }; |
| 9710 |
auto x = Foo(1, 2); |
| 9711 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 9712 |
matches Foo(1, 2) |
| 9713 |
|
| 9714 |
Usable 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>>, |
| 9715 |
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>>, |
| 9716 |
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>>, |
| 9717 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 9718 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 9719 |
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>>, |
| 9720 |
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>>, |
| 9721 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 9722 |
</pre></td></tr> |
| 9723 |
|
| 9724 |
|
| 9725 |
<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> |
| 9726 |
<tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression |
| 9727 |
or opaque value's source expression matches the given matcher. |
| 9728 |
|
| 9729 |
Example 1: matches "a string" |
| 9730 |
(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) |
| 9731 |
class URL { URL(string); }; |
| 9732 |
URL url = "a string"; |
| 9733 |
|
| 9734 |
Example 2: matches 'b' (matcher = |
| 9735 |
opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) |
| 9736 |
int a = b ?: 1; |
| 9737 |
</pre></td></tr> |
| 9738 |
|
| 9739 |
|
| 9740 |
<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> |
| 9741 |
<tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of |
| 9742 |
overloads matches the given matcher. |
| 9743 |
|
| 9744 |
Given |
| 9745 |
template <typename T> void foo(T); |
| 9746 |
template <typename T> void bar(T); |
| 9747 |
template <typename T> void baz(T t) { |
| 9748 |
foo(t); |
| 9749 |
bar(t); |
| 9750 |
} |
| 9751 |
unresolvedLookupExpr(hasAnyDeclaration( |
| 9752 |
functionTemplateDecl(hasName("foo")))) |
| 9753 |
matches foo in foo(t); but not bar in bar(t); |
| 9754 |
</pre></td></tr> |
| 9755 |
|
| 9756 |
|
| 9757 |
<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> |
| 9758 |
<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. |
| 9759 |
|
| 9760 |
Given |
| 9761 |
int (*ptr_to_array)[4]; |
| 9762 |
int (*ptr_to_func)(int); |
| 9763 |
|
| 9764 |
varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches |
| 9765 |
ptr_to_func but not ptr_to_array. |
| 9766 |
|
| 9767 |
Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> |
| 9768 |
</pre></td></tr> |
| 9769 |
|
| 9770 |
|
| 9771 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>></td><td class="name" onclick="toggle('hasPointeeLoc0')"><a name="hasPointeeLoc0Anchor">hasPointeeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> PointeeMatcher</td></tr> |
| 9772 |
<tr><td colspan="4" class="doc" id="hasPointeeLoc0"><pre>Matches pointer `TypeLoc`s that have a pointee `TypeLoc` matching |
| 9773 |
`PointeeMatcher`. |
| 9774 |
|
| 9775 |
Given |
| 9776 |
int* x; |
| 9777 |
pointerTypeLoc(hasPointeeLoc(loc(asString("int")))) |
| 9778 |
matches `int*`. |
| 9779 |
</pre></td></tr> |
| 9780 |
|
| 9781 |
|
| 9782 |
<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> |
| 9783 |
<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the |
| 9784 |
pointee matches a given matcher. |
| 9785 |
|
| 9786 |
Given |
| 9787 |
int *a; |
| 9788 |
int const *b; |
| 9789 |
float const *f; |
| 9790 |
pointerType(pointee(isConstQualified(), isInteger())) |
| 9791 |
matches "int const *b" |
| 9792 |
|
| 9793 |
Usable 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>>, |
| 9794 |
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>>, |
| 9795 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>> |
| 9796 |
</pre></td></tr> |
| 9797 |
|
| 9798 |
|
| 9799 |
<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> |
| 9800 |
<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. |
| 9801 |
|
| 9802 |
Given: |
| 9803 |
typedef int &int_ref; |
| 9804 |
int a; |
| 9805 |
int_ref b = a; |
| 9806 |
|
| 9807 |
varDecl(hasType(qualType(referenceType()))))) will not match the |
| 9808 |
declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. |
| 9809 |
</pre></td></tr> |
| 9810 |
|
| 9811 |
|
| 9812 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</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> |
| 9813 |
<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node |
| 9814 |
matches the given matcher. |
| 9815 |
|
| 9816 |
The associated declaration is: |
| 9817 |
- for type nodes, the declaration of the underlying type |
| 9818 |
- for CallExpr, the declaration of the callee |
| 9819 |
- for MemberExpr, the declaration of the referenced member |
| 9820 |
- for CXXConstructExpr, the declaration of the constructor |
| 9821 |
- for CXXNewExpr, the declaration of the operator new |
| 9822 |
- for ObjCIvarExpr, the declaration of the ivar |
| 9823 |
|
| 9824 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 9825 |
sugared type. Given |
| 9826 |
class X {}; |
| 9827 |
typedef X Y; |
| 9828 |
Y y; |
| 9829 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 9830 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 9831 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 9832 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 9833 |
recordType(hasDeclaration(decl()))))) |
| 9834 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 9835 |
|
| 9836 |
Usable 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>>, |
| 9837 |
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>>, |
| 9838 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 9839 |
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<RecordType>, |
| 9840 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 9841 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 9842 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 9843 |
</pre></td></tr> |
| 9844 |
|
| 9845 |
|
| 9846 |
<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> |
| 9847 |
<tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped. |
| 9848 |
|
| 9849 |
Given |
| 9850 |
void (*fp)(void); |
| 9851 |
The matcher |
| 9852 |
varDecl(hasType(pointerType(pointee(ignoringParens(functionType()))))) |
| 9853 |
would match the declaration for fp. |
| 9854 |
</pre></td></tr> |
| 9855 |
|
| 9856 |
|
| 9857 |
<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> |
| 9858 |
<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. |
| 9859 |
</pre></td></tr> |
| 9860 |
|
| 9861 |
|
| 9862 |
<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> |
| 9863 |
<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type |
| 9864 |
matches the specified matcher. |
| 9865 |
|
| 9866 |
Example matches y->x() |
| 9867 |
(matcher = cxxMemberCallExpr(on(hasType(pointsTo |
| 9868 |
cxxRecordDecl(hasName("Y"))))))) |
| 9869 |
class Y { public: void x(); }; |
| 9870 |
void z() { Y *y; y->x(); } |
| 9871 |
</pre></td></tr> |
| 9872 |
|
| 9873 |
|
| 9874 |
<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> |
| 9875 |
<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. |
| 9876 |
</pre></td></tr> |
| 9877 |
|
| 9878 |
|
| 9879 |
<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> |
| 9880 |
<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced |
| 9881 |
type matches the specified matcher. |
| 9882 |
|
| 9883 |
Example matches X &x and const X &y |
| 9884 |
(matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) |
| 9885 |
class X { |
| 9886 |
void a(X b) { |
| 9887 |
X &x = b; |
| 9888 |
const X &y = b; |
| 9889 |
} |
| 9890 |
}; |
| 9891 |
</pre></td></tr> |
| 9892 |
|
| 9893 |
|
| 9894 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualifiedTypeLoc.html">QualifiedTypeLoc</a>></td><td class="name" onclick="toggle('hasUnqualifiedLoc0')"><a name="hasUnqualifiedLoc0Anchor">hasUnqualifiedLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> InnerMatcher</td></tr> |
| 9895 |
<tr><td colspan="4" class="doc" id="hasUnqualifiedLoc0"><pre>Matches `QualifiedTypeLoc`s that have an unqualified `TypeLoc` matching |
| 9896 |
`InnerMatcher`. |
| 9897 |
|
| 9898 |
Given |
| 9899 |
int* const x; |
| 9900 |
const int y; |
| 9901 |
qualifiedTypeLoc(hasUnqualifiedLoc(pointerTypeLoc())) |
| 9902 |
matches the `TypeLoc` of the variable declaration of `x`, but not `y`. |
| 9903 |
</pre></td></tr> |
| 9904 |
|
| 9905 |
|
| 9906 |
<tr><td>Matcher<RecordType></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> |
| 9907 |
<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node |
| 9908 |
matches the given matcher. |
| 9909 |
|
| 9910 |
The associated declaration is: |
| 9911 |
- for type nodes, the declaration of the underlying type |
| 9912 |
- for CallExpr, the declaration of the callee |
| 9913 |
- for MemberExpr, the declaration of the referenced member |
| 9914 |
- for CXXConstructExpr, the declaration of the constructor |
| 9915 |
- for CXXNewExpr, the declaration of the operator new |
| 9916 |
- for ObjCIvarExpr, the declaration of the ivar |
| 9917 |
|
| 9918 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 9919 |
sugared type. Given |
| 9920 |
class X {}; |
| 9921 |
typedef X Y; |
| 9922 |
Y y; |
| 9923 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 9924 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 9925 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 9926 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 9927 |
recordType(hasDeclaration(decl()))))) |
| 9928 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 9929 |
|
| 9930 |
Usable 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>>, |
| 9931 |
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>>, |
| 9932 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 9933 |
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<RecordType>, |
| 9934 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 9935 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 9936 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 9937 |
</pre></td></tr> |
| 9938 |
|
| 9939 |
|
| 9940 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>></td><td class="name" onclick="toggle('hasReferentLoc0')"><a name="hasReferentLoc0Anchor">hasReferentLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> ReferentMatcher</td></tr> |
| 9941 |
<tr><td colspan="4" class="doc" id="hasReferentLoc0"><pre>Matches reference `TypeLoc`s that have a referent `TypeLoc` matching |
| 9942 |
`ReferentMatcher`. |
| 9943 |
|
| 9944 |
Given |
| 9945 |
int x = 3; |
| 9946 |
int& xx = x; |
| 9947 |
referenceTypeLoc(hasReferentLoc(loc(asString("int")))) |
| 9948 |
matches `int&`. |
| 9949 |
</pre></td></tr> |
| 9950 |
|
| 9951 |
|
| 9952 |
<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> |
| 9953 |
<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the |
| 9954 |
pointee matches a given matcher. |
| 9955 |
|
| 9956 |
Given |
| 9957 |
int *a; |
| 9958 |
int const *b; |
| 9959 |
float const *f; |
| 9960 |
pointerType(pointee(isConstQualified(), isInteger())) |
| 9961 |
matches "int const *b" |
| 9962 |
|
| 9963 |
Usable 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>>, |
| 9964 |
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>>, |
| 9965 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>> |
| 9966 |
</pre></td></tr> |
| 9967 |
|
| 9968 |
|
| 9969 |
<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> |
| 9970 |
<tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement |
| 9971 |
|
| 9972 |
Given |
| 9973 |
return a + b; |
| 9974 |
hasReturnValue(binaryOperator()) |
| 9975 |
matches 'return a + b' |
| 9976 |
with binaryOperator() |
| 9977 |
matching 'a + b' |
| 9978 |
</pre></td></tr> |
| 9979 |
|
| 9980 |
|
| 9981 |
<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> |
| 9982 |
<tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches |
| 9983 |
a given matcher. Also matches StmtExprs that have CompoundStmt as children. |
| 9984 |
|
| 9985 |
Given |
| 9986 |
{ {}; 1+2; } |
| 9987 |
hasAnySubstatement(compoundStmt()) |
| 9988 |
matches '{ {}; 1+2; }' |
| 9989 |
with compoundStmt() |
| 9990 |
matching '{}' |
| 9991 |
</pre></td></tr> |
| 9992 |
|
| 9993 |
|
| 9994 |
<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> |
| 9995 |
<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 9996 |
alignof. |
| 9997 |
</pre></td></tr> |
| 9998 |
|
| 9999 |
|
| 10000 |
<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> |
| 10001 |
<tr><td colspan="4" class="doc" id="forCallable0"><pre>Matches declaration of the function, method, or block the statement |
| 10002 |
belongs to. |
| 10003 |
|
| 10004 |
Given: |
| 10005 |
F& operator=(const F& o) { |
| 10006 |
std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); |
| 10007 |
return *this; |
| 10008 |
} |
| 10009 |
returnStmt(forCallable(functionDecl(hasName("operator=")))) |
| 10010 |
matches 'return *this' |
| 10011 |
but does not match 'return v > 0' |
| 10012 |
|
| 10013 |
Given: |
| 10014 |
-(void) foo { |
| 10015 |
int x = 1; |
| 10016 |
dispatch_sync(queue, ^{ int y = 2; }); |
| 10017 |
} |
| 10018 |
declStmt(forCallable(objcMethodDecl())) |
| 10019 |
matches 'int x = 1' |
| 10020 |
but does not match 'int y = 2'. |
| 10021 |
whereas declStmt(forCallable(blockDecl())) |
| 10022 |
matches 'int y = 2' |
| 10023 |
but does not match 'int x = 1'. |
| 10024 |
</pre></td></tr> |
| 10025 |
|
| 10026 |
|
| 10027 |
<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> |
| 10028 |
<tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to. |
| 10029 |
|
| 10030 |
Deprecated. Use forCallable() to correctly handle the situation when |
| 10031 |
the declaration is not a function (but a block or an Objective-C method). |
| 10032 |
forFunction() not only fails to take non-functions into account but also |
| 10033 |
may match the wrong declaration in their presence. |
| 10034 |
|
| 10035 |
Given: |
| 10036 |
F& operator=(const F& o) { |
| 10037 |
std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); |
| 10038 |
return *this; |
| 10039 |
} |
| 10040 |
returnStmt(forFunction(hasName("operator="))) |
| 10041 |
matches 'return *this' |
| 10042 |
but does not match 'return v > 0' |
| 10043 |
</pre></td></tr> |
| 10044 |
|
| 10045 |
|
| 10046 |
<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> |
| 10047 |
<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 10048 |
sizeof. |
| 10049 |
</pre></td></tr> |
| 10050 |
|
| 10051 |
|
| 10052 |
<tr><td>Matcher<SubstTemplateTypeParmType></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> |
| 10053 |
<tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement |
| 10054 |
type that matches the provided matcher. |
| 10055 |
|
| 10056 |
Given |
| 10057 |
template <typename T> |
| 10058 |
double F(T t); |
| 10059 |
int i; |
| 10060 |
double j = F(i); |
| 10061 |
|
| 10062 |
substTemplateTypeParmType(hasReplacementType(type())) matches int |
| 10063 |
</pre></td></tr> |
| 10064 |
|
| 10065 |
|
| 10066 |
<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> |
| 10067 |
<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch |
| 10068 |
statement. This matcher may produce multiple matches. |
| 10069 |
|
| 10070 |
Given |
| 10071 |
switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } |
| 10072 |
switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") |
| 10073 |
matches four times, with "c" binding each of "case 1:", "case 2:", |
| 10074 |
"case 3:" and "case 4:", and "s" respectively binding "switch (1)", |
| 10075 |
"switch (1)", "switch (2)" and "switch (2)". |
| 10076 |
</pre></td></tr> |
| 10077 |
|
| 10078 |
|
| 10079 |
<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> |
| 10080 |
<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, while loop, |
| 10081 |
do-while loop, switch statement or conditional operator. |
| 10082 |
|
| 10083 |
Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 10084 |
if (true) {} |
| 10085 |
</pre></td></tr> |
| 10086 |
|
| 10087 |
|
| 10088 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>></td><td class="name" onclick="toggle('hasConditionVariableStatement3')"><a name="hasConditionVariableStatement3Anchor">hasConditionVariableStatement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>> InnerMatcher</td></tr> |
| 10089 |
<tr><td colspan="4" class="doc" id="hasConditionVariableStatement3"><pre>Matches the condition variable statement in an if statement, for loop, |
| 10090 |
while loop or switch statement. |
| 10091 |
|
| 10092 |
Given |
| 10093 |
if (A* a = GetAPointer()) {} |
| 10094 |
for (; A* a = GetAPointer(); ) {} |
| 10095 |
hasConditionVariableStatement(...) |
| 10096 |
matches both 'A* a = GetAPointer()'. |
| 10097 |
</pre></td></tr> |
| 10098 |
|
| 10099 |
|
| 10100 |
<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> |
| 10101 |
<tr><td colspan="4" class="doc" id="hasInitStatement1"><pre>Matches selection statements with initializer. |
| 10102 |
|
| 10103 |
Given: |
| 10104 |
void foo() { |
| 10105 |
if (int i = foobar(); i > 0) {} |
| 10106 |
switch (int i = foobar(); i) {} |
| 10107 |
for (auto& a = get_range(); auto& x : a) {} |
| 10108 |
} |
| 10109 |
void bar() { |
| 10110 |
if (foobar() > 0) {} |
| 10111 |
switch (foobar()) {} |
| 10112 |
for (auto& x : get_range()) {} |
| 10113 |
} |
| 10114 |
ifStmt(hasInitStatement(anything())) |
| 10115 |
matches the if statement in foo but not in bar. |
| 10116 |
switchStmt(hasInitStatement(anything())) |
| 10117 |
matches the switch statement in foo but not in bar. |
| 10118 |
cxxForRangeStmt(hasInitStatement(anything())) |
| 10119 |
matches the range for statement in foo but not in bar. |
| 10120 |
</pre></td></tr> |
| 10121 |
|
| 10122 |
|
| 10123 |
<tr><td>Matcher<TagType></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> |
| 10124 |
<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node |
| 10125 |
matches the given matcher. |
| 10126 |
|
| 10127 |
The associated declaration is: |
| 10128 |
- for type nodes, the declaration of the underlying type |
| 10129 |
- for CallExpr, the declaration of the callee |
| 10130 |
- for MemberExpr, the declaration of the referenced member |
| 10131 |
- for CXXConstructExpr, the declaration of the constructor |
| 10132 |
- for CXXNewExpr, the declaration of the operator new |
| 10133 |
- for ObjCIvarExpr, the declaration of the ivar |
| 10134 |
|
| 10135 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 10136 |
sugared type. Given |
| 10137 |
class X {}; |
| 10138 |
typedef X Y; |
| 10139 |
Y y; |
| 10140 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 10141 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 10142 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 10143 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 10144 |
recordType(hasDeclaration(decl()))))) |
| 10145 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 10146 |
|
| 10147 |
Usable 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>>, |
| 10148 |
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>>, |
| 10149 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 10150 |
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<RecordType>, |
| 10151 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 10152 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 10153 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 10154 |
</pre></td></tr> |
| 10155 |
|
| 10156 |
|
| 10157 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</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> |
| 10158 |
<tr><td colspan="4" class="doc" id="hasTypeLoc11"><pre>Matches if the type location of a node matches the inner matcher. |
| 10159 |
|
| 10160 |
Examples: |
| 10161 |
int x; |
| 10162 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 10163 |
matches int x |
| 10164 |
|
| 10165 |
auto x = int(3); |
| 10166 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 10167 |
matches int(3) |
| 10168 |
|
| 10169 |
struct Foo { Foo(int, int); }; |
| 10170 |
auto x = Foo(1, 2); |
| 10171 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 10172 |
matches Foo(1, 2) |
| 10173 |
|
| 10174 |
Usable 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>>, |
| 10175 |
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>>, |
| 10176 |
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>>, |
| 10177 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 10178 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 10179 |
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>>, |
| 10180 |
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>>, |
| 10181 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 10182 |
</pre></td></tr> |
| 10183 |
|
| 10184 |
|
| 10185 |
<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> |
| 10186 |
<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. |
| 10187 |
|
| 10188 |
Given |
| 10189 |
struct B { int next; }; |
| 10190 |
template<int(B::*next_ptr)> struct A {}; |
| 10191 |
A<&B::next> a; |
| 10192 |
templateSpecializationType(hasAnyTemplateArgument( |
| 10193 |
isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) |
| 10194 |
matches the specialization A<&B::next> with fieldDecl(...) matching |
| 10195 |
B::next |
| 10196 |
</pre></td></tr> |
| 10197 |
|
| 10198 |
|
| 10199 |
<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> |
| 10200 |
<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain |
| 10201 |
declaration. |
| 10202 |
|
| 10203 |
Given |
| 10204 |
struct B { int next; }; |
| 10205 |
template<int(B::*next_ptr)> struct A {}; |
| 10206 |
A<&B::next> a; |
| 10207 |
classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 10208 |
refersToDeclaration(fieldDecl(hasName("next"))))) |
| 10209 |
matches the specialization A<&B::next> with fieldDecl(...) matching |
| 10210 |
B::next |
| 10211 |
</pre></td></tr> |
| 10212 |
|
| 10213 |
|
| 10214 |
<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> |
| 10215 |
<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that refers to an integral type. |
| 10216 |
|
| 10217 |
Given |
| 10218 |
template<int T> struct C {}; |
| 10219 |
C<42> c; |
| 10220 |
classTemplateSpecializationDecl( |
| 10221 |
hasAnyTemplateArgument(refersToIntegralType(asString("int")))) |
| 10222 |
matches the implicit instantiation of C in C<42>. |
| 10223 |
</pre></td></tr> |
| 10224 |
|
| 10225 |
|
| 10226 |
<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> |
| 10227 |
<tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template. |
| 10228 |
|
| 10229 |
Given |
| 10230 |
template<template <typename> class S> class X {}; |
| 10231 |
template<typename T> class Y {}; |
| 10232 |
X<Y> xi; |
| 10233 |
classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 10234 |
refersToTemplate(templateName()))) |
| 10235 |
matches the specialization X<Y> |
| 10236 |
</pre></td></tr> |
| 10237 |
|
| 10238 |
|
| 10239 |
<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> |
| 10240 |
<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. |
| 10241 |
|
| 10242 |
Given |
| 10243 |
struct X {}; |
| 10244 |
template<typename T> struct A {}; |
| 10245 |
A<X> a; |
| 10246 |
classTemplateSpecializationDecl(hasAnyTemplateArgument(refersToType( |
| 10247 |
recordType(hasDeclaration(recordDecl(hasName("X"))))))) |
| 10248 |
matches the specialization of struct A generated by A<X>. |
| 10249 |
</pre></td></tr> |
| 10250 |
|
| 10251 |
|
| 10252 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgumentLoc4')"><a name="hasAnyTemplateArgumentLoc4Anchor">hasAnyTemplateArgumentLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> |
| 10253 |
<tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc4"><pre>Matches template specialization `TypeLoc`s, class template specializations, |
| 10254 |
variable template specializations, and function template specializations |
| 10255 |
that have at least one `TemplateArgumentLoc` matching the given |
| 10256 |
`InnerMatcher`. |
| 10257 |
|
| 10258 |
Given |
| 10259 |
template<typename T> class A {}; |
| 10260 |
A<int> a; |
| 10261 |
varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc( |
| 10262 |
hasTypeLoc(loc(asString("int"))))))) |
| 10263 |
matches `A<int> a`. |
| 10264 |
</pre></td></tr> |
| 10265 |
|
| 10266 |
|
| 10267 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>></td><td class="name" onclick="toggle('hasTemplateArgumentLoc4')"><a name="hasTemplateArgumentLoc4Anchor">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> |
| 10268 |
<tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc4"><pre>Matches template specialization `TypeLoc`s, class template specializations, |
| 10269 |
variable template specializations, and function template specializations |
| 10270 |
where the n'th `TemplateArgumentLoc` matches the given `InnerMatcher`. |
| 10271 |
|
| 10272 |
Given |
| 10273 |
template<typename T, typename U> class A {}; |
| 10274 |
A<double, int> b; |
| 10275 |
A<int, double> c; |
| 10276 |
varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0, |
| 10277 |
hasTypeLoc(loc(asString("double"))))))) |
| 10278 |
matches `A<double, int> b`, but not `A<int, double> c`. |
| 10279 |
</pre></td></tr> |
| 10280 |
|
| 10281 |
|
| 10282 |
<tr><td>Matcher<TemplateSpecializationType></td><td class="name" onclick="toggle('forEachTemplateArgument3')"><a name="forEachTemplateArgument3Anchor">forEachTemplateArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> |
| 10283 |
<tr><td colspan="4" class="doc" id="forEachTemplateArgument3"><pre>Matches templateSpecializationType, class template specialization, |
| 10284 |
variable template specialization, and function template specialization |
| 10285 |
nodes where the template argument matches the inner matcher. This matcher |
| 10286 |
may produce multiple matches. |
| 10287 |
|
| 10288 |
Given |
| 10289 |
template <typename T, unsigned N, unsigned M> |
| 10290 |
struct Matrix {}; |
| 10291 |
|
| 10292 |
constexpr unsigned R = 2; |
| 10293 |
Matrix<int, R * 2, R * 4> M; |
| 10294 |
|
| 10295 |
template <typename T, typename U> |
| 10296 |
void f(T&& t, U&& u) {} |
| 10297 |
|
| 10298 |
bool B = false; |
| 10299 |
f(R, B); |
| 10300 |
templateSpecializationType(forEachTemplateArgument(isExpr(expr()))) |
| 10301 |
matches twice, with expr() matching 'R * 2' and 'R * 4' |
| 10302 |
functionDecl(forEachTemplateArgument(refersToType(builtinType()))) |
| 10303 |
matches the specialization f<unsigned, bool> twice, for 'unsigned' |
| 10304 |
and 'bool' |
| 10305 |
</pre></td></tr> |
| 10306 |
|
| 10307 |
|
| 10308 |
<tr><td>Matcher<TemplateSpecializationType></td><td class="name" onclick="toggle('hasAnyTemplateArgument3')"><a name="hasAnyTemplateArgument3Anchor">hasAnyTemplateArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> |
| 10309 |
<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument3"><pre>Matches templateSpecializationTypes, class template specializations, |
| 10310 |
variable template specializations, and function template specializations |
| 10311 |
that have at least one TemplateArgument matching the given InnerMatcher. |
| 10312 |
|
| 10313 |
Given |
| 10314 |
template<typename T> class A {}; |
| 10315 |
template<> class A<double> {}; |
| 10316 |
A<int> a; |
| 10317 |
|
| 10318 |
template<typename T> f() {}; |
| 10319 |
void func() { f<int>(); }; |
| 10320 |
|
| 10321 |
classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 10322 |
refersToType(asString("int")))) |
| 10323 |
matches the specialization A<int> |
| 10324 |
|
| 10325 |
functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) |
| 10326 |
matches the specialization f<int> |
| 10327 |
</pre></td></tr> |
| 10328 |
|
| 10329 |
|
| 10330 |
<tr><td>Matcher<TemplateSpecializationType></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> |
| 10331 |
<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node |
| 10332 |
matches the given matcher. |
| 10333 |
|
| 10334 |
The associated declaration is: |
| 10335 |
- for type nodes, the declaration of the underlying type |
| 10336 |
- for CallExpr, the declaration of the callee |
| 10337 |
- for MemberExpr, the declaration of the referenced member |
| 10338 |
- for CXXConstructExpr, the declaration of the constructor |
| 10339 |
- for CXXNewExpr, the declaration of the operator new |
| 10340 |
- for ObjCIvarExpr, the declaration of the ivar |
| 10341 |
|
| 10342 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 10343 |
sugared type. Given |
| 10344 |
class X {}; |
| 10345 |
typedef X Y; |
| 10346 |
Y y; |
| 10347 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 10348 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 10349 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 10350 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 10351 |
recordType(hasDeclaration(decl()))))) |
| 10352 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 10353 |
|
| 10354 |
Usable 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>>, |
| 10355 |
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>>, |
| 10356 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 10357 |
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<RecordType>, |
| 10358 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 10359 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 10360 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 10361 |
</pre></td></tr> |
| 10362 |
|
| 10363 |
|
| 10364 |
<tr><td>Matcher<TemplateSpecializationType></td><td class="name" onclick="toggle('hasTemplateArgument3')"><a name="hasTemplateArgument3Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> |
| 10365 |
<tr><td colspan="4" class="doc" id="hasTemplateArgument3"><pre>Matches templateSpecializationType, class template specializations, |
| 10366 |
variable template specializations, and function template specializations |
| 10367 |
where the n'th TemplateArgument matches the given InnerMatcher. |
| 10368 |
|
| 10369 |
Given |
| 10370 |
template<typename T, typename U> class A {}; |
| 10371 |
A<bool, int> b; |
| 10372 |
A<int, bool> c; |
| 10373 |
|
| 10374 |
template<typename T> void f() {} |
| 10375 |
void func() { f<int>(); }; |
| 10376 |
classTemplateSpecializationDecl(hasTemplateArgument( |
| 10377 |
1, refersToType(asString("int")))) |
| 10378 |
matches the specialization A<bool, int> |
| 10379 |
|
| 10380 |
functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) |
| 10381 |
matches the specialization f<int> |
| 10382 |
</pre></td></tr> |
| 10383 |
|
| 10384 |
|
| 10385 |
<tr><td>Matcher<TemplateTypeParmType></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> |
| 10386 |
<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node |
| 10387 |
matches the given matcher. |
| 10388 |
|
| 10389 |
The associated declaration is: |
| 10390 |
- for type nodes, the declaration of the underlying type |
| 10391 |
- for CallExpr, the declaration of the callee |
| 10392 |
- for MemberExpr, the declaration of the referenced member |
| 10393 |
- for CXXConstructExpr, the declaration of the constructor |
| 10394 |
- for CXXNewExpr, the declaration of the operator new |
| 10395 |
- for ObjCIvarExpr, the declaration of the ivar |
| 10396 |
|
| 10397 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 10398 |
sugared type. Given |
| 10399 |
class X {}; |
| 10400 |
typedef X Y; |
| 10401 |
Y y; |
| 10402 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 10403 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 10404 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 10405 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 10406 |
recordType(hasDeclaration(decl()))))) |
| 10407 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 10408 |
|
| 10409 |
Usable 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>>, |
| 10410 |
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>>, |
| 10411 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 10412 |
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<RecordType>, |
| 10413 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 10414 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 10415 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 10416 |
</pre></td></tr> |
| 10417 |
|
| 10418 |
|
| 10419 |
<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> |
| 10420 |
<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner |
| 10421 |
QualType-matcher matches. |
| 10422 |
</pre></td></tr> |
| 10423 |
|
| 10424 |
|
| 10425 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</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> |
| 10426 |
<tr><td colspan="4" class="doc" id="hasTypeLoc12"><pre>Matches if the type location of a node matches the inner matcher. |
| 10427 |
|
| 10428 |
Examples: |
| 10429 |
int x; |
| 10430 |
declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 10431 |
matches int x |
| 10432 |
|
| 10433 |
auto x = int(3); |
| 10434 |
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) |
| 10435 |
matches int(3) |
| 10436 |
|
| 10437 |
struct Foo { Foo(int, int); }; |
| 10438 |
auto x = Foo(1, 2); |
| 10439 |
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo")))) |
| 10440 |
matches Foo(1, 2) |
| 10441 |
|
| 10442 |
Usable 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>>, |
| 10443 |
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>>, |
| 10444 |
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>>, |
| 10445 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>, |
| 10446 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>, |
| 10447 |
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>>, |
| 10448 |
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>>, |
| 10449 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> |
| 10450 |
</pre></td></tr> |
| 10451 |
|
| 10452 |
|
| 10453 |
<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> |
| 10454 |
<tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type |
| 10455 |
matcher. |
| 10456 |
|
| 10457 |
Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 10458 |
and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 10459 |
and U (matcher = typedefDecl(hasType(asString("int"))) |
| 10460 |
and friend class X (matcher = friendDecl(hasType("X")) |
| 10461 |
and public virtual X (matcher = cxxBaseSpecifier(hasType( |
| 10462 |
asString("class X"))) |
| 10463 |
class X {}; |
| 10464 |
void y(X &x) { x; X z; } |
| 10465 |
typedef int U; |
| 10466 |
class Y { friend class X; }; |
| 10467 |
class Z : public virtual X {}; |
| 10468 |
</pre></td></tr> |
| 10469 |
|
| 10470 |
|
| 10471 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</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> |
| 10472 |
<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node |
| 10473 |
matches the given matcher. |
| 10474 |
|
| 10475 |
The associated declaration is: |
| 10476 |
- for type nodes, the declaration of the underlying type |
| 10477 |
- for CallExpr, the declaration of the callee |
| 10478 |
- for MemberExpr, the declaration of the referenced member |
| 10479 |
- for CXXConstructExpr, the declaration of the constructor |
| 10480 |
- for CXXNewExpr, the declaration of the operator new |
| 10481 |
- for ObjCIvarExpr, the declaration of the ivar |
| 10482 |
|
| 10483 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 10484 |
sugared type. Given |
| 10485 |
class X {}; |
| 10486 |
typedef X Y; |
| 10487 |
Y y; |
| 10488 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 10489 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 10490 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 10491 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 10492 |
recordType(hasDeclaration(decl()))))) |
| 10493 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 10494 |
|
| 10495 |
Usable 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>>, |
| 10496 |
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>>, |
| 10497 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 10498 |
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<RecordType>, |
| 10499 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 10500 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 10501 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 10502 |
</pre></td></tr> |
| 10503 |
|
| 10504 |
|
| 10505 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</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> |
| 10506 |
<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches Types whose qualifier, a NestedNameSpecifier, |
| 10507 |
matches InnerMatcher if the qualifier exists. |
| 10508 |
|
| 10509 |
Given |
| 10510 |
namespace N { |
| 10511 |
namespace M { |
| 10512 |
class D {}; |
| 10513 |
} |
| 10514 |
} |
| 10515 |
N::M::D d; |
| 10516 |
|
| 10517 |
elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) |
| 10518 |
matches the type of the variable declaration of d. |
| 10519 |
</pre></td></tr> |
| 10520 |
|
| 10521 |
|
| 10522 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</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_1QualType.html">QualType</a>> Inner</td></tr> |
| 10523 |
<tr><td colspan="4" class="doc" id="hasUnderlyingType0"><pre>Matches QualType nodes to find the underlying type. |
| 10524 |
|
| 10525 |
Given |
| 10526 |
decltype(1) a = 1; |
| 10527 |
decltype(2.0) b = 2.0; |
| 10528 |
decltypeType(hasUnderlyingType(isInteger())) |
| 10529 |
matches the type of "a" |
| 10530 |
|
| 10531 |
Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> |
| 10532 |
</pre></td></tr> |
| 10533 |
|
| 10534 |
|
| 10535 |
<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> |
| 10536 |
<tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared |
| 10537 |
type of the matched node. |
| 10538 |
|
| 10539 |
For example, in: |
| 10540 |
class A {}; |
| 10541 |
using B = A; |
| 10542 |
The matcher type(hasUnqualifiedDesugaredType(recordType())) matches |
| 10543 |
both B and A. |
| 10544 |
</pre></td></tr> |
| 10545 |
|
| 10546 |
|
| 10547 |
<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> |
| 10548 |
<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. |
| 10549 |
|
| 10550 |
Given |
| 10551 |
int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); |
| 10552 |
unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) |
| 10553 |
matches sizeof(a) and alignof(c) |
| 10554 |
</pre></td></tr> |
| 10555 |
|
| 10556 |
|
| 10557 |
<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> |
| 10558 |
<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. |
| 10559 |
|
| 10560 |
Example matches true (matcher = hasUnaryOperand( |
| 10561 |
cxxBoolLiteral(equals(true)))) |
| 10562 |
!true |
| 10563 |
</pre></td></tr> |
| 10564 |
|
| 10565 |
|
| 10566 |
<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> |
| 10567 |
<tr><td colspan="4" class="doc" id="hasObjectExpression1"><pre>Matches a member expression where the object expression is matched by a |
| 10568 |
given matcher. Implicit object expressions are included; that is, it matches |
| 10569 |
use of implicit `this`. |
| 10570 |
|
| 10571 |
Given |
| 10572 |
struct X { |
| 10573 |
int m; |
| 10574 |
int f(X x) { x.m; return m; } |
| 10575 |
}; |
| 10576 |
memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) |
| 10577 |
matches `x.m`, but not `m`; however, |
| 10578 |
memberExpr(hasObjectExpression(hasType(pointsTo( |
| 10579 |
cxxRecordDecl(hasName("X")))))) |
| 10580 |
matches `m` (aka. `this->m`), but not `x.m`. |
| 10581 |
</pre></td></tr> |
| 10582 |
|
| 10583 |
|
| 10584 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</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> |
| 10585 |
<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node |
| 10586 |
matches the given matcher. |
| 10587 |
|
| 10588 |
The associated declaration is: |
| 10589 |
- for type nodes, the declaration of the underlying type |
| 10590 |
- for CallExpr, the declaration of the callee |
| 10591 |
- for MemberExpr, the declaration of the referenced member |
| 10592 |
- for CXXConstructExpr, the declaration of the constructor |
| 10593 |
- for CXXNewExpr, the declaration of the operator new |
| 10594 |
- for ObjCIvarExpr, the declaration of the ivar |
| 10595 |
|
| 10596 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 10597 |
sugared type. Given |
| 10598 |
class X {}; |
| 10599 |
typedef X Y; |
| 10600 |
Y y; |
| 10601 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 10602 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 10603 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 10604 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 10605 |
recordType(hasDeclaration(decl()))))) |
| 10606 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 10607 |
|
| 10608 |
Usable 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>>, |
| 10609 |
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>>, |
| 10610 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 10611 |
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<RecordType>, |
| 10612 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 10613 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 10614 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 10615 |
</pre></td></tr> |
| 10616 |
|
| 10617 |
|
| 10618 |
<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> |
| 10619 |
<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is |
| 10620 |
matched by the given matcher. |
| 10621 |
|
| 10622 |
Given |
| 10623 |
namespace X { int a; void b(); } |
| 10624 |
using X::a; |
| 10625 |
using X::b; |
| 10626 |
usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) |
| 10627 |
matches using X::b but not using X::a </pre></td></tr> |
| 10628 |
|
| 10629 |
|
| 10630 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</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> |
| 10631 |
<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node |
| 10632 |
matches the given matcher. |
| 10633 |
|
| 10634 |
The associated declaration is: |
| 10635 |
- for type nodes, the declaration of the underlying type |
| 10636 |
- for CallExpr, the declaration of the callee |
| 10637 |
- for MemberExpr, the declaration of the referenced member |
| 10638 |
- for CXXConstructExpr, the declaration of the constructor |
| 10639 |
- for CXXNewExpr, the declaration of the operator new |
| 10640 |
- for ObjCIvarExpr, the declaration of the ivar |
| 10641 |
|
| 10642 |
For type nodes, hasDeclaration will generally match the declaration of the |
| 10643 |
sugared type. Given |
| 10644 |
class X {}; |
| 10645 |
typedef X Y; |
| 10646 |
Y y; |
| 10647 |
in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 10648 |
typedefDecl. A common use case is to match the underlying, desugared type. |
| 10649 |
This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 10650 |
varDecl(hasType(hasUnqualifiedDesugaredType( |
| 10651 |
recordType(hasDeclaration(decl()))))) |
| 10652 |
In this matcher, the decl will match the CXXRecordDecl of class X. |
| 10653 |
|
| 10654 |
Usable 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>>, |
| 10655 |
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>>, |
| 10656 |
Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 10657 |
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<RecordType>, |
| 10658 |
Matcher<TagType>, Matcher<TemplateSpecializationType>, |
| 10659 |
Matcher<TemplateTypeParmType>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 10660 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 10661 |
</pre></td></tr> |
| 10662 |
|
| 10663 |
|
| 10664 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>></td><td class="name" onclick="toggle('throughUsingDecl1')"><a name="throughUsingDecl1Anchor">throughUsingDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>> Inner</td></tr> |
| 10665 |
<tr><td colspan="4" class="doc" id="throughUsingDecl1"><pre>Matches if a node refers to a declaration through a specific |
| 10666 |
using shadow declaration. |
| 10667 |
|
| 10668 |
Examples: |
| 10669 |
namespace a { int f(); } |
| 10670 |
using a::f; |
| 10671 |
int x = f(); |
| 10672 |
declRefExpr(throughUsingDecl(anything())) |
| 10673 |
matches f |
| 10674 |
|
| 10675 |
namespace a { class X{}; } |
| 10676 |
using a::X; |
| 10677 |
X x; |
| 10678 |
typeLoc(loc(usingType(throughUsingDecl(anything())))) |
| 10679 |
matches X |
| 10680 |
|
| 10681 |
Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>> |
| 10682 |
</pre></td></tr> |
| 10683 |
|
| 10684 |
|
| 10685 |
<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> |
| 10686 |
<tr><td colspan="4" class="doc" id="hasType7"><pre>Overloaded to match the declaration of the expression's or value |
| 10687 |
declaration's type. |
| 10688 |
|
| 10689 |
In case of a value declaration (for example a variable declaration), |
| 10690 |
this resolves one layer of indirection. For example, in the value |
| 10691 |
declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 10692 |
X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 10693 |
declaration of x. |
| 10694 |
|
| 10695 |
Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 10696 |
and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 10697 |
and friend class X (matcher = friendDecl(hasType("X")) |
| 10698 |
and public virtual X (matcher = cxxBaseSpecifier(hasType( |
| 10699 |
cxxRecordDecl(hasName("X")))) |
| 10700 |
class X {}; |
| 10701 |
void y(X &x) { x; X z; } |
| 10702 |
class Y { friend class X; }; |
| 10703 |
class Z : public virtual X {}; |
| 10704 |
|
| 10705 |
Example matches class Derived |
| 10706 |
(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))) |
| 10707 |
class Base {}; |
| 10708 |
class Derived : Base {}; |
| 10709 |
|
| 10710 |
Usable 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>>, |
| 10711 |
Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>> |
| 10712 |
</pre></td></tr> |
| 10713 |
|
| 10714 |
|
| 10715 |
<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> |
| 10716 |
<tr><td colspan="4" class="doc" id="hasType3"><pre>Matches if the expression's or declaration's type matches a type |
| 10717 |
matcher. |
| 10718 |
|
| 10719 |
Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 10720 |
and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 10721 |
and U (matcher = typedefDecl(hasType(asString("int"))) |
| 10722 |
and friend class X (matcher = friendDecl(hasType("X")) |
| 10723 |
and public virtual X (matcher = cxxBaseSpecifier(hasType( |
| 10724 |
asString("class X"))) |
| 10725 |
class X {}; |
| 10726 |
void y(X &x) { x; X z; } |
| 10727 |
typedef int U; |
| 10728 |
class Y { friend class X; }; |
| 10729 |
class Z : public virtual X {}; |
| 10730 |
</pre></td></tr> |
| 10731 |
|
| 10732 |
|
| 10733 |
<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> |
| 10734 |
<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression |
| 10735 |
that matches the given matcher. |
| 10736 |
|
| 10737 |
Example matches x (matcher = varDecl(hasInitializer(callExpr()))) |
| 10738 |
bool y() { return true; } |
| 10739 |
bool x = y(); |
| 10740 |
</pre></td></tr> |
| 10741 |
|
| 10742 |
|
| 10743 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarTemplateSpecializationDecl.html">VarTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('forEachTemplateArgument1')"><a name="forEachTemplateArgument1Anchor">forEachTemplateArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> |
| 10744 |
<tr><td colspan="4" class="doc" id="forEachTemplateArgument1"><pre>Matches templateSpecializationType, class template specialization, |
| 10745 |
variable template specialization, and function template specialization |
| 10746 |
nodes where the template argument matches the inner matcher. This matcher |
| 10747 |
may produce multiple matches. |
| 10748 |
|
| 10749 |
Given |
| 10750 |
template <typename T, unsigned N, unsigned M> |
| 10751 |
struct Matrix {}; |
| 10752 |
|
| 10753 |
constexpr unsigned R = 2; |
| 10754 |
Matrix<int, R * 2, R * 4> M; |
| 10755 |
|
| 10756 |
template <typename T, typename U> |
| 10757 |
void f(T&& t, U&& u) {} |
| 10758 |
|
| 10759 |
bool B = false; |
| 10760 |
f(R, B); |
| 10761 |
templateSpecializationType(forEachTemplateArgument(isExpr(expr()))) |
| 10762 |
matches twice, with expr() matching 'R * 2' and 'R * 4' |
| 10763 |
functionDecl(forEachTemplateArgument(refersToType(builtinType()))) |
| 10764 |
matches the specialization f<unsigned, bool> twice, for 'unsigned' |
| 10765 |
and 'bool' |
| 10766 |
</pre></td></tr> |
| 10767 |
|
| 10768 |
|
| 10769 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarTemplateSpecializationDecl.html">VarTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgumentLoc1')"><a name="hasAnyTemplateArgumentLoc1Anchor">hasAnyTemplateArgumentLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> |
| 10770 |
<tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc1"><pre>Matches template specialization `TypeLoc`s, class template specializations, |
| 10771 |
variable template specializations, and function template specializations |
| 10772 |
that have at least one `TemplateArgumentLoc` matching the given |
| 10773 |
`InnerMatcher`. |
| 10774 |
|
| 10775 |
Given |
| 10776 |
template<typename T> class A {}; |
| 10777 |
A<int> a; |
| 10778 |
varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc( |
| 10779 |
hasTypeLoc(loc(asString("int"))))))) |
| 10780 |
matches `A<int> a`. |
| 10781 |
</pre></td></tr> |
| 10782 |
|
| 10783 |
|
| 10784 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarTemplateSpecializationDecl.html">VarTemplateSpecializationDecl</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> |
| 10785 |
<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches templateSpecializationTypes, class template specializations, |
| 10786 |
variable template specializations, and function template specializations |
| 10787 |
that have at least one TemplateArgument matching the given InnerMatcher. |
| 10788 |
|
| 10789 |
Given |
| 10790 |
template<typename T> class A {}; |
| 10791 |
template<> class A<double> {}; |
| 10792 |
A<int> a; |
| 10793 |
|
| 10794 |
template<typename T> f() {}; |
| 10795 |
void func() { f<int>(); }; |
| 10796 |
|
| 10797 |
classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 10798 |
refersToType(asString("int")))) |
| 10799 |
matches the specialization A<int> |
| 10800 |
|
| 10801 |
functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) |
| 10802 |
matches the specialization f<int> |
| 10803 |
</pre></td></tr> |
| 10804 |
|
| 10805 |
|
| 10806 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarTemplateSpecializationDecl.html">VarTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('hasTemplateArgumentLoc1')"><a name="hasTemplateArgumentLoc1Anchor">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>> InnerMatcher</td></tr> |
| 10807 |
<tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc1"><pre>Matches template specialization `TypeLoc`s, class template specializations, |
| 10808 |
variable template specializations, and function template specializations |
| 10809 |
where the n'th `TemplateArgumentLoc` matches the given `InnerMatcher`. |
| 10810 |
|
| 10811 |
Given |
| 10812 |
template<typename T, typename U> class A {}; |
| 10813 |
A<double, int> b; |
| 10814 |
A<int, double> c; |
| 10815 |
varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0, |
| 10816 |
hasTypeLoc(loc(asString("double"))))))) |
| 10817 |
matches `A<double, int> b`, but not `A<int, double> c`. |
| 10818 |
</pre></td></tr> |
| 10819 |
|
| 10820 |
|
| 10821 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarTemplateSpecializationDecl.html">VarTemplateSpecializationDecl</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> |
| 10822 |
<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches templateSpecializationType, class template specializations, |
| 10823 |
variable template specializations, and function template specializations |
| 10824 |
where the n'th TemplateArgument matches the given InnerMatcher. |
| 10825 |
|
| 10826 |
Given |
| 10827 |
template<typename T, typename U> class A {}; |
| 10828 |
A<bool, int> b; |
| 10829 |
A<int, bool> c; |
| 10830 |
|
| 10831 |
template<typename T> void f() {} |
| 10832 |
void func() { f<int>(); }; |
| 10833 |
classTemplateSpecializationDecl(hasTemplateArgument( |
| 10834 |
1, refersToType(asString("int")))) |
| 10835 |
matches the specialization A<bool, int> |
| 10836 |
|
| 10837 |
functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) |
| 10838 |
matches the specialization f<int> |
| 10839 |
</pre></td></tr> |
| 10840 |
|
| 10841 |
|
| 10842 |
<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> |
| 10843 |
<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size |
| 10844 |
expression. |
| 10845 |
|
| 10846 |
Given |
| 10847 |
void f(int b) { |
| 10848 |
int a[b]; |
| 10849 |
} |
| 10850 |
variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( |
| 10851 |
varDecl(hasName("b"))))))) |
| 10852 |
matches "int a[b]" |
| 10853 |
</pre></td></tr> |
| 10854 |
|
| 10855 |
|
| 10856 |
<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> |
| 10857 |
<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine |
| 10858 |
definition that has a given body. Note that in case of functions or |
| 10859 |
coroutines this matcher only matches the definition itself and not the |
| 10860 |
other declarations of the same function or coroutine. |
| 10861 |
|
| 10862 |
Given |
| 10863 |
for (;;) {} |
| 10864 |
forStmt(hasBody(compoundStmt())) |
| 10865 |
matches 'for (;;) {}' |
| 10866 |
with compoundStmt() |
| 10867 |
matching '{}' |
| 10868 |
|
| 10869 |
Given |
| 10870 |
void f(); |
| 10871 |
void f() {} |
| 10872 |
functionDecl(hasBody(compoundStmt())) |
| 10873 |
matches 'void f() {}' |
| 10874 |
with compoundStmt() |
| 10875 |
matching '{}' |
| 10876 |
but does not match 'void f();' |
| 10877 |
</pre></td></tr> |
| 10878 |
|
| 10879 |
|
| 10880 |
<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> |
| 10881 |
<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, while loop, |
| 10882 |
do-while loop, switch statement or conditional operator. |
| 10883 |
|
| 10884 |
Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 10885 |
if (true) {} |
| 10886 |
</pre></td></tr> |
| 10887 |
|
| 10888 |
|
| 10889 |
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>></td><td class="name" onclick="toggle('hasConditionVariableStatement2')"><a name="hasConditionVariableStatement2Anchor">hasConditionVariableStatement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>> InnerMatcher</td></tr> |
| 10890 |
<tr><td colspan="4" class="doc" id="hasConditionVariableStatement2"><pre>Matches the condition variable statement in an if statement, for loop, |
| 10891 |
while loop or switch statement. |
| 10892 |
|
| 10893 |
Given |
| 10894 |
if (A* a = GetAPointer()) {} |
| 10895 |
for (; A* a = GetAPointer(); ) {} |
| 10896 |
hasConditionVariableStatement(...) |
| 10897 |
matches both 'A* a = GetAPointer()'. |
| 10898 |
</pre></td></tr> |
| 10899 |
|
| 10900 |
<!--END_TRAVERSAL_MATCHERS --> |
| 10901 |
</table> |
| 10902 |
|
| 10903 |
</div> |
| 10904 |
</body> |
| 10905 |
</html> |
| 10906 |
|
| 10907 |
|