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