Aaron Ballman | 11825f2 | 2015-08-18 19:55:20 +0000 | [diff] [blame^] | 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 | </style>
|
| 21 | <script type="text/javascript">
|
| 22 | function toggle(id) {
|
| 23 | if (!id) return;
|
| 24 | row = document.getElementById(id);
|
| 25 | if (row.style.display != 'table-cell')
|
| 26 | row.style.display = 'table-cell';
|
| 27 | else
|
| 28 | row.style.display = 'none';
|
| 29 | }
|
| 30 | </script>
|
| 31 | </head>
|
| 32 | <body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))">
|
| 33 |
|
| 34 | <!--#include virtual="../menu.html.incl"-->
|
| 35 |
|
| 36 | <div id="content">
|
| 37 |
|
| 38 | <h1>AST Matcher Reference</h1>
|
| 39 |
|
| 40 | <p>This document shows all currently implemented matchers. The matchers are grouped
|
| 41 | by category and node type they match. You can click on matcher names to show the
|
| 42 | matcher's source documentation.</p>
|
| 43 |
|
| 44 | <p>There are three different basic categories of matchers:
|
| 45 | <ul>
|
| 46 | <li><a href="#decl-matchers">Node Matchers:</a> Matchers that match a specific type of AST node.</li>
|
| 47 | <li><a href="#narrowing-matchers">Narrowing Matchers:</a> Matchers that match attributes on AST nodes.</li>
|
| 48 | <li><a href="#traversal-matchers">Traversal Matchers:</a> Matchers that allow traversal between AST nodes.</li>
|
| 49 | </ul>
|
| 50 | </p>
|
| 51 |
|
| 52 | <p>Within each category the matchers are ordered by node type they match on.
|
| 53 | Note that if a matcher can match multiple node types, it will it will appear
|
| 54 | multiple times. This means that by searching for Matcher<Stmt> you can
|
| 55 | find all matchers that can be used to match on Stmt nodes.</p>
|
| 56 |
|
| 57 | <p>The exception to that rule are matchers that can match on any node. Those
|
| 58 | are marked with a * and are listed in the beginning of each category.</p>
|
| 59 |
|
| 60 | <p>Note that the categorization of matchers is a great help when you combine
|
| 61 | them into matcher expressions. You will usually want to form matcher expressions
|
| 62 | that read like english sentences by alternating between node matchers and
|
| 63 | narrowing or traversal matchers, like this:
|
| 64 | <pre>
|
| 65 | recordDecl(hasDescendant(
|
| 66 | ifStmt(hasTrueExpression(
|
| 67 | expr(hasDescendant(
|
| 68 | ifStmt()))))))
|
| 69 | </pre>
|
| 70 | </p>
|
| 71 |
|
| 72 | <!-- ======================================================================= -->
|
| 73 | <h2 id="decl-matchers">Node Matchers</h2>
|
| 74 | <!-- ======================================================================= -->
|
| 75 |
|
| 76 | <p>Node matchers are at the core of matcher expressions - they specify the type
|
| 77 | of node that is expected. Every match expression starts with a node matcher,
|
| 78 | which can then be further refined with a narrowing or traversal matcher. All
|
| 79 | traversal matchers take node matchers as their arguments.</p>
|
| 80 |
|
| 81 | <p>For convenience, all node matchers take an arbitrary number of arguments
|
| 82 | and implicitly act as allOf matchers.</p>
|
| 83 |
|
| 84 | <p>Node matchers are the only matchers that support the bind("id") call to
|
| 85 | bind the matched node to the given string, to be later retrieved from the
|
| 86 | match callback.</p>
|
| 87 |
|
| 88 | <p>It is important to remember that the arguments to node matchers are
|
| 89 | predicates on the same node, just with additional information about the type.
|
| 90 | This is often useful to make matcher expression more readable by inlining bind
|
| 91 | calls into redundant node matchers inside another node matcher:
|
| 92 | <pre>
|
| 93 | // This binds the CXXRecordDecl to "id", as the decl() matcher will stay on
|
| 94 | // the same node.
|
| 95 | recordDecl(decl().bind("id"), hasName("::MyClass"))
|
| 96 | </pre>
|
| 97 | </p>
|
| 98 |
|
| 99 | <table>
|
| 100 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
|
| 101 | <!-- START_DECL_MATCHERS -->
|
| 102 |
|
| 103 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('ctorInitializer0')"><a name="ctorInitializer0Anchor">ctorInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>...</td></tr>
|
| 104 | <tr><td colspan="4" class="doc" id="ctorInitializer0"><pre>Matches constructor initializers.
|
| 105 |
|
| 106 | Examples matches i(42).
|
| 107 | class C {
|
| 108 | C() : i(42) {}
|
| 109 | int i;
|
| 110 | };
|
| 111 | </pre></td></tr>
|
| 112 |
|
| 113 |
|
| 114 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('accessSpecDecl0')"><a name="accessSpecDecl0Anchor">accessSpecDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AccessSpecDecl.html">AccessSpecDecl</a>>...</td></tr>
|
| 115 | <tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations.
|
| 116 |
|
| 117 | Given
|
| 118 | class C {
|
| 119 | public:
|
| 120 | int a;
|
| 121 | };
|
| 122 | accessSpecDecl()
|
| 123 | matches 'public:'
|
| 124 | </pre></td></tr>
|
| 125 |
|
| 126 |
|
| 127 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('classTemplateDecl0')"><a name="classTemplateDecl0Anchor">classTemplateDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>>...</td></tr>
|
| 128 | <tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations.
|
| 129 |
|
| 130 | Example matches Z
|
| 131 | template<class T> class Z {};
|
| 132 | </pre></td></tr>
|
| 133 |
|
| 134 |
|
| 135 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('classTemplateSpecializationDecl0')"><a name="classTemplateSpecializationDecl0Anchor">classTemplateSpecializationDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>...</td></tr>
|
| 136 | <tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations.
|
| 137 |
|
| 138 | Given
|
| 139 | template<typename T> class A {};
|
| 140 | template<> class A<double> {};
|
| 141 | A<int> a;
|
| 142 | classTemplateSpecializationDecl()
|
| 143 | matches the specializations A<int> and A<double>
|
| 144 | </pre></td></tr>
|
| 145 |
|
| 146 |
|
| 147 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('constructorDecl0')"><a name="constructorDecl0Anchor">constructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>>...</td></tr>
|
| 148 | <tr><td colspan="4" class="doc" id="constructorDecl0"><pre>Matches C++ constructor declarations.
|
| 149 |
|
| 150 | Example matches Foo::Foo() and Foo::Foo(int)
|
| 151 | class Foo {
|
| 152 | public:
|
| 153 | Foo();
|
| 154 | Foo(int);
|
| 155 | int DoSomething();
|
| 156 | };
|
| 157 | </pre></td></tr>
|
| 158 |
|
| 159 |
|
| 160 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('conversionDecl0')"><a name="conversionDecl0Anchor">conversionDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>>...</td></tr>
|
| 161 | <tr><td colspan="4" class="doc" id="conversionDecl0"><pre>Matches conversion operator declarations.
|
| 162 |
|
| 163 | Example matches the operator.
|
| 164 | class X { operator int() const; };
|
| 165 | </pre></td></tr>
|
| 166 |
|
| 167 |
|
| 168 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('decl0')"><a name="decl0Anchor">decl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>...</td></tr>
|
| 169 | <tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations.
|
| 170 |
|
| 171 | Examples matches X, C, and the friend declaration inside C;
|
| 172 | void X();
|
| 173 | class C {
|
| 174 | friend X;
|
| 175 | };
|
| 176 | </pre></td></tr>
|
| 177 |
|
| 178 |
|
| 179 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('declaratorDecl0')"><a name="declaratorDecl0Anchor">declaratorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>...</td></tr>
|
| 180 | <tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function
|
| 181 | and non-type template parameter declarations).
|
| 182 |
|
| 183 | Given
|
| 184 | class X { int y; };
|
| 185 | declaratorDecl()
|
| 186 | matches int y.
|
| 187 | </pre></td></tr>
|
| 188 |
|
| 189 |
|
| 190 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('destructorDecl0')"><a name="destructorDecl0Anchor">destructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>>...</td></tr>
|
| 191 | <tr><td colspan="4" class="doc" id="destructorDecl0"><pre>Matches explicit C++ destructor declarations.
|
| 192 |
|
| 193 | Example matches Foo::~Foo()
|
| 194 | class Foo {
|
| 195 | public:
|
| 196 | virtual ~Foo();
|
| 197 | };
|
| 198 | </pre></td></tr>
|
| 199 |
|
| 200 |
|
| 201 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('enumConstantDecl0')"><a name="enumConstantDecl0Anchor">enumConstantDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html">EnumConstantDecl</a>>...</td></tr>
|
| 202 | <tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants.
|
| 203 |
|
| 204 | Example matches A, B, C
|
| 205 | enum X {
|
| 206 | A, B, C
|
| 207 | };
|
| 208 | </pre></td></tr>
|
| 209 |
|
| 210 |
|
| 211 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('enumDecl0')"><a name="enumDecl0Anchor">enumDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>>...</td></tr>
|
| 212 | <tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations.
|
| 213 |
|
| 214 | Example matches X
|
| 215 | enum X {
|
| 216 | A, B, C
|
| 217 | };
|
| 218 | </pre></td></tr>
|
| 219 |
|
| 220 |
|
| 221 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('fieldDecl0')"><a name="fieldDecl0Anchor">fieldDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>>...</td></tr>
|
| 222 | <tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations.
|
| 223 |
|
| 224 | Given
|
| 225 | class X { int m; };
|
| 226 | fieldDecl()
|
| 227 | matches 'm'.
|
| 228 | </pre></td></tr>
|
| 229 |
|
| 230 |
|
| 231 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('friendDecl0')"><a name="friendDecl0Anchor">friendDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>>...</td></tr>
|
| 232 | <tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations.
|
| 233 |
|
| 234 | Given
|
| 235 | class X { friend void foo(); };
|
| 236 | friendDecl()
|
| 237 | matches 'friend void foo()'.
|
| 238 | </pre></td></tr>
|
| 239 |
|
| 240 |
|
| 241 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('functionDecl0')"><a name="functionDecl0Anchor">functionDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>...</td></tr>
|
| 242 | <tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations.
|
| 243 |
|
| 244 | Example matches f
|
| 245 | void f();
|
| 246 | </pre></td></tr>
|
| 247 |
|
| 248 |
|
| 249 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('functionTemplateDecl0')"><a name="functionTemplateDecl0Anchor">functionTemplateDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionTemplateDecl.html">FunctionTemplateDecl</a>>...</td></tr>
|
| 250 | <tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations.
|
| 251 |
|
| 252 | Example matches f
|
| 253 | template<class T> void f(T t) {}
|
| 254 | </pre></td></tr>
|
| 255 |
|
| 256 |
|
| 257 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('linkageSpecDecl0')"><a name="linkageSpecDecl0Anchor">linkageSpecDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LinkageSpecDecl.html">LinkageSpecDecl</a>>...</td></tr>
|
| 258 | <tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification.
|
| 259 |
|
| 260 | Given
|
| 261 | extern "C" {}
|
| 262 | linkageSpecDecl()
|
| 263 | matches "extern "C" {}"
|
| 264 | </pre></td></tr>
|
| 265 |
|
| 266 |
|
| 267 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('methodDecl0')"><a name="methodDecl0Anchor">methodDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>>...</td></tr>
|
| 268 | <tr><td colspan="4" class="doc" id="methodDecl0"><pre>Matches method declarations.
|
| 269 |
|
| 270 | Example matches y
|
| 271 | class X { void y(); };
|
| 272 | </pre></td></tr>
|
| 273 |
|
| 274 |
|
| 275 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('namedDecl0')"><a name="namedDecl0Anchor">namedDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>>...</td></tr>
|
| 276 | <tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name.
|
| 277 |
|
| 278 | Example matches X, S, the anonymous union type, i, and U;
|
| 279 | typedef int X;
|
| 280 | struct S {
|
| 281 | union {
|
| 282 | int i;
|
| 283 | } U;
|
| 284 | };
|
| 285 | </pre></td></tr>
|
| 286 |
|
| 287 |
|
| 288 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('namespaceDecl0')"><a name="namespaceDecl0Anchor">namespaceDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>>...</td></tr>
|
| 289 | <tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace.
|
| 290 |
|
| 291 | Given
|
| 292 | namespace {}
|
| 293 | namespace test {}
|
| 294 | namespaceDecl()
|
| 295 | matches "namespace {}" and "namespace test {}"
|
| 296 | </pre></td></tr>
|
| 297 |
|
| 298 |
|
| 299 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('parmVarDecl0')"><a name="parmVarDecl0Anchor">parmVarDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>>...</td></tr>
|
| 300 | <tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations.
|
| 301 |
|
| 302 | Given
|
| 303 | void f(int x);
|
| 304 | parmVarDecl()
|
| 305 | matches int x.
|
| 306 | </pre></td></tr>
|
| 307 |
|
| 308 |
|
| 309 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('recordDecl0')"><a name="recordDecl0Anchor">recordDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>...</td></tr>
|
| 310 | <tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches C++ class declarations.
|
| 311 |
|
| 312 | Example matches X, Z
|
| 313 | class X;
|
| 314 | template<class T> class Z {};
|
| 315 | </pre></td></tr>
|
| 316 |
|
| 317 |
|
| 318 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('staticAssertDecl0')"><a name="staticAssertDecl0Anchor">staticAssertDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StaticAssertDecl.html">StaticAssertDecl</a>>...</td></tr>
|
| 319 | <tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration.
|
| 320 |
|
| 321 | Example:
|
| 322 | staticAssertExpr()
|
| 323 | matches
|
| 324 | static_assert(sizeof(S) == sizeof(int))
|
| 325 | in
|
| 326 | struct S {
|
| 327 | int x;
|
| 328 | };
|
| 329 | static_assert(sizeof(S) == sizeof(int));
|
| 330 | </pre></td></tr>
|
| 331 |
|
| 332 |
|
| 333 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('translationUnitDecl0')"><a name="translationUnitDecl0Anchor">translationUnitDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TranslationUnitDecl.html">TranslationUnitDecl</a>>...</td></tr>
|
| 334 | <tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context.
|
| 335 |
|
| 336 | Given
|
| 337 | int X;
|
| 338 | namespace NS {
|
| 339 | int Y;
|
| 340 | } namespace NS
|
| 341 | decl(hasDeclContext(translationUnitDecl()))
|
| 342 | matches "int X", but not "int Y".
|
| 343 | </pre></td></tr>
|
| 344 |
|
| 345 |
|
| 346 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typedefDecl0')"><a name="typedefDecl0Anchor">typedefDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html">TypedefDecl</a>>...</td></tr>
|
| 347 | <tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations.
|
| 348 |
|
| 349 | Given
|
| 350 | typedef int X;
|
| 351 | typedefDecl()
|
| 352 | matches "typedef int X"
|
| 353 | </pre></td></tr>
|
| 354 |
|
| 355 |
|
| 356 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('unresolvedUsingValueDecl0')"><a name="unresolvedUsingValueDecl0Anchor">unresolvedUsingValueDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingValueDecl.html">UnresolvedUsingValueDecl</a>>...</td></tr>
|
| 357 | <tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations.
|
| 358 |
|
| 359 | Given
|
| 360 | template<typename X>
|
| 361 | class C : private X {
|
| 362 | using X::x;
|
| 363 | };
|
| 364 | unresolvedUsingValueDecl()
|
| 365 | matches using X::x </pre></td></tr>
|
| 366 |
|
| 367 |
|
| 368 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('usingDecl0')"><a name="usingDecl0Anchor">usingDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>>...</td></tr>
|
| 369 | <tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations.
|
| 370 |
|
| 371 | Given
|
| 372 | namespace X { int x; }
|
| 373 | using X::x;
|
| 374 | usingDecl()
|
| 375 | matches using X::x </pre></td></tr>
|
| 376 |
|
| 377 |
|
| 378 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('usingDirectiveDecl0')"><a name="usingDirectiveDecl0Anchor">usingDirectiveDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDirectiveDecl.html">UsingDirectiveDecl</a>>...</td></tr>
|
| 379 | <tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations.
|
| 380 |
|
| 381 | Given
|
| 382 | namespace X { int x; }
|
| 383 | using namespace X;
|
| 384 | usingDirectiveDecl()
|
| 385 | matches using namespace X </pre></td></tr>
|
| 386 |
|
| 387 |
|
| 388 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('valueDecl0')"><a name="valueDecl0Anchor">valueDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>...</td></tr>
|
| 389 | <tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration.
|
| 390 |
|
| 391 | Example matches A, B, C and F
|
| 392 | enum X { A, B, C };
|
| 393 | void F();
|
| 394 | </pre></td></tr>
|
| 395 |
|
| 396 |
|
| 397 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('varDecl0')"><a name="varDecl0Anchor">varDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>...</td></tr>
|
| 398 | <tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations.
|
| 399 |
|
| 400 | Note: this does not match declarations of member variables, which are
|
| 401 | "field" declarations in Clang parlance.
|
| 402 |
|
| 403 | Example matches a
|
| 404 | int a;
|
| 405 | </pre></td></tr>
|
| 406 |
|
| 407 |
|
| 408 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>></td><td class="name" onclick="toggle('nestedNameSpecifierLoc0')"><a name="nestedNameSpecifierLoc0Anchor">nestedNameSpecifierLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>>...</td></tr>
|
| 409 | <tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
|
| 410 | </pre></td></tr>
|
| 411 |
|
| 412 |
|
| 413 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>></td><td class="name" onclick="toggle('nestedNameSpecifier0')"><a name="nestedNameSpecifier0Anchor">nestedNameSpecifier</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>>...</td></tr>
|
| 414 | <tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers.
|
| 415 |
|
| 416 | Given
|
| 417 | namespace ns {
|
| 418 | struct A { static void f(); };
|
| 419 | void A::f() {}
|
| 420 | void g() { A::f(); }
|
| 421 | }
|
| 422 | ns::A a;
|
| 423 | nestedNameSpecifier()
|
| 424 | matches "ns::" and both "A::"
|
| 425 | </pre></td></tr>
|
| 426 |
|
| 427 |
|
| 428 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('qualType0')"><a name="qualType0Anchor">qualType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>...</td></tr>
|
| 429 | <tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST.
|
| 430 | </pre></td></tr>
|
| 431 |
|
| 432 |
|
| 433 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('CUDAKernelCallExpr0')"><a name="CUDAKernelCallExpr0Anchor">CUDAKernelCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr</a>>...</td></tr>
|
| 434 | <tr><td colspan="4" class="doc" id="CUDAKernelCallExpr0"><pre>Matches CUDA kernel call expression.
|
| 435 |
|
| 436 | Example matches,
|
| 437 | kernel<<<i,j>>>();
|
| 438 | </pre></td></tr>
|
| 439 |
|
| 440 |
|
| 441 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('arraySubscriptExpr0')"><a name="arraySubscriptExpr0Anchor">arraySubscriptExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>>...</td></tr>
|
| 442 | <tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions.
|
| 443 |
|
| 444 | Given
|
| 445 | int i = a[1];
|
| 446 | arraySubscriptExpr()
|
| 447 | matches "a[1]"
|
| 448 | </pre></td></tr>
|
| 449 |
|
| 450 |
|
| 451 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('asmStmt0')"><a name="asmStmt0Anchor">asmStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AsmStmt.html">AsmStmt</a>>...</td></tr>
|
| 452 | <tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements.
|
| 453 |
|
| 454 | int i = 100;
|
| 455 | __asm("mov al, 2");
|
| 456 | asmStmt()
|
| 457 | matches '__asm("mov al, 2")'
|
| 458 | </pre></td></tr>
|
| 459 |
|
| 460 |
|
| 461 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('binaryOperator0')"><a name="binaryOperator0Anchor">binaryOperator</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>>...</td></tr>
|
| 462 | <tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions.
|
| 463 |
|
| 464 | Example matches a || b
|
| 465 | !(a || b)
|
| 466 | </pre></td></tr>
|
| 467 |
|
| 468 |
|
| 469 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('bindTemporaryExpr0')"><a name="bindTemporaryExpr0Anchor">bindTemporaryExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>>...</td></tr>
|
| 470 | <tr><td colspan="4" class="doc" id="bindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
|
| 471 |
|
| 472 | Example matches FunctionTakesString(GetStringByValue())
|
| 473 | (matcher = bindTemporaryExpr())
|
| 474 | FunctionTakesString(GetStringByValue());
|
| 475 | FunctionTakesStringByPointer(GetStringPointer());
|
| 476 | </pre></td></tr>
|
| 477 |
|
| 478 |
|
| 479 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('boolLiteral0')"><a name="boolLiteral0Anchor">boolLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>...</td></tr>
|
| 480 | <tr><td colspan="4" class="doc" id="boolLiteral0"><pre>Matches bool literals.
|
| 481 |
|
| 482 | Example matches true
|
| 483 | true
|
| 484 | </pre></td></tr>
|
| 485 |
|
| 486 |
|
| 487 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('breakStmt0')"><a name="breakStmt0Anchor">breakStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BreakStmt.html">BreakStmt</a>>...</td></tr>
|
| 488 | <tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements.
|
| 489 |
|
| 490 | Given
|
| 491 | while (true) { break; }
|
| 492 | breakStmt()
|
| 493 | matches 'break'
|
| 494 | </pre></td></tr>
|
| 495 |
|
| 496 |
|
| 497 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cStyleCastExpr0')"><a name="cStyleCastExpr0Anchor">cStyleCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CStyleCastExpr.html">CStyleCastExpr</a>>...</td></tr>
|
| 498 | <tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression.
|
| 499 |
|
| 500 | Example: Matches (int*) 2.2f in
|
| 501 | int i = (int) 2.2f;
|
| 502 | </pre></td></tr>
|
| 503 |
|
| 504 |
|
| 505 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('callExpr0')"><a name="callExpr0Anchor">callExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>...</td></tr>
|
| 506 | <tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions.
|
| 507 |
|
| 508 | Example matches x.y() and y()
|
| 509 | X x;
|
| 510 | x.y();
|
| 511 | y();
|
| 512 | </pre></td></tr>
|
| 513 |
|
| 514 |
|
| 515 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('caseStmt0')"><a name="caseStmt0Anchor">caseStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>>...</td></tr>
|
| 516 | <tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements.
|
| 517 |
|
| 518 | Given
|
| 519 | switch(a) { case 42: break; default: break; }
|
| 520 | caseStmt()
|
| 521 | matches 'case 42: break;'.
|
| 522 | </pre></td></tr>
|
| 523 |
|
| 524 |
|
| 525 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('castExpr0')"><a name="castExpr0Anchor">castExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>>...</td></tr>
|
| 526 | <tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST.
|
| 527 |
|
| 528 | Example: castExpr() matches each of the following:
|
| 529 | (int) 3;
|
| 530 | const_cast<Expr *>(SubExpr);
|
| 531 | char c = 0;
|
| 532 | but does not match
|
| 533 | int i = (0);
|
| 534 | int k = 0;
|
| 535 | </pre></td></tr>
|
| 536 |
|
| 537 |
|
| 538 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('catchStmt0')"><a name="catchStmt0Anchor">catchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>>...</td></tr>
|
| 539 | <tr><td colspan="4" class="doc" id="catchStmt0"><pre>Matches catch statements.
|
| 540 |
|
| 541 | try {} catch(int i) {}
|
| 542 | catchStmt()
|
| 543 | matches 'catch(int i)'
|
| 544 | </pre></td></tr>
|
| 545 |
|
| 546 |
|
| 547 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('characterLiteral0')"><a name="characterLiteral0Anchor">characterLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>...</td></tr>
|
| 548 | <tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t).
|
| 549 |
|
| 550 | Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
|
| 551 | though.
|
| 552 |
|
| 553 | Example matches 'a', L'a'
|
| 554 | char ch = 'a'; wchar_t chw = L'a';
|
| 555 | </pre></td></tr>
|
| 556 |
|
| 557 |
|
| 558 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('compoundLiteralExpr0')"><a name="compoundLiteralExpr0Anchor">compoundLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>...</td></tr>
|
| 559 | <tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals
|
| 560 |
|
| 561 | Example match: {1}, (1, 2)
|
| 562 | int array[4] = {1}; vector int myvec = (vector int)(1, 2);
|
| 563 | </pre></td></tr>
|
| 564 |
|
| 565 |
|
| 566 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('compoundStmt0')"><a name="compoundStmt0Anchor">compoundStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>>...</td></tr>
|
| 567 | <tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements.
|
| 568 |
|
| 569 | Example matches '{}' and '{{}}'in 'for (;;) {{}}'
|
| 570 | for (;;) {{}}
|
| 571 | </pre></td></tr>
|
| 572 |
|
| 573 |
|
| 574 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('conditionalOperator0')"><a name="conditionalOperator0Anchor">conditionalOperator</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>>...</td></tr>
|
| 575 | <tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions.
|
| 576 |
|
| 577 | Example matches a ? b : c
|
| 578 | (a ? b : c) + 42
|
| 579 | </pre></td></tr>
|
| 580 |
|
| 581 |
|
| 582 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('constCastExpr0')"><a name="constCastExpr0Anchor">constCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>>...</td></tr>
|
| 583 | <tr><td colspan="4" class="doc" id="constCastExpr0"><pre>Matches a const_cast expression.
|
| 584 |
|
| 585 | Example: Matches const_cast<int*>(&r) in
|
| 586 | int n = 42;
|
| 587 | const int &r(n);
|
| 588 | int* p = const_cast<int*>(&r);
|
| 589 | </pre></td></tr>
|
| 590 |
|
| 591 |
|
| 592 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('constructExpr0')"><a name="constructExpr0Anchor">constructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>...</td></tr>
|
| 593 | <tr><td colspan="4" class="doc" id="constructExpr0"><pre>Matches constructor call expressions (including implicit ones).
|
| 594 |
|
| 595 | Example matches string(ptr, n) and ptr within arguments of f
|
| 596 | (matcher = constructExpr())
|
| 597 | void f(const string &a, const string &b);
|
| 598 | char *ptr;
|
| 599 | int n;
|
| 600 | f(string(ptr, n), ptr);
|
| 601 | </pre></td></tr>
|
| 602 |
|
| 603 |
|
| 604 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('continueStmt0')"><a name="continueStmt0Anchor">continueStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ContinueStmt.html">ContinueStmt</a>>...</td></tr>
|
| 605 | <tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements.
|
| 606 |
|
| 607 | Given
|
| 608 | while (true) { continue; }
|
| 609 | continueStmt()
|
| 610 | matches 'continue'
|
| 611 | </pre></td></tr>
|
| 612 |
|
| 613 |
|
| 614 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('declRefExpr0')"><a name="declRefExpr0Anchor">declRefExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>...</td></tr>
|
| 615 | <tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations.
|
| 616 |
|
| 617 | Example matches x in if (x)
|
| 618 | bool x;
|
| 619 | if (x) {}
|
| 620 | </pre></td></tr>
|
| 621 |
|
| 622 |
|
| 623 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('declStmt0')"><a name="declStmt0Anchor">declStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>>...</td></tr>
|
| 624 | <tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements.
|
| 625 |
|
| 626 | Given
|
| 627 | int a;
|
| 628 | declStmt()
|
| 629 | matches 'int a'.
|
| 630 | </pre></td></tr>
|
| 631 |
|
| 632 |
|
| 633 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('defaultArgExpr0')"><a name="defaultArgExpr0Anchor">defaultArgExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>>...</td></tr>
|
| 634 | <tr><td colspan="4" class="doc" id="defaultArgExpr0"><pre>Matches the value of a default argument at the call site.
|
| 635 |
|
| 636 | Example matches the CXXDefaultArgExpr placeholder inserted for the
|
| 637 | default value of the second parameter in the call expression f(42)
|
| 638 | (matcher = defaultArgExpr())
|
| 639 | void f(int x, int y = 0);
|
| 640 | f(42);
|
| 641 | </pre></td></tr>
|
| 642 |
|
| 643 |
|
| 644 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('defaultStmt0')"><a name="defaultStmt0Anchor">defaultStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DefaultStmt.html">DefaultStmt</a>>...</td></tr>
|
| 645 | <tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements.
|
| 646 |
|
| 647 | Given
|
| 648 | switch(a) { case 42: break; default: break; }
|
| 649 | defaultStmt()
|
| 650 | matches 'default: break;'.
|
| 651 | </pre></td></tr>
|
| 652 |
|
| 653 |
|
| 654 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('deleteExpr0')"><a name="deleteExpr0Anchor">deleteExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>>...</td></tr>
|
| 655 | <tr><td colspan="4" class="doc" id="deleteExpr0"><pre>Matches delete expressions.
|
| 656 |
|
| 657 | Given
|
| 658 | delete X;
|
| 659 | deleteExpr()
|
| 660 | matches 'delete X'.
|
| 661 | </pre></td></tr>
|
| 662 |
|
| 663 |
|
| 664 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('doStmt0')"><a name="doStmt0Anchor">doStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>>...</td></tr>
|
| 665 | <tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements.
|
| 666 |
|
| 667 | Given
|
| 668 | do {} while (true);
|
| 669 | doStmt()
|
| 670 | matches 'do {} while(true)'
|
| 671 | </pre></td></tr>
|
| 672 |
|
| 673 |
|
| 674 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('dynamicCastExpr0')"><a name="dynamicCastExpr0Anchor">dynamicCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>>...</td></tr>
|
| 675 | <tr><td colspan="4" class="doc" id="dynamicCastExpr0"><pre>Matches a dynamic_cast expression.
|
| 676 |
|
| 677 | Example:
|
| 678 | dynamicCastExpr()
|
| 679 | matches
|
| 680 | dynamic_cast<D*>(&b);
|
| 681 | in
|
| 682 | struct B { virtual ~B() {} }; struct D : B {};
|
| 683 | B b;
|
| 684 | D* p = dynamic_cast<D*>(&b);
|
| 685 | </pre></td></tr>
|
| 686 |
|
| 687 |
|
| 688 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('explicitCastExpr0')"><a name="explicitCastExpr0Anchor">explicitCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>...</td></tr>
|
| 689 | <tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions.
|
| 690 |
|
| 691 | Matches any cast expression written in user code, whether it be a
|
| 692 | C-style cast, a functional-style cast, or a keyword cast.
|
| 693 |
|
| 694 | Does not match implicit conversions.
|
| 695 |
|
| 696 | Note: the name "explicitCast" is chosen to match Clang's terminology, as
|
| 697 | Clang uses the term "cast" to apply to implicit conversions as well as to
|
| 698 | actual cast expressions.
|
| 699 |
|
| 700 | hasDestinationType.
|
| 701 |
|
| 702 | Example: matches all five of the casts in
|
| 703 | int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42)))))
|
| 704 | but does not match the implicit conversion in
|
| 705 | long ell = 42;
|
| 706 | </pre></td></tr>
|
| 707 |
|
| 708 |
|
| 709 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('expr0')"><a name="expr0Anchor">expr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>...</td></tr>
|
| 710 | <tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions.
|
| 711 |
|
| 712 | Example matches x()
|
| 713 | void f() { x(); }
|
| 714 | </pre></td></tr>
|
| 715 |
|
| 716 |
|
| 717 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('exprWithCleanups0')"><a name="exprWithCleanups0Anchor">exprWithCleanups</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ExprWithCleanups.html">ExprWithCleanups</a>>...</td></tr>
|
| 718 | <tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end
|
| 719 | of the sub-expression's evaluation.
|
| 720 |
|
| 721 | Example matches std::string()
|
| 722 | const std::string str = std::string();
|
| 723 | </pre></td></tr>
|
| 724 |
|
| 725 |
|
| 726 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('floatLiteral0')"><a name="floatLiteral0Anchor">floatLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>...</td></tr>
|
| 727 | <tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g.
|
| 728 | 1.0, 1.0f, 1.0L and 1e10.
|
| 729 |
|
| 730 | Does not match implicit conversions such as
|
| 731 | float a = 10;
|
| 732 | </pre></td></tr>
|
| 733 |
|
| 734 |
|
| 735 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('forRangeStmt0')"><a name="forRangeStmt0Anchor">forRangeStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>>...</td></tr>
|
| 736 | <tr><td colspan="4" class="doc" id="forRangeStmt0"><pre>Matches range-based for statements.
|
| 737 |
|
| 738 | forRangeStmt() matches 'for (auto a : i)'
|
| 739 | int i[] = {1, 2, 3}; for (auto a : i);
|
| 740 | for(int j = 0; j < 5; ++j);
|
| 741 | </pre></td></tr>
|
| 742 |
|
| 743 |
|
| 744 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('forStmt0')"><a name="forStmt0Anchor">forStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>>...</td></tr>
|
| 745 | <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements.
|
| 746 |
|
| 747 | Example matches 'for (;;) {}'
|
| 748 | for (;;) {}
|
| 749 | int i[] = {1, 2, 3}; for (auto a : i);
|
| 750 | </pre></td></tr>
|
| 751 |
|
| 752 |
|
| 753 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('functionalCastExpr0')"><a name="functionalCastExpr0Anchor">functionalCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>...</td></tr>
|
| 754 | <tr><td colspan="4" class="doc" id="functionalCastExpr0"><pre>Matches functional cast expressions
|
| 755 |
|
| 756 | Example: Matches Foo(bar);
|
| 757 | Foo f = bar;
|
| 758 | Foo g = (Foo) bar;
|
| 759 | Foo h = Foo(bar);
|
| 760 | </pre></td></tr>
|
| 761 |
|
| 762 |
|
| 763 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('gnuNullExpr0')"><a name="gnuNullExpr0Anchor">gnuNullExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1GNUNullExpr.html">GNUNullExpr</a>>...</td></tr>
|
| 764 | <tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression.
|
| 765 | </pre></td></tr>
|
| 766 |
|
| 767 |
|
| 768 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('gotoStmt0')"><a name="gotoStmt0Anchor">gotoStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1GotoStmt.html">GotoStmt</a>>...</td></tr>
|
| 769 | <tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements.
|
| 770 |
|
| 771 | Given
|
| 772 | goto FOO;
|
| 773 | FOO: bar();
|
| 774 | gotoStmt()
|
| 775 | matches 'goto FOO'
|
| 776 | </pre></td></tr>
|
| 777 |
|
| 778 |
|
| 779 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('ifStmt0')"><a name="ifStmt0Anchor">ifStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>>...</td></tr>
|
| 780 | <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements.
|
| 781 |
|
| 782 | Example matches 'if (x) {}'
|
| 783 | if (x) {}
|
| 784 | </pre></td></tr>
|
| 785 |
|
| 786 |
|
| 787 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('implicitCastExpr0')"><a name="implicitCastExpr0Anchor">implicitCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr</a>>...</td></tr>
|
| 788 | <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
|
| 789 |
|
| 790 | This matches many different places, including function call return value
|
| 791 | eliding, as well as any type conversions.
|
| 792 | </pre></td></tr>
|
| 793 |
|
| 794 |
|
| 795 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('initListExpr0')"><a name="initListExpr0Anchor">initListExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>>...</td></tr>
|
| 796 | <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions.
|
| 797 |
|
| 798 | Given
|
| 799 | int a[] = { 1, 2 };
|
| 800 | struct B { int x, y; };
|
| 801 | B b = { 5, 6 };
|
| 802 | initListExpr()
|
| 803 | matches "{ 1, 2 }" and "{ 5, 6 }"
|
| 804 | </pre></td></tr>
|
| 805 |
|
| 806 |
|
| 807 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('integerLiteral0')"><a name="integerLiteral0Anchor">integerLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>...</td></tr>
|
| 808 | <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g.
|
| 809 | 1, 1L, 0x1 and 1U.
|
| 810 |
|
| 811 | Does not match character-encoded integers such as L'a'.
|
| 812 | </pre></td></tr>
|
| 813 |
|
| 814 |
|
| 815 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('labelStmt0')"><a name="labelStmt0Anchor">labelStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>...</td></tr>
|
| 816 | <tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements.
|
| 817 |
|
| 818 | Given
|
| 819 | goto FOO;
|
| 820 | FOO: bar();
|
| 821 | labelStmt()
|
| 822 | matches 'FOO:'
|
| 823 | </pre></td></tr>
|
| 824 |
|
| 825 |
|
| 826 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('lambdaExpr0')"><a name="lambdaExpr0Anchor">lambdaExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>>...</td></tr>
|
| 827 | <tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions.
|
| 828 |
|
| 829 | Example matches [&](){return 5;}
|
| 830 | [&](){return 5;}
|
| 831 | </pre></td></tr>
|
| 832 |
|
| 833 |
|
| 834 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('materializeTemporaryExpr0')"><a name="materializeTemporaryExpr0Anchor">materializeTemporaryExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MaterializeTemporaryExpr.html">MaterializeTemporaryExpr</a>>...</td></tr>
|
| 835 | <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
|
| 836 |
|
| 837 | Example: Given
|
| 838 | struct T {void func()};
|
| 839 | T f();
|
| 840 | void g(T);
|
| 841 | materializeTemporaryExpr() matches 'f()' in these statements
|
| 842 | T u(f());
|
| 843 | g(f());
|
| 844 | but does not match
|
| 845 | f();
|
| 846 | f().func();
|
| 847 | </pre></td></tr>
|
| 848 |
|
| 849 |
|
| 850 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('memberCallExpr0')"><a name="memberCallExpr0Anchor">memberCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>>...</td></tr>
|
| 851 | <tr><td colspan="4" class="doc" id="memberCallExpr0"><pre>Matches member call expressions.
|
| 852 |
|
| 853 | Example matches x.y()
|
| 854 | X x;
|
| 855 | x.y();
|
| 856 | </pre></td></tr>
|
| 857 |
|
| 858 |
|
| 859 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('memberExpr0')"><a name="memberExpr0Anchor">memberExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>...</td></tr>
|
| 860 | <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions.
|
| 861 |
|
| 862 | Given
|
| 863 | class Y {
|
| 864 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
|
| 865 | int a; static int b;
|
| 866 | };
|
| 867 | memberExpr()
|
| 868 | matches this->x, x, y.x, a, this->b
|
| 869 | </pre></td></tr>
|
| 870 |
|
| 871 |
|
| 872 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('newExpr0')"><a name="newExpr0Anchor">newExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>...</td></tr>
|
| 873 | <tr><td colspan="4" class="doc" id="newExpr0"><pre>Matches new expressions.
|
| 874 |
|
| 875 | Given
|
| 876 | new X;
|
| 877 | newExpr()
|
| 878 | matches 'new X'.
|
| 879 | </pre></td></tr>
|
| 880 |
|
| 881 |
|
| 882 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('nullPtrLiteralExpr0')"><a name="nullPtrLiteralExpr0Anchor">nullPtrLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>>...</td></tr>
|
| 883 | <tr><td colspan="4" class="doc" id="nullPtrLiteralExpr0"><pre>Matches nullptr literal.
|
| 884 | </pre></td></tr>
|
| 885 |
|
| 886 |
|
| 887 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('nullStmt0')"><a name="nullStmt0Anchor">nullStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NullStmt.html">NullStmt</a>>...</td></tr>
|
| 888 | <tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements.
|
| 889 |
|
| 890 | foo();;
|
| 891 | nullStmt()
|
| 892 | matches the second ';'
|
| 893 | </pre></td></tr>
|
| 894 |
|
| 895 |
|
| 896 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcMessageExpr0')"><a name="objcMessageExpr0Anchor">objcMessageExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>>...</td></tr>
|
| 897 | <tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions.
|
| 898 |
|
| 899 | The innermost message send invokes the "alloc" class method on the
|
| 900 | NSString class, while the outermost message send invokes the
|
| 901 | "initWithString" instance method on the object returned from
|
| 902 | NSString's "alloc". This matcher should match both message sends.
|
| 903 | [[NSString alloc] initWithString:@"Hello"]
|
| 904 | </pre></td></tr>
|
| 905 |
|
| 906 |
|
| 907 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('operatorCallExpr0')"><a name="operatorCallExpr0Anchor">operatorCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>...</td></tr>
|
| 908 | <tr><td colspan="4" class="doc" id="operatorCallExpr0"><pre>Matches overloaded operator calls.
|
| 909 |
|
| 910 | Note that if an operator isn't overloaded, it won't match. Instead, use
|
| 911 | binaryOperator matcher.
|
| 912 | Currently it does not match operators such as new delete.
|
| 913 | FIXME: figure out why these do not match?
|
| 914 |
|
| 915 | Example matches both operator<<((o << b), c) and operator<<(o, b)
|
| 916 | (matcher = operatorCallExpr())
|
| 917 | ostream &operator<< (ostream &out, int i) { };
|
| 918 | ostream &o; int b = 1, c = 1;
|
| 919 | o << b << c;
|
| 920 | </pre></td></tr>
|
| 921 |
|
| 922 |
|
| 923 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('reinterpretCastExpr0')"><a name="reinterpretCastExpr0Anchor">reinterpretCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>>...</td></tr>
|
| 924 | <tr><td colspan="4" class="doc" id="reinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
|
| 925 |
|
| 926 | Either the source expression or the destination type can be matched
|
| 927 | using has(), but hasDestinationType() is more specific and can be
|
| 928 | more readable.
|
| 929 |
|
| 930 | Example matches reinterpret_cast<char*>(&p) in
|
| 931 | void* p = reinterpret_cast<char*>(&p);
|
| 932 | </pre></td></tr>
|
| 933 |
|
| 934 |
|
| 935 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('returnStmt0')"><a name="returnStmt0Anchor">returnStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>>...</td></tr>
|
| 936 | <tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements.
|
| 937 |
|
| 938 | Given
|
| 939 | return 1;
|
| 940 | returnStmt()
|
| 941 | matches 'return 1'
|
| 942 | </pre></td></tr>
|
| 943 |
|
| 944 |
|
| 945 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('staticCastExpr0')"><a name="staticCastExpr0Anchor">staticCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>>...</td></tr>
|
| 946 | <tr><td colspan="4" class="doc" id="staticCastExpr0"><pre>Matches a C++ static_cast expression.
|
| 947 |
|
| 948 | hasDestinationType
|
| 949 | reinterpretCast
|
| 950 |
|
| 951 | Example:
|
| 952 | staticCastExpr()
|
| 953 | matches
|
| 954 | static_cast<long>(8)
|
| 955 | in
|
| 956 | long eight(static_cast<long>(8));
|
| 957 | </pre></td></tr>
|
| 958 |
|
| 959 |
|
| 960 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('stmt0')"><a name="stmt0Anchor">stmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>...</td></tr>
|
| 961 | <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements.
|
| 962 |
|
| 963 | Given
|
| 964 | { ++a; }
|
| 965 | stmt()
|
| 966 | matches both the compound statement '{ ++a; }' and '++a'.
|
| 967 | </pre></td></tr>
|
| 968 |
|
| 969 |
|
| 970 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('stringLiteral0')"><a name="stringLiteral0Anchor">stringLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>>...</td></tr>
|
| 971 | <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals).
|
| 972 |
|
| 973 | Example matches "abcd", L"abcd"
|
| 974 | char *s = "abcd"; wchar_t *ws = L"abcd"
|
| 975 | </pre></td></tr>
|
| 976 |
|
| 977 |
|
| 978 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('substNonTypeTemplateParmExpr0')"><a name="substNonTypeTemplateParmExpr0Anchor">substNonTypeTemplateParmExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstNonTypeTemplateParmExpr.html">SubstNonTypeTemplateParmExpr</a>>...</td></tr>
|
| 979 | <tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters.
|
| 980 |
|
| 981 | Given
|
| 982 | template <int N>
|
| 983 | struct A { static const int n = N; };
|
| 984 | struct B : public A<42> {};
|
| 985 | substNonTypeTemplateParmExpr()
|
| 986 | matches "N" in the right-hand side of "static const int n = N;"
|
| 987 | </pre></td></tr>
|
| 988 |
|
| 989 |
|
| 990 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('switchCase0')"><a name="switchCase0Anchor">switchCase</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>>...</td></tr>
|
| 991 | <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements.
|
| 992 |
|
| 993 | Given
|
| 994 | switch(a) { case 42: break; default: break; }
|
| 995 | switchCase()
|
| 996 | matches 'case 42: break;' and 'default: break;'.
|
| 997 | </pre></td></tr>
|
| 998 |
|
| 999 |
|
| 1000 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('switchStmt0')"><a name="switchStmt0Anchor">switchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>>...</td></tr>
|
| 1001 | <tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements.
|
| 1002 |
|
| 1003 | Given
|
| 1004 | switch(a) { case 42: break; default: break; }
|
| 1005 | switchStmt()
|
| 1006 | matches 'switch(a)'.
|
| 1007 | </pre></td></tr>
|
| 1008 |
|
| 1009 |
|
| 1010 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('temporaryObjectExpr0')"><a name="temporaryObjectExpr0Anchor">temporaryObjectExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>...</td></tr>
|
| 1011 | <tr><td colspan="4" class="doc" id="temporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments
|
| 1012 |
|
| 1013 | Example: Matches Foo(bar, bar)
|
| 1014 | Foo h = Foo(bar, bar);
|
| 1015 | </pre></td></tr>
|
| 1016 |
|
| 1017 |
|
| 1018 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('thisExpr0')"><a name="thisExpr0Anchor">thisExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>>...</td></tr>
|
| 1019 | <tr><td colspan="4" class="doc" id="thisExpr0"><pre>Matches implicit and explicit this expressions.
|
| 1020 |
|
| 1021 | Example matches the implicit this expression in "return i".
|
| 1022 | (matcher = thisExpr())
|
| 1023 | struct foo {
|
| 1024 | int i;
|
| 1025 | int f() { return i; }
|
| 1026 | };
|
| 1027 | </pre></td></tr>
|
| 1028 |
|
| 1029 |
|
| 1030 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('throwExpr0')"><a name="throwExpr0Anchor">throwExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>>...</td></tr>
|
| 1031 | <tr><td colspan="4" class="doc" id="throwExpr0"><pre>Matches throw expressions.
|
| 1032 |
|
| 1033 | try { throw 5; } catch(int i) {}
|
| 1034 | throwExpr()
|
| 1035 | matches 'throw 5'
|
| 1036 | </pre></td></tr>
|
| 1037 |
|
| 1038 |
|
| 1039 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('tryStmt0')"><a name="tryStmt0Anchor">tryStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>>...</td></tr>
|
| 1040 | <tr><td colspan="4" class="doc" id="tryStmt0"><pre>Matches try statements.
|
| 1041 |
|
| 1042 | try {} catch(int i) {}
|
| 1043 | tryStmt()
|
| 1044 | matches 'try {}'
|
| 1045 | </pre></td></tr>
|
| 1046 |
|
| 1047 |
|
| 1048 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unaryExprOrTypeTraitExpr0')"><a name="unaryExprOrTypeTraitExpr0Anchor">unaryExprOrTypeTraitExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>>...</td></tr>
|
| 1049 | <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
|
| 1050 |
|
| 1051 | Given
|
| 1052 | Foo x = bar;
|
| 1053 | int y = sizeof(x) + alignof(x);
|
| 1054 | unaryExprOrTypeTraitExpr()
|
| 1055 | matches sizeof(x) and alignof(x)
|
| 1056 | </pre></td></tr>
|
| 1057 |
|
| 1058 |
|
| 1059 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unaryOperator0')"><a name="unaryOperator0Anchor">unaryOperator</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>>...</td></tr>
|
| 1060 | <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions.
|
| 1061 |
|
| 1062 | Example matches !a
|
| 1063 | !a || b
|
| 1064 | </pre></td></tr>
|
| 1065 |
|
| 1066 |
|
| 1067 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unresolvedConstructExpr0')"><a name="unresolvedConstructExpr0Anchor">unresolvedConstructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>...</td></tr>
|
| 1068 | <tr><td colspan="4" class="doc" id="unresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions.
|
| 1069 |
|
| 1070 | Example matches T(t) in return statement of f
|
| 1071 | (matcher = unresolvedConstructExpr())
|
| 1072 | template <typename T>
|
| 1073 | void f(const T& t) { return T(t); }
|
| 1074 | </pre></td></tr>
|
| 1075 |
|
| 1076 |
|
| 1077 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('userDefinedLiteral0')"><a name="userDefinedLiteral0Anchor">userDefinedLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UserDefinedLiteral.html">UserDefinedLiteral</a>>...</td></tr>
|
| 1078 | <tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
|
| 1079 |
|
| 1080 | Example match: "foo"_suffix
|
| 1081 | </pre></td></tr>
|
| 1082 |
|
| 1083 |
|
| 1084 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('whileStmt0')"><a name="whileStmt0Anchor">whileStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>>...</td></tr>
|
| 1085 | <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements.
|
| 1086 |
|
| 1087 | Given
|
| 1088 | while (true) {}
|
| 1089 | whileStmt()
|
| 1090 | matches 'while (true) {}'.
|
| 1091 | </pre></td></tr>
|
| 1092 |
|
| 1093 |
|
| 1094 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('templateArgument0')"><a name="templateArgument0Anchor">templateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>>...</td></tr>
|
| 1095 | <tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments.
|
| 1096 |
|
| 1097 | Given
|
| 1098 | template <typename T> struct C {};
|
| 1099 | C<int> c;
|
| 1100 | templateArgument()
|
| 1101 | matches 'int' in C<int>.
|
| 1102 | </pre></td></tr>
|
| 1103 |
|
| 1104 |
|
| 1105 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('typeLoc0')"><a name="typeLoc0Anchor">typeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>...</td></tr>
|
| 1106 | <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST.
|
| 1107 | </pre></td></tr>
|
| 1108 |
|
| 1109 |
|
| 1110 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('arrayType0')"><a name="arrayType0Anchor">arrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>...</td></tr>
|
| 1111 | <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays.
|
| 1112 |
|
| 1113 | Given
|
| 1114 | int a[] = { 2, 3 };
|
| 1115 | int b[4];
|
| 1116 | void f() { int c[a[0]]; }
|
| 1117 | arrayType()
|
| 1118 | matches "int a[]", "int b[4]" and "int c[a[0]]";
|
| 1119 | </pre></td></tr>
|
| 1120 |
|
| 1121 |
|
| 1122 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('atomicType0')"><a name="atomicType0Anchor">atomicType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>>...</td></tr>
|
| 1123 | <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types.
|
| 1124 |
|
| 1125 | Given
|
| 1126 | _Atomic(int) i;
|
| 1127 | atomicType()
|
| 1128 | matches "_Atomic(int) i"
|
| 1129 | </pre></td></tr>
|
| 1130 |
|
| 1131 |
|
| 1132 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('autoType0')"><a name="autoType0Anchor">autoType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>>...</td></tr>
|
| 1133 | <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types.
|
| 1134 |
|
| 1135 | Given:
|
| 1136 | auto n = 4;
|
| 1137 | int v[] = { 2, 3 }
|
| 1138 | for (auto i : v) { }
|
| 1139 | autoType()
|
| 1140 | matches "auto n" and "auto i"
|
| 1141 | </pre></td></tr>
|
| 1142 |
|
| 1143 |
|
| 1144 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('blockPointerType0')"><a name="blockPointerType0Anchor">blockPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>...</td></tr>
|
| 1145 | <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
|
| 1146 | "void (^)(int)".
|
| 1147 |
|
| 1148 | The pointee is always required to be a FunctionType.
|
| 1149 | </pre></td></tr>
|
| 1150 |
|
| 1151 |
|
| 1152 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('builtinType0')"><a name="builtinType0Anchor">builtinType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BuiltinType.html">BuiltinType</a>>...</td></tr>
|
| 1153 | <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types.
|
| 1154 |
|
| 1155 | Given
|
| 1156 | struct A {};
|
| 1157 | A a;
|
| 1158 | int b;
|
| 1159 | float c;
|
| 1160 | bool d;
|
| 1161 | builtinType()
|
| 1162 | matches "int b", "float c" and "bool d"
|
| 1163 | </pre></td></tr>
|
| 1164 |
|
| 1165 |
|
| 1166 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('complexType0')"><a name="complexType0Anchor">complexType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>>...</td></tr>
|
| 1167 | <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types.
|
| 1168 |
|
| 1169 | Given
|
| 1170 | _Complex float f;
|
| 1171 | complexType()
|
| 1172 | matches "_Complex float f"
|
| 1173 | </pre></td></tr>
|
| 1174 |
|
| 1175 |
|
| 1176 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('constantArrayType0')"><a name="constantArrayType0Anchor">constantArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>>...</td></tr>
|
| 1177 | <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size.
|
| 1178 |
|
| 1179 | Given
|
| 1180 | void() {
|
| 1181 | int a[2];
|
| 1182 | int b[] = { 2, 3 };
|
| 1183 | int c[b[0]];
|
| 1184 | }
|
| 1185 | constantArrayType()
|
| 1186 | matches "int a[2]"
|
| 1187 | </pre></td></tr>
|
| 1188 |
|
| 1189 |
|
| 1190 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('dependentSizedArrayType0')"><a name="dependentSizedArrayType0Anchor">dependentSizedArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html">DependentSizedArrayType</a>>...</td></tr>
|
| 1191 | <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
|
| 1192 |
|
| 1193 | Given
|
| 1194 | template<typename T, int Size>
|
| 1195 | class array {
|
| 1196 | T data[Size];
|
| 1197 | };
|
| 1198 | dependentSizedArrayType
|
| 1199 | matches "T data[Size]"
|
| 1200 | </pre></td></tr>
|
| 1201 |
|
| 1202 |
|
| 1203 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('elaboratedType0')"><a name="elaboratedType0Anchor">elaboratedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>>...</td></tr>
|
| 1204 | <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a
|
| 1205 | qualified name.
|
| 1206 |
|
| 1207 | Given
|
| 1208 | namespace N {
|
| 1209 | namespace M {
|
| 1210 | class D {};
|
| 1211 | }
|
| 1212 | }
|
| 1213 | class C {};
|
| 1214 |
|
| 1215 | class C c;
|
| 1216 | N::M::D d;
|
| 1217 |
|
| 1218 | elaboratedType() matches the type of the variable declarations of both
|
| 1219 | c and d.
|
| 1220 | </pre></td></tr>
|
| 1221 |
|
| 1222 |
|
| 1223 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('functionType0')"><a name="functionType0Anchor">functionType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionType.html">FunctionType</a>>...</td></tr>
|
| 1224 | <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes.
|
| 1225 |
|
| 1226 | Given
|
| 1227 | int (*f)(int);
|
| 1228 | void g();
|
| 1229 | functionType()
|
| 1230 | matches "int (*f)(int)" and the type of "g".
|
| 1231 | </pre></td></tr>
|
| 1232 |
|
| 1233 |
|
| 1234 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('incompleteArrayType0')"><a name="incompleteArrayType0Anchor">incompleteArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IncompleteArrayType.html">IncompleteArrayType</a>>...</td></tr>
|
| 1235 | <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size.
|
| 1236 |
|
| 1237 | Given
|
| 1238 | int a[] = { 2, 3 };
|
| 1239 | int b[42];
|
| 1240 | void f(int c[]) { int d[a[0]]; };
|
| 1241 | incompleteArrayType()
|
| 1242 | matches "int a[]" and "int c[]"
|
| 1243 | </pre></td></tr>
|
| 1244 |
|
| 1245 |
|
| 1246 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('lValueReferenceType0')"><a name="lValueReferenceType0Anchor">lValueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType</a>>...</td></tr>
|
| 1247 | <tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types.
|
| 1248 |
|
| 1249 | Given:
|
| 1250 | int *a;
|
| 1251 | int &b = *a;
|
| 1252 | int &&c = 1;
|
| 1253 | auto &d = b;
|
| 1254 | auto &&e = c;
|
| 1255 | auto &&f = 2;
|
| 1256 | int g = 5;
|
| 1257 |
|
| 1258 | lValueReferenceType() matches the types of b, d, and e. e is
|
| 1259 | matched since the type is deduced as int& by reference collapsing rules.
|
| 1260 | </pre></td></tr>
|
| 1261 |
|
| 1262 |
|
| 1263 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('memberPointerType0')"><a name="memberPointerType0Anchor">memberPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>...</td></tr>
|
| 1264 | <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types.
|
| 1265 | Given
|
| 1266 | struct A { int i; }
|
| 1267 | A::* ptr = A::i;
|
| 1268 | memberPointerType()
|
| 1269 | matches "A::* ptr"
|
| 1270 | </pre></td></tr>
|
| 1271 |
|
| 1272 |
|
| 1273 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('parenType0')"><a name="parenType0Anchor">parenType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>>...</td></tr>
|
| 1274 | <tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes.
|
| 1275 |
|
| 1276 | Given
|
| 1277 | int (*ptr_to_array)[4];
|
| 1278 | int *array_of_ptrs[4];
|
| 1279 |
|
| 1280 | varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not
|
| 1281 | array_of_ptrs.
|
| 1282 | </pre></td></tr>
|
| 1283 |
|
| 1284 |
|
| 1285 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('pointerType0')"><a name="pointerType0Anchor">pointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>...</td></tr>
|
| 1286 | <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types.
|
| 1287 |
|
| 1288 | Given
|
| 1289 | int *a;
|
| 1290 | int &b = *a;
|
| 1291 | int c = 5;
|
| 1292 | pointerType()
|
| 1293 | matches "int *a"
|
| 1294 | </pre></td></tr>
|
| 1295 |
|
| 1296 |
|
| 1297 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('rValueReferenceType0')"><a name="rValueReferenceType0Anchor">rValueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType</a>>...</td></tr>
|
| 1298 | <tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types.
|
| 1299 |
|
| 1300 | Given:
|
| 1301 | int *a;
|
| 1302 | int &b = *a;
|
| 1303 | int &&c = 1;
|
| 1304 | auto &d = b;
|
| 1305 | auto &&e = c;
|
| 1306 | auto &&f = 2;
|
| 1307 | int g = 5;
|
| 1308 |
|
| 1309 | rValueReferenceType() matches the types of c and f. e is not
|
| 1310 | matched as it is deduced to int& by reference collapsing rules.
|
| 1311 | </pre></td></tr>
|
| 1312 |
|
| 1313 |
|
| 1314 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('recordType0')"><a name="recordType0Anchor">recordType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>...</td></tr>
|
| 1315 | <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes).
|
| 1316 |
|
| 1317 | Given
|
| 1318 | class C {};
|
| 1319 | struct S {};
|
| 1320 |
|
| 1321 | C c;
|
| 1322 | S s;
|
| 1323 |
|
| 1324 | recordType() matches the type of the variable declarations of both c
|
| 1325 | and s.
|
| 1326 | </pre></td></tr>
|
| 1327 |
|
| 1328 |
|
| 1329 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('referenceType0')"><a name="referenceType0Anchor">referenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>...</td></tr>
|
| 1330 | <tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types.
|
| 1331 |
|
| 1332 | Given
|
| 1333 | int *a;
|
| 1334 | int &b = *a;
|
| 1335 | int &&c = 1;
|
| 1336 | auto &d = b;
|
| 1337 | auto &&e = c;
|
| 1338 | auto &&f = 2;
|
| 1339 | int g = 5;
|
| 1340 |
|
| 1341 | referenceType() matches the types of b, c, d, e, and f.
|
| 1342 | </pre></td></tr>
|
| 1343 |
|
| 1344 |
|
| 1345 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('templateSpecializationType0')"><a name="templateSpecializationType0Anchor">templateSpecializationType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>...</td></tr>
|
| 1346 | <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types.
|
| 1347 |
|
| 1348 | Given
|
| 1349 | template <typename T>
|
| 1350 | class C { };
|
| 1351 |
|
| 1352 | template class C<int>; A
|
| 1353 | C<char> var; B
|
| 1354 |
|
| 1355 | templateSpecializationType() matches the type of the explicit
|
| 1356 | instantiation in A and the type of the variable declaration in B.
|
| 1357 | </pre></td></tr>
|
| 1358 |
|
| 1359 |
|
| 1360 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('type0')"><a name="type0Anchor">type</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>>...</td></tr>
|
| 1361 | <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST.
|
| 1362 | </pre></td></tr>
|
| 1363 |
|
| 1364 |
|
| 1365 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('typedefType0')"><a name="typedefType0Anchor">typedefType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>...</td></tr>
|
| 1366 | <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types.
|
| 1367 |
|
| 1368 | Given
|
| 1369 | typedef int X;
|
| 1370 | typedefType()
|
| 1371 | matches "typedef int X"
|
| 1372 | </pre></td></tr>
|
| 1373 |
|
| 1374 |
|
| 1375 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('unaryTransformType0')"><a name="unaryTransformType0Anchor">unaryTransformType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryTransformType.html">UnaryTransformType</a>>...</td></tr>
|
| 1376 | <tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations.
|
| 1377 |
|
| 1378 | Given:
|
| 1379 | typedef __underlying_type(T) type;
|
| 1380 | unaryTransformType()
|
| 1381 | matches "__underlying_type(T)"
|
| 1382 | </pre></td></tr>
|
| 1383 |
|
| 1384 |
|
| 1385 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('variableArrayType0')"><a name="variableArrayType0Anchor">variableArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html">VariableArrayType</a>>...</td></tr>
|
| 1386 | <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an
|
| 1387 | integer-constant-expression.
|
| 1388 |
|
| 1389 | Given
|
| 1390 | void f() {
|
| 1391 | int a[] = { 2, 3 }
|
| 1392 | int b[42];
|
| 1393 | int c[a[0]];
|
| 1394 | }
|
| 1395 | variableArrayType()
|
| 1396 | matches "int c[a[0]]"
|
| 1397 | </pre></td></tr>
|
| 1398 |
|
| 1399 | <!--END_DECL_MATCHERS -->
|
| 1400 | </table>
|
| 1401 |
|
| 1402 | <!-- ======================================================================= -->
|
| 1403 | <h2 id="narrowing-matchers">Narrowing Matchers</h2>
|
| 1404 | <!-- ======================================================================= -->
|
| 1405 |
|
| 1406 | <p>Narrowing matchers match certain attributes on the current node, thus
|
| 1407 | narrowing down the set of nodes of the current type to match on.</p>
|
| 1408 |
|
| 1409 | <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
|
| 1410 | which allow users to create more powerful match expressions.</p>
|
| 1411 |
|
| 1412 | <table>
|
| 1413 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
|
| 1414 | <!-- START_NARROWING_MATCHERS -->
|
| 1415 |
|
| 1416 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr>
|
| 1417 | <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match.
|
| 1418 |
|
| 1419 | Usable as: Any Matcher
|
| 1420 | </pre></td></tr>
|
| 1421 |
|
| 1422 |
|
| 1423 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr>
|
| 1424 | <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches.
|
| 1425 |
|
| 1426 | Usable as: Any Matcher
|
| 1427 | </pre></td></tr>
|
| 1428 |
|
| 1429 |
|
| 1430 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr>
|
| 1431 | <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node.
|
| 1432 |
|
| 1433 | Useful when another matcher requires a child matcher, but there's no
|
| 1434 | additional constraint. This will often be used with an explicit conversion
|
| 1435 | to an internal::Matcher<> type such as TypeMatcher.
|
| 1436 |
|
| 1437 | Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
|
| 1438 | "int* p" and "void f()" in
|
| 1439 | int* p;
|
| 1440 | void f();
|
| 1441 |
|
| 1442 | Usable as: Any Matcher
|
| 1443 | </pre></td></tr>
|
| 1444 |
|
| 1445 |
|
| 1446 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr>
|
| 1447 | <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match.
|
| 1448 |
|
| 1449 | Example matches Y (matcher = recordDecl(unless(hasName("X"))))
|
| 1450 | class X {};
|
| 1451 | class Y {};
|
| 1452 |
|
| 1453 | Usable as: Any Matcher
|
| 1454 | </pre></td></tr>
|
| 1455 |
|
| 1456 |
|
| 1457 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('hasOperatorName0')"><a name="hasOperatorName0Anchor">hasOperatorName</a></td><td>std::string Name</td></tr>
|
| 1458 | <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or
|
| 1459 | unary).
|
| 1460 |
|
| 1461 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
|
| 1462 | !(a || b)
|
| 1463 | </pre></td></tr>
|
| 1464 |
|
| 1465 |
|
| 1466 | <tr><td>Matcher<CXXBoolLiteral></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr>
|
| 1467 | <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value.
|
| 1468 |
|
| 1469 | Example matches true (matcher = boolLiteral(equals(true)))
|
| 1470 | true
|
| 1471 |
|
| 1472 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>,
|
| 1473 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>
|
| 1474 | </pre></td></tr>
|
| 1475 |
|
| 1476 |
|
| 1477 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>></td><td class="name" onclick="toggle('isCatchAll0')"><a name="isCatchAll0Anchor">isCatchAll</a></td><td></td></tr>
|
| 1478 | <tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler.
|
| 1479 |
|
| 1480 | Given
|
| 1481 | try {
|
| 1482 | ...
|
| 1483 | } catch (int) {
|
| 1484 | ...
|
| 1485 | } catch (...) {
|
| 1486 | ...
|
| 1487 | }
|
| 1488 | endcode
|
| 1489 | catchStmt(isCatchAll()) matches catch(...) but not catch(int).
|
| 1490 | </pre></td></tr>
|
| 1491 |
|
| 1492 |
|
| 1493 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('argumentCountIs1')"><a name="argumentCountIs1Anchor">argumentCountIs</a></td><td>unsigned N</td></tr>
|
| 1494 | <tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has
|
| 1495 | a specific number of arguments (including absent default arguments).
|
| 1496 |
|
| 1497 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
|
| 1498 | void f(int x, int y);
|
| 1499 | f(0, 0);
|
| 1500 | </pre></td></tr>
|
| 1501 |
|
| 1502 |
|
| 1503 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('isListInitialization0')"><a name="isListInitialization0Anchor">isListInitialization</a></td><td></td></tr>
|
| 1504 | <tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization.
|
| 1505 | </pre></td></tr>
|
| 1506 |
|
| 1507 |
|
| 1508 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isCopyConstructor0')"><a name="isCopyConstructor0Anchor">isCopyConstructor</a></td><td></td></tr>
|
| 1509 | <tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors.
|
| 1510 |
|
| 1511 | Given
|
| 1512 | struct S {
|
| 1513 | S(); #1
|
| 1514 | S(const S &); #2
|
| 1515 | S(S &&); #3
|
| 1516 | };
|
| 1517 | constructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
|
| 1518 | </pre></td></tr>
|
| 1519 |
|
| 1520 |
|
| 1521 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isDefaultConstructor0')"><a name="isDefaultConstructor0Anchor">isDefaultConstructor</a></td><td></td></tr>
|
| 1522 | <tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors.
|
| 1523 |
|
| 1524 | Given
|
| 1525 | struct S {
|
| 1526 | S(); #1
|
| 1527 | S(const S &); #2
|
| 1528 | S(S &&); #3
|
| 1529 | };
|
| 1530 | constructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
|
| 1531 | </pre></td></tr>
|
| 1532 |
|
| 1533 |
|
| 1534 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isExplicit0')"><a name="isExplicit0Anchor">isExplicit</a></td><td></td></tr>
|
| 1535 | <tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with
|
| 1536 | the explicit keyword.
|
| 1537 |
|
| 1538 | Given
|
| 1539 | struct S {
|
| 1540 | S(int); #1
|
| 1541 | explicit S(double); #2
|
| 1542 | operator int(); #3
|
| 1543 | explicit operator bool(); #4
|
| 1544 | };
|
| 1545 | constructorDecl(isExplicit()) will match #2, but not #1.
|
| 1546 | conversionDecl(isExplicit()) will match #4, but not #3.
|
| 1547 | </pre></td></tr>
|
| 1548 |
|
| 1549 |
|
| 1550 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isMoveConstructor0')"><a name="isMoveConstructor0Anchor">isMoveConstructor</a></td><td></td></tr>
|
| 1551 | <tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors.
|
| 1552 |
|
| 1553 | Given
|
| 1554 | struct S {
|
| 1555 | S(); #1
|
| 1556 | S(const S &); #2
|
| 1557 | S(S &&); #3
|
| 1558 | };
|
| 1559 | constructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
|
| 1560 | </pre></td></tr>
|
| 1561 |
|
| 1562 |
|
| 1563 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>></td><td class="name" onclick="toggle('isExplicit1')"><a name="isExplicit1Anchor">isExplicit</a></td><td></td></tr>
|
| 1564 | <tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with
|
| 1565 | the explicit keyword.
|
| 1566 |
|
| 1567 | Given
|
| 1568 | struct S {
|
| 1569 | S(int); #1
|
| 1570 | explicit S(double); #2
|
| 1571 | operator int(); #3
|
| 1572 | explicit operator bool(); #4
|
| 1573 | };
|
| 1574 | constructorDecl(isExplicit()) will match #2, but not #1.
|
| 1575 | conversionDecl(isExplicit()) will match #4, but not #3.
|
| 1576 | </pre></td></tr>
|
| 1577 |
|
| 1578 |
|
| 1579 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isBaseInitializer0')"><a name="isBaseInitializer0Anchor">isBaseInitializer</a></td><td></td></tr>
|
| 1580 | <tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as
|
| 1581 | opposed to a member.
|
| 1582 |
|
| 1583 | Given
|
| 1584 | struct B {};
|
| 1585 | struct D : B {
|
| 1586 | int I;
|
| 1587 | D(int i) : I(i) {}
|
| 1588 | };
|
| 1589 | struct E : B {
|
| 1590 | E() : B() {}
|
| 1591 | };
|
| 1592 | constructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
|
| 1593 | will match E(), but not match D(int).
|
| 1594 | </pre></td></tr>
|
| 1595 |
|
| 1596 |
|
| 1597 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isMemberInitializer0')"><a name="isMemberInitializer0Anchor">isMemberInitializer</a></td><td></td></tr>
|
| 1598 | <tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as
|
| 1599 | opposed to a base.
|
| 1600 |
|
| 1601 | Given
|
| 1602 | struct B {};
|
| 1603 | struct D : B {
|
| 1604 | int I;
|
| 1605 | D(int i) : I(i) {}
|
| 1606 | };
|
| 1607 | struct E : B {
|
| 1608 | E() : B() {}
|
| 1609 | };
|
| 1610 | constructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
|
| 1611 | will match D(int), but not match E().
|
| 1612 | </pre></td></tr>
|
| 1613 |
|
| 1614 |
|
| 1615 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isWritten0')"><a name="isWritten0Anchor">isWritten</a></td><td></td></tr>
|
| 1616 | <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in
|
| 1617 | code (as opposed to implicitly added by the compiler).
|
| 1618 |
|
| 1619 | Given
|
| 1620 | struct Foo {
|
| 1621 | Foo() { }
|
| 1622 | Foo(int) : foo_("A") { }
|
| 1623 | string foo_;
|
| 1624 | };
|
| 1625 | constructorDecl(hasAnyConstructorInitializer(isWritten()))
|
| 1626 | will match Foo(int), but not Foo()
|
| 1627 | </pre></td></tr>
|
| 1628 |
|
| 1629 |
|
| 1630 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isConst0')"><a name="isConst0Anchor">isConst</a></td><td></td></tr>
|
| 1631 | <tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const.
|
| 1632 |
|
| 1633 | Given
|
| 1634 | struct A {
|
| 1635 | void foo() const;
|
| 1636 | void bar();
|
| 1637 | };
|
| 1638 |
|
| 1639 | methodDecl(isConst()) matches A::foo() but not A::bar()
|
| 1640 | </pre></td></tr>
|
| 1641 |
|
| 1642 |
|
| 1643 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isFinal1')"><a name="isFinal1Anchor">isFinal</a></td><td></td></tr>
|
| 1644 | <tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final.
|
| 1645 |
|
| 1646 | Given:
|
| 1647 | class A final {};
|
| 1648 |
|
| 1649 | struct B {
|
| 1650 | virtual void f();
|
| 1651 | };
|
| 1652 |
|
| 1653 | struct C : B {
|
| 1654 | void f() final;
|
| 1655 | };
|
| 1656 | matches A and C::f, but not B, C, or B::f
|
| 1657 | </pre></td></tr>
|
| 1658 |
|
| 1659 |
|
| 1660 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isOverride0')"><a name="isOverride0Anchor">isOverride</a></td><td></td></tr>
|
| 1661 | <tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method.
|
| 1662 |
|
| 1663 | Given
|
| 1664 | class A {
|
| 1665 | public:
|
| 1666 | virtual void x();
|
| 1667 | };
|
| 1668 | class B : public A {
|
| 1669 | public:
|
| 1670 | virtual void x();
|
| 1671 | };
|
| 1672 | matches B::x
|
| 1673 | </pre></td></tr>
|
| 1674 |
|
| 1675 |
|
| 1676 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isPure0')"><a name="isPure0Anchor">isPure</a></td><td></td></tr>
|
| 1677 | <tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure.
|
| 1678 |
|
| 1679 | Given
|
| 1680 | class A {
|
| 1681 | public:
|
| 1682 | virtual void x() = 0;
|
| 1683 | };
|
| 1684 | matches A::x
|
| 1685 | </pre></td></tr>
|
| 1686 |
|
| 1687 |
|
| 1688 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isVirtual0')"><a name="isVirtual0Anchor">isVirtual</a></td><td></td></tr>
|
| 1689 | <tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual.
|
| 1690 |
|
| 1691 | Given
|
| 1692 | class A {
|
| 1693 | public:
|
| 1694 | virtual void x();
|
| 1695 | };
|
| 1696 | matches A::x
|
| 1697 | </pre></td></tr>
|
| 1698 |
|
| 1699 |
|
| 1700 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName1')"><a name="hasOverloadedOperatorName1Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr>
|
| 1701 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names.
|
| 1702 |
|
| 1703 | Matches overloaded operator names specified in strings without the
|
| 1704 | "operator" prefix: e.g. "<<".
|
| 1705 |
|
| 1706 | Given:
|
| 1707 | class A { int operator*(); };
|
| 1708 | const A &operator<<(const A &a, const A &b);
|
| 1709 | A a;
|
| 1710 | a << a; <-- This matches
|
| 1711 |
|
| 1712 | operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified
|
| 1713 | line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches
|
| 1714 | the declaration of A.
|
| 1715 |
|
| 1716 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>
|
| 1717 | </pre></td></tr>
|
| 1718 |
|
| 1719 |
|
| 1720 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isDerivedFrom1')"><a name="isDerivedFrom1Anchor">isDerivedFrom</a></td><td>std::string BaseName</td></tr>
|
| 1721 | <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
|
| 1722 | </pre></td></tr>
|
| 1723 |
|
| 1724 |
|
| 1725 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization2')"><a name="isExplicitTemplateSpecialization2Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr>
|
| 1726 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
|
| 1727 | static member variable template instantiations.
|
| 1728 |
|
| 1729 | Given
|
| 1730 | template<typename T> void A(T t) { }
|
| 1731 | template<> void A(int N) { }
|
| 1732 | functionDecl(isExplicitTemplateSpecialization())
|
| 1733 | matches the specialization A<int>().
|
| 1734 |
|
| 1735 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>
|
| 1736 | </pre></td></tr>
|
| 1737 |
|
| 1738 |
|
| 1739 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isFinal0')"><a name="isFinal0Anchor">isFinal</a></td><td></td></tr>
|
| 1740 | <tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final.
|
| 1741 |
|
| 1742 | Given:
|
| 1743 | class A final {};
|
| 1744 |
|
| 1745 | struct B {
|
| 1746 | virtual void f();
|
| 1747 | };
|
| 1748 |
|
| 1749 | struct C : B {
|
| 1750 | void f() final;
|
| 1751 | };
|
| 1752 | matches A and C::f, but not B, C, or B::f
|
| 1753 | </pre></td></tr>
|
| 1754 |
|
| 1755 |
|
| 1756 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isSameOrDerivedFrom1')"><a name="isSameOrDerivedFrom1Anchor">isSameOrDerivedFrom</a></td><td>std::string BaseName</td></tr>
|
| 1757 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for
|
| 1758 | isSameOrDerivedFrom(hasName(...)).
|
| 1759 | </pre></td></tr>
|
| 1760 |
|
| 1761 |
|
| 1762 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation2')"><a name="isTemplateInstantiation2Anchor">isTemplateInstantiation</a></td><td></td></tr>
|
| 1763 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
|
| 1764 | member variable template instantiations.
|
| 1765 |
|
| 1766 | Given
|
| 1767 | template <typename T> class X {}; class A {}; X<A> x;
|
| 1768 | or
|
| 1769 | template <typename T> class X {}; class A {}; template class X<A>;
|
| 1770 | recordDecl(hasName("::X"), isTemplateInstantiation())
|
| 1771 | matches the template instantiation of X<A>.
|
| 1772 |
|
| 1773 | But given
|
| 1774 | template <typename T> class X {}; class A {};
|
| 1775 | template <> class X<A> {}; X<A> x;
|
| 1776 | recordDecl(hasName("::X"), isTemplateInstantiation())
|
| 1777 | does not match, as X<A> is an explicit template specialization.
|
| 1778 |
|
| 1779 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>
|
| 1780 | </pre></td></tr>
|
| 1781 |
|
| 1782 |
|
| 1783 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('argumentCountIs0')"><a name="argumentCountIs0Anchor">argumentCountIs</a></td><td>unsigned N</td></tr>
|
| 1784 | <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
|
| 1785 | a specific number of arguments (including absent default arguments).
|
| 1786 |
|
| 1787 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
|
| 1788 | void f(int x, int y);
|
| 1789 | f(0, 0);
|
| 1790 | </pre></td></tr>
|
| 1791 |
|
| 1792 |
|
| 1793 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals3')"><a name="equals3Anchor">equals</a></td><td>ValueT Value</td></tr>
|
| 1794 | <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value.
|
| 1795 |
|
| 1796 | Example matches true (matcher = boolLiteral(equals(true)))
|
| 1797 | true
|
| 1798 |
|
| 1799 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>,
|
| 1800 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>
|
| 1801 | </pre></td></tr>
|
| 1802 |
|
| 1803 |
|
| 1804 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('templateArgumentCountIs0')"><a name="templateArgumentCountIs0Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr>
|
| 1805 | <tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N.
|
| 1806 |
|
| 1807 | Given
|
| 1808 | template<typename T> struct C {};
|
| 1809 | C<int> c;
|
| 1810 | classTemplateSpecializationDecl(templateArgumentCountIs(1))
|
| 1811 | matches C<int>.
|
| 1812 | </pre></td></tr>
|
| 1813 |
|
| 1814 |
|
| 1815 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>></td><td class="name" onclick="toggle('statementCountIs0')"><a name="statementCountIs0Anchor">statementCountIs</a></td><td>unsigned N</td></tr>
|
| 1816 | <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of
|
| 1817 | child statements.
|
| 1818 |
|
| 1819 | Example: Given
|
| 1820 | { for (;;) {} }
|
| 1821 | compoundStmt(statementCountIs(0)))
|
| 1822 | matches '{}'
|
| 1823 | but does not match the outer compound statement.
|
| 1824 | </pre></td></tr>
|
| 1825 |
|
| 1826 |
|
| 1827 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>></td><td class="name" onclick="toggle('hasSize0')"><a name="hasSize0Anchor">hasSize</a></td><td>unsigned N</td></tr>
|
| 1828 | <tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size.
|
| 1829 |
|
| 1830 | Given
|
| 1831 | int a[42];
|
| 1832 | int b[2 * 21];
|
| 1833 | int c[41], d[43];
|
| 1834 | constantArrayType(hasSize(42))
|
| 1835 | matches "int a[42]" and "int b[2 * 21]"
|
| 1836 | </pre></td></tr>
|
| 1837 |
|
| 1838 |
|
| 1839 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>></td><td class="name" onclick="toggle('declCountIs0')"><a name="declCountIs0Anchor">declCountIs</a></td><td>unsigned N</td></tr>
|
| 1840 | <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of
|
| 1841 | declarations.
|
| 1842 |
|
| 1843 | Example: Given
|
| 1844 | int a, b;
|
| 1845 | int c;
|
| 1846 | int d = 2, e;
|
| 1847 | declCountIs(2)
|
| 1848 | matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
|
| 1849 | </pre></td></tr>
|
| 1850 |
|
| 1851 |
|
| 1852 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('equalsBoundNode1')"><a name="equalsBoundNode1Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr>
|
| 1853 | <tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node.
|
| 1854 |
|
| 1855 | Matches a node if it equals the node previously bound to ID.
|
| 1856 |
|
| 1857 | Given
|
| 1858 | class X { int a; int b; };
|
| 1859 | recordDecl(
|
| 1860 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
|
| 1861 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
|
| 1862 | matches the class X, as a and b have the same type.
|
| 1863 |
|
| 1864 | Note that when multiple matches are involved via forEach* matchers,
|
| 1865 | equalsBoundNodes acts as a filter.
|
| 1866 | For example:
|
| 1867 | compoundStmt(
|
| 1868 | forEachDescendant(varDecl().bind("d")),
|
| 1869 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
|
| 1870 | will trigger a match for each combination of variable declaration
|
| 1871 | and reference to that variable declaration within a compound statement.
|
| 1872 | </pre></td></tr>
|
| 1873 |
|
| 1874 |
|
| 1875 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('hasAttr0')"><a name="hasAttr0Anchor">hasAttr</a></td><td>attr::Kind AttrKind</td></tr>
|
| 1876 | <tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute.
|
| 1877 |
|
| 1878 | Given
|
| 1879 | __attribute__((device)) void f() { ... }
|
| 1880 | decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
|
| 1881 | f. If the matcher is use from clang-query, attr::Kind parameter should be
|
| 1882 | passed as a quoted string. e.g., hasAttr("attr::CUDADevice").
|
| 1883 | </pre></td></tr>
|
| 1884 |
|
| 1885 |
|
| 1886 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching0')"><a name="isExpansionInFileMatching0Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr>
|
| 1887 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is
|
| 1888 | partially matching a given regex.
|
| 1889 |
|
| 1890 | Example matches Y but not X
|
| 1891 | (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
|
| 1892 | #include "ASTMatcher.h"
|
| 1893 | class X {};
|
| 1894 | ASTMatcher.h:
|
| 1895 | class Y {};
|
| 1896 |
|
| 1897 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>
|
| 1898 | </pre></td></tr>
|
| 1899 |
|
| 1900 |
|
| 1901 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInMainFile0')"><a name="isExpansionInMainFile0Anchor">isExpansionInMainFile</a></td><td></td></tr>
|
| 1902 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file.
|
| 1903 |
|
| 1904 | Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
|
| 1905 | #include <Y.h>
|
| 1906 | class X {};
|
| 1907 | Y.h:
|
| 1908 | class Y {};
|
| 1909 |
|
| 1910 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>
|
| 1911 | </pre></td></tr>
|
| 1912 |
|
| 1913 |
|
| 1914 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader0')"><a name="isExpansionInSystemHeader0Anchor">isExpansionInSystemHeader</a></td><td></td></tr>
|
| 1915 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files.
|
| 1916 |
|
| 1917 | Example matches Y but not X
|
| 1918 | (matcher = recordDecl(isExpansionInSystemHeader())
|
| 1919 | #include <SystemHeader.h>
|
| 1920 | class X {};
|
| 1921 | SystemHeader.h:
|
| 1922 | class Y {};
|
| 1923 |
|
| 1924 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>
|
| 1925 | </pre></td></tr>
|
| 1926 |
|
| 1927 |
|
| 1928 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr>
|
| 1929 | <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added
|
| 1930 | by the compiler (eg. implicit defaultcopy constructors).
|
| 1931 | </pre></td></tr>
|
| 1932 |
|
| 1933 |
|
| 1934 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isPrivate0')"><a name="isPrivate0Anchor">isPrivate</a></td><td></td></tr>
|
| 1935 | <tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations.
|
| 1936 |
|
| 1937 | Given
|
| 1938 | class C {
|
| 1939 | public: int a;
|
| 1940 | protected: int b;
|
| 1941 | private: int c;
|
| 1942 | };
|
| 1943 | fieldDecl(isPrivate())
|
| 1944 | matches 'int c;'
|
| 1945 | </pre></td></tr>
|
| 1946 |
|
| 1947 |
|
| 1948 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isProtected0')"><a name="isProtected0Anchor">isProtected</a></td><td></td></tr>
|
| 1949 | <tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations.
|
| 1950 |
|
| 1951 | Given
|
| 1952 | class C {
|
| 1953 | public: int a;
|
| 1954 | protected: int b;
|
| 1955 | private: int c;
|
| 1956 | };
|
| 1957 | fieldDecl(isProtected())
|
| 1958 | matches 'int b;'
|
| 1959 | </pre></td></tr>
|
| 1960 |
|
| 1961 |
|
| 1962 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isPublic0')"><a name="isPublic0Anchor">isPublic</a></td><td></td></tr>
|
| 1963 | <tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations.
|
| 1964 |
|
| 1965 | Given
|
| 1966 | class C {
|
| 1967 | public: int a;
|
| 1968 | protected: int b;
|
| 1969 | private: int c;
|
| 1970 | };
|
| 1971 | fieldDecl(isPublic())
|
| 1972 | matches 'int a;'
|
| 1973 | </pre></td></tr>
|
| 1974 |
|
| 1975 |
|
| 1976 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>></td><td class="name" onclick="toggle('equals1')"><a name="equals1Anchor">equals</a></td><td>ValueT Value</td></tr>
|
| 1977 | <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value.
|
| 1978 |
|
| 1979 | Example matches true (matcher = boolLiteral(equals(true)))
|
| 1980 | true
|
| 1981 |
|
| 1982 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>,
|
| 1983 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>
|
| 1984 | </pre></td></tr>
|
| 1985 |
|
| 1986 |
|
| 1987 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr>
|
| 1988 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
|
| 1989 |
|
| 1990 | Matches overloaded operator names specified in strings without the
|
| 1991 | "operator" prefix: e.g. "<<".
|
| 1992 |
|
| 1993 | Given:
|
| 1994 | class A { int operator*(); };
|
| 1995 | const A &operator<<(const A &a, const A &b);
|
| 1996 | A a;
|
| 1997 | a << a; <-- This matches
|
| 1998 |
|
| 1999 | operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified
|
| 2000 | line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches
|
| 2001 | the declaration of A.
|
| 2002 |
|
| 2003 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>
|
| 2004 | </pre></td></tr>
|
| 2005 |
|
| 2006 |
|
| 2007 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isConstexpr1')"><a name="isConstexpr1Anchor">isConstexpr</a></td><td></td></tr>
|
| 2008 | <tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations.
|
| 2009 |
|
| 2010 | Given:
|
| 2011 | constexpr int foo = 42;
|
| 2012 | constexpr int bar();
|
| 2013 | varDecl(isConstexpr())
|
| 2014 | matches the declaration of foo.
|
| 2015 | functionDecl(isConstexpr())
|
| 2016 | matches the declaration of bar.
|
| 2017 | </pre></td></tr>
|
| 2018 |
|
| 2019 |
|
| 2020 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDefinition2')"><a name="isDefinition2Anchor">isDefinition</a></td><td></td></tr>
|
| 2021 | <tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached.
|
| 2022 |
|
| 2023 | Example matches A, va, fa
|
| 2024 | class A {};
|
| 2025 | class B; Doesn't match, as it has no body.
|
| 2026 | int va;
|
| 2027 | extern int vb; Doesn't match, as it doesn't define the variable.
|
| 2028 | void fa() {}
|
| 2029 | void fb(); Doesn't match, as it has no body.
|
| 2030 |
|
| 2031 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>
|
| 2032 | </pre></td></tr>
|
| 2033 |
|
| 2034 |
|
| 2035 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDeleted0')"><a name="isDeleted0Anchor">isDeleted</a></td><td></td></tr>
|
| 2036 | <tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations.
|
| 2037 |
|
| 2038 | Given:
|
| 2039 | void Func();
|
| 2040 | void DeletedFunc() = delete;
|
| 2041 | functionDecl(isDeleted())
|
| 2042 | matches the declaration of DeletedFunc, but not Func.
|
| 2043 | </pre></td></tr>
|
| 2044 |
|
| 2045 |
|
| 2046 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization0')"><a name="isExplicitTemplateSpecialization0Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr>
|
| 2047 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
|
| 2048 | static member variable template instantiations.
|
| 2049 |
|
| 2050 | Given
|
| 2051 | template<typename T> void A(T t) { }
|
| 2052 | template<> void A(int N) { }
|
| 2053 | functionDecl(isExplicitTemplateSpecialization())
|
| 2054 | matches the specialization A<int>().
|
| 2055 |
|
| 2056 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>
|
| 2057 | </pre></td></tr>
|
| 2058 |
|
| 2059 |
|
| 2060 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isExternC0')"><a name="isExternC0Anchor">isExternC</a></td><td></td></tr>
|
| 2061 | <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations.
|
| 2062 |
|
| 2063 | Given:
|
| 2064 | extern "C" void f() {}
|
| 2065 | extern "C" { void g() {} }
|
| 2066 | void h() {}
|
| 2067 | functionDecl(isExternC())
|
| 2068 | matches the declaration of f and g, but not the declaration h
|
| 2069 | </pre></td></tr>
|
| 2070 |
|
| 2071 |
|
| 2072 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isInline1')"><a name="isInline1Anchor">isInline</a></td><td></td></tr>
|
| 2073 | <tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with
|
| 2074 | the inline keyword.
|
| 2075 |
|
| 2076 | Given
|
| 2077 | inline void f();
|
| 2078 | void g();
|
| 2079 | namespace n {
|
| 2080 | inline namespace m {}
|
| 2081 | }
|
| 2082 | functionDecl(isInline()) will match ::f().
|
| 2083 | namespaceDecl(isInline()) will match n::m.
|
| 2084 | </pre></td></tr>
|
| 2085 |
|
| 2086 |
|
| 2087 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation0')"><a name="isTemplateInstantiation0Anchor">isTemplateInstantiation</a></td><td></td></tr>
|
| 2088 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
|
| 2089 | member variable template instantiations.
|
| 2090 |
|
| 2091 | Given
|
| 2092 | template <typename T> class X {}; class A {}; X<A> x;
|
| 2093 | or
|
| 2094 | template <typename T> class X {}; class A {}; template class X<A>;
|
| 2095 | recordDecl(hasName("::X"), isTemplateInstantiation())
|
| 2096 | matches the template instantiation of X<A>.
|
| 2097 |
|
| 2098 | But given
|
| 2099 | template <typename T> class X {}; class A {};
|
| 2100 | template <> class X<A> {}; X<A> x;
|
| 2101 | recordDecl(hasName("::X"), isTemplateInstantiation())
|
| 2102 | does not match, as X<A> is an explicit template specialization.
|
| 2103 |
|
| 2104 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>
|
| 2105 | </pre></td></tr>
|
| 2106 |
|
| 2107 |
|
| 2108 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('parameterCountIs0')"><a name="parameterCountIs0Anchor">parameterCountIs</a></td><td>unsigned N</td></tr>
|
| 2109 | <tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count.
|
| 2110 |
|
| 2111 | Given
|
| 2112 | void f(int i) {}
|
| 2113 | void g(int i, int j) {}
|
| 2114 | functionDecl(parameterCountIs(2))
|
| 2115 | matches g(int i, int j) {}
|
| 2116 | </pre></td></tr>
|
| 2117 |
|
| 2118 |
|
| 2119 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals0')"><a name="equals0Anchor">equals</a></td><td>ValueT Value</td></tr>
|
| 2120 | <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value.
|
| 2121 |
|
| 2122 | Example matches true (matcher = boolLiteral(equals(true)))
|
| 2123 | true
|
| 2124 |
|
| 2125 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>,
|
| 2126 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>
|
| 2127 | </pre></td></tr>
|
| 2128 |
|
| 2129 |
|
| 2130 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('isArrow0')"><a name="isArrow0Anchor">isArrow</a></td><td></td></tr>
|
| 2131 | <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed
|
| 2132 | to '.'.
|
| 2133 |
|
| 2134 | Member calls on the implicit this pointer match as called with '->'.
|
| 2135 |
|
| 2136 | Given
|
| 2137 | class Y {
|
| 2138 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
|
| 2139 | int a;
|
| 2140 | static int b;
|
| 2141 | };
|
| 2142 | memberExpr(isArrow())
|
| 2143 | matches this->x, x, y.x, a, this->b
|
| 2144 | </pre></td></tr>
|
| 2145 |
|
| 2146 |
|
| 2147 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('hasName0')"><a name="hasName0Anchor">hasName</a></td><td>std::string Name</td></tr>
|
| 2148 | <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name.
|
| 2149 |
|
| 2150 | Supports specifying enclosing namespaces or classes by prefixing the name
|
| 2151 | with '<enclosing>::'.
|
| 2152 | Does not match typedefs of an underlying type with the given name.
|
| 2153 |
|
| 2154 | Example matches X (Name == "X")
|
| 2155 | class X;
|
| 2156 |
|
| 2157 | Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
|
| 2158 | namespace a { namespace b { class X; } }
|
| 2159 | </pre></td></tr>
|
| 2160 |
|
| 2161 |
|
| 2162 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('matchesName0')"><a name="matchesName0Anchor">matchesName</a></td><td>std::string RegExp</td></tr>
|
| 2163 | <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
|
| 2164 | a substring matched by the given RegExp.
|
| 2165 |
|
| 2166 | Supports specifying enclosing namespaces or classes by
|
| 2167 | prefixing the name with '<enclosing>::'. Does not match typedefs
|
| 2168 | of an underlying type with the given name.
|
| 2169 |
|
| 2170 | Example matches X (regexp == "::X")
|
| 2171 | class X;
|
| 2172 |
|
| 2173 | Example matches X (regexp is one of "::X", "^foo::.*X", among others)
|
| 2174 | namespace foo { namespace bar { class X; } }
|
| 2175 | </pre></td></tr>
|
| 2176 |
|
| 2177 |
|
| 2178 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>></td><td class="name" onclick="toggle('isAnonymous0')"><a name="isAnonymous0Anchor">isAnonymous</a></td><td></td></tr>
|
| 2179 | <tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations.
|
| 2180 |
|
| 2181 | Given
|
| 2182 | namespace n {
|
| 2183 | namespace {} #1
|
| 2184 | }
|
| 2185 | namespaceDecl(isAnonymous()) will match #1 but not ::n.
|
| 2186 | </pre></td></tr>
|
| 2187 |
|
| 2188 |
|
| 2189 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>></td><td class="name" onclick="toggle('isInline0')"><a name="isInline0Anchor">isInline</a></td><td></td></tr>
|
| 2190 | <tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with
|
| 2191 | the inline keyword.
|
| 2192 |
|
| 2193 | Given
|
| 2194 | inline void f();
|
| 2195 | void g();
|
| 2196 | namespace n {
|
| 2197 | inline namespace m {}
|
| 2198 | }
|
| 2199 | functionDecl(isInline()) will match ::f().
|
| 2200 | namespaceDecl(isInline()) will match n::m.
|
| 2201 | </pre></td></tr>
|
| 2202 |
|
| 2203 |
|
| 2204 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('argumentCountIs2')"><a name="argumentCountIs2Anchor">argumentCountIs</a></td><td>unsigned N</td></tr>
|
| 2205 | <tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has
|
| 2206 | a specific number of arguments (including absent default arguments).
|
| 2207 |
|
| 2208 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
|
| 2209 | void f(int x, int y);
|
| 2210 | f(0, 0);
|
| 2211 | </pre></td></tr>
|
| 2212 |
|
| 2213 |
|
| 2214 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasKeywordSelector0')"><a name="hasKeywordSelector0Anchor">hasKeywordSelector</a></td><td></td></tr>
|
| 2215 | <tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre></pre></td></tr>
|
| 2216 |
|
| 2217 |
|
| 2218 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasNullSelector0')"><a name="hasNullSelector0Anchor">hasNullSelector</a></td><td></td></tr>
|
| 2219 | <tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector
|
| 2220 |
|
| 2221 | Matches only when the selector of the objCMessageExpr is NULL. This may
|
| 2222 | represent an error condition in the tree!
|
| 2223 | </pre></td></tr>
|
| 2224 |
|
| 2225 |
|
| 2226 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasSelector0')"><a name="hasSelector0Anchor">hasSelector</a></td><td>std::string BaseName</td></tr>
|
| 2227 | <tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString()
|
| 2228 |
|
| 2229 | matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:"));
|
| 2230 | matches the outer message expr in the code below, but NOT the message
|
| 2231 | invocation for self.bodyView.
|
| 2232 | [self.bodyView loadHTMLString:html baseURL:NULL];
|
| 2233 | </pre></td></tr>
|
| 2234 |
|
| 2235 |
|
| 2236 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasUnarySelector0')"><a name="hasUnarySelector0Anchor">hasUnarySelector</a></td><td></td></tr>
|
| 2237 | <tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector
|
| 2238 |
|
| 2239 | matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
|
| 2240 | matches self.bodyView in the code below, but NOT the outer message
|
| 2241 | invocation of "loadHTMLString:baseURL:".
|
| 2242 | [self.bodyView loadHTMLString:html baseURL:NULL];
|
| 2243 | </pre></td></tr>
|
| 2244 |
|
| 2245 |
|
| 2246 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('matchesSelector0')"><a name="matchesSelector0Anchor">matchesSelector</a></td><td>std::string RegExp</td></tr>
|
| 2247 | <tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains
|
| 2248 | a substring matched by the given RegExp.
|
| 2249 | matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message
|
| 2250 | invocation for self.bodyView.
|
| 2251 | [self.bodyView loadHTMLString:html baseURL:NULL];
|
| 2252 | </pre></td></tr>
|
| 2253 |
|
| 2254 |
|
| 2255 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('numSelectorArgs0')"><a name="numSelectorArgs0Anchor">numSelectorArgs</a></td><td>unsigned N</td></tr>
|
| 2256 | <tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments
|
| 2257 |
|
| 2258 | matcher = objCMessageExpr(numSelectorArgs(1));
|
| 2259 | matches self.bodyView in the code below
|
| 2260 |
|
| 2261 | matcher = objCMessageExpr(numSelectorArgs(2));
|
| 2262 | matches the invocation of "loadHTMLString:baseURL:" but not that
|
| 2263 | of self.bodyView
|
| 2264 | [self.bodyView loadHTMLString:html baseURL:NULL];
|
| 2265 | </pre></td></tr>
|
| 2266 |
|
| 2267 |
|
| 2268 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('asString0')"><a name="asString0Anchor">asString</a></td><td>std::string Name</td></tr>
|
| 2269 | <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string.
|
| 2270 |
|
| 2271 | Given
|
| 2272 | class Y { public: void x(); };
|
| 2273 | void z() { Y* y; y->x(); }
|
| 2274 | memberCallExpr(on(hasType(asString("class Y *"))))
|
| 2275 | matches y->x()
|
| 2276 | </pre></td></tr>
|
| 2277 |
|
| 2278 |
|
| 2279 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('equalsBoundNode3')"><a name="equalsBoundNode3Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr>
|
| 2280 | <tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node.
|
| 2281 |
|
| 2282 | Matches a node if it equals the node previously bound to ID.
|
| 2283 |
|
| 2284 | Given
|
| 2285 | class X { int a; int b; };
|
| 2286 | recordDecl(
|
| 2287 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
|
| 2288 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
|
| 2289 | matches the class X, as a and b have the same type.
|
| 2290 |
|
| 2291 | Note that when multiple matches are involved via forEach* matchers,
|
| 2292 | equalsBoundNodes acts as a filter.
|
| 2293 | For example:
|
| 2294 | compoundStmt(
|
| 2295 | forEachDescendant(varDecl().bind("d")),
|
| 2296 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
|
| 2297 | will trigger a match for each combination of variable declaration
|
| 2298 | and reference to that variable declaration within a compound statement.
|
| 2299 | </pre></td></tr>
|
| 2300 |
|
| 2301 |
|
| 2302 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasLocalQualifiers0')"><a name="hasLocalQualifiers0Anchor">hasLocalQualifiers</a></td><td></td></tr>
|
| 2303 | <tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to
|
| 2304 | the node, not hidden within a typedef.
|
| 2305 |
|
| 2306 | Given
|
| 2307 | typedef const int const_int;
|
| 2308 | const_int i;
|
| 2309 | int *const j;
|
| 2310 | int *volatile k;
|
| 2311 | int m;
|
| 2312 | varDecl(hasType(hasLocalQualifiers())) matches only j and k.
|
| 2313 | i is const-qualified but the qualifier is not local.
|
| 2314 | </pre></td></tr>
|
| 2315 |
|
| 2316 |
|
| 2317 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isConstQualified0')"><a name="isConstQualified0Anchor">isConstQualified</a></td><td></td></tr>
|
| 2318 | <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that
|
| 2319 | include "top-level" const.
|
| 2320 |
|
| 2321 | Given
|
| 2322 | void a(int);
|
| 2323 | void b(int const);
|
| 2324 | void c(const int);
|
| 2325 | void d(const int*);
|
| 2326 | void e(int const) {};
|
| 2327 | functionDecl(hasAnyParameter(hasType(isConstQualified())))
|
| 2328 | matches "void b(int const)", "void c(const int)" and
|
| 2329 | "void e(int const) {}". It does not match d as there
|
| 2330 | is no top-level const on the parameter type "const int *".
|
| 2331 | </pre></td></tr>
|
| 2332 |
|
| 2333 |
|
| 2334 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isInteger0')"><a name="isInteger0Anchor">isInteger</a></td><td></td></tr>
|
| 2335 | <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type.
|
| 2336 |
|
| 2337 | Given
|
| 2338 | void a(int);
|
| 2339 | void b(long);
|
| 2340 | void c(double);
|
| 2341 | functionDecl(hasAnyParameter(hasType(isInteger())))
|
| 2342 | matches "a(int)", "b(long)", but not "c(double)".
|
| 2343 | </pre></td></tr>
|
| 2344 |
|
| 2345 |
|
| 2346 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('equalsBoundNode0')"><a name="equalsBoundNode0Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr>
|
| 2347 | <tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node.
|
| 2348 |
|
| 2349 | Matches a node if it equals the node previously bound to ID.
|
| 2350 |
|
| 2351 | Given
|
| 2352 | class X { int a; int b; };
|
| 2353 | recordDecl(
|
| 2354 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
|
| 2355 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
|
| 2356 | matches the class X, as a and b have the same type.
|
| 2357 |
|
| 2358 | Note that when multiple matches are involved via forEach* matchers,
|
| 2359 | equalsBoundNodes acts as a filter.
|
| 2360 | For example:
|
| 2361 | compoundStmt(
|
| 2362 | forEachDescendant(varDecl().bind("d")),
|
| 2363 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
|
| 2364 | will trigger a match for each combination of variable declaration
|
| 2365 | and reference to that variable declaration within a compound statement.
|
| 2366 | </pre></td></tr>
|
| 2367 |
|
| 2368 |
|
| 2369 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching1')"><a name="isExpansionInFileMatching1Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr>
|
| 2370 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is
|
| 2371 | partially matching a given regex.
|
| 2372 |
|
| 2373 | Example matches Y but not X
|
| 2374 | (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
|
| 2375 | #include "ASTMatcher.h"
|
| 2376 | class X {};
|
| 2377 | ASTMatcher.h:
|
| 2378 | class Y {};
|
| 2379 |
|
| 2380 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>
|
| 2381 | </pre></td></tr>
|
| 2382 |
|
| 2383 |
|
| 2384 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInMainFile1')"><a name="isExpansionInMainFile1Anchor">isExpansionInMainFile</a></td><td></td></tr>
|
| 2385 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file.
|
| 2386 |
|
| 2387 | Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
|
| 2388 | #include <Y.h>
|
| 2389 | class X {};
|
| 2390 | Y.h:
|
| 2391 | class Y {};
|
| 2392 |
|
| 2393 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>
|
| 2394 | </pre></td></tr>
|
| 2395 |
|
| 2396 |
|
| 2397 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader1')"><a name="isExpansionInSystemHeader1Anchor">isExpansionInSystemHeader</a></td><td></td></tr>
|
| 2398 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files.
|
| 2399 |
|
| 2400 | Example matches Y but not X
|
| 2401 | (matcher = recordDecl(isExpansionInSystemHeader())
|
| 2402 | #include <SystemHeader.h>
|
| 2403 | class X {};
|
| 2404 | SystemHeader.h:
|
| 2405 | class Y {};
|
| 2406 |
|
| 2407 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>
|
| 2408 | </pre></td></tr>
|
| 2409 |
|
| 2410 |
|
| 2411 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>></td><td class="name" onclick="toggle('isDefinition0')"><a name="isDefinition0Anchor">isDefinition</a></td><td></td></tr>
|
| 2412 | <tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached.
|
| 2413 |
|
| 2414 | Example matches A, va, fa
|
| 2415 | class A {};
|
| 2416 | class B; Doesn't match, as it has no body.
|
| 2417 | int va;
|
| 2418 | extern int vb; Doesn't match, as it doesn't define the variable.
|
| 2419 | void fa() {}
|
| 2420 | void fb(); Doesn't match, as it has no body.
|
| 2421 |
|
| 2422 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>
|
| 2423 | </pre></td></tr>
|
| 2424 |
|
| 2425 |
|
| 2426 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('equalsIntegralValue0')"><a name="equalsIntegralValue0Anchor">equalsIntegralValue</a></td><td>std::string Value</td></tr>
|
| 2427 | <tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value.
|
| 2428 |
|
| 2429 | Note that 'Value' is a string as the template argument's value is
|
| 2430 | an arbitrary precision integer. 'Value' must be euqal to the canonical
|
| 2431 | representation of that integral value in base 10.
|
| 2432 |
|
| 2433 | Given
|
| 2434 | template<int T> struct A {};
|
| 2435 | C<42> c;
|
| 2436 | classTemplateSpecializationDecl(
|
| 2437 | hasAnyTemplateArgument(equalsIntegralValue("42")))
|
| 2438 | matches the implicit instantiation of C in C<42>.
|
| 2439 | </pre></td></tr>
|
| 2440 |
|
| 2441 |
|
| 2442 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('isIntegral0')"><a name="isIntegral0Anchor">isIntegral</a></td><td></td></tr>
|
| 2443 | <tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value.
|
| 2444 |
|
| 2445 | Given
|
| 2446 | template<int T> struct A {};
|
| 2447 | C<42> c;
|
| 2448 | classTemplateSpecializationDecl(
|
| 2449 | hasAnyTemplateArgument(isIntegral()))
|
| 2450 | matches the implicit instantiation of C in C<42>
|
| 2451 | with isIntegral() matching 42.
|
| 2452 | </pre></td></tr>
|
| 2453 |
|
| 2454 |
|
| 2455 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('templateArgumentCountIs1')"><a name="templateArgumentCountIs1Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr>
|
| 2456 | <tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N.
|
| 2457 |
|
| 2458 | Given
|
| 2459 | template<typename T> struct C {};
|
| 2460 | C<int> c;
|
| 2461 | classTemplateSpecializationDecl(templateArgumentCountIs(1))
|
| 2462 | matches C<int>.
|
| 2463 | </pre></td></tr>
|
| 2464 |
|
| 2465 |
|
| 2466 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching2')"><a name="isExpansionInFileMatching2Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr>
|
| 2467 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is
|
| 2468 | partially matching a given regex.
|
| 2469 |
|
| 2470 | Example matches Y but not X
|
| 2471 | (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
|
| 2472 | #include "ASTMatcher.h"
|
| 2473 | class X {};
|
| 2474 | ASTMatcher.h:
|
| 2475 | class Y {};
|
| 2476 |
|
| 2477 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>
|
| 2478 | </pre></td></tr>
|
| 2479 |
|
| 2480 |
|
| 2481 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInMainFile2')"><a name="isExpansionInMainFile2Anchor">isExpansionInMainFile</a></td><td></td></tr>
|
| 2482 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file.
|
| 2483 |
|
| 2484 | Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
|
| 2485 | #include <Y.h>
|
| 2486 | class X {};
|
| 2487 | Y.h:
|
| 2488 | class Y {};
|
| 2489 |
|
| 2490 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>
|
| 2491 | </pre></td></tr>
|
| 2492 |
|
| 2493 |
|
| 2494 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader2')"><a name="isExpansionInSystemHeader2Anchor">isExpansionInSystemHeader</a></td><td></td></tr>
|
| 2495 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files.
|
| 2496 |
|
| 2497 | Example matches Y but not X
|
| 2498 | (matcher = recordDecl(isExpansionInSystemHeader())
|
| 2499 | #include <SystemHeader.h>
|
| 2500 | class X {};
|
| 2501 | SystemHeader.h:
|
| 2502 | class Y {};
|
| 2503 |
|
| 2504 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>
|
| 2505 | </pre></td></tr>
|
| 2506 |
|
| 2507 |
|
| 2508 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('equalsBoundNode2')"><a name="equalsBoundNode2Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr>
|
| 2509 | <tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node.
|
| 2510 |
|
| 2511 | Matches a node if it equals the node previously bound to ID.
|
| 2512 |
|
| 2513 | Given
|
| 2514 | class X { int a; int b; };
|
| 2515 | recordDecl(
|
| 2516 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
|
| 2517 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
|
| 2518 | matches the class X, as a and b have the same type.
|
| 2519 |
|
| 2520 | Note that when multiple matches are involved via forEach* matchers,
|
| 2521 | equalsBoundNodes acts as a filter.
|
| 2522 | For example:
|
| 2523 | compoundStmt(
|
| 2524 | forEachDescendant(varDecl().bind("d")),
|
| 2525 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
|
| 2526 | will trigger a match for each combination of variable declaration
|
| 2527 | and reference to that variable declaration within a compound statement.
|
| 2528 | </pre></td></tr>
|
| 2529 |
|
| 2530 |
|
| 2531 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('voidType0')"><a name="voidType0Anchor">voidType</a></td><td></td></tr>
|
| 2532 | <tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void.
|
| 2533 |
|
| 2534 | Given
|
| 2535 | struct S { void func(); };
|
| 2536 | functionDecl(returns(voidType()))
|
| 2537 | matches "void func();"
|
| 2538 | </pre></td></tr>
|
| 2539 |
|
| 2540 |
|
| 2541 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>></td><td class="name" onclick="toggle('ofKind0')"><a name="ofKind0Anchor">ofKind</a></td><td>UnaryExprOrTypeTrait Kind</td></tr>
|
| 2542 | <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind.
|
| 2543 |
|
| 2544 | Given
|
| 2545 | int x;
|
| 2546 | int s = sizeof(x) + alignof(x)
|
| 2547 | unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
|
| 2548 | matches sizeof(x)
|
| 2549 | </pre></td></tr>
|
| 2550 |
|
| 2551 |
|
| 2552 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>></td><td class="name" onclick="toggle('hasOperatorName1')"><a name="hasOperatorName1Anchor">hasOperatorName</a></td><td>std::string Name</td></tr>
|
| 2553 | <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or
|
| 2554 | unary).
|
| 2555 |
|
| 2556 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
|
| 2557 | !(a || b)
|
| 2558 | </pre></td></tr>
|
| 2559 |
|
| 2560 |
|
| 2561 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasGlobalStorage0')"><a name="hasGlobalStorage0Anchor">hasGlobalStorage</a></td><td></td></tr>
|
| 2562 | <tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage.
|
| 2563 |
|
| 2564 | Example matches y and z (matcher = varDecl(hasGlobalStorage())
|
| 2565 | void f() {
|
| 2566 | int x;
|
| 2567 | static int y;
|
| 2568 | }
|
| 2569 | int z;
|
| 2570 | </pre></td></tr>
|
| 2571 |
|
| 2572 |
|
| 2573 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasLocalStorage0')"><a name="hasLocalStorage0Anchor">hasLocalStorage</a></td><td></td></tr>
|
| 2574 | <tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a
|
| 2575 | non-static local variable.
|
| 2576 |
|
| 2577 | Example matches x (matcher = varDecl(hasLocalStorage())
|
| 2578 | void f() {
|
| 2579 | int x;
|
| 2580 | static int y;
|
| 2581 | }
|
| 2582 | int z;
|
| 2583 | </pre></td></tr>
|
| 2584 |
|
| 2585 |
|
| 2586 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isConstexpr0')"><a name="isConstexpr0Anchor">isConstexpr</a></td><td></td></tr>
|
| 2587 | <tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations.
|
| 2588 |
|
| 2589 | Given:
|
| 2590 | constexpr int foo = 42;
|
| 2591 | constexpr int bar();
|
| 2592 | varDecl(isConstexpr())
|
| 2593 | matches the declaration of foo.
|
| 2594 | functionDecl(isConstexpr())
|
| 2595 | matches the declaration of bar.
|
| 2596 | </pre></td></tr>
|
| 2597 |
|
| 2598 |
|
| 2599 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isDefinition1')"><a name="isDefinition1Anchor">isDefinition</a></td><td></td></tr>
|
| 2600 | <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached.
|
| 2601 |
|
| 2602 | Example matches A, va, fa
|
| 2603 | class A {};
|
| 2604 | class B; Doesn't match, as it has no body.
|
| 2605 | int va;
|
| 2606 | extern int vb; Doesn't match, as it doesn't define the variable.
|
| 2607 | void fa() {}
|
| 2608 | void fb(); Doesn't match, as it has no body.
|
| 2609 |
|
| 2610 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>
|
| 2611 | </pre></td></tr>
|
| 2612 |
|
| 2613 |
|
| 2614 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isExceptionVariable0')"><a name="isExceptionVariable0Anchor">isExceptionVariable</a></td><td></td></tr>
|
| 2615 | <tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from
|
| 2616 | a C++ catch block, or an Objective-C statement.
|
| 2617 |
|
| 2618 | Example matches x (matcher = varDecl(isExceptionVariable())
|
| 2619 | void f(int y) {
|
| 2620 | try {
|
| 2621 | } catch (int x) {
|
| 2622 | }
|
| 2623 | }
|
| 2624 | </pre></td></tr>
|
| 2625 |
|
| 2626 |
|
| 2627 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization1')"><a name="isExplicitTemplateSpecialization1Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr>
|
| 2628 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or
|
| 2629 | static member variable template instantiations.
|
| 2630 |
|
| 2631 | Given
|
| 2632 | template<typename T> void A(T t) { }
|
| 2633 | template<> void A(int N) { }
|
| 2634 | functionDecl(isExplicitTemplateSpecialization())
|
| 2635 | matches the specialization A<int>().
|
| 2636 |
|
| 2637 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>
|
| 2638 | </pre></td></tr>
|
| 2639 |
|
| 2640 |
|
| 2641 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation1')"><a name="isTemplateInstantiation1Anchor">isTemplateInstantiation</a></td><td></td></tr>
|
| 2642 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static
|
| 2643 | member variable template instantiations.
|
| 2644 |
|
| 2645 | Given
|
| 2646 | template <typename T> class X {}; class A {}; X<A> x;
|
| 2647 | or
|
| 2648 | template <typename T> class X {}; class A {}; template class X<A>;
|
| 2649 | recordDecl(hasName("::X"), isTemplateInstantiation())
|
| 2650 | matches the template instantiation of X<A>.
|
| 2651 |
|
| 2652 | But given
|
| 2653 | template <typename T> class X {}; class A {};
|
| 2654 | template <> class X<A> {}; X<A> x;
|
| 2655 | recordDecl(hasName("::X"), isTemplateInstantiation())
|
| 2656 | does not match, as X<A> is an explicit template specialization.
|
| 2657 |
|
| 2658 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>
|
| 2659 | </pre></td></tr>
|
| 2660 |
|
| 2661 |
|
| 2662 | <tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>></td><td class="name" onclick="toggle('isInstantiated0')"><a name="isInstantiated0Anchor">isInstantiated</a></td><td></td></tr>
|
| 2663 | <tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside
|
| 2664 | template instantiations.
|
| 2665 |
|
| 2666 | Given
|
| 2667 | template<typename T> void A(T t) { T i; }
|
| 2668 | A(0);
|
| 2669 | A(0U);
|
| 2670 | functionDecl(isInstantiated())
|
| 2671 | matches 'A(int) {...};' and 'A(unsigned) {...}'.
|
| 2672 | </pre></td></tr>
|
| 2673 |
|
| 2674 |
|
| 2675 | <tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>></td><td class="name" onclick="toggle('isInTemplateInstantiation0')"><a name="isInTemplateInstantiation0Anchor">isInTemplateInstantiation</a></td><td></td></tr>
|
| 2676 | <tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation.
|
| 2677 |
|
| 2678 | Given
|
| 2679 | int j;
|
| 2680 | template<typename T> void A(T t) { T i; j += 42;}
|
| 2681 | A(0);
|
| 2682 | A(0U);
|
| 2683 | declStmt(isInTemplateInstantiation())
|
| 2684 | matches 'int i;' and 'unsigned i'.
|
| 2685 | unless(stmt(isInTemplateInstantiation()))
|
| 2686 | will NOT match j += 42; as it's shared between the template definition and
|
| 2687 | instantiation.
|
| 2688 | </pre></td></tr>
|
| 2689 |
|
| 2690 | <!--END_NARROWING_MATCHERS -->
|
| 2691 | </table>
|
| 2692 |
|
| 2693 | <!-- ======================================================================= -->
|
| 2694 | <h2 id="traversal-matchers">AST Traversal Matchers</h2>
|
| 2695 | <!-- ======================================================================= -->
|
| 2696 |
|
| 2697 | <p>Traversal matchers specify the relationship to other nodes that are
|
| 2698 | reachable from the current node.</p>
|
| 2699 |
|
| 2700 | <p>Note that there are special traversal matchers (has, hasDescendant, forEach and
|
| 2701 | forEachDescendant) which work on all nodes and allow users to write more generic
|
| 2702 | match expressions.</p>
|
| 2703 |
|
| 2704 | <table>
|
| 2705 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
|
| 2706 | <!-- START_TRAVERSAL_MATCHERS -->
|
| 2707 |
|
| 2708 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr>
|
| 2709 | <tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches.
|
| 2710 |
|
| 2711 | Unlike anyOf, eachOf will generate a match result for each
|
| 2712 | matching submatcher.
|
| 2713 |
|
| 2714 | For example, in:
|
| 2715 | class A { int a; int b; };
|
| 2716 | The matcher:
|
| 2717 | recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
|
| 2718 | has(fieldDecl(hasName("b")).bind("v"))))
|
| 2719 | will generate two results binding "v", the first of which binds
|
| 2720 | the field declaration of a, the second the field declaration of
|
| 2721 | b.
|
| 2722 |
|
| 2723 | Usable as: Any Matcher
|
| 2724 | </pre></td></tr>
|
| 2725 |
|
| 2726 |
|
| 2727 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr>
|
| 2728 | <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
|
| 2729 | provided matcher.
|
| 2730 |
|
| 2731 | Example matches X, A, B, C
|
| 2732 | (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X")))))
|
| 2733 | class X {}; Matches X, because X::X is a class of name X inside X.
|
| 2734 | class A { class X {}; };
|
| 2735 | class B { class C { class X {}; }; };
|
| 2736 |
|
| 2737 | DescendantT must be an AST base type.
|
| 2738 |
|
| 2739 | As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
|
| 2740 | each result that matches instead of only on the first one.
|
| 2741 |
|
| 2742 | Note: Recursively combined ForEachDescendant can cause many matches:
|
| 2743 | recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl()))))
|
| 2744 | will match 10 times (plus injected class name matches) on:
|
| 2745 | class A { class B { class C { class D { class E {}; }; }; }; };
|
| 2746 |
|
| 2747 | Usable as: Any Matcher
|
| 2748 | </pre></td></tr>
|
| 2749 |
|
| 2750 |
|
| 2751 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr>
|
| 2752 | <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
|
| 2753 | provided matcher.
|
| 2754 |
|
| 2755 | Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X")))
|
| 2756 | class X {}; Matches X, because X::X is a class of name X inside X.
|
| 2757 | class Y { class X {}; };
|
| 2758 | class Z { class Y { class X {}; }; }; Does not match Z.
|
| 2759 |
|
| 2760 | ChildT must be an AST base type.
|
| 2761 |
|
| 2762 | As opposed to 'has', 'forEach' will cause a match for each result that
|
| 2763 | matches instead of only on the first one.
|
| 2764 |
|
| 2765 | Usable as: Any Matcher
|
| 2766 | </pre></td></tr>
|
| 2767 |
|
| 2768 |
|
| 2769 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr>
|
| 2770 | <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided
|
| 2771 | matcher.
|
| 2772 |
|
| 2773 | Given
|
| 2774 | void f() { if (true) { int x = 42; } }
|
| 2775 | void g() { for (;;) { int x = 43; } }
|
| 2776 | expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
|
| 2777 |
|
| 2778 | Usable as: Any Matcher
|
| 2779 | </pre></td></tr>
|
| 2780 |
|
| 2781 |
|
| 2782 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr>
|
| 2783 | <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
|
| 2784 | provided matcher.
|
| 2785 |
|
| 2786 | Example matches X, Y, Z
|
| 2787 | (matcher = recordDecl(hasDescendant(recordDecl(hasName("X")))))
|
| 2788 | class X {}; Matches X, because X::X is a class of name X inside X.
|
| 2789 | class Y { class X {}; };
|
| 2790 | class Z { class Y { class X {}; }; };
|
| 2791 |
|
| 2792 | DescendantT must be an AST base type.
|
| 2793 |
|
| 2794 | Usable as: Any Matcher
|
| 2795 | </pre></td></tr>
|
| 2796 |
|
| 2797 |
|
| 2798 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr>
|
| 2799 | <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the
|
| 2800 | provided matcher.
|
| 2801 |
|
| 2802 | Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X")))
|
| 2803 | class X {}; Matches X, because X::X is a class of name X inside X.
|
| 2804 | class Y { class X {}; };
|
| 2805 | class Z { class Y { class X {}; }; }; Does not match Z.
|
| 2806 |
|
| 2807 | ChildT must be an AST base type.
|
| 2808 |
|
| 2809 | Usable as: Any Matcher
|
| 2810 | </pre></td></tr>
|
| 2811 |
|
| 2812 |
|
| 2813 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr>
|
| 2814 | <tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided
|
| 2815 | matcher.
|
| 2816 |
|
| 2817 | Given
|
| 2818 | void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
|
| 2819 | compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
|
| 2820 |
|
| 2821 | Usable as: Any Matcher
|
| 2822 | </pre></td></tr>
|
| 2823 |
|
| 2824 |
|
| 2825 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>></td><td class="name" onclick="toggle('hasBase0')"><a name="hasBase0Anchor">hasBase</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 2826 | <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression.
|
| 2827 |
|
| 2828 | Given
|
| 2829 | int i[5];
|
| 2830 | void f() { i[1] = 42; }
|
| 2831 | arraySubscriptExpression(hasBase(implicitCastExpr(
|
| 2832 | hasSourceExpression(declRefExpr()))))
|
| 2833 | matches i[1] with the declRefExpr() matching i
|
| 2834 | </pre></td></tr>
|
| 2835 |
|
| 2836 |
|
| 2837 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>></td><td class="name" onclick="toggle('hasIndex0')"><a name="hasIndex0Anchor">hasIndex</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 2838 | <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression.
|
| 2839 |
|
| 2840 | Given
|
| 2841 | int i[5];
|
| 2842 | void f() { i[1] = 42; }
|
| 2843 | arraySubscriptExpression(hasIndex(integerLiteral()))
|
| 2844 | matches i[1] with the integerLiteral() matching 1
|
| 2845 | </pre></td></tr>
|
| 2846 |
|
| 2847 |
|
| 2848 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayTypeLoc.html">ArrayTypeLoc</a>></td><td class="name" onclick="toggle('hasElementTypeLoc0')"><a name="hasElementTypeLoc0Anchor">hasElementTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr>
|
| 2849 | <tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element
|
| 2850 | type.
|
| 2851 |
|
| 2852 | Given
|
| 2853 | struct A {};
|
| 2854 | A a[7];
|
| 2855 | int b[7];
|
| 2856 | arrayType(hasElementType(builtinType()))
|
| 2857 | matches "int b[7]"
|
| 2858 |
|
| 2859 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>>
|
| 2860 | </pre></td></tr>
|
| 2861 |
|
| 2862 |
|
| 2863 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>></td><td class="name" onclick="toggle('hasElementType0')"><a name="hasElementType0Anchor">hasElementType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr>
|
| 2864 | <tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element
|
| 2865 | type.
|
| 2866 |
|
| 2867 | Given
|
| 2868 | struct A {};
|
| 2869 | A a[7];
|
| 2870 | int b[7];
|
| 2871 | arrayType(hasElementType(builtinType()))
|
| 2872 | matches "int b[7]"
|
| 2873 |
|
| 2874 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>>
|
| 2875 | </pre></td></tr>
|
| 2876 |
|
| 2877 |
|
| 2878 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicTypeLoc.html">AtomicTypeLoc</a>></td><td class="name" onclick="toggle('hasValueTypeLoc0')"><a name="hasValueTypeLoc0Anchor">hasValueTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr>
|
| 2879 | <tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type.
|
| 2880 |
|
| 2881 | Given
|
| 2882 | _Atomic(int) i;
|
| 2883 | _Atomic(float) f;
|
| 2884 | atomicType(hasValueType(isInteger()))
|
| 2885 | matches "_Atomic(int) i"
|
| 2886 |
|
| 2887 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>>
|
| 2888 | </pre></td></tr>
|
| 2889 |
|
| 2890 |
|
| 2891 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>></td><td class="name" onclick="toggle('hasValueType0')"><a name="hasValueType0Anchor">hasValueType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr>
|
| 2892 | <tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type.
|
| 2893 |
|
| 2894 | Given
|
| 2895 | _Atomic(int) i;
|
| 2896 | _Atomic(float) f;
|
| 2897 | atomicType(hasValueType(isInteger()))
|
| 2898 | matches "_Atomic(int) i"
|
| 2899 |
|
| 2900 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>>
|
| 2901 | </pre></td></tr>
|
| 2902 |
|
| 2903 |
|
| 2904 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>></td><td class="name" onclick="toggle('hasDeducedType0')"><a name="hasDeducedType0Anchor">hasDeducedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr>
|
| 2905 | <tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type.
|
| 2906 |
|
| 2907 | Note: There is no TypeLoc for the deduced type and thus no
|
| 2908 | getDeducedLoc() matcher.
|
| 2909 |
|
| 2910 | Given
|
| 2911 | auto a = 1;
|
| 2912 | auto b = 2.0;
|
| 2913 | autoType(hasDeducedType(isInteger()))
|
| 2914 | matches "auto a"
|
| 2915 |
|
| 2916 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>>
|
| 2917 | </pre></td></tr>
|
| 2918 |
|
| 2919 |
|
| 2920 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('hasEitherOperand0')"><a name="hasEitherOperand0Anchor">hasEitherOperand</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 2921 | <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a
|
| 2922 | binary operator matches.
|
| 2923 | </pre></td></tr>
|
| 2924 |
|
| 2925 |
|
| 2926 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('hasLHS0')"><a name="hasLHS0Anchor">hasLHS</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 2927 | <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions.
|
| 2928 |
|
| 2929 | Example matches a (matcher = binaryOperator(hasLHS()))
|
| 2930 | a || b
|
| 2931 | </pre></td></tr>
|
| 2932 |
|
| 2933 |
|
| 2934 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('hasRHS0')"><a name="hasRHS0Anchor">hasRHS</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 2935 | <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions.
|
| 2936 |
|
| 2937 | Example matches b (matcher = binaryOperator(hasRHS()))
|
| 2938 | a || b
|
| 2939 | </pre></td></tr>
|
| 2940 |
|
| 2941 |
|
| 2942 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerTypeLoc.html">BlockPointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc0')"><a name="pointeeLoc0Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr>
|
| 2943 | <tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the
|
| 2944 | pointee matches a given matcher.
|
| 2945 |
|
| 2946 | Given
|
| 2947 | int *a;
|
| 2948 | int const *b;
|
| 2949 | float const *f;
|
| 2950 | pointerType(pointee(isConstQualified(), isInteger()))
|
| 2951 | matches "int const *b"
|
| 2952 |
|
| 2953 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>,
|
| 2954 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>
|
| 2955 | </pre></td></tr>
|
| 2956 |
|
| 2957 |
|
| 2958 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>></td><td class="name" onclick="toggle('pointee0')"><a name="pointee0Anchor">pointee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr>
|
| 2959 | <tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the
|
| 2960 | pointee matches a given matcher.
|
| 2961 |
|
| 2962 | Given
|
| 2963 | int *a;
|
| 2964 | int const *b;
|
| 2965 | float const *f;
|
| 2966 | pointerType(pointee(isConstQualified(), isInteger()))
|
| 2967 | matches "int const *b"
|
| 2968 |
|
| 2969 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>,
|
| 2970 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>
|
| 2971 | </pre></td></tr>
|
| 2972 |
|
| 2973 |
|
| 2974 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasAnyArgument1')"><a name="hasAnyArgument1Anchor">hasAnyArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 2975 | <tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call
|
| 2976 | expression.
|
| 2977 |
|
| 2978 | Given
|
| 2979 | void x(int, int, int) { int y; x(1, y, 42); }
|
| 2980 | callExpr(hasAnyArgument(declRefExpr()))
|
| 2981 | matches x(1, y, 42)
|
| 2982 | with hasAnyArgument(...)
|
| 2983 | matching y
|
| 2984 |
|
| 2985 | FIXME: Currently this will ignore parentheses and implicit casts on
|
| 2986 | the argument before applying the inner matcher. We'll want to remove
|
| 2987 | this to allow for greater control by the user once ignoreImplicit()
|
| 2988 | has been implemented.
|
| 2989 | </pre></td></tr>
|
| 2990 |
|
| 2991 |
|
| 2992 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasArgument1')"><a name="hasArgument1Anchor">hasArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 2993 | <tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor
|
| 2994 | call expression.
|
| 2995 |
|
| 2996 | Example matches y in x(y)
|
| 2997 | (matcher = callExpr(hasArgument(0, declRefExpr())))
|
| 2998 | void x(int) { int y; x(y); }
|
| 2999 | </pre></td></tr>
|
| 3000 |
|
| 3001 |
|
| 3002 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasDeclaration12')"><a name="hasDeclaration12Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3003 | <tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node
|
| 3004 | matches the given matcher.
|
| 3005 |
|
| 3006 | The associated declaration is:
|
| 3007 | - for type nodes, the declaration of the underlying type
|
| 3008 | - for CallExpr, the declaration of the callee
|
| 3009 | - for MemberExpr, the declaration of the referenced member
|
| 3010 | - for CXXConstructExpr, the declaration of the constructor
|
| 3011 |
|
| 3012 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 3013 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 3014 |
|
| 3015 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 3016 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 3017 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 3018 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 3019 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 3020 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 3021 | </pre></td></tr>
|
| 3022 |
|
| 3023 |
|
| 3024 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('forEachConstructorInitializer0')"><a name="forEachConstructorInitializer0Anchor">forEachConstructorInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>> InnerMatcher</td></tr>
|
| 3025 | <tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition.
|
| 3026 |
|
| 3027 | Given
|
| 3028 | class A { A() : i(42), j(42) {} int i; int j; };
|
| 3029 | constructorDecl(forEachConstructorInitializer(forField(decl().bind("x"))))
|
| 3030 | will trigger two matches, binding for 'i' and 'j' respectively.
|
| 3031 | </pre></td></tr>
|
| 3032 |
|
| 3033 |
|
| 3034 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('hasAnyConstructorInitializer0')"><a name="hasAnyConstructorInitializer0Anchor">hasAnyConstructorInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>> InnerMatcher</td></tr>
|
| 3035 | <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
|
| 3036 |
|
| 3037 | Given
|
| 3038 | struct Foo {
|
| 3039 | Foo() : foo_(1) { }
|
| 3040 | int foo_;
|
| 3041 | };
|
| 3042 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything()))))
|
| 3043 | record matches Foo, hasAnyConstructorInitializer matches foo_(1)
|
| 3044 | </pre></td></tr>
|
| 3045 |
|
| 3046 |
|
| 3047 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('forField0')"><a name="forField0Anchor">forField</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>> InnerMatcher</td></tr>
|
| 3048 | <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer.
|
| 3049 |
|
| 3050 | Given
|
| 3051 | struct Foo {
|
| 3052 | Foo() : foo_(1) { }
|
| 3053 | int foo_;
|
| 3054 | };
|
| 3055 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
|
| 3056 | forField(hasName("foo_"))))))
|
| 3057 | matches Foo
|
| 3058 | with forField matching foo_
|
| 3059 | </pre></td></tr>
|
| 3060 |
|
| 3061 |
|
| 3062 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('withInitializer0')"><a name="withInitializer0Anchor">withInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3063 | <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
|
| 3064 |
|
| 3065 | Given
|
| 3066 | struct Foo {
|
| 3067 | Foo() : foo_(1) { }
|
| 3068 | int foo_;
|
| 3069 | };
|
| 3070 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
|
| 3071 | withInitializer(integerLiteral(equals(1)))))))
|
| 3072 | matches Foo
|
| 3073 | with withInitializer matching (1)
|
| 3074 | </pre></td></tr>
|
| 3075 |
|
| 3076 |
|
| 3077 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasBody3')"><a name="hasBody3Anchor">hasBody</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr>
|
| 3078 | <tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', or 'do while' statement that has
|
| 3079 | a given body.
|
| 3080 |
|
| 3081 | Given
|
| 3082 | for (;;) {}
|
| 3083 | hasBody(compoundStmt())
|
| 3084 | matches 'for (;;) {}'
|
| 3085 | with compoundStmt()
|
| 3086 | matching '{}'
|
| 3087 | </pre></td></tr>
|
| 3088 |
|
| 3089 |
|
| 3090 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasLoopVariable0')"><a name="hasLoopVariable0Anchor">hasLoopVariable</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>> InnerMatcher</td></tr>
|
| 3091 | <tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop.
|
| 3092 |
|
| 3093 | Example:
|
| 3094 | forStmt(hasLoopVariable(anything()))
|
| 3095 | matches 'int x' in
|
| 3096 | for (int x : a) { }
|
| 3097 | </pre></td></tr>
|
| 3098 |
|
| 3099 |
|
| 3100 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasRangeInit0')"><a name="hasRangeInit0Anchor">hasRangeInit</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3101 | <tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop.
|
| 3102 |
|
| 3103 | Example:
|
| 3104 | forStmt(hasRangeInit(anything()))
|
| 3105 | matches 'a' in
|
| 3106 | for (int x : a) { }
|
| 3107 | </pre></td></tr>
|
| 3108 |
|
| 3109 |
|
| 3110 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>></td><td class="name" onclick="toggle('onImplicitObjectArgument0')"><a name="onImplicitObjectArgument0Anchor">onImplicitObjectArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3111 | <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr>
|
| 3112 |
|
| 3113 |
|
| 3114 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>></td><td class="name" onclick="toggle('on0')"><a name="on0Anchor">on</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3115 | <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression.
|
| 3116 |
|
| 3117 | Example matches y.x()
|
| 3118 | (matcher = memberCallExpr(on(hasType(recordDecl(hasName("Y"))))))
|
| 3119 | class Y { public: void x(); };
|
| 3120 | void z() { Y y; y.x(); }",
|
| 3121 |
|
| 3122 | FIXME: Overload to allow directly matching types?
|
| 3123 | </pre></td></tr>
|
| 3124 |
|
| 3125 |
|
| 3126 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>></td><td class="name" onclick="toggle('thisPointerType1')"><a name="thisPointerType1Anchor">thisPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3127 | <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration.
|
| 3128 | </pre></td></tr>
|
| 3129 |
|
| 3130 |
|
| 3131 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>></td><td class="name" onclick="toggle('thisPointerType0')"><a name="thisPointerType0Anchor">thisPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 3132 | <tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified
|
| 3133 | matcher, or is a pointer to a type that matches the InnerMatcher.
|
| 3134 | </pre></td></tr>
|
| 3135 |
|
| 3136 |
|
| 3137 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('ofClass0')"><a name="ofClass0Anchor">ofClass</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> InnerMatcher</td></tr>
|
| 3138 | <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration
|
| 3139 | belongs to.
|
| 3140 |
|
| 3141 | FIXME: Generalize this for other kinds of declarations.
|
| 3142 | FIXME: What other kind of declarations would we need to generalize
|
| 3143 | this to?
|
| 3144 |
|
| 3145 | Example matches A() in the last line
|
| 3146 | (matcher = constructExpr(hasDeclaration(methodDecl(
|
| 3147 | ofClass(hasName("A"))))))
|
| 3148 | class A {
|
| 3149 | public:
|
| 3150 | A();
|
| 3151 | };
|
| 3152 | A a = A();
|
| 3153 | </pre></td></tr>
|
| 3154 |
|
| 3155 |
|
| 3156 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('hasMethod0')"><a name="hasMethod0Anchor">hasMethod</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> InnerMatcher</td></tr>
|
| 3157 | <tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher.
|
| 3158 |
|
| 3159 | Given:
|
| 3160 | class A { void func(); };
|
| 3161 | class B { void member(); };
|
| 3162 |
|
| 3163 | recordDecl(hasMethod(hasName("func"))) matches the declaration of A
|
| 3164 | but not B.
|
| 3165 | </pre></td></tr>
|
| 3166 |
|
| 3167 |
|
| 3168 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isDerivedFrom0')"><a name="isDerivedFrom0Anchor">isDerivedFrom</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> Base</td></tr>
|
| 3169 | <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from
|
| 3170 | a class matching Base.
|
| 3171 |
|
| 3172 | Note that a class is not considered to be derived from itself.
|
| 3173 |
|
| 3174 | Example matches Y, Z, C (Base == hasName("X"))
|
| 3175 | class X;
|
| 3176 | class Y : public X {}; directly derived
|
| 3177 | class Z : public Y {}; indirectly derived
|
| 3178 | typedef X A;
|
| 3179 | typedef A B;
|
| 3180 | class C : public B {}; derived from a typedef of X
|
| 3181 |
|
| 3182 | In the following example, Bar matches isDerivedFrom(hasName("X")):
|
| 3183 | class Foo;
|
| 3184 | typedef Foo X;
|
| 3185 | class Bar : public Foo {}; derived from a type that X is a typedef of
|
| 3186 | </pre></td></tr>
|
| 3187 |
|
| 3188 |
|
| 3189 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isSameOrDerivedFrom0')"><a name="isSameOrDerivedFrom0Anchor">isSameOrDerivedFrom</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> Base</td></tr>
|
| 3190 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
|
| 3191 | match Base.
|
| 3192 | </pre></td></tr>
|
| 3193 |
|
| 3194 |
|
| 3195 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('callee1')"><a name="callee1Anchor">callee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3196 | <tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the
|
| 3197 | given matcher.
|
| 3198 |
|
| 3199 | Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x")))))
|
| 3200 | class Y { public: void x(); };
|
| 3201 | void z() { Y y; y.x(); }
|
| 3202 | </pre></td></tr>
|
| 3203 |
|
| 3204 |
|
| 3205 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('callee0')"><a name="callee0Anchor">callee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr>
|
| 3206 | <tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches.
|
| 3207 |
|
| 3208 | Given
|
| 3209 | class Y { void x() { this->x(); x(); Y y; y.x(); } };
|
| 3210 | void f() { f(); }
|
| 3211 | callExpr(callee(expr()))
|
| 3212 | matches this->x(), x(), y.x(), f()
|
| 3213 | with callee(...)
|
| 3214 | matching this->x, x, y.x, f respectively
|
| 3215 |
|
| 3216 | Note: Callee cannot take the more general internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>
|
| 3217 | because this introduces ambiguous overloads with calls to Callee taking a
|
| 3218 | internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely
|
| 3219 | implemented in terms of implicit casts.
|
| 3220 | </pre></td></tr>
|
| 3221 |
|
| 3222 |
|
| 3223 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasAnyArgument0')"><a name="hasAnyArgument0Anchor">hasAnyArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3224 | <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call
|
| 3225 | expression.
|
| 3226 |
|
| 3227 | Given
|
| 3228 | void x(int, int, int) { int y; x(1, y, 42); }
|
| 3229 | callExpr(hasAnyArgument(declRefExpr()))
|
| 3230 | matches x(1, y, 42)
|
| 3231 | with hasAnyArgument(...)
|
| 3232 | matching y
|
| 3233 |
|
| 3234 | FIXME: Currently this will ignore parentheses and implicit casts on
|
| 3235 | the argument before applying the inner matcher. We'll want to remove
|
| 3236 | this to allow for greater control by the user once ignoreImplicit()
|
| 3237 | has been implemented.
|
| 3238 | </pre></td></tr>
|
| 3239 |
|
| 3240 |
|
| 3241 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasArgument0')"><a name="hasArgument0Anchor">hasArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3242 | <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor
|
| 3243 | call expression.
|
| 3244 |
|
| 3245 | Example matches y in x(y)
|
| 3246 | (matcher = callExpr(hasArgument(0, declRefExpr())))
|
| 3247 | void x(int) { int y; x(y); }
|
| 3248 | </pre></td></tr>
|
| 3249 |
|
| 3250 |
|
| 3251 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasDeclaration13')"><a name="hasDeclaration13Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3252 | <tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node
|
| 3253 | matches the given matcher.
|
| 3254 |
|
| 3255 | The associated declaration is:
|
| 3256 | - for type nodes, the declaration of the underlying type
|
| 3257 | - for CallExpr, the declaration of the callee
|
| 3258 | - for MemberExpr, the declaration of the referenced member
|
| 3259 | - for CXXConstructExpr, the declaration of the constructor
|
| 3260 |
|
| 3261 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 3262 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 3263 |
|
| 3264 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 3265 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 3266 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 3267 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 3268 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 3269 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 3270 | </pre></td></tr>
|
| 3271 |
|
| 3272 |
|
| 3273 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>></td><td class="name" onclick="toggle('hasCaseConstant0')"><a name="hasCaseConstant0Anchor">hasCaseConstant</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3274 | <tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range
|
| 3275 | extension, matches the constant given in the statement.
|
| 3276 |
|
| 3277 | Given
|
| 3278 | switch (1) { case 1: case 1+1: case 3 ... 4: ; }
|
| 3279 | caseStmt(hasCaseConstant(integerLiteral()))
|
| 3280 | matches "case 1:"
|
| 3281 | </pre></td></tr>
|
| 3282 |
|
| 3283 |
|
| 3284 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>></td><td class="name" onclick="toggle('hasSourceExpression0')"><a name="hasSourceExpression0Anchor">hasSourceExpression</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3285 | <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher.
|
| 3286 |
|
| 3287 | Example: matches "a string" (matcher =
|
| 3288 | hasSourceExpression(constructExpr()))
|
| 3289 | class URL { URL(string); };
|
| 3290 | URL url = "a string";
|
| 3291 | </pre></td></tr>
|
| 3292 |
|
| 3293 |
|
| 3294 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgument0')"><a name="hasAnyTemplateArgument0Anchor">hasAnyTemplateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr>
|
| 3295 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one
|
| 3296 | TemplateArgument matching the given InnerMatcher.
|
| 3297 |
|
| 3298 | Given
|
| 3299 | template<typename T> class A {};
|
| 3300 | template<> class A<double> {};
|
| 3301 | A<int> a;
|
| 3302 | classTemplateSpecializationDecl(hasAnyTemplateArgument(
|
| 3303 | refersToType(asString("int"))))
|
| 3304 | matches the specialization A<int>
|
| 3305 | </pre></td></tr>
|
| 3306 |
|
| 3307 |
|
| 3308 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('hasTemplateArgument0')"><a name="hasTemplateArgument0Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr>
|
| 3309 | <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument
|
| 3310 | matches the given InnerMatcher.
|
| 3311 |
|
| 3312 | Given
|
| 3313 | template<typename T, typename U> class A {};
|
| 3314 | A<bool, int> b;
|
| 3315 | A<int, bool> c;
|
| 3316 | classTemplateSpecializationDecl(hasTemplateArgument(
|
| 3317 | 1, refersToType(asString("int"))))
|
| 3318 | matches the specialization A<bool, int>
|
| 3319 | </pre></td></tr>
|
| 3320 |
|
| 3321 |
|
| 3322 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexTypeLoc.html">ComplexTypeLoc</a>></td><td class="name" onclick="toggle('hasElementTypeLoc1')"><a name="hasElementTypeLoc1Anchor">hasElementTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr>
|
| 3323 | <tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element
|
| 3324 | type.
|
| 3325 |
|
| 3326 | Given
|
| 3327 | struct A {};
|
| 3328 | A a[7];
|
| 3329 | int b[7];
|
| 3330 | arrayType(hasElementType(builtinType()))
|
| 3331 | matches "int b[7]"
|
| 3332 |
|
| 3333 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>>
|
| 3334 | </pre></td></tr>
|
| 3335 |
|
| 3336 |
|
| 3337 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>></td><td class="name" onclick="toggle('hasElementType1')"><a name="hasElementType1Anchor">hasElementType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr>
|
| 3338 | <tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element
|
| 3339 | type.
|
| 3340 |
|
| 3341 | Given
|
| 3342 | struct A {};
|
| 3343 | A a[7];
|
| 3344 | int b[7];
|
| 3345 | arrayType(hasElementType(builtinType()))
|
| 3346 | matches "int b[7]"
|
| 3347 |
|
| 3348 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>>
|
| 3349 | </pre></td></tr>
|
| 3350 |
|
| 3351 |
|
| 3352 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>></td><td class="name" onclick="toggle('hasAnySubstatement0')"><a name="hasAnySubstatement0Anchor">hasAnySubstatement</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr>
|
| 3353 | <tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches
|
| 3354 | a given matcher.
|
| 3355 |
|
| 3356 | Given
|
| 3357 | { {}; 1+2; }
|
| 3358 | hasAnySubstatement(compoundStmt())
|
| 3359 | matches '{ {}; 1+2; }'
|
| 3360 | with compoundStmt()
|
| 3361 | matching '{}'
|
| 3362 | </pre></td></tr>
|
| 3363 |
|
| 3364 |
|
| 3365 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>></td><td class="name" onclick="toggle('hasCondition4')"><a name="hasCondition4Anchor">hasCondition</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3366 | <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop,
|
| 3367 | or conditional operator.
|
| 3368 |
|
| 3369 | Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
|
| 3370 | if (true) {}
|
| 3371 | </pre></td></tr>
|
| 3372 |
|
| 3373 |
|
| 3374 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>></td><td class="name" onclick="toggle('hasFalseExpression0')"><a name="hasFalseExpression0Anchor">hasFalseExpression</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3375 | <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator.
|
| 3376 |
|
| 3377 | Example matches b
|
| 3378 | condition ? a : b
|
| 3379 | </pre></td></tr>
|
| 3380 |
|
| 3381 |
|
| 3382 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>></td><td class="name" onclick="toggle('hasTrueExpression0')"><a name="hasTrueExpression0Anchor">hasTrueExpression</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3383 | <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator.
|
| 3384 |
|
| 3385 | Example matches a
|
| 3386 | condition ? a : b
|
| 3387 | </pre></td></tr>
|
| 3388 |
|
| 3389 |
|
| 3390 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('hasDeclaration11')"><a name="hasDeclaration11Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3391 | <tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node
|
| 3392 | matches the given matcher.
|
| 3393 |
|
| 3394 | The associated declaration is:
|
| 3395 | - for type nodes, the declaration of the underlying type
|
| 3396 | - for CallExpr, the declaration of the callee
|
| 3397 | - for MemberExpr, the declaration of the referenced member
|
| 3398 | - for CXXConstructExpr, the declaration of the constructor
|
| 3399 |
|
| 3400 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 3401 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 3402 |
|
| 3403 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 3404 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 3405 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 3406 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 3407 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 3408 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 3409 | </pre></td></tr>
|
| 3410 |
|
| 3411 |
|
| 3412 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('throughUsingDecl0')"><a name="throughUsingDecl0Anchor">throughUsingDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>> InnerMatcher</td></tr>
|
| 3413 | <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a
|
| 3414 | specific using shadow declaration.
|
| 3415 |
|
| 3416 | Given
|
| 3417 | namespace a { void f() {} }
|
| 3418 | using a::f;
|
| 3419 | void g() {
|
| 3420 | f(); Matches this ..
|
| 3421 | a::f(); .. but not this.
|
| 3422 | }
|
| 3423 | declRefExpr(throughUsingDecl(anything()))
|
| 3424 | matches f()
|
| 3425 | </pre></td></tr>
|
| 3426 |
|
| 3427 |
|
| 3428 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('to0')"><a name="to0Anchor">to</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3429 | <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
|
| 3430 | specified matcher.
|
| 3431 |
|
| 3432 | Example matches x in if(x)
|
| 3433 | (matcher = declRefExpr(to(varDecl(hasName("x")))))
|
| 3434 | bool x;
|
| 3435 | if (x) {}
|
| 3436 | </pre></td></tr>
|
| 3437 |
|
| 3438 |
|
| 3439 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>></td><td class="name" onclick="toggle('containsDeclaration0')"><a name="containsDeclaration0Anchor">containsDeclaration</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3440 | <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement.
|
| 3441 |
|
| 3442 | Note that this does not work for global declarations because the AST
|
| 3443 | breaks up multiple-declaration DeclStmt's into multiple single-declaration
|
| 3444 | DeclStmt's.
|
| 3445 | Example: Given non-global declarations
|
| 3446 | int a, b = 0;
|
| 3447 | int c;
|
| 3448 | int d = 2, e;
|
| 3449 | declStmt(containsDeclaration(
|
| 3450 | 0, varDecl(hasInitializer(anything()))))
|
| 3451 | matches only 'int d = 2, e;', and
|
| 3452 | declStmt(containsDeclaration(1, varDecl()))
|
| 3453 | matches 'int a, b = 0' as well as 'int d = 2, e;'
|
| 3454 | but 'int c;' is not matched.
|
| 3455 | </pre></td></tr>
|
| 3456 |
|
| 3457 |
|
| 3458 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>></td><td class="name" onclick="toggle('hasSingleDecl0')"><a name="hasSingleDecl0Anchor">hasSingleDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3459 | <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration.
|
| 3460 |
|
| 3461 | Given
|
| 3462 | int a, b;
|
| 3463 | int c;
|
| 3464 | declStmt(hasSingleDecl(anything()))
|
| 3465 | matches 'int c;' but not 'int a, b;'.
|
| 3466 | </pre></td></tr>
|
| 3467 |
|
| 3468 |
|
| 3469 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>></td><td class="name" onclick="toggle('hasTypeLoc0')"><a name="hasTypeLoc0Anchor">hasTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr>
|
| 3470 | <tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches
|
| 3471 | the inner matcher.
|
| 3472 |
|
| 3473 | Given
|
| 3474 | int x;
|
| 3475 | declaratorDecl(hasTypeLoc(loc(asString("int"))))
|
| 3476 | matches int x
|
| 3477 | </pre></td></tr>
|
| 3478 |
|
| 3479 |
|
| 3480 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('hasDeclContext0')"><a name="hasDeclContext0Anchor">hasDeclContext</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3481 | <tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a
|
| 3482 | Decl, matches InnerMatcher.
|
| 3483 |
|
| 3484 | Given
|
| 3485 | namespace N {
|
| 3486 | namespace M {
|
| 3487 | class D {};
|
| 3488 | }
|
| 3489 | }
|
| 3490 |
|
| 3491 | recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
|
| 3492 | declaration of class D.
|
| 3493 | </pre></td></tr>
|
| 3494 |
|
| 3495 |
|
| 3496 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>></td><td class="name" onclick="toggle('hasBody0')"><a name="hasBody0Anchor">hasBody</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr>
|
| 3497 | <tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has
|
| 3498 | a given body.
|
| 3499 |
|
| 3500 | Given
|
| 3501 | for (;;) {}
|
| 3502 | hasBody(compoundStmt())
|
| 3503 | matches 'for (;;) {}'
|
| 3504 | with compoundStmt()
|
| 3505 | matching '{}'
|
| 3506 | </pre></td></tr>
|
| 3507 |
|
| 3508 |
|
| 3509 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>></td><td class="name" onclick="toggle('hasCondition3')"><a name="hasCondition3Anchor">hasCondition</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3510 | <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop,
|
| 3511 | or conditional operator.
|
| 3512 |
|
| 3513 | Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
|
| 3514 | if (true) {}
|
| 3515 | </pre></td></tr>
|
| 3516 |
|
| 3517 |
|
| 3518 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>></td><td class="name" onclick="toggle('hasQualifier0')"><a name="hasQualifier0Anchor">hasQualifier</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr>
|
| 3519 | <tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
|
| 3520 | matches InnerMatcher if the qualifier exists.
|
| 3521 |
|
| 3522 | Given
|
| 3523 | namespace N {
|
| 3524 | namespace M {
|
| 3525 | class D {};
|
| 3526 | }
|
| 3527 | }
|
| 3528 | N::M::D d;
|
| 3529 |
|
| 3530 | elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"))))
|
| 3531 | matches the type of the variable declaration of d.
|
| 3532 | </pre></td></tr>
|
| 3533 |
|
| 3534 |
|
| 3535 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>></td><td class="name" onclick="toggle('namesType0')"><a name="namesType0Anchor">namesType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 3536 | <tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher.
|
| 3537 |
|
| 3538 | Given
|
| 3539 | namespace N {
|
| 3540 | namespace M {
|
| 3541 | class D {};
|
| 3542 | }
|
| 3543 | }
|
| 3544 | N::M::D d;
|
| 3545 |
|
| 3546 | elaboratedType(namesType(recordType(
|
| 3547 | hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
|
| 3548 | declaration of d.
|
| 3549 | </pre></td></tr>
|
| 3550 |
|
| 3551 |
|
| 3552 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>></td><td class="name" onclick="toggle('hasDeclaration10')"><a name="hasDeclaration10Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3553 | <tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node
|
| 3554 | matches the given matcher.
|
| 3555 |
|
| 3556 | The associated declaration is:
|
| 3557 | - for type nodes, the declaration of the underlying type
|
| 3558 | - for CallExpr, the declaration of the callee
|
| 3559 | - for MemberExpr, the declaration of the referenced member
|
| 3560 | - for CXXConstructExpr, the declaration of the constructor
|
| 3561 |
|
| 3562 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 3563 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 3564 |
|
| 3565 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 3566 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 3567 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 3568 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 3569 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 3570 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 3571 | </pre></td></tr>
|
| 3572 |
|
| 3573 |
|
| 3574 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>></td><td class="name" onclick="toggle('hasDestinationType0')"><a name="hasDestinationType0Anchor">hasDestinationType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 3575 | <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher.
|
| 3576 |
|
| 3577 | (Note: Clang's AST refers to other conversions as "casts" too, and calls
|
| 3578 | actual casts "explicit" casts.)
|
| 3579 | </pre></td></tr>
|
| 3580 |
|
| 3581 |
|
| 3582 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('hasType2')"><a name="hasType2Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3583 | <tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value
|
| 3584 | declaration's type.
|
| 3585 |
|
| 3586 | In case of a value declaration (for example a variable declaration),
|
| 3587 | this resolves one layer of indirection. For example, in the value
|
| 3588 | declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
|
| 3589 | while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
|
| 3590 | of x."
|
| 3591 |
|
| 3592 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
|
| 3593 | and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
|
| 3594 | class X {};
|
| 3595 | void y(X &x) { x; X z; }
|
| 3596 |
|
| 3597 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>
|
| 3598 | </pre></td></tr>
|
| 3599 |
|
| 3600 |
|
| 3601 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('hasType0')"><a name="hasType0Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 3602 | <tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type
|
| 3603 | matcher.
|
| 3604 |
|
| 3605 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
|
| 3606 | and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
|
| 3607 | class X {};
|
| 3608 | void y(X &x) { x; X z; }
|
| 3609 | </pre></td></tr>
|
| 3610 |
|
| 3611 |
|
| 3612 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('ignoringImpCasts0')"><a name="ignoringImpCasts0Anchor">ignoringImpCasts</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3613 | <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts
|
| 3614 | are stripped off.
|
| 3615 |
|
| 3616 | Parentheses and explicit casts are not discarded.
|
| 3617 | Given
|
| 3618 | int arr[5];
|
| 3619 | int a = 0;
|
| 3620 | char b = 0;
|
| 3621 | const int c = a;
|
| 3622 | int *d = arr;
|
| 3623 | long e = (long) 0l;
|
| 3624 | The matchers
|
| 3625 | varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
|
| 3626 | varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
|
| 3627 | would match the declarations for a, b, c, and d, but not e.
|
| 3628 | While
|
| 3629 | varDecl(hasInitializer(integerLiteral()))
|
| 3630 | varDecl(hasInitializer(declRefExpr()))
|
| 3631 | only match the declarations for b, c, and d.
|
| 3632 | </pre></td></tr>
|
| 3633 |
|
| 3634 |
|
| 3635 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('ignoringParenCasts0')"><a name="ignoringParenCasts0Anchor">ignoringParenCasts</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3636 | <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and
|
| 3637 | casts are stripped off.
|
| 3638 |
|
| 3639 | Implicit and non-C Style casts are also discarded.
|
| 3640 | Given
|
| 3641 | int a = 0;
|
| 3642 | char b = (0);
|
| 3643 | void* c = reinterpret_cast<char*>(0);
|
| 3644 | char d = char(0);
|
| 3645 | The matcher
|
| 3646 | varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
|
| 3647 | would match the declarations for a, b, c, and d.
|
| 3648 | while
|
| 3649 | varDecl(hasInitializer(integerLiteral()))
|
| 3650 | only match the declaration for a.
|
| 3651 | </pre></td></tr>
|
| 3652 |
|
| 3653 |
|
| 3654 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('ignoringParenImpCasts0')"><a name="ignoringParenImpCasts0Anchor">ignoringParenImpCasts</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3655 | <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and
|
| 3656 | parentheses are stripped off.
|
| 3657 |
|
| 3658 | Explicit casts are not discarded.
|
| 3659 | Given
|
| 3660 | int arr[5];
|
| 3661 | int a = 0;
|
| 3662 | char b = (0);
|
| 3663 | const int c = a;
|
| 3664 | int *d = (arr);
|
| 3665 | long e = ((long) 0l);
|
| 3666 | The matchers
|
| 3667 | varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
|
| 3668 | varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
|
| 3669 | would match the declarations for a, b, c, and d, but not e.
|
| 3670 | while
|
| 3671 | varDecl(hasInitializer(integerLiteral()))
|
| 3672 | varDecl(hasInitializer(declRefExpr()))
|
| 3673 | would only match the declaration for a.
|
| 3674 | </pre></td></tr>
|
| 3675 |
|
| 3676 |
|
| 3677 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>></td><td class="name" onclick="toggle('hasBody1')"><a name="hasBody1Anchor">hasBody</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr>
|
| 3678 | <tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has
|
| 3679 | a given body.
|
| 3680 |
|
| 3681 | Given
|
| 3682 | for (;;) {}
|
| 3683 | hasBody(compoundStmt())
|
| 3684 | matches 'for (;;) {}'
|
| 3685 | with compoundStmt()
|
| 3686 | matching '{}'
|
| 3687 | </pre></td></tr>
|
| 3688 |
|
| 3689 |
|
| 3690 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>></td><td class="name" onclick="toggle('hasCondition1')"><a name="hasCondition1Anchor">hasCondition</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3691 | <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop,
|
| 3692 | or conditional operator.
|
| 3693 |
|
| 3694 | Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
|
| 3695 | if (true) {}
|
| 3696 | </pre></td></tr>
|
| 3697 |
|
| 3698 |
|
| 3699 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>></td><td class="name" onclick="toggle('hasIncrement0')"><a name="hasIncrement0Anchor">hasIncrement</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr>
|
| 3700 | <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop.
|
| 3701 |
|
| 3702 | Example:
|
| 3703 | forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
|
| 3704 | matches '++x' in
|
| 3705 | for (x; x < N; ++x) { }
|
| 3706 | </pre></td></tr>
|
| 3707 |
|
| 3708 |
|
| 3709 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>></td><td class="name" onclick="toggle('hasLoopInit0')"><a name="hasLoopInit0Anchor">hasLoopInit</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr>
|
| 3710 | <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop.
|
| 3711 |
|
| 3712 | Example:
|
| 3713 | forStmt(hasLoopInit(declStmt()))
|
| 3714 | matches 'int x = 0' in
|
| 3715 | for (int x = 0; x < N; ++x) { }
|
| 3716 | </pre></td></tr>
|
| 3717 |
|
| 3718 |
|
| 3719 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasAnyParameter0')"><a name="hasAnyParameter0Anchor">hasAnyParameter</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr>
|
| 3720 | <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration.
|
| 3721 |
|
| 3722 | Does not match the 'this' parameter of a method.
|
| 3723 |
|
| 3724 | Given
|
| 3725 | class X { void f(int x, int y, int z) {} };
|
| 3726 | methodDecl(hasAnyParameter(hasName("y")))
|
| 3727 | matches f(int x, int y, int z) {}
|
| 3728 | with hasAnyParameter(...)
|
| 3729 | matching int y
|
| 3730 | </pre></td></tr>
|
| 3731 |
|
| 3732 |
|
| 3733 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasParameter0')"><a name="hasParameter0Anchor">hasParameter</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr>
|
| 3734 | <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration.
|
| 3735 |
|
| 3736 | Given
|
| 3737 | class X { void f(int x) {} };
|
| 3738 | methodDecl(hasParameter(0, hasType(varDecl())))
|
| 3739 | matches f(int x) {}
|
| 3740 | with hasParameter(...)
|
| 3741 | matching int x
|
| 3742 | </pre></td></tr>
|
| 3743 |
|
| 3744 |
|
| 3745 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('returns0')"><a name="returns0Anchor">returns</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 3746 | <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration.
|
| 3747 |
|
| 3748 | Given:
|
| 3749 | class X { int f() { return 1; } };
|
| 3750 | methodDecl(returns(asString("int")))
|
| 3751 | matches int f() { return 1; }
|
| 3752 | </pre></td></tr>
|
| 3753 |
|
| 3754 |
|
| 3755 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasCondition0')"><a name="hasCondition0Anchor">hasCondition</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3756 | <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop,
|
| 3757 | or conditional operator.
|
| 3758 |
|
| 3759 | Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
|
| 3760 | if (true) {}
|
| 3761 | </pre></td></tr>
|
| 3762 |
|
| 3763 |
|
| 3764 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasConditionVariableStatement0')"><a name="hasConditionVariableStatement0Anchor">hasConditionVariableStatement</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>> InnerMatcher</td></tr>
|
| 3765 | <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement.
|
| 3766 |
|
| 3767 | Given
|
| 3768 | if (A* a = GetAPointer()) {}
|
| 3769 | hasConditionVariableStatement(...)
|
| 3770 | matches 'A* a = GetAPointer()'.
|
| 3771 | </pre></td></tr>
|
| 3772 |
|
| 3773 |
|
| 3774 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasElse0')"><a name="hasElse0Anchor">hasElse</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr>
|
| 3775 | <tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement.
|
| 3776 |
|
| 3777 | Examples matches the if statement
|
| 3778 | (matcher = ifStmt(hasElse(boolLiteral(equals(true)))))
|
| 3779 | if (false) false; else true;
|
| 3780 | </pre></td></tr>
|
| 3781 |
|
| 3782 |
|
| 3783 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasThen0')"><a name="hasThen0Anchor">hasThen</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr>
|
| 3784 | <tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement.
|
| 3785 |
|
| 3786 | Examples matches the if statement
|
| 3787 | (matcher = ifStmt(hasThen(boolLiteral(equals(true)))))
|
| 3788 | if (false) true; else false;
|
| 3789 | </pre></td></tr>
|
| 3790 |
|
| 3791 |
|
| 3792 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr</a>></td><td class="name" onclick="toggle('hasImplicitDestinationType0')"><a name="hasImplicitDestinationType0Anchor">hasImplicitDestinationType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 3793 | <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given
|
| 3794 | matcher.
|
| 3795 |
|
| 3796 | FIXME: Unit test this matcher
|
| 3797 | </pre></td></tr>
|
| 3798 |
|
| 3799 |
|
| 3800 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>></td><td class="name" onclick="toggle('hasDeclaration9')"><a name="hasDeclaration9Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3801 | <tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node
|
| 3802 | matches the given matcher.
|
| 3803 |
|
| 3804 | The associated declaration is:
|
| 3805 | - for type nodes, the declaration of the underlying type
|
| 3806 | - for CallExpr, the declaration of the callee
|
| 3807 | - for MemberExpr, the declaration of the referenced member
|
| 3808 | - for CXXConstructExpr, the declaration of the constructor
|
| 3809 |
|
| 3810 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 3811 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 3812 |
|
| 3813 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 3814 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 3815 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 3816 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 3817 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 3818 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 3819 | </pre></td></tr>
|
| 3820 |
|
| 3821 |
|
| 3822 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>></td><td class="name" onclick="toggle('hasDeclaration8')"><a name="hasDeclaration8Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3823 | <tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node
|
| 3824 | matches the given matcher.
|
| 3825 |
|
| 3826 | The associated declaration is:
|
| 3827 | - for type nodes, the declaration of the underlying type
|
| 3828 | - for CallExpr, the declaration of the callee
|
| 3829 | - for MemberExpr, the declaration of the referenced member
|
| 3830 | - for CXXConstructExpr, the declaration of the constructor
|
| 3831 |
|
| 3832 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 3833 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 3834 |
|
| 3835 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 3836 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 3837 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 3838 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 3839 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 3840 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 3841 | </pre></td></tr>
|
| 3842 |
|
| 3843 |
|
| 3844 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('hasDeclaration7')"><a name="hasDeclaration7Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 3845 | <tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node
|
| 3846 | matches the given matcher.
|
| 3847 |
|
| 3848 | The associated declaration is:
|
| 3849 | - for type nodes, the declaration of the underlying type
|
| 3850 | - for CallExpr, the declaration of the callee
|
| 3851 | - for MemberExpr, the declaration of the referenced member
|
| 3852 | - for CXXConstructExpr, the declaration of the constructor
|
| 3853 |
|
| 3854 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 3855 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 3856 |
|
| 3857 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 3858 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 3859 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 3860 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 3861 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 3862 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 3863 | </pre></td></tr>
|
| 3864 |
|
| 3865 |
|
| 3866 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('hasObjectExpression0')"><a name="hasObjectExpression0Anchor">hasObjectExpression</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3867 | <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is
|
| 3868 | matched by a given matcher.
|
| 3869 |
|
| 3870 | Given
|
| 3871 | struct X { int m; };
|
| 3872 | void f(X x) { x.m; m; }
|
| 3873 | memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))))
|
| 3874 | matches "x.m" and "m"
|
| 3875 | with hasObjectExpression(...)
|
| 3876 | matching "x" and the implicit object expression of "m" which has type X*.
|
| 3877 | </pre></td></tr>
|
| 3878 |
|
| 3879 |
|
| 3880 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('member0')"><a name="member0Anchor">member</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>> InnerMatcher</td></tr>
|
| 3881 | <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a
|
| 3882 | given matcher.
|
| 3883 |
|
| 3884 | Given
|
| 3885 | struct { int first, second; } first, second;
|
| 3886 | int i(second.first);
|
| 3887 | int j(first.second);
|
| 3888 | memberExpr(member(hasName("first")))
|
| 3889 | matches second.first
|
| 3890 | but not first.second (because the member name there is "second").
|
| 3891 | </pre></td></tr>
|
| 3892 |
|
| 3893 |
|
| 3894 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerTypeLoc.html">MemberPointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc1')"><a name="pointeeLoc1Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr>
|
| 3895 | <tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the
|
| 3896 | pointee matches a given matcher.
|
| 3897 |
|
| 3898 | Given
|
| 3899 | int *a;
|
| 3900 | int const *b;
|
| 3901 | float const *f;
|
| 3902 | pointerType(pointee(isConstQualified(), isInteger()))
|
| 3903 | matches "int const *b"
|
| 3904 |
|
| 3905 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>,
|
| 3906 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>
|
| 3907 | </pre></td></tr>
|
| 3908 |
|
| 3909 |
|
| 3910 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>></td><td class="name" onclick="toggle('pointee1')"><a name="pointee1Anchor">pointee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr>
|
| 3911 | <tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the
|
| 3912 | pointee matches a given matcher.
|
| 3913 |
|
| 3914 | Given
|
| 3915 | int *a;
|
| 3916 | int const *b;
|
| 3917 | float const *f;
|
| 3918 | pointerType(pointee(isConstQualified(), isInteger()))
|
| 3919 | matches "int const *b"
|
| 3920 |
|
| 3921 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>,
|
| 3922 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>
|
| 3923 | </pre></td></tr>
|
| 3924 |
|
| 3925 |
|
| 3926 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>></td><td class="name" onclick="toggle('hasPrefix1')"><a name="hasPrefix1Anchor">hasPrefix</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>> InnerMatcher</td></tr>
|
| 3927 | <tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
|
| 3928 |
|
| 3929 | Given
|
| 3930 | struct A { struct B { struct C {}; }; };
|
| 3931 | A::B::C c;
|
| 3932 | nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
|
| 3933 | matches "A::"
|
| 3934 | </pre></td></tr>
|
| 3935 |
|
| 3936 |
|
| 3937 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>></td><td class="name" onclick="toggle('specifiesTypeLoc0')"><a name="specifiesTypeLoc0Anchor">specifiesTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> InnerMatcher</td></tr>
|
| 3938 | <tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the
|
| 3939 | given TypeLoc.
|
| 3940 |
|
| 3941 | Given
|
| 3942 | struct A { struct B { struct C {}; }; };
|
| 3943 | A::B::C c;
|
| 3944 | nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
|
| 3945 | hasDeclaration(recordDecl(hasName("A")))))))
|
| 3946 | matches "A::"
|
| 3947 | </pre></td></tr>
|
| 3948 |
|
| 3949 |
|
| 3950 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>></td><td class="name" onclick="toggle('hasPrefix0')"><a name="hasPrefix0Anchor">hasPrefix</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr>
|
| 3951 | <tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier.
|
| 3952 |
|
| 3953 | Given
|
| 3954 | struct A { struct B { struct C {}; }; };
|
| 3955 | A::B::C c;
|
| 3956 | nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
|
| 3957 | matches "A::"
|
| 3958 | </pre></td></tr>
|
| 3959 |
|
| 3960 |
|
| 3961 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>></td><td class="name" onclick="toggle('specifiesNamespace0')"><a name="specifiesNamespace0Anchor">specifiesNamespace</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>> InnerMatcher</td></tr>
|
| 3962 | <tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the
|
| 3963 | given namespace matcher.
|
| 3964 |
|
| 3965 | Given
|
| 3966 | namespace ns { struct A {}; }
|
| 3967 | ns::A a;
|
| 3968 | nestedNameSpecifier(specifiesNamespace(hasName("ns")))
|
| 3969 | matches "ns::"
|
| 3970 | </pre></td></tr>
|
| 3971 |
|
| 3972 |
|
| 3973 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>></td><td class="name" onclick="toggle('specifiesType0')"><a name="specifiesType0Anchor">specifiesType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 3974 | <tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the
|
| 3975 | given QualType matcher without qualifiers.
|
| 3976 |
|
| 3977 | Given
|
| 3978 | struct A { struct B { struct C {}; }; };
|
| 3979 | A::B::C c;
|
| 3980 | nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A")))))
|
| 3981 | matches "A::"
|
| 3982 | </pre></td></tr>
|
| 3983 |
|
| 3984 |
|
| 3985 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasArgument2')"><a name="hasArgument2Anchor">hasArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 3986 | <tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor
|
| 3987 | call expression.
|
| 3988 |
|
| 3989 | Example matches y in x(y)
|
| 3990 | (matcher = callExpr(hasArgument(0, declRefExpr())))
|
| 3991 | void x(int) { int y; x(y); }
|
| 3992 | </pre></td></tr>
|
| 3993 |
|
| 3994 |
|
| 3995 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasReceiverType0')"><a name="hasReceiverType0Anchor">hasReceiverType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 3996 | <tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression.
|
| 3997 |
|
| 3998 | Example
|
| 3999 | matcher = objCMessageExpr(hasRecieverType(asString("UIWebView *")));
|
| 4000 | matches the [webView ...] message invocation.
|
| 4001 | NSString *webViewJavaScript = ...
|
| 4002 | UIWebView *webView = ...
|
| 4003 | [webView stringByEvaluatingJavaScriptFromString:webViewJavascript];
|
| 4004 | </pre></td></tr>
|
| 4005 |
|
| 4006 |
|
| 4007 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>></td><td class="name" onclick="toggle('innerType0')"><a name="innerType0Anchor">innerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr>
|
| 4008 | <tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type.
|
| 4009 |
|
| 4010 | Given
|
| 4011 | int (*ptr_to_array)[4];
|
| 4012 | int (*ptr_to_func)(int);
|
| 4013 |
|
| 4014 | varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
|
| 4015 | ptr_to_func but not ptr_to_array.
|
| 4016 |
|
| 4017 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>>
|
| 4018 | </pre></td></tr>
|
| 4019 |
|
| 4020 |
|
| 4021 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc2')"><a name="pointeeLoc2Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr>
|
| 4022 | <tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the
|
| 4023 | pointee matches a given matcher.
|
| 4024 |
|
| 4025 | Given
|
| 4026 | int *a;
|
| 4027 | int const *b;
|
| 4028 | float const *f;
|
| 4029 | pointerType(pointee(isConstQualified(), isInteger()))
|
| 4030 | matches "int const *b"
|
| 4031 |
|
| 4032 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>,
|
| 4033 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>
|
| 4034 | </pre></td></tr>
|
| 4035 |
|
| 4036 |
|
| 4037 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>></td><td class="name" onclick="toggle('pointee2')"><a name="pointee2Anchor">pointee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr>
|
| 4038 | <tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the
|
| 4039 | pointee matches a given matcher.
|
| 4040 |
|
| 4041 | Given
|
| 4042 | int *a;
|
| 4043 | int const *b;
|
| 4044 | float const *f;
|
| 4045 | pointerType(pointee(isConstQualified(), isInteger()))
|
| 4046 | matches "int const *b"
|
| 4047 |
|
| 4048 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>,
|
| 4049 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>
|
| 4050 | </pre></td></tr>
|
| 4051 |
|
| 4052 |
|
| 4053 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasCanonicalType0')"><a name="hasCanonicalType0Anchor">hasCanonicalType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 4054 | <tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher.
|
| 4055 |
|
| 4056 | Given:
|
| 4057 | typedef int &int_ref;
|
| 4058 | int a;
|
| 4059 | int_ref b = a;
|
| 4060 |
|
| 4061 | varDecl(hasType(qualType(referenceType()))))) will not match the
|
| 4062 | declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
|
| 4063 | </pre></td></tr>
|
| 4064 |
|
| 4065 |
|
| 4066 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasDeclaration6')"><a name="hasDeclaration6Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 4067 | <tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node
|
| 4068 | matches the given matcher.
|
| 4069 |
|
| 4070 | The associated declaration is:
|
| 4071 | - for type nodes, the declaration of the underlying type
|
| 4072 | - for CallExpr, the declaration of the callee
|
| 4073 | - for MemberExpr, the declaration of the referenced member
|
| 4074 | - for CXXConstructExpr, the declaration of the constructor
|
| 4075 |
|
| 4076 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 4077 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 4078 |
|
| 4079 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 4080 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 4081 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 4082 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 4083 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 4084 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 4085 | </pre></td></tr>
|
| 4086 |
|
| 4087 |
|
| 4088 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('pointsTo1')"><a name="pointsTo1Anchor">pointsTo</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 4089 | <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration.
|
| 4090 | </pre></td></tr>
|
| 4091 |
|
| 4092 |
|
| 4093 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('pointsTo0')"><a name="pointsTo0Anchor">pointsTo</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 4094 | <tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type
|
| 4095 | matches the specified matcher.
|
| 4096 |
|
| 4097 | Example matches y->x()
|
| 4098 | (matcher = memberCallExpr(on(hasType(pointsTo
|
| 4099 | recordDecl(hasName("Y")))))))
|
| 4100 | class Y { public: void x(); };
|
| 4101 | void z() { Y *y; y->x(); }
|
| 4102 | </pre></td></tr>
|
| 4103 |
|
| 4104 |
|
| 4105 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('references1')"><a name="references1Anchor">references</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 4106 | <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration.
|
| 4107 | </pre></td></tr>
|
| 4108 |
|
| 4109 |
|
| 4110 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('references0')"><a name="references0Anchor">references</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 4111 | <tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced
|
| 4112 | type matches the specified matcher.
|
| 4113 |
|
| 4114 | Example matches X &x and const X &y
|
| 4115 | (matcher = varDecl(hasType(references(recordDecl(hasName("X"))))))
|
| 4116 | class X {
|
| 4117 | void a(X b) {
|
| 4118 | X &x = b;
|
| 4119 | const X &y = b;
|
| 4120 | }
|
| 4121 | };
|
| 4122 | </pre></td></tr>
|
| 4123 |
|
| 4124 |
|
| 4125 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>></td><td class="name" onclick="toggle('hasDeclaration5')"><a name="hasDeclaration5Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 4126 | <tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node
|
| 4127 | matches the given matcher.
|
| 4128 |
|
| 4129 | The associated declaration is:
|
| 4130 | - for type nodes, the declaration of the underlying type
|
| 4131 | - for CallExpr, the declaration of the callee
|
| 4132 | - for MemberExpr, the declaration of the referenced member
|
| 4133 | - for CXXConstructExpr, the declaration of the constructor
|
| 4134 |
|
| 4135 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 4136 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 4137 |
|
| 4138 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 4139 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 4140 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 4141 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 4142 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 4143 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 4144 | </pre></td></tr>
|
| 4145 |
|
| 4146 |
|
| 4147 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc3')"><a name="pointeeLoc3Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr>
|
| 4148 | <tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the
|
| 4149 | pointee matches a given matcher.
|
| 4150 |
|
| 4151 | Given
|
| 4152 | int *a;
|
| 4153 | int const *b;
|
| 4154 | float const *f;
|
| 4155 | pointerType(pointee(isConstQualified(), isInteger()))
|
| 4156 | matches "int const *b"
|
| 4157 |
|
| 4158 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>,
|
| 4159 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>
|
| 4160 | </pre></td></tr>
|
| 4161 |
|
| 4162 |
|
| 4163 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>></td><td class="name" onclick="toggle('pointee3')"><a name="pointee3Anchor">pointee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr>
|
| 4164 | <tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the
|
| 4165 | pointee matches a given matcher.
|
| 4166 |
|
| 4167 | Given
|
| 4168 | int *a;
|
| 4169 | int const *b;
|
| 4170 | float const *f;
|
| 4171 | pointerType(pointee(isConstQualified(), isInteger()))
|
| 4172 | matches "int const *b"
|
| 4173 |
|
| 4174 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>,
|
| 4175 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>
|
| 4176 | </pre></td></tr>
|
| 4177 |
|
| 4178 |
|
| 4179 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('alignOfExpr0')"><a name="alignOfExpr0Anchor">alignOfExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr>
|
| 4180 | <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
|
| 4181 | alignof.
|
| 4182 | </pre></td></tr>
|
| 4183 |
|
| 4184 |
|
| 4185 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('sizeOfExpr0')"><a name="sizeOfExpr0Anchor">sizeOfExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr>
|
| 4186 | <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
|
| 4187 | sizeof.
|
| 4188 | </pre></td></tr>
|
| 4189 |
|
| 4190 |
|
| 4191 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>></td><td class="name" onclick="toggle('forEachSwitchCase0')"><a name="forEachSwitchCase0Anchor">forEachSwitchCase</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>> InnerMatcher</td></tr>
|
| 4192 | <tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch
|
| 4193 | statement. This matcher may produce multiple matches.
|
| 4194 |
|
| 4195 | Given
|
| 4196 | switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
|
| 4197 | switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s")
|
| 4198 | matches four times, with "c" binding each of "case 1:", "case 2:",
|
| 4199 | "case 3:" and "case 4:", and "s" respectively binding "switch (1)",
|
| 4200 | "switch (1)", "switch (2)" and "switch (2)".
|
| 4201 | </pre></td></tr>
|
| 4202 |
|
| 4203 |
|
| 4204 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>></td><td class="name" onclick="toggle('hasDeclaration4')"><a name="hasDeclaration4Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 4205 | <tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node
|
| 4206 | matches the given matcher.
|
| 4207 |
|
| 4208 | The associated declaration is:
|
| 4209 | - for type nodes, the declaration of the underlying type
|
| 4210 | - for CallExpr, the declaration of the callee
|
| 4211 | - for MemberExpr, the declaration of the referenced member
|
| 4212 | - for CXXConstructExpr, the declaration of the constructor
|
| 4213 |
|
| 4214 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 4215 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 4216 |
|
| 4217 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 4218 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 4219 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 4220 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 4221 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 4222 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 4223 | </pre></td></tr>
|
| 4224 |
|
| 4225 |
|
| 4226 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('isExpr0')"><a name="isExpr0Anchor">isExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 4227 | <tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression.
|
| 4228 |
|
| 4229 | Given
|
| 4230 | template<typename T> struct A {};
|
| 4231 | struct B { B* next; };
|
| 4232 | A<&B::next> a;
|
| 4233 | templateSpecializationType(hasAnyTemplateArgument(
|
| 4234 | isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next"))))))))
|
| 4235 | matches the specialization A<&B::next> with fieldDecl(...) matching
|
| 4236 | B::next
|
| 4237 | </pre></td></tr>
|
| 4238 |
|
| 4239 |
|
| 4240 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('refersToDeclaration0')"><a name="refersToDeclaration0Anchor">refersToDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 4241 | <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain
|
| 4242 | declaration.
|
| 4243 |
|
| 4244 | Given
|
| 4245 | template<typename T> struct A {};
|
| 4246 | struct B { B* next; };
|
| 4247 | A<&B::next> a;
|
| 4248 | classTemplateSpecializationDecl(hasAnyTemplateArgument(
|
| 4249 | refersToDeclaration(fieldDecl(hasName("next"))))
|
| 4250 | matches the specialization A<&B::next> with fieldDecl(...) matching
|
| 4251 | B::next
|
| 4252 | </pre></td></tr>
|
| 4253 |
|
| 4254 |
|
| 4255 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('refersToIntegralType0')"><a name="refersToIntegralType0Anchor">refersToIntegralType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 4256 | <tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type.
|
| 4257 |
|
| 4258 | Given
|
| 4259 | template<int T> struct A {};
|
| 4260 | C<42> c;
|
| 4261 | classTemplateSpecializationDecl(
|
| 4262 | hasAnyTemplateArgument(refersToIntegralType(asString("int"))))
|
| 4263 | matches the implicit instantiation of C in C<42>.
|
| 4264 | </pre></td></tr>
|
| 4265 |
|
| 4266 |
|
| 4267 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('refersToType0')"><a name="refersToType0Anchor">refersToType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 4268 | <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type.
|
| 4269 |
|
| 4270 | Given
|
| 4271 | struct X {};
|
| 4272 | template<typename T> struct A {};
|
| 4273 | A<X> a;
|
| 4274 | classTemplateSpecializationDecl(hasAnyTemplateArgument(
|
| 4275 | refersToType(class(hasName("X")))))
|
| 4276 | matches the specialization A<X>
|
| 4277 | </pre></td></tr>
|
| 4278 |
|
| 4279 |
|
| 4280 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgument1')"><a name="hasAnyTemplateArgument1Anchor">hasAnyTemplateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr>
|
| 4281 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations that have at least one
|
| 4282 | TemplateArgument matching the given InnerMatcher.
|
| 4283 |
|
| 4284 | Given
|
| 4285 | template<typename T> class A {};
|
| 4286 | template<> class A<double> {};
|
| 4287 | A<int> a;
|
| 4288 | classTemplateSpecializationDecl(hasAnyTemplateArgument(
|
| 4289 | refersToType(asString("int"))))
|
| 4290 | matches the specialization A<int>
|
| 4291 | </pre></td></tr>
|
| 4292 |
|
| 4293 |
|
| 4294 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasDeclaration3')"><a name="hasDeclaration3Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 4295 | <tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node
|
| 4296 | matches the given matcher.
|
| 4297 |
|
| 4298 | The associated declaration is:
|
| 4299 | - for type nodes, the declaration of the underlying type
|
| 4300 | - for CallExpr, the declaration of the callee
|
| 4301 | - for MemberExpr, the declaration of the referenced member
|
| 4302 | - for CXXConstructExpr, the declaration of the constructor
|
| 4303 |
|
| 4304 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 4305 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 4306 |
|
| 4307 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 4308 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 4309 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 4310 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 4311 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 4312 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 4313 | </pre></td></tr>
|
| 4314 |
|
| 4315 |
|
| 4316 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasTemplateArgument1')"><a name="hasTemplateArgument1Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr>
|
| 4317 | <tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument
|
| 4318 | matches the given InnerMatcher.
|
| 4319 |
|
| 4320 | Given
|
| 4321 | template<typename T, typename U> class A {};
|
| 4322 | A<bool, int> b;
|
| 4323 | A<int, bool> c;
|
| 4324 | classTemplateSpecializationDecl(hasTemplateArgument(
|
| 4325 | 1, refersToType(asString("int"))))
|
| 4326 | matches the specialization A<bool, int>
|
| 4327 | </pre></td></tr>
|
| 4328 |
|
| 4329 |
|
| 4330 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>></td><td class="name" onclick="toggle('hasDeclaration2')"><a name="hasDeclaration2Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 4331 | <tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node
|
| 4332 | matches the given matcher.
|
| 4333 |
|
| 4334 | The associated declaration is:
|
| 4335 | - for type nodes, the declaration of the underlying type
|
| 4336 | - for CallExpr, the declaration of the callee
|
| 4337 | - for MemberExpr, the declaration of the referenced member
|
| 4338 | - for CXXConstructExpr, the declaration of the constructor
|
| 4339 |
|
| 4340 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 4341 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 4342 |
|
| 4343 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 4344 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 4345 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 4346 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 4347 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 4348 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 4349 | </pre></td></tr>
|
| 4350 |
|
| 4351 |
|
| 4352 | <tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<T> Matcher</td></tr>
|
| 4353 | <tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches.
|
| 4354 |
|
| 4355 | Generates results for each match.
|
| 4356 |
|
| 4357 | For example, in:
|
| 4358 | class A { class B {}; class C {}; };
|
| 4359 | The matcher:
|
| 4360 | recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m")))
|
| 4361 | will generate results for A, B and C.
|
| 4362 |
|
| 4363 | Usable as: Any Matcher
|
| 4364 | </pre></td></tr>
|
| 4365 |
|
| 4366 |
|
| 4367 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>></td><td class="name" onclick="toggle('hasDeclaration1')"><a name="hasDeclaration1Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 4368 | <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node
|
| 4369 | matches the given matcher.
|
| 4370 |
|
| 4371 | The associated declaration is:
|
| 4372 | - for type nodes, the declaration of the underlying type
|
| 4373 | - for CallExpr, the declaration of the callee
|
| 4374 | - for MemberExpr, the declaration of the referenced member
|
| 4375 | - for CXXConstructExpr, the declaration of the constructor
|
| 4376 |
|
| 4377 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 4378 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 4379 |
|
| 4380 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 4381 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 4382 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 4383 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 4384 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 4385 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 4386 | </pre></td></tr>
|
| 4387 |
|
| 4388 |
|
| 4389 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>></td><td class="name" onclick="toggle('hasArgumentOfType0')"><a name="hasArgumentOfType0Anchor">hasArgumentOfType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 4390 | <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument.
|
| 4391 |
|
| 4392 | Given
|
| 4393 | int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
|
| 4394 | unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
|
| 4395 | matches sizeof(a) and alignof(c)
|
| 4396 | </pre></td></tr>
|
| 4397 |
|
| 4398 |
|
| 4399 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>></td><td class="name" onclick="toggle('hasUnaryOperand0')"><a name="hasUnaryOperand0Anchor">hasUnaryOperand</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 4400 | <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches.
|
| 4401 |
|
| 4402 | Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true))))
|
| 4403 | !true
|
| 4404 | </pre></td></tr>
|
| 4405 |
|
| 4406 |
|
| 4407 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>></td><td class="name" onclick="toggle('hasDeclaration0')"><a name="hasDeclaration0Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 4408 | <tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node
|
| 4409 | matches the given matcher.
|
| 4410 |
|
| 4411 | The associated declaration is:
|
| 4412 | - for type nodes, the declaration of the underlying type
|
| 4413 | - for CallExpr, the declaration of the callee
|
| 4414 | - for MemberExpr, the declaration of the referenced member
|
| 4415 | - for CXXConstructExpr, the declaration of the constructor
|
| 4416 |
|
| 4417 | Also usable as Matcher<T> for any T supporting the getDecl() member
|
| 4418 | function. e.g. various subtypes of clang::Type and various expressions.
|
| 4419 |
|
| 4420 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>,
|
| 4421 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>,
|
| 4422 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>,
|
| 4423 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>,
|
| 4424 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>,
|
| 4425 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>>
|
| 4426 | </pre></td></tr>
|
| 4427 |
|
| 4428 |
|
| 4429 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>></td><td class="name" onclick="toggle('hasAnyUsingShadowDecl0')"><a name="hasAnyUsingShadowDecl0Anchor">hasAnyUsingShadowDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>> InnerMatcher</td></tr>
|
| 4430 | <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration.
|
| 4431 |
|
| 4432 | Given
|
| 4433 | namespace X { void b(); }
|
| 4434 | using X::b;
|
| 4435 | usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
|
| 4436 | matches using X::b </pre></td></tr>
|
| 4437 |
|
| 4438 |
|
| 4439 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>></td><td class="name" onclick="toggle('hasTargetDecl0')"><a name="hasTargetDecl0Anchor">hasTargetDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> InnerMatcher</td></tr>
|
| 4440 | <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is
|
| 4441 | matched by the given matcher.
|
| 4442 |
|
| 4443 | Given
|
| 4444 | namespace X { int a; void b(); }
|
| 4445 | using X::a;
|
| 4446 | using X::b;
|
| 4447 | usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
|
| 4448 | matches using X::b but not using X::a </pre></td></tr>
|
| 4449 |
|
| 4450 |
|
| 4451 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType3')"><a name="hasType3Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr>
|
| 4452 | <tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value
|
| 4453 | declaration's type.
|
| 4454 |
|
| 4455 | In case of a value declaration (for example a variable declaration),
|
| 4456 | this resolves one layer of indirection. For example, in the value
|
| 4457 | declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
|
| 4458 | while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
|
| 4459 | of x."
|
| 4460 |
|
| 4461 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
|
| 4462 | and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
|
| 4463 | class X {};
|
| 4464 | void y(X &x) { x; X z; }
|
| 4465 |
|
| 4466 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>
|
| 4467 | </pre></td></tr>
|
| 4468 |
|
| 4469 |
|
| 4470 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType1')"><a name="hasType1Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 4471 | <tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type
|
| 4472 | matcher.
|
| 4473 |
|
| 4474 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
|
| 4475 | and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
|
| 4476 | class X {};
|
| 4477 | void y(X &x) { x; X z; }
|
| 4478 | </pre></td></tr>
|
| 4479 |
|
| 4480 |
|
| 4481 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasInitializer0')"><a name="hasInitializer0Anchor">hasInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 4482 | <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression
|
| 4483 | that matches the given matcher.
|
| 4484 |
|
| 4485 | Example matches x (matcher = varDecl(hasInitializer(callExpr())))
|
| 4486 | bool y() { return true; }
|
| 4487 | bool x = y();
|
| 4488 | </pre></td></tr>
|
| 4489 |
|
| 4490 |
|
| 4491 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html">VariableArrayType</a>></td><td class="name" onclick="toggle('hasSizeExpr0')"><a name="hasSizeExpr0Anchor">hasSizeExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 4492 | <tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size
|
| 4493 | expression.
|
| 4494 |
|
| 4495 | Given
|
| 4496 | void f(int b) {
|
| 4497 | int a[b];
|
| 4498 | }
|
| 4499 | variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
|
| 4500 | varDecl(hasName("b")))))))
|
| 4501 | matches "int a[b]"
|
| 4502 | </pre></td></tr>
|
| 4503 |
|
| 4504 |
|
| 4505 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>></td><td class="name" onclick="toggle('hasBody2')"><a name="hasBody2Anchor">hasBody</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr>
|
| 4506 | <tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has
|
| 4507 | a given body.
|
| 4508 |
|
| 4509 | Given
|
| 4510 | for (;;) {}
|
| 4511 | hasBody(compoundStmt())
|
| 4512 | matches 'for (;;) {}'
|
| 4513 | with compoundStmt()
|
| 4514 | matching '{}'
|
| 4515 | </pre></td></tr>
|
| 4516 |
|
| 4517 |
|
| 4518 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>></td><td class="name" onclick="toggle('hasCondition2')"><a name="hasCondition2Anchor">hasCondition</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr>
|
| 4519 | <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop,
|
| 4520 | or conditional operator.
|
| 4521 |
|
| 4522 | Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
|
| 4523 | if (true) {}
|
| 4524 | </pre></td></tr>
|
| 4525 |
|
| 4526 |
|
| 4527 | <tr><td>Matcher<internal::BindableMatcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>>></td><td class="name" onclick="toggle('loc1')"><a name="loc1Anchor">loc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr>
|
| 4528 | <tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner
|
| 4529 | NestedNameSpecifier-matcher matches.
|
| 4530 | </pre></td></tr>
|
| 4531 |
|
| 4532 |
|
| 4533 | <tr><td>Matcher<internal::BindableMatcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>></td><td class="name" onclick="toggle('loc0')"><a name="loc0Anchor">loc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr>
|
| 4534 | <tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner
|
| 4535 | QualType-matcher matches.
|
| 4536 | </pre></td></tr>
|
| 4537 |
|
| 4538 | <!--END_TRAVERSAL_MATCHERS -->
|
| 4539 | </table>
|
| 4540 |
|
| 4541 | </div>
|
| 4542 | </body>
|
| 4543 | </html>
|
| 4544 |
|
| 4545 |
|