Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +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) { |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 23 | if (!id) return; |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 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> |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 32 | <body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))"> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 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 | |
Manuel Klimek | 8c5f948 | 2013-06-21 09:59:59 +0000 | [diff] [blame] | 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 | |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 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 | |
Manuel Klimek | 8c5f948 | 2013-06-21 09:59:59 +0000 | [diff] [blame] | 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 | |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 99 | <table> |
| 100 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| 101 | <!-- START_DECL_MATCHERS --> |
| 102 | |
Daniel Jasper | c7093d9 | 2013-02-25 12:39:41 +0000 | [diff] [blame] | 103 | <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> |
| 104 | <tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations. |
| 105 | |
| 106 | Given |
| 107 | class C { |
| 108 | public: |
| 109 | int a; |
| 110 | }; |
| 111 | accessSpecDecl() |
| 112 | matches 'public:' |
| 113 | </pre></td></tr> |
| 114 | |
| 115 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 116 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 117 | <tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 118 | |
| 119 | Example matches Z |
| 120 | template<class T> class Z {}; |
| 121 | </pre></td></tr> |
| 122 | |
| 123 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 124 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 125 | <tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 126 | |
| 127 | Given |
| 128 | template<typename T> class A {}; |
| 129 | template<> class A<double> {}; |
| 130 | A<int> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 131 | classTemplateSpecializationDecl() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 132 | matches the specializations A<int> and A<double> |
| 133 | </pre></td></tr> |
| 134 | |
| 135 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 136 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('constructorDecl0')"><a name="constructorDecl0Anchor">constructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>>...</td></tr> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 137 | <tr><td colspan="4" class="doc" id="constructorDecl0"><pre>Matches C++ constructor declarations. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 138 | |
| 139 | Example matches Foo::Foo() and Foo::Foo(int) |
| 140 | class Foo { |
| 141 | public: |
| 142 | Foo(); |
| 143 | Foo(int); |
| 144 | int DoSomething(); |
| 145 | }; |
| 146 | </pre></td></tr> |
| 147 | |
| 148 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 149 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 150 | <tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. |
| 151 | |
| 152 | Examples matches X, C, and the friend declaration inside C; |
| 153 | void X(); |
| 154 | class C { |
| 155 | friend X; |
| 156 | }; |
| 157 | </pre></td></tr> |
| 158 | |
| 159 | |
Manuel Klimek | 1a68afd | 2013-06-20 13:08:29 +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('declaratorDecl0')"><a name="declaratorDecl0Anchor">declaratorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>...</td></tr> |
| 161 | <tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function |
| 162 | and non-type template parameter declarations). |
| 163 | |
| 164 | Given |
| 165 | class X { int y; }; |
| 166 | declaratorDecl() |
| 167 | matches int y. |
| 168 | </pre></td></tr> |
| 169 | |
| 170 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 171 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('destructorDecl0')"><a name="destructorDecl0Anchor">destructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>>...</td></tr> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 172 | <tr><td colspan="4" class="doc" id="destructorDecl0"><pre>Matches explicit C++ destructor declarations. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 173 | |
| 174 | Example matches Foo::~Foo() |
| 175 | class Foo { |
| 176 | public: |
| 177 | virtual ~Foo(); |
| 178 | }; |
| 179 | </pre></td></tr> |
| 180 | |
| 181 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 182 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 183 | <tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 184 | |
| 185 | Example matches A, B, C |
| 186 | enum X { |
| 187 | A, B, C |
| 188 | }; |
| 189 | </pre></td></tr> |
| 190 | |
| 191 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 192 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 193 | <tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. |
| 194 | |
| 195 | Example matches X |
| 196 | enum X { |
| 197 | A, B, C |
| 198 | }; |
| 199 | </pre></td></tr> |
| 200 | |
| 201 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 202 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 203 | <tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 204 | |
| 205 | Given |
| 206 | class X { int m; }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 207 | fieldDecl() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 208 | matches 'm'. |
| 209 | </pre></td></tr> |
| 210 | |
| 211 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 212 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 213 | <tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 214 | |
| 215 | Example matches f |
| 216 | void f(); |
| 217 | </pre></td></tr> |
| 218 | |
| 219 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 220 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 221 | <tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 222 | |
| 223 | Example matches f |
| 224 | template<class T> void f(T t) {} |
| 225 | </pre></td></tr> |
| 226 | |
| 227 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 228 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('methodDecl0')"><a name="methodDecl0Anchor">methodDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>>...</td></tr> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 229 | <tr><td colspan="4" class="doc" id="methodDecl0"><pre>Matches method declarations. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 230 | |
| 231 | Example matches y |
| 232 | class X { void y() }; |
| 233 | </pre></td></tr> |
| 234 | |
| 235 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 236 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 237 | <tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 238 | |
| 239 | Example matches X, S, the anonymous union type, i, and U; |
| 240 | typedef int X; |
| 241 | struct S { |
| 242 | union { |
| 243 | int i; |
| 244 | } U; |
| 245 | }; |
| 246 | </pre></td></tr> |
| 247 | |
| 248 | |
Edwin Vane | 0332e0a | 2013-05-09 16:42:37 +0000 | [diff] [blame] | 249 | <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> |
| 250 | <tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. |
| 251 | |
| 252 | Given |
| 253 | namespace {} |
| 254 | namespace test {} |
| 255 | namespaceDecl() |
| 256 | matches "namespace {}" and "namespace test {}" |
| 257 | </pre></td></tr> |
| 258 | |
| 259 | |
Manuel Klimek | 1a68afd | 2013-06-20 13:08:29 +0000 | [diff] [blame] | 260 | <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> |
| 261 | <tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. |
| 262 | |
| 263 | Given |
| 264 | void f(int x); |
| 265 | parmVarDecl() |
| 266 | matches int x. |
| 267 | </pre></td></tr> |
| 268 | |
| 269 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 270 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('recordDecl0')"><a name="recordDecl0Anchor">recordDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>...</td></tr> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 271 | <tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches C++ class declarations. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 272 | |
| 273 | Example matches X, Z |
| 274 | class X; |
| 275 | template<class T> class Z {}; |
| 276 | </pre></td></tr> |
| 277 | |
| 278 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 279 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 280 | <tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. |
| 281 | |
| 282 | Given |
| 283 | namespace X { int x; } |
| 284 | using X::x; |
| 285 | usingDecl() |
| 286 | matches using X::x </pre></td></tr> |
| 287 | |
| 288 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 289 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 290 | <tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 291 | |
| 292 | Note: this does not match declarations of member variables, which are |
| 293 | "field" declarations in Clang parlance. |
| 294 | |
| 295 | Example matches a |
| 296 | int a; |
| 297 | </pre></td></tr> |
| 298 | |
| 299 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 300 | <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> |
| 301 | <tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. |
| 302 | </pre></td></tr> |
| 303 | |
| 304 | |
| 305 | <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> |
| 306 | <tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. |
| 307 | |
| 308 | Given |
| 309 | namespace ns { |
| 310 | struct A { static void f(); }; |
| 311 | void A::f() {} |
| 312 | void g() { A::f(); } |
| 313 | } |
| 314 | ns::A a; |
| 315 | nestedNameSpecifier() |
| 316 | matches "ns::" and both "A::" |
| 317 | </pre></td></tr> |
| 318 | |
| 319 | |
| 320 | <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> |
| 321 | <tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. |
| 322 | </pre></td></tr> |
| 323 | |
| 324 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 325 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 326 | <tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. |
| 327 | |
| 328 | Given |
| 329 | int i = a[1]; |
| 330 | arraySubscriptExpr() |
| 331 | matches "a[1]" |
| 332 | </pre></td></tr> |
| 333 | |
| 334 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 335 | <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> |
| 336 | <tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. |
| 337 | |
| 338 | int i = 100; |
| 339 | __asm("mov al, 2"); |
| 340 | asmStmt() |
| 341 | matches '__asm("mov al, 2")' |
| 342 | </pre></td></tr> |
| 343 | |
| 344 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 345 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 346 | <tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. |
| 347 | |
| 348 | Example matches a || b |
| 349 | !(a || b) |
| 350 | </pre></td></tr> |
| 351 | |
| 352 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 353 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('bindTemporaryExpr0')"><a name="bindTemporaryExpr0Anchor">bindTemporaryExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>>...</td></tr> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 354 | <tr><td colspan="4" class="doc" id="bindTemporaryExpr0"><pre>Matches nodes where temporaries are created. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 355 | |
| 356 | Example matches FunctionTakesString(GetStringByValue()) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 357 | (matcher = bindTemporaryExpr()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 358 | FunctionTakesString(GetStringByValue()); |
| 359 | FunctionTakesStringByPointer(GetStringPointer()); |
| 360 | </pre></td></tr> |
| 361 | |
| 362 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 363 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('boolLiteral0')"><a name="boolLiteral0Anchor">boolLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>...</td></tr> |
| 364 | <tr><td colspan="4" class="doc" id="boolLiteral0"><pre>Matches bool literals. |
| 365 | |
| 366 | Example matches true |
| 367 | true |
| 368 | </pre></td></tr> |
| 369 | |
| 370 | |
| 371 | <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> |
| 372 | <tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. |
| 373 | |
| 374 | Given |
| 375 | while (true) { break; } |
| 376 | breakStmt() |
| 377 | matches 'break' |
| 378 | </pre></td></tr> |
| 379 | |
| 380 | |
| 381 | <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> |
| 382 | <tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. |
| 383 | |
| 384 | Example: Matches (int*) 2.2f in |
| 385 | int i = (int) 2.2f; |
| 386 | </pre></td></tr> |
| 387 | |
| 388 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 389 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 390 | <tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 391 | |
| 392 | Example matches x.y() and y() |
| 393 | X x; |
| 394 | x.y(); |
| 395 | y(); |
| 396 | </pre></td></tr> |
| 397 | |
| 398 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 399 | <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> |
| 400 | <tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. |
| 401 | |
| 402 | Given |
| 403 | switch(a) { case 42: break; default: break; } |
| 404 | caseStmt() |
| 405 | matches 'case 42: break;'. |
| 406 | </pre></td></tr> |
| 407 | |
| 408 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 409 | <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> |
| 410 | <tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. |
| 411 | |
| 412 | Example: castExpr() matches each of the following: |
| 413 | (int) 3; |
| 414 | const_cast<Expr *>(SubExpr); |
| 415 | char c = 0; |
| 416 | but does not match |
| 417 | int i = (0); |
| 418 | int k = 0; |
| 419 | </pre></td></tr> |
| 420 | |
| 421 | |
| 422 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('catchStmt0')"><a name="catchStmt0Anchor">catchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>>...</td></tr> |
| 423 | <tr><td colspan="4" class="doc" id="catchStmt0"><pre>Matches catch statements. |
| 424 | |
| 425 | try {} catch(int i) {} |
| 426 | catchStmt() |
| 427 | matches 'catch(int i)' |
| 428 | </pre></td></tr> |
| 429 | |
| 430 | |
| 431 | <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> |
| 432 | <tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). |
| 433 | |
| 434 | Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), |
| 435 | though. |
| 436 | |
| 437 | Example matches 'a', L'a' |
| 438 | char ch = 'a'; wchar_t chw = L'a'; |
| 439 | </pre></td></tr> |
| 440 | |
| 441 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 442 | <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> |
| 443 | <tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals |
| 444 | |
| 445 | Example match: {1}, (1, 2) |
| 446 | int array[4] = {1}; vector int myvec = (vector int)(1, 2); |
| 447 | </pre></td></tr> |
| 448 | |
| 449 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 450 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 451 | <tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 452 | |
| 453 | Example matches '{}' and '{{}}'in 'for (;;) {{}}' |
| 454 | for (;;) {{}} |
| 455 | </pre></td></tr> |
| 456 | |
| 457 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 458 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 459 | <tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. |
| 460 | |
| 461 | Example matches a ? b : c |
| 462 | (a ? b : c) + 42 |
| 463 | </pre></td></tr> |
| 464 | |
| 465 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 466 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('constCastExpr0')"><a name="constCastExpr0Anchor">constCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>>...</td></tr> |
| 467 | <tr><td colspan="4" class="doc" id="constCastExpr0"><pre>Matches a const_cast expression. |
| 468 | |
| 469 | Example: Matches const_cast<int*>(&r) in |
| 470 | int n = 42; |
| 471 | const int &r(n); |
| 472 | int* p = const_cast<int*>(&r); |
| 473 | </pre></td></tr> |
| 474 | |
| 475 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 476 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('constructExpr0')"><a name="constructExpr0Anchor">constructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>...</td></tr> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 477 | <tr><td colspan="4" class="doc" id="constructExpr0"><pre>Matches constructor call expressions (including implicit ones). |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 478 | |
| 479 | Example matches string(ptr, n) and ptr within arguments of f |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 480 | (matcher = constructExpr()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 481 | void f(const string &a, const string &b); |
| 482 | char *ptr; |
| 483 | int n; |
| 484 | f(string(ptr, n), ptr); |
| 485 | </pre></td></tr> |
| 486 | |
| 487 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 488 | <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> |
| 489 | <tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. |
| 490 | |
| 491 | Given |
| 492 | while (true) { continue; } |
| 493 | continueStmt() |
| 494 | matches 'continue' |
| 495 | </pre></td></tr> |
| 496 | |
| 497 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 498 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 499 | <tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 500 | |
| 501 | Example matches x in if (x) |
| 502 | bool x; |
| 503 | if (x) {} |
| 504 | </pre></td></tr> |
| 505 | |
| 506 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 507 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 508 | <tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 509 | |
| 510 | Given |
| 511 | int a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 512 | declStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 513 | matches 'int a'. |
| 514 | </pre></td></tr> |
| 515 | |
| 516 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 517 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('defaultArgExpr0')"><a name="defaultArgExpr0Anchor">defaultArgExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>>...</td></tr> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 518 | <tr><td colspan="4" class="doc" id="defaultArgExpr0"><pre>Matches the value of a default argument at the call site. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 519 | |
| 520 | Example matches the CXXDefaultArgExpr placeholder inserted for the |
| 521 | default value of the second parameter in the call expression f(42) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 522 | (matcher = defaultArgExpr()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 523 | void f(int x, int y = 0); |
| 524 | f(42); |
| 525 | </pre></td></tr> |
| 526 | |
| 527 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 528 | <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> |
| 529 | <tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. |
| 530 | |
| 531 | Given |
| 532 | switch(a) { case 42: break; default: break; } |
| 533 | defaultStmt() |
| 534 | matches 'default: break;'. |
| 535 | </pre></td></tr> |
| 536 | |
| 537 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 538 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('deleteExpr0')"><a name="deleteExpr0Anchor">deleteExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>>...</td></tr> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 539 | <tr><td colspan="4" class="doc" id="deleteExpr0"><pre>Matches delete expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 540 | |
| 541 | Given |
| 542 | delete X; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 543 | deleteExpr() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 544 | matches 'delete X'. |
| 545 | </pre></td></tr> |
| 546 | |
| 547 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 548 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 549 | <tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. |
| 550 | |
| 551 | Given |
| 552 | do {} while (true); |
| 553 | doStmt() |
| 554 | matches 'do {} while(true)' |
| 555 | </pre></td></tr> |
| 556 | |
| 557 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 558 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('dynamicCastExpr0')"><a name="dynamicCastExpr0Anchor">dynamicCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>>...</td></tr> |
| 559 | <tr><td colspan="4" class="doc" id="dynamicCastExpr0"><pre>Matches a dynamic_cast expression. |
| 560 | |
| 561 | Example: |
| 562 | dynamicCastExpr() |
| 563 | matches |
| 564 | dynamic_cast<D*>(&b); |
| 565 | in |
| 566 | struct B { virtual ~B() {} }; struct D : B {}; |
| 567 | B b; |
| 568 | D* p = dynamic_cast<D*>(&b); |
| 569 | </pre></td></tr> |
| 570 | |
| 571 | |
| 572 | <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> |
| 573 | <tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. |
| 574 | |
| 575 | Matches any cast expression written in user code, whether it be a |
| 576 | C-style cast, a functional-style cast, or a keyword cast. |
| 577 | |
| 578 | Does not match implicit conversions. |
| 579 | |
| 580 | Note: the name "explicitCast" is chosen to match Clang's terminology, as |
| 581 | Clang uses the term "cast" to apply to implicit conversions as well as to |
| 582 | actual cast expressions. |
| 583 | |
| 584 | hasDestinationType. |
| 585 | |
| 586 | Example: matches all five of the casts in |
| 587 | int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) |
| 588 | but does not match the implicit conversion in |
| 589 | long ell = 42; |
| 590 | </pre></td></tr> |
| 591 | |
| 592 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 593 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 594 | <tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 595 | |
| 596 | Example matches x() |
| 597 | void f() { x(); } |
| 598 | </pre></td></tr> |
| 599 | |
| 600 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 601 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('forRangeStmt0')"><a name="forRangeStmt0Anchor">forRangeStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>>...</td></tr> |
| 602 | <tr><td colspan="4" class="doc" id="forRangeStmt0"><pre>Matches range-based for statements. |
| 603 | |
| 604 | forRangeStmt() matches 'for (auto a : i)' |
| 605 | int i[] = {1, 2, 3}; for (auto a : i); |
| 606 | for(int j = 0; j < 5; ++j); |
| 607 | </pre></td></tr> |
| 608 | |
| 609 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 610 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 611 | <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. |
| 612 | |
| 613 | Example matches 'for (;;) {}' |
| 614 | for (;;) {} |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 615 | int i[] = {1, 2, 3}; for (auto a : i); |
| 616 | </pre></td></tr> |
| 617 | |
| 618 | |
| 619 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('functionalCastExpr0')"><a name="functionalCastExpr0Anchor">functionalCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>...</td></tr> |
| 620 | <tr><td colspan="4" class="doc" id="functionalCastExpr0"><pre>Matches functional cast expressions |
| 621 | |
| 622 | Example: Matches Foo(bar); |
| 623 | Foo f = bar; |
| 624 | Foo g = (Foo) bar; |
| 625 | Foo h = Foo(bar); |
| 626 | </pre></td></tr> |
| 627 | |
| 628 | |
| 629 | <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> |
| 630 | <tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. |
| 631 | |
| 632 | Given |
| 633 | goto FOO; |
| 634 | FOO: bar(); |
| 635 | gotoStmt() |
| 636 | matches 'goto FOO' |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 637 | </pre></td></tr> |
| 638 | |
| 639 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 640 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 641 | <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. |
| 642 | |
| 643 | Example matches 'if (x) {}' |
| 644 | if (x) {} |
| 645 | </pre></td></tr> |
| 646 | |
| 647 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 648 | <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> |
| 649 | <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. |
| 650 | |
| 651 | This matches many different places, including function call return value |
| 652 | eliding, as well as any type conversions. |
| 653 | </pre></td></tr> |
| 654 | |
| 655 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 656 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 657 | <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. |
| 658 | |
| 659 | Given |
| 660 | int a[] = { 1, 2 }; |
| 661 | struct B { int x, y; }; |
| 662 | B b = { 5, 6 }; |
| 663 | initList() |
| 664 | matches "{ 1, 2 }" and "{ 5, 6 }" |
| 665 | </pre></td></tr> |
| 666 | |
| 667 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 668 | <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> |
| 669 | <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings. |
| 670 | |
| 671 | Not matching character-encoded integers such as L'a'. |
| 672 | |
| 673 | Example matches 1, 1L, 0x1, 1U |
| 674 | </pre></td></tr> |
| 675 | |
| 676 | |
| 677 | <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> |
| 678 | <tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. |
| 679 | |
| 680 | Given |
| 681 | goto FOO; |
| 682 | FOO: bar(); |
| 683 | labelStmt() |
| 684 | matches 'FOO:' |
| 685 | </pre></td></tr> |
| 686 | |
| 687 | |
| 688 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('lambdaExpr0')"><a name="lambdaExpr0Anchor">lambdaExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>>...</td></tr> |
| 689 | <tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. |
| 690 | |
| 691 | Example matches [&](){return 5;} |
| 692 | [&](){return 5;} |
| 693 | </pre></td></tr> |
| 694 | |
| 695 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 696 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 697 | <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. |
| 698 | |
| 699 | Example: Given |
| 700 | struct T {void func()}; |
| 701 | T f(); |
| 702 | void g(T); |
| 703 | materializeTemporaryExpr() matches 'f()' in these statements |
| 704 | T u(f()); |
| 705 | g(f()); |
| 706 | but does not match |
| 707 | f(); |
| 708 | f().func(); |
| 709 | </pre></td></tr> |
| 710 | |
| 711 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 712 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('memberCallExpr0')"><a name="memberCallExpr0Anchor">memberCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>>...</td></tr> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 713 | <tr><td colspan="4" class="doc" id="memberCallExpr0"><pre>Matches member call expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 714 | |
| 715 | Example matches x.y() |
| 716 | X x; |
| 717 | x.y(); |
| 718 | </pre></td></tr> |
| 719 | |
| 720 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 721 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 722 | <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 723 | |
| 724 | Given |
| 725 | class Y { |
| 726 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 727 | int a; static int b; |
| 728 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 729 | memberExpr() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 730 | matches this->x, x, y.x, a, this->b |
| 731 | </pre></td></tr> |
| 732 | |
| 733 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 734 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('newExpr0')"><a name="newExpr0Anchor">newExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>...</td></tr> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 735 | <tr><td colspan="4" class="doc" id="newExpr0"><pre>Matches new expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 736 | |
| 737 | Given |
| 738 | new X; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 739 | newExpr() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 740 | matches 'new X'. |
| 741 | </pre></td></tr> |
| 742 | |
| 743 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 744 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('nullPtrLiteralExpr0')"><a name="nullPtrLiteralExpr0Anchor">nullPtrLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>>...</td></tr> |
| 745 | <tr><td colspan="4" class="doc" id="nullPtrLiteralExpr0"><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('nullStmt0')"><a name="nullStmt0Anchor">nullStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NullStmt.html">NullStmt</a>>...</td></tr> |
| 750 | <tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. |
| 751 | |
| 752 | foo();; |
| 753 | nullStmt() |
| 754 | matches the second ';' |
| 755 | </pre></td></tr> |
| 756 | |
| 757 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 758 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('operatorCallExpr0')"><a name="operatorCallExpr0Anchor">operatorCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>...</td></tr> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 759 | <tr><td colspan="4" class="doc" id="operatorCallExpr0"><pre>Matches overloaded operator calls. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 760 | |
| 761 | Note that if an operator isn't overloaded, it won't match. Instead, use |
| 762 | binaryOperator matcher. |
| 763 | Currently it does not match operators such as new delete. |
| 764 | FIXME: figure out why these do not match? |
| 765 | |
| 766 | Example matches both operator<<((o << b), c) and operator<<(o, b) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 767 | (matcher = operatorCallExpr()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 768 | ostream &operator<< (ostream &out, int i) { }; |
| 769 | ostream &o; int b = 1, c = 1; |
| 770 | o << b << c; |
| 771 | </pre></td></tr> |
| 772 | |
| 773 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 774 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('reinterpretCastExpr0')"><a name="reinterpretCastExpr0Anchor">reinterpretCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>>...</td></tr> |
| 775 | <tr><td colspan="4" class="doc" id="reinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. |
| 776 | |
| 777 | Either the source expression or the destination type can be matched |
| 778 | using has(), but hasDestinationType() is more specific and can be |
| 779 | more readable. |
| 780 | |
| 781 | Example matches reinterpret_cast<char*>(&p) in |
| 782 | void* p = reinterpret_cast<char*>(&p); |
| 783 | </pre></td></tr> |
| 784 | |
| 785 | |
| 786 | <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> |
| 787 | <tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. |
| 788 | |
| 789 | Given |
| 790 | return 1; |
| 791 | returnStmt() |
| 792 | matches 'return 1' |
| 793 | </pre></td></tr> |
| 794 | |
| 795 | |
| 796 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('staticCastExpr0')"><a name="staticCastExpr0Anchor">staticCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>>...</td></tr> |
| 797 | <tr><td colspan="4" class="doc" id="staticCastExpr0"><pre>Matches a C++ static_cast expression. |
| 798 | |
| 799 | hasDestinationType |
| 800 | reinterpretCast |
| 801 | |
| 802 | Example: |
| 803 | staticCastExpr() |
| 804 | matches |
| 805 | static_cast<long>(8) |
| 806 | in |
| 807 | long eight(static_cast<long>(8)); |
| 808 | </pre></td></tr> |
| 809 | |
| 810 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 811 | <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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 812 | <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 813 | |
| 814 | Given |
| 815 | { ++a; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 816 | stmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 817 | matches both the compound statement '{ ++a; }' and '++a'. |
| 818 | </pre></td></tr> |
| 819 | |
| 820 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 821 | <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> |
| 822 | <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). |
| 823 | |
| 824 | Example matches "abcd", L"abcd" |
| 825 | char *s = "abcd"; wchar_t *ws = L"abcd" |
| 826 | </pre></td></tr> |
| 827 | |
| 828 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 829 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 830 | <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. |
| 831 | |
| 832 | Given |
| 833 | switch(a) { case 42: break; default: break; } |
| 834 | switchCase() |
| 835 | matches 'case 42: break;' and 'default: break;'. |
| 836 | </pre></td></tr> |
| 837 | |
| 838 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 839 | <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> |
| 840 | <tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. |
| 841 | |
| 842 | Given |
| 843 | switch(a) { case 42: break; default: break; } |
| 844 | switchStmt() |
| 845 | matches 'switch(a)'. |
| 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('thisExpr0')"><a name="thisExpr0Anchor">thisExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>>...</td></tr> |
| 850 | <tr><td colspan="4" class="doc" id="thisExpr0"><pre>Matches implicit and explicit this expressions. |
| 851 | |
| 852 | Example matches the implicit this expression in "return i". |
| 853 | (matcher = thisExpr()) |
| 854 | struct foo { |
| 855 | int i; |
| 856 | int f() { return i; } |
| 857 | }; |
| 858 | </pre></td></tr> |
| 859 | |
| 860 | |
| 861 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('throwExpr0')"><a name="throwExpr0Anchor">throwExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>>...</td></tr> |
| 862 | <tr><td colspan="4" class="doc" id="throwExpr0"><pre>Matches throw expressions. |
| 863 | |
| 864 | try { throw 5; } catch(int i) {} |
| 865 | throwExpr() |
| 866 | matches 'throw 5' |
| 867 | </pre></td></tr> |
| 868 | |
| 869 | |
| 870 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('tryStmt0')"><a name="tryStmt0Anchor">tryStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>>...</td></tr> |
| 871 | <tr><td colspan="4" class="doc" id="tryStmt0"><pre>Matches try statements. |
| 872 | |
| 873 | try {} catch(int i) {} |
| 874 | tryStmt() |
| 875 | matches 'try {}' |
| 876 | </pre></td></tr> |
| 877 | |
| 878 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +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('unaryExprOrTypeTraitExpr0')"><a name="unaryExprOrTypeTraitExpr0Anchor">unaryExprOrTypeTraitExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>>...</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 880 | <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) |
| 881 | |
| 882 | Given |
| 883 | Foo x = bar; |
| 884 | int y = sizeof(x) + alignof(x); |
| 885 | unaryExprOrTypeTraitExpr() |
| 886 | matches sizeof(x) and alignof(x) |
| 887 | </pre></td></tr> |
| 888 | |
| 889 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 890 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 891 | <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. |
| 892 | |
| 893 | Example matches !a |
| 894 | !a || b |
| 895 | </pre></td></tr> |
| 896 | |
| 897 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 898 | <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> |
| 899 | <tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. |
| 900 | |
| 901 | Example match: "foo"_suffix |
| 902 | </pre></td></tr> |
| 903 | |
| 904 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 905 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 906 | <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. |
| 907 | |
| 908 | Given |
| 909 | while (true) {} |
| 910 | whileStmt() |
| 911 | matches 'while (true) {}'. |
| 912 | </pre></td></tr> |
| 913 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 914 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 915 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('arrayTypeLoc0')"><a name="arrayTypeLoc0Anchor">arrayTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayTypeLoc.html">ArrayTypeLoc</a>>...</td></tr> |
| 916 | <tr><td colspan="4" class="doc" id="arrayTypeLoc0"><pre>Matches all kinds of arrays. |
| 917 | |
| 918 | Given |
| 919 | int a[] = { 2, 3 }; |
| 920 | int b[4]; |
| 921 | void f() { int c[a[0]]; } |
| 922 | arrayType() |
| 923 | matches "int a[]", "int b[4]" and "int c[a[0]]"; |
| 924 | </pre></td></tr> |
| 925 | |
| 926 | |
| 927 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('atomicTypeLoc0')"><a name="atomicTypeLoc0Anchor">atomicTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicTypeLoc.html">AtomicTypeLoc</a>>...</td></tr> |
| 928 | <tr><td colspan="4" class="doc" id="atomicTypeLoc0"><pre>Matches atomic types. |
| 929 | |
| 930 | Given |
| 931 | _Atomic(int) i; |
| 932 | atomicType() |
| 933 | matches "_Atomic(int) i" |
| 934 | </pre></td></tr> |
| 935 | |
| 936 | |
| 937 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('autoTypeLoc0')"><a name="autoTypeLoc0Anchor">autoTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoTypeLoc.html">AutoTypeLoc</a>>...</td></tr> |
| 938 | <tr><td colspan="4" class="doc" id="autoTypeLoc0"><pre>Matches types nodes representing C++11 auto types. |
| 939 | |
| 940 | Given: |
| 941 | auto n = 4; |
| 942 | int v[] = { 2, 3 } |
| 943 | for (auto i : v) { } |
| 944 | autoType() |
| 945 | matches "auto n" and "auto i" |
| 946 | </pre></td></tr> |
| 947 | |
| 948 | |
| 949 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('blockPointerTypeLoc0')"><a name="blockPointerTypeLoc0Anchor">blockPointerTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerTypeLoc.html">BlockPointerTypeLoc</a>>...</td></tr> |
| 950 | <tr><td colspan="4" class="doc" id="blockPointerTypeLoc0"><pre>Matches block pointer types, i.e. types syntactically represented as |
| 951 | "void (^)(int)". |
| 952 | |
| 953 | The pointee is always required to be a FunctionType. |
| 954 | </pre></td></tr> |
| 955 | |
| 956 | |
| 957 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('builtinTypeLoc0')"><a name="builtinTypeLoc0Anchor">builtinTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BuiltinTypeLoc.html">BuiltinTypeLoc</a>>...</td></tr> |
| 958 | <tr><td colspan="4" class="doc" id="builtinTypeLoc0"><pre>Matches builtin Types. |
| 959 | |
| 960 | Given |
| 961 | struct A {}; |
| 962 | A a; |
| 963 | int b; |
| 964 | float c; |
| 965 | bool d; |
| 966 | builtinType() |
| 967 | matches "int b", "float c" and "bool d" |
| 968 | </pre></td></tr> |
| 969 | |
| 970 | |
| 971 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('complexTypeLoc0')"><a name="complexTypeLoc0Anchor">complexTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexTypeLoc.html">ComplexTypeLoc</a>>...</td></tr> |
| 972 | <tr><td colspan="4" class="doc" id="complexTypeLoc0"><pre>Matches C99 complex types. |
| 973 | |
| 974 | Given |
| 975 | _Complex float f; |
| 976 | complexType() |
| 977 | matches "_Complex float f" |
| 978 | </pre></td></tr> |
| 979 | |
| 980 | |
| 981 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('constantArrayTypeLoc0')"><a name="constantArrayTypeLoc0Anchor">constantArrayTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayTypeLoc.html">ConstantArrayTypeLoc</a>>...</td></tr> |
| 982 | <tr><td colspan="4" class="doc" id="constantArrayTypeLoc0"><pre>Matches C arrays with a specified constant size. |
| 983 | |
| 984 | Given |
| 985 | void() { |
| 986 | int a[2]; |
| 987 | int b[] = { 2, 3 }; |
| 988 | int c[b[0]]; |
| 989 | } |
| 990 | constantArrayType() |
| 991 | matches "int a[2]" |
| 992 | </pre></td></tr> |
| 993 | |
| 994 | |
| 995 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('dependentSizedArrayTypeLoc0')"><a name="dependentSizedArrayTypeLoc0Anchor">dependentSizedArrayTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayTypeLoc.html">DependentSizedArrayTypeLoc</a>>...</td></tr> |
| 996 | <tr><td colspan="4" class="doc" id="dependentSizedArrayTypeLoc0"><pre>Matches C++ arrays whose size is a value-dependent expression. |
| 997 | |
| 998 | Given |
| 999 | template<typename T, int Size> |
| 1000 | class array { |
| 1001 | T data[Size]; |
| 1002 | }; |
| 1003 | dependentSizedArrayType |
| 1004 | matches "T data[Size]" |
| 1005 | </pre></td></tr> |
| 1006 | |
| 1007 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 1008 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('elaboratedTypeLoc0')"><a name="elaboratedTypeLoc0Anchor">elaboratedTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedTypeLoc.html">ElaboratedTypeLoc</a>>...</td></tr> |
| 1009 | <tr><td colspan="4" class="doc" id="elaboratedTypeLoc0"><pre>Matches types specified with an elaborated type keyword or with a |
| 1010 | qualified name. |
| 1011 | |
| 1012 | Given |
| 1013 | namespace N { |
| 1014 | namespace M { |
| 1015 | class D {}; |
| 1016 | } |
| 1017 | } |
| 1018 | class C {}; |
| 1019 | |
| 1020 | class C c; |
| 1021 | N::M::D d; |
| 1022 | |
| 1023 | elaboratedType() matches the type of the variable declarations of both |
| 1024 | c and d. |
| 1025 | </pre></td></tr> |
| 1026 | |
| 1027 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1028 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('functionTypeLoc0')"><a name="functionTypeLoc0Anchor">functionTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionTypeLoc.html">FunctionTypeLoc</a>>...</td></tr> |
| 1029 | <tr><td colspan="4" class="doc" id="functionTypeLoc0"><pre>Matches FunctionType nodes. |
| 1030 | |
| 1031 | Given |
| 1032 | int (*f)(int); |
| 1033 | void g(); |
| 1034 | functionType() |
| 1035 | matches "int (*f)(int)" and the type of "g". |
| 1036 | </pre></td></tr> |
| 1037 | |
| 1038 | |
| 1039 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('incompleteArrayTypeLoc0')"><a name="incompleteArrayTypeLoc0Anchor">incompleteArrayTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IncompleteArrayTypeLoc.html">IncompleteArrayTypeLoc</a>>...</td></tr> |
| 1040 | <tr><td colspan="4" class="doc" id="incompleteArrayTypeLoc0"><pre>Matches C arrays with unspecified size. |
| 1041 | |
| 1042 | Given |
| 1043 | int a[] = { 2, 3 }; |
| 1044 | int b[42]; |
| 1045 | void f(int c[]) { int d[a[0]]; }; |
| 1046 | incompleteArrayType() |
| 1047 | matches "int a[]" and "int c[]" |
| 1048 | </pre></td></tr> |
| 1049 | |
| 1050 | |
Edwin Vane | 8203d9f | 2013-03-28 13:50:22 +0000 | [diff] [blame] | 1051 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('lValueReferenceTypeLoc0')"><a name="lValueReferenceTypeLoc0Anchor">lValueReferenceTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LValueReferenceTypeLoc.html">LValueReferenceTypeLoc</a>>...</td></tr> |
| 1052 | <tr><td colspan="4" class="doc" id="lValueReferenceTypeLoc0"><pre>Matches lvalue reference types. |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1053 | |
| 1054 | Given: |
| 1055 | int *a; |
| 1056 | int &b = *a; |
| 1057 | int &&c = 1; |
| 1058 | auto &d = b; |
| 1059 | auto &&e = c; |
| 1060 | auto &&f = 2; |
| 1061 | int g = 5; |
| 1062 | |
Edwin Vane | 8203d9f | 2013-03-28 13:50:22 +0000 | [diff] [blame] | 1063 | lValueReferenceType() matches the types of b, d, and e. e is |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1064 | matched since the type is deduced as int& by reference collapsing rules. |
| 1065 | </pre></td></tr> |
| 1066 | |
| 1067 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1068 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('memberPointerTypeLoc0')"><a name="memberPointerTypeLoc0Anchor">memberPointerTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerTypeLoc.html">MemberPointerTypeLoc</a>>...</td></tr> |
| 1069 | <tr><td colspan="4" class="doc" id="memberPointerTypeLoc0"><pre>Matches member pointer types. |
| 1070 | Given |
| 1071 | struct A { int i; } |
| 1072 | A::* ptr = A::i; |
| 1073 | memberPointerType() |
| 1074 | matches "A::* ptr" |
| 1075 | </pre></td></tr> |
| 1076 | |
| 1077 | |
Edwin Vane | 88be2fd | 2013-04-01 18:33:34 +0000 | [diff] [blame] | 1078 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('parenTypeLoc0')"><a name="parenTypeLoc0Anchor">parenTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenTypeLoc.html">ParenTypeLoc</a>>...</td></tr> |
| 1079 | <tr><td colspan="4" class="doc" id="parenTypeLoc0"><pre>Matches ParenType nodes. |
| 1080 | |
| 1081 | Given |
| 1082 | int (*ptr_to_array)[4]; |
| 1083 | int *array_of_ptrs[4]; |
| 1084 | |
| 1085 | varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not |
| 1086 | array_of_ptrs. |
| 1087 | </pre></td></tr> |
| 1088 | |
| 1089 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1090 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('pointerTypeLoc0')"><a name="pointerTypeLoc0Anchor">pointerTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>>...</td></tr> |
| 1091 | <tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer types. |
| 1092 | |
| 1093 | Given |
| 1094 | int *a; |
| 1095 | int &b = *a; |
| 1096 | int c = 5; |
| 1097 | pointerType() |
| 1098 | matches "int *a" |
| 1099 | </pre></td></tr> |
| 1100 | |
| 1101 | |
Edwin Vane | 8203d9f | 2013-03-28 13:50:22 +0000 | [diff] [blame] | 1102 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('rValueReferenceTypeLoc0')"><a name="rValueReferenceTypeLoc0Anchor">rValueReferenceTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RValueReferenceTypeLoc.html">RValueReferenceTypeLoc</a>>...</td></tr> |
| 1103 | <tr><td colspan="4" class="doc" id="rValueReferenceTypeLoc0"><pre>Matches rvalue reference types. |
| 1104 | |
| 1105 | Given: |
| 1106 | int *a; |
| 1107 | int &b = *a; |
| 1108 | int &&c = 1; |
| 1109 | auto &d = b; |
| 1110 | auto &&e = c; |
| 1111 | auto &&f = 2; |
| 1112 | int g = 5; |
| 1113 | |
| 1114 | rValueReferenceType() matches the types of c and f. e is not |
| 1115 | matched as it is deduced to int& by reference collapsing rules. |
| 1116 | </pre></td></tr> |
| 1117 | |
| 1118 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 1119 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('recordTypeLoc0')"><a name="recordTypeLoc0Anchor">recordTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordTypeLoc.html">RecordTypeLoc</a>>...</td></tr> |
| 1120 | <tr><td colspan="4" class="doc" id="recordTypeLoc0"><pre>Matches record types (e.g. structs, classes). |
| 1121 | |
| 1122 | Given |
| 1123 | class C {}; |
| 1124 | struct S {}; |
| 1125 | |
| 1126 | C c; |
| 1127 | S s; |
| 1128 | |
| 1129 | recordType() matches the type of the variable declarations of both c |
| 1130 | and s. |
| 1131 | </pre></td></tr> |
| 1132 | |
| 1133 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1134 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('referenceTypeLoc0')"><a name="referenceTypeLoc0Anchor">referenceTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>>...</td></tr> |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1135 | <tr><td colspan="4" class="doc" id="referenceTypeLoc0"><pre>Matches both lvalue and rvalue reference types. |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1136 | |
| 1137 | Given |
| 1138 | int *a; |
| 1139 | int &b = *a; |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1140 | int &&c = 1; |
| 1141 | auto &d = b; |
| 1142 | auto &&e = c; |
| 1143 | auto &&f = 2; |
| 1144 | int g = 5; |
| 1145 | |
| 1146 | referenceType() matches the types of b, c, d, e, and f. |
| 1147 | </pre></td></tr> |
| 1148 | |
| 1149 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 1150 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('templateSpecializationTypeLoc0')"><a name="templateSpecializationTypeLoc0Anchor">templateSpecializationTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>>...</td></tr> |
| 1151 | <tr><td colspan="4" class="doc" id="templateSpecializationTypeLoc0"><pre>Matches template specialization types. |
| 1152 | |
| 1153 | Given |
| 1154 | template <typename T> |
| 1155 | class C { }; |
| 1156 | |
| 1157 | template class C<int>; A |
| 1158 | C<char> var; B |
| 1159 | |
| 1160 | templateSpecializationType() matches the type of the explicit |
| 1161 | instantiation in A and the type of the variable declaration in B. |
| 1162 | </pre></td></tr> |
| 1163 | |
| 1164 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1165 | <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> |
| 1166 | <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. |
| 1167 | </pre></td></tr> |
| 1168 | |
| 1169 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1170 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('typedefTypeLoc0')"><a name="typedefTypeLoc0Anchor">typedefTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefTypeLoc.html">TypedefTypeLoc</a>>...</td></tr> |
| 1171 | <tr><td colspan="4" class="doc" id="typedefTypeLoc0"><pre>Matches typedef types. |
| 1172 | |
| 1173 | Given |
| 1174 | typedef int X; |
| 1175 | typedefType() |
| 1176 | matches "typedef int X" |
| 1177 | </pre></td></tr> |
| 1178 | |
| 1179 | |
| 1180 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('variableArrayTypeLoc0')"><a name="variableArrayTypeLoc0Anchor">variableArrayTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VariableArrayTypeLoc.html">VariableArrayTypeLoc</a>>...</td></tr> |
| 1181 | <tr><td colspan="4" class="doc" id="variableArrayTypeLoc0"><pre>Matches C arrays with a specified size that is not an |
| 1182 | integer-constant-expression. |
| 1183 | |
| 1184 | Given |
| 1185 | void f() { |
| 1186 | int a[] = { 2, 3 } |
| 1187 | int b[42]; |
| 1188 | int c[a[0]]; |
| 1189 | variableArrayType() |
| 1190 | matches "int c[a[0]]" |
| 1191 | </pre></td></tr> |
| 1192 | |
| 1193 | |
| 1194 | <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> |
| 1195 | <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. |
| 1196 | |
| 1197 | Given |
| 1198 | int a[] = { 2, 3 }; |
| 1199 | int b[4]; |
| 1200 | void f() { int c[a[0]]; } |
| 1201 | arrayType() |
| 1202 | matches "int a[]", "int b[4]" and "int c[a[0]]"; |
| 1203 | </pre></td></tr> |
| 1204 | |
| 1205 | |
| 1206 | <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> |
| 1207 | <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. |
| 1208 | |
| 1209 | Given |
| 1210 | _Atomic(int) i; |
| 1211 | atomicType() |
| 1212 | matches "_Atomic(int) i" |
| 1213 | </pre></td></tr> |
| 1214 | |
| 1215 | |
| 1216 | <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> |
| 1217 | <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. |
| 1218 | |
| 1219 | Given: |
| 1220 | auto n = 4; |
| 1221 | int v[] = { 2, 3 } |
| 1222 | for (auto i : v) { } |
| 1223 | autoType() |
| 1224 | matches "auto n" and "auto i" |
| 1225 | </pre></td></tr> |
| 1226 | |
| 1227 | |
| 1228 | <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> |
| 1229 | <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as |
| 1230 | "void (^)(int)". |
| 1231 | |
| 1232 | The pointee is always required to be a FunctionType. |
| 1233 | </pre></td></tr> |
| 1234 | |
| 1235 | |
| 1236 | <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> |
| 1237 | <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. |
| 1238 | |
| 1239 | Given |
| 1240 | struct A {}; |
| 1241 | A a; |
| 1242 | int b; |
| 1243 | float c; |
| 1244 | bool d; |
| 1245 | builtinType() |
| 1246 | matches "int b", "float c" and "bool d" |
| 1247 | </pre></td></tr> |
| 1248 | |
| 1249 | |
| 1250 | <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> |
| 1251 | <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. |
| 1252 | |
| 1253 | Given |
| 1254 | _Complex float f; |
| 1255 | complexType() |
| 1256 | matches "_Complex float f" |
| 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('constantArrayType0')"><a name="constantArrayType0Anchor">constantArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>>...</td></tr> |
| 1261 | <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. |
| 1262 | |
| 1263 | Given |
| 1264 | void() { |
| 1265 | int a[2]; |
| 1266 | int b[] = { 2, 3 }; |
| 1267 | int c[b[0]]; |
| 1268 | } |
| 1269 | constantArrayType() |
| 1270 | matches "int a[2]" |
| 1271 | </pre></td></tr> |
| 1272 | |
| 1273 | |
| 1274 | <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> |
| 1275 | <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. |
| 1276 | |
| 1277 | Given |
| 1278 | template<typename T, int Size> |
| 1279 | class array { |
| 1280 | T data[Size]; |
| 1281 | }; |
| 1282 | dependentSizedArrayType |
| 1283 | matches "T data[Size]" |
| 1284 | </pre></td></tr> |
| 1285 | |
| 1286 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 1287 | <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> |
| 1288 | <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a |
| 1289 | qualified name. |
| 1290 | |
| 1291 | Given |
| 1292 | namespace N { |
| 1293 | namespace M { |
| 1294 | class D {}; |
| 1295 | } |
| 1296 | } |
| 1297 | class C {}; |
| 1298 | |
| 1299 | class C c; |
| 1300 | N::M::D d; |
| 1301 | |
| 1302 | elaboratedType() matches the type of the variable declarations of both |
| 1303 | c and d. |
| 1304 | </pre></td></tr> |
| 1305 | |
| 1306 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1307 | <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> |
| 1308 | <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. |
| 1309 | |
| 1310 | Given |
| 1311 | int (*f)(int); |
| 1312 | void g(); |
| 1313 | functionType() |
| 1314 | matches "int (*f)(int)" and the type of "g". |
| 1315 | </pre></td></tr> |
| 1316 | |
| 1317 | |
| 1318 | <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> |
| 1319 | <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. |
| 1320 | |
| 1321 | Given |
| 1322 | int a[] = { 2, 3 }; |
| 1323 | int b[42]; |
| 1324 | void f(int c[]) { int d[a[0]]; }; |
| 1325 | incompleteArrayType() |
| 1326 | matches "int a[]" and "int c[]" |
| 1327 | </pre></td></tr> |
| 1328 | |
| 1329 | |
Edwin Vane | 8203d9f | 2013-03-28 13:50:22 +0000 | [diff] [blame] | 1330 | <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> |
| 1331 | <tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1332 | |
| 1333 | Given: |
| 1334 | int *a; |
| 1335 | int &b = *a; |
| 1336 | int &&c = 1; |
| 1337 | auto &d = b; |
| 1338 | auto &&e = c; |
| 1339 | auto &&f = 2; |
| 1340 | int g = 5; |
| 1341 | |
Edwin Vane | 8203d9f | 2013-03-28 13:50:22 +0000 | [diff] [blame] | 1342 | lValueReferenceType() matches the types of b, d, and e. e is |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1343 | matched since the type is deduced as int& by reference collapsing rules. |
| 1344 | </pre></td></tr> |
| 1345 | |
| 1346 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1347 | <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> |
| 1348 | <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. |
| 1349 | Given |
| 1350 | struct A { int i; } |
| 1351 | A::* ptr = A::i; |
| 1352 | memberPointerType() |
| 1353 | matches "A::* ptr" |
| 1354 | </pre></td></tr> |
| 1355 | |
| 1356 | |
Edwin Vane | 88be2fd | 2013-04-01 18:33:34 +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 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 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> |
| 1370 | <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types. |
| 1371 | |
| 1372 | Given |
| 1373 | int *a; |
| 1374 | int &b = *a; |
| 1375 | int c = 5; |
| 1376 | pointerType() |
| 1377 | matches "int *a" |
| 1378 | </pre></td></tr> |
| 1379 | |
| 1380 | |
Edwin Vane | 8203d9f | 2013-03-28 13:50:22 +0000 | [diff] [blame] | 1381 | <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> |
| 1382 | <tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. |
| 1383 | |
| 1384 | Given: |
| 1385 | int *a; |
| 1386 | int &b = *a; |
| 1387 | int &&c = 1; |
| 1388 | auto &d = b; |
| 1389 | auto &&e = c; |
| 1390 | auto &&f = 2; |
| 1391 | int g = 5; |
| 1392 | |
| 1393 | rValueReferenceType() matches the types of c and f. e is not |
| 1394 | matched as it is deduced to int& by reference collapsing rules. |
| 1395 | </pre></td></tr> |
| 1396 | |
| 1397 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 1398 | <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> |
| 1399 | <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). |
| 1400 | |
| 1401 | Given |
| 1402 | class C {}; |
| 1403 | struct S {}; |
| 1404 | |
| 1405 | C c; |
| 1406 | S s; |
| 1407 | |
| 1408 | recordType() matches the type of the variable declarations of both c |
| 1409 | and s. |
| 1410 | </pre></td></tr> |
| 1411 | |
| 1412 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1413 | <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> |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1414 | <tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1415 | |
| 1416 | Given |
| 1417 | int *a; |
| 1418 | int &b = *a; |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1419 | int &&c = 1; |
| 1420 | auto &d = b; |
| 1421 | auto &&e = c; |
| 1422 | auto &&f = 2; |
| 1423 | int g = 5; |
| 1424 | |
| 1425 | referenceType() matches the types of b, c, d, e, and f. |
| 1426 | </pre></td></tr> |
| 1427 | |
| 1428 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 1429 | <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> |
| 1430 | <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. |
| 1431 | |
| 1432 | Given |
| 1433 | template <typename T> |
| 1434 | class C { }; |
| 1435 | |
| 1436 | template class C<int>; A |
| 1437 | C<char> var; B |
| 1438 | |
| 1439 | templateSpecializationType() matches the type of the explicit |
| 1440 | instantiation in A and the type of the variable declaration in B. |
| 1441 | </pre></td></tr> |
| 1442 | |
| 1443 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1444 | <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> |
| 1445 | <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. |
| 1446 | </pre></td></tr> |
| 1447 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1448 | |
| 1449 | <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> |
| 1450 | <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. |
| 1451 | |
| 1452 | Given |
| 1453 | typedef int X; |
| 1454 | typedefType() |
| 1455 | matches "typedef int X" |
| 1456 | </pre></td></tr> |
| 1457 | |
| 1458 | |
| 1459 | <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> |
| 1460 | <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an |
| 1461 | integer-constant-expression. |
| 1462 | |
| 1463 | Given |
| 1464 | void f() { |
| 1465 | int a[] = { 2, 3 } |
| 1466 | int b[42]; |
| 1467 | int c[a[0]]; |
| 1468 | variableArrayType() |
| 1469 | matches "int c[a[0]]" |
| 1470 | </pre></td></tr> |
| 1471 | |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1472 | <!--END_DECL_MATCHERS --> |
| 1473 | </table> |
| 1474 | |
| 1475 | <!-- ======================================================================= --> |
| 1476 | <h2 id="narrowing-matchers">Narrowing Matchers</h2> |
| 1477 | <!-- ======================================================================= --> |
| 1478 | |
| 1479 | <p>Narrowing matchers match certain attributes on the current node, thus |
| 1480 | narrowing down the set of nodes of the current type to match on.</p> |
| 1481 | |
| 1482 | <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) |
| 1483 | which allow users to create more powerful match expressions.</p> |
| 1484 | |
| 1485 | <table> |
| 1486 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| 1487 | <!-- START_NARROWING_MATCHERS --> |
| 1488 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1489 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*> P1, Matcher<*> P2</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1490 | <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. |
| 1491 | |
| 1492 | Usable as: Any Matcher |
| 1493 | </pre></td></tr> |
| 1494 | |
| 1495 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1496 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*> P1, Matcher<*> P2</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1497 | <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. |
| 1498 | |
| 1499 | Usable as: Any Matcher |
| 1500 | </pre></td></tr> |
| 1501 | |
| 1502 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1503 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1504 | <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. |
| 1505 | |
| 1506 | Useful when another matcher requires a child matcher, but there's no |
| 1507 | additional constraint. This will often be used with an explicit conversion |
| 1508 | to an internal::Matcher<> type such as TypeMatcher. |
| 1509 | |
| 1510 | Example: DeclarationMatcher(anything()) matches all declarations, e.g., |
| 1511 | "int* p" and "void f()" in |
| 1512 | int* p; |
| 1513 | void f(); |
| 1514 | |
| 1515 | Usable as: Any Matcher |
| 1516 | </pre></td></tr> |
| 1517 | |
| 1518 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1519 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*> InnerMatcher</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1520 | <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. |
| 1521 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1522 | Example matches Y (matcher = recordDecl(unless(hasName("X")))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1523 | class X {}; |
| 1524 | class Y {}; |
| 1525 | |
| 1526 | Usable as: Any Matcher |
| 1527 | </pre></td></tr> |
| 1528 | |
| 1529 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1530 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1531 | <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or |
| 1532 | unary). |
| 1533 | |
| 1534 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 1535 | !(a || b) |
| 1536 | </pre></td></tr> |
| 1537 | |
| 1538 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1539 | <tr><td>Matcher<CXXBoolLiteral></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1540 | <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value. |
| 1541 | |
| 1542 | Example matches true (matcher = boolLiteral(equals(true))) |
| 1543 | true |
| 1544 | |
| 1545 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1546 | 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>> |
| 1547 | </pre></td></tr> |
| 1548 | |
| 1549 | |
Samuel Benzaquen | ef7eb02 | 2013-06-21 15:51:31 +0000 | [diff] [blame] | 1550 | <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> |
| 1551 | <tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has |
| 1552 | a specific number of arguments (including absent default arguments). |
| 1553 | |
| 1554 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 1555 | void f(int x, int y); |
| 1556 | f(0, 0); |
| 1557 | </pre></td></tr> |
| 1558 | |
| 1559 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1560 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1561 | <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a constructor declaration that has been implicitly added |
| 1562 | by the compiler (eg. implicit defaultcopy constructors). |
| 1563 | </pre></td></tr> |
| 1564 | |
| 1565 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1566 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1567 | <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a contructor initializer if it is explicitly written in |
| 1568 | code (as opposed to implicitly added by the compiler). |
| 1569 | |
| 1570 | Given |
| 1571 | struct Foo { |
| 1572 | Foo() { } |
| 1573 | Foo(int) : foo_("A") { } |
| 1574 | string foo_; |
| 1575 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1576 | constructorDecl(hasAnyConstructorInitializer(isWritten())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1577 | will match Foo(int), but not Foo() |
| 1578 | </pre></td></tr> |
| 1579 | |
| 1580 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 1581 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1582 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. |
| 1583 | |
| 1584 | Matches overloaded operator names specified in strings without the |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 1585 | "operator" prefix: e.g. "<<". |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1586 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 1587 | Given: |
| 1588 | class A { int operator*(); }; |
| 1589 | const A &operator<<(const A &a, const A &b); |
| 1590 | A a; |
| 1591 | a << a; <-- This matches |
| 1592 | |
| 1593 | operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified |
| 1594 | line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches |
| 1595 | the declaration of A. |
| 1596 | |
| 1597 | 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_1CXXMethodDecl.html">CXXMethodDecl</a>> |
| 1598 | </pre></td></tr> |
| 1599 | |
| 1600 | |
Edwin Vane | 32a6ebc | 2013-05-09 17:00:17 +0000 | [diff] [blame] | 1601 | <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> |
| 1602 | <tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. |
| 1603 | |
| 1604 | Given |
| 1605 | struct A { |
| 1606 | void foo() const; |
| 1607 | void bar(); |
| 1608 | }; |
| 1609 | |
| 1610 | methodDecl(isConst()) matches A::foo() but not A::bar() |
| 1611 | </pre></td></tr> |
| 1612 | |
| 1613 | |
Edwin Vane | 5771a2f | 2013-04-09 20:46:36 +0000 | [diff] [blame] | 1614 | <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> |
| 1615 | <tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. |
| 1616 | |
| 1617 | Given |
| 1618 | class A { |
| 1619 | public: |
| 1620 | virtual void x(); |
| 1621 | }; |
| 1622 | class B : public A { |
| 1623 | public: |
| 1624 | virtual void x(); |
| 1625 | }; |
| 1626 | matches B::x |
| 1627 | </pre></td></tr> |
| 1628 | |
| 1629 | |
| 1630 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isVirtual0')"><a name="isVirtual0Anchor">isVirtual</a></td><td></td></tr> |
| 1631 | <tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. |
| 1632 | |
| 1633 | Given |
| 1634 | class A { |
| 1635 | public: |
| 1636 | virtual void x(); |
| 1637 | }; |
| 1638 | matches A::x |
| 1639 | </pre></td></tr> |
| 1640 | |
| 1641 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 1642 | <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> |
| 1643 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. |
| 1644 | |
| 1645 | Matches overloaded operator names specified in strings without the |
| 1646 | "operator" prefix: e.g. "<<". |
| 1647 | |
| 1648 | Given: |
| 1649 | class A { int operator*(); }; |
| 1650 | const A &operator<<(const A &a, const A &b); |
| 1651 | A a; |
| 1652 | a << a; <-- This matches |
| 1653 | |
| 1654 | operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified |
| 1655 | line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches |
| 1656 | the declaration of A. |
| 1657 | |
| 1658 | 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_1CXXMethodDecl.html">CXXMethodDecl</a>> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1659 | </pre></td></tr> |
| 1660 | |
| 1661 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1662 | <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>StringRef BaseName</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1663 | <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). |
| 1664 | </pre></td></tr> |
| 1665 | |
| 1666 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1667 | <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> |
| 1668 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1669 | static member variable template instantiations. |
| 1670 | |
| 1671 | Given |
| 1672 | template<typename T> void A(T t) { } |
| 1673 | template<> void A(int N) { } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1674 | functionDecl(isExplicitTemplateSpecialization()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1675 | matches the specialization A<int>(). |
| 1676 | |
| 1677 | 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>> |
| 1678 | </pre></td></tr> |
| 1679 | |
| 1680 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1681 | <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>StringRef BaseName</td></tr> |
| 1682 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for |
| 1683 | isSameOrDerivedFrom(hasName(...)). |
| 1684 | </pre></td></tr> |
| 1685 | |
| 1686 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1687 | <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> |
| 1688 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1689 | member variable template instantiations. |
| 1690 | |
| 1691 | Given |
| 1692 | template <typename T> class X {}; class A {}; X<A> x; |
| 1693 | or |
| 1694 | template <typename T> class X {}; class A {}; template class X<A>; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1695 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1696 | matches the template instantiation of X<A>. |
| 1697 | |
| 1698 | But given |
| 1699 | template <typename T> class X {}; class A {}; |
| 1700 | template <> class X<A> {}; X<A> x; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1701 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1702 | does not match, as X<A> is an explicit template specialization. |
| 1703 | |
| 1704 | 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>> |
| 1705 | </pre></td></tr> |
| 1706 | |
| 1707 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1708 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1709 | <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has |
| 1710 | a specific number of arguments (including absent default arguments). |
| 1711 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1712 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1713 | void f(int x, int y); |
| 1714 | f(0, 0); |
| 1715 | </pre></td></tr> |
| 1716 | |
| 1717 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1718 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1719 | <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value. |
| 1720 | |
| 1721 | Example matches true (matcher = boolLiteral(equals(true))) |
| 1722 | true |
| 1723 | |
| 1724 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1725 | 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>> |
| 1726 | </pre></td></tr> |
| 1727 | |
| 1728 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1729 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1730 | <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of |
| 1731 | child statements. |
| 1732 | |
| 1733 | Example: Given |
| 1734 | { for (;;) {} } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1735 | compoundStmt(statementCountIs(0))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1736 | matches '{}' |
| 1737 | but does not match the outer compound statement. |
| 1738 | </pre></td></tr> |
| 1739 | |
| 1740 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1741 | <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> |
| 1742 | <tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size. |
| 1743 | |
| 1744 | Given |
| 1745 | int a[42]; |
| 1746 | int b[2 * 21]; |
| 1747 | int c[41], d[43]; |
| 1748 | constantArrayType(hasSize(42)) |
| 1749 | matches "int a[42]" and "int b[2 * 21]" |
| 1750 | </pre></td></tr> |
| 1751 | |
| 1752 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1753 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1754 | <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of |
| 1755 | declarations. |
| 1756 | |
| 1757 | Example: Given |
| 1758 | int a, b; |
| 1759 | int c; |
| 1760 | int d = 2, e; |
| 1761 | declCountIs(2) |
| 1762 | matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. |
| 1763 | </pre></td></tr> |
| 1764 | |
| 1765 | |
Manuel Klimek | cf52ca6 | 2013-06-20 14:06:32 +0000 | [diff] [blame] | 1766 | <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> |
| 1767 | <tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. |
| 1768 | |
| 1769 | Matches a node if it equals the node previously bound to ID. |
| 1770 | |
| 1771 | Given |
| 1772 | class X { int a; int b; }; |
| 1773 | recordDecl( |
| 1774 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 1775 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 1776 | matches the class X, as a and b have the same type. |
| 1777 | |
| 1778 | Note that when multiple matches are involved via forEach* matchers, |
| 1779 | equalsBoundNodes acts as a filter. |
| 1780 | For example: |
| 1781 | compoundStmt( |
| 1782 | forEachDescendant(varDecl().bind("d")), |
| 1783 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 1784 | will trigger a match for each combination of variable declaration |
| 1785 | and reference to that variable declaration within a compound statement. |
| 1786 | </pre></td></tr> |
| 1787 | |
| 1788 | |
Manuel Klimek | fa37c5c | 2013-02-07 12:42:10 +0000 | [diff] [blame] | 1789 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('equalsNode0')"><a name="equalsNode0Anchor">equalsNode</a></td><td>Decl* Other</td></tr> |
| 1790 | <tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node. |
| 1791 | |
| 1792 | Decl has pointer identity in the AST. |
| 1793 | </pre></td></tr> |
| 1794 | |
| 1795 | |
Daniel Jasper | c7093d9 | 2013-02-25 12:39:41 +0000 | [diff] [blame] | 1796 | <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> |
| 1797 | <tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. |
| 1798 | |
| 1799 | Given |
| 1800 | class C { |
| 1801 | public: int a; |
| 1802 | protected: int b; |
| 1803 | private: int c; |
| 1804 | }; |
| 1805 | fieldDecl(isPrivate()) |
| 1806 | matches 'int c;' |
| 1807 | </pre></td></tr> |
| 1808 | |
| 1809 | |
| 1810 | <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> |
| 1811 | <tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. |
| 1812 | |
| 1813 | Given |
| 1814 | class C { |
| 1815 | public: int a; |
| 1816 | protected: int b; |
| 1817 | private: int c; |
| 1818 | }; |
| 1819 | fieldDecl(isProtected()) |
| 1820 | matches 'int b;' |
| 1821 | </pre></td></tr> |
| 1822 | |
| 1823 | |
| 1824 | <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> |
| 1825 | <tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. |
| 1826 | |
| 1827 | Given |
| 1828 | class C { |
| 1829 | public: int a; |
| 1830 | protected: int b; |
| 1831 | private: int c; |
| 1832 | }; |
| 1833 | fieldDecl(isPublic()) |
| 1834 | matches 'int a;' |
| 1835 | </pre></td></tr> |
| 1836 | |
| 1837 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1838 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1839 | <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. |
| 1840 | |
| 1841 | Example matches true (matcher = boolLiteral(equals(true))) |
| 1842 | true |
| 1843 | |
| 1844 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1845 | 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>> |
| 1846 | </pre></td></tr> |
| 1847 | |
| 1848 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1849 | <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> |
| 1850 | <tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1851 | |
| 1852 | Example matches A, va, fa |
| 1853 | class A {}; |
| 1854 | class B; Doesn't match, as it has no body. |
| 1855 | int va; |
| 1856 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 1857 | void fa() {} |
| 1858 | void fb(); Doesn't match, as it has no body. |
| 1859 | |
| 1860 | 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>> |
| 1861 | </pre></td></tr> |
| 1862 | |
| 1863 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1864 | <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> |
| 1865 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1866 | static member variable template instantiations. |
| 1867 | |
| 1868 | Given |
| 1869 | template<typename T> void A(T t) { } |
| 1870 | template<> void A(int N) { } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1871 | functionDecl(isExplicitTemplateSpecialization()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1872 | matches the specialization A<int>(). |
| 1873 | |
| 1874 | 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>> |
| 1875 | </pre></td></tr> |
| 1876 | |
| 1877 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1878 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1879 | <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. |
| 1880 | |
| 1881 | Given: |
| 1882 | extern "C" void f() {} |
| 1883 | extern "C" { void g() {} } |
| 1884 | void h() {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1885 | functionDecl(isExternC()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1886 | matches the declaration of f and g, but not the declaration h |
| 1887 | </pre></td></tr> |
| 1888 | |
| 1889 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1890 | <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> |
| 1891 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1892 | member variable template instantiations. |
| 1893 | |
| 1894 | Given |
| 1895 | template <typename T> class X {}; class A {}; X<A> x; |
| 1896 | or |
| 1897 | template <typename T> class X {}; class A {}; template class X<A>; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1898 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1899 | matches the template instantiation of X<A>. |
| 1900 | |
| 1901 | But given |
| 1902 | template <typename T> class X {}; class A {}; |
| 1903 | template <> class X<A> {}; X<A> x; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1904 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1905 | does not match, as X<A> is an explicit template specialization. |
| 1906 | |
| 1907 | 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>> |
| 1908 | </pre></td></tr> |
| 1909 | |
| 1910 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1911 | <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> |
| 1912 | <tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count. |
| 1913 | |
| 1914 | Given |
| 1915 | void f(int i) {} |
| 1916 | void g(int i, int j) {} |
| 1917 | functionDecl(parameterCountIs(2)) |
| 1918 | matches g(int i, int j) {} |
| 1919 | </pre></td></tr> |
| 1920 | |
| 1921 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1922 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1923 | <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. |
| 1924 | |
| 1925 | Example matches true (matcher = boolLiteral(equals(true))) |
| 1926 | true |
| 1927 | |
| 1928 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1929 | 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>> |
| 1930 | </pre></td></tr> |
| 1931 | |
| 1932 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1933 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1934 | <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed |
| 1935 | to '.'. |
| 1936 | |
| 1937 | Member calls on the implicit this pointer match as called with '->'. |
| 1938 | |
| 1939 | Given |
| 1940 | class Y { |
| 1941 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 1942 | int a; |
| 1943 | static int b; |
| 1944 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1945 | memberExpr(isArrow()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1946 | matches this->x, x, y.x, a, this->b |
| 1947 | </pre></td></tr> |
| 1948 | |
| 1949 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1950 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1951 | <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. |
| 1952 | |
| 1953 | Supports specifying enclosing namespaces or classes by prefixing the name |
| 1954 | with '<enclosing>::'. |
| 1955 | Does not match typedefs of an underlying type with the given name. |
| 1956 | |
| 1957 | Example matches X (Name == "X") |
| 1958 | class X; |
| 1959 | |
| 1960 | Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") |
| 1961 | namespace a { namespace b { class X; } } |
| 1962 | </pre></td></tr> |
| 1963 | |
| 1964 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1965 | <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> |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1966 | <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain |
| 1967 | a substring matched by the given RegExp. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1968 | |
| 1969 | Supports specifying enclosing namespaces or classes by |
| 1970 | prefixing the name with '<enclosing>::'. Does not match typedefs |
| 1971 | of an underlying type with the given name. |
| 1972 | |
| 1973 | Example matches X (regexp == "::X") |
| 1974 | class X; |
| 1975 | |
| 1976 | Example matches X (regexp is one of "::X", "^foo::.*X", among others) |
| 1977 | namespace foo { namespace bar { class X; } } |
| 1978 | </pre></td></tr> |
| 1979 | |
| 1980 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1981 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1982 | <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. |
| 1983 | |
| 1984 | Given |
| 1985 | class Y { public: void x(); }; |
| 1986 | void z() { Y* y; y->x(); } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1987 | callExpr(on(hasType(asString("class Y *")))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1988 | matches y->x() |
| 1989 | </pre></td></tr> |
| 1990 | |
| 1991 | |
Manuel Klimek | cf52ca6 | 2013-06-20 14:06:32 +0000 | [diff] [blame] | 1992 | <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> |
| 1993 | <tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. |
| 1994 | |
| 1995 | Matches a node if it equals the node previously bound to ID. |
| 1996 | |
| 1997 | Given |
| 1998 | class X { int a; int b; }; |
| 1999 | recordDecl( |
| 2000 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 2001 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 2002 | matches the class X, as a and b have the same type. |
| 2003 | |
| 2004 | Note that when multiple matches are involved via forEach* matchers, |
| 2005 | equalsBoundNodes acts as a filter. |
| 2006 | For example: |
| 2007 | compoundStmt( |
| 2008 | forEachDescendant(varDecl().bind("d")), |
| 2009 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 2010 | will trigger a match for each combination of variable declaration |
| 2011 | and reference to that variable declaration within a compound statement. |
| 2012 | </pre></td></tr> |
| 2013 | |
| 2014 | |
Edwin Vane | 7b69cd0 | 2013-04-02 18:15:55 +0000 | [diff] [blame] | 2015 | <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> |
| 2016 | <tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to |
| 2017 | the node, not hidden within a typedef. |
| 2018 | |
| 2019 | Given |
| 2020 | typedef const int const_int; |
| 2021 | const_int i; |
| 2022 | int *const j; |
| 2023 | int *volatile k; |
| 2024 | int m; |
| 2025 | varDecl(hasType(hasLocalQualifiers())) matches only j and k. |
| 2026 | i is const-qualified but the qualifier is not local. |
| 2027 | </pre></td></tr> |
| 2028 | |
| 2029 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2030 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2031 | <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that |
| 2032 | include "top-level" const. |
| 2033 | |
| 2034 | Given |
| 2035 | void a(int); |
| 2036 | void b(int const); |
| 2037 | void c(const int); |
| 2038 | void d(const int*); |
| 2039 | void e(int const) {}; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2040 | functionDecl(hasAnyParameter(hasType(isConstQualified()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2041 | matches "void b(int const)", "void c(const int)" and |
| 2042 | "void e(int const) {}". It does not match d as there |
| 2043 | is no top-level const on the parameter type "const int *". |
| 2044 | </pre></td></tr> |
| 2045 | |
| 2046 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2047 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2048 | <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. |
| 2049 | |
| 2050 | Given |
| 2051 | void a(int); |
| 2052 | void b(long); |
| 2053 | void c(double); |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2054 | functionDecl(hasAnyParameter(hasType(isInteger()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2055 | matches "a(int)", "b(long)", but not "c(double)". |
| 2056 | </pre></td></tr> |
| 2057 | |
| 2058 | |
Manuel Klimek | cf52ca6 | 2013-06-20 14:06:32 +0000 | [diff] [blame] | 2059 | <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> |
| 2060 | <tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. |
| 2061 | |
| 2062 | Matches a node if it equals the node previously bound to ID. |
| 2063 | |
| 2064 | Given |
| 2065 | class X { int a; int b; }; |
| 2066 | recordDecl( |
| 2067 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 2068 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 2069 | matches the class X, as a and b have the same type. |
| 2070 | |
| 2071 | Note that when multiple matches are involved via forEach* matchers, |
| 2072 | equalsBoundNodes acts as a filter. |
| 2073 | For example: |
| 2074 | compoundStmt( |
| 2075 | forEachDescendant(varDecl().bind("d")), |
| 2076 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 2077 | will trigger a match for each combination of variable declaration |
| 2078 | and reference to that variable declaration within a compound statement. |
| 2079 | </pre></td></tr> |
| 2080 | |
| 2081 | |
Manuel Klimek | fa37c5c | 2013-02-07 12:42:10 +0000 | [diff] [blame] | 2082 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('equalsNode1')"><a name="equalsNode1Anchor">equalsNode</a></td><td>Stmt* Other</td></tr> |
| 2083 | <tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. |
| 2084 | |
| 2085 | Stmt has pointer identity in the AST. |
| 2086 | |
| 2087 | </pre></td></tr> |
| 2088 | |
| 2089 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 2090 | <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> |
| 2091 | <tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2092 | |
| 2093 | Example matches A, va, fa |
| 2094 | class A {}; |
| 2095 | class B; Doesn't match, as it has no body. |
| 2096 | int va; |
| 2097 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 2098 | void fa() {} |
| 2099 | void fb(); Doesn't match, as it has no body. |
| 2100 | |
| 2101 | 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>> |
| 2102 | </pre></td></tr> |
| 2103 | |
| 2104 | |
Manuel Klimek | cf52ca6 | 2013-06-20 14:06:32 +0000 | [diff] [blame] | 2105 | <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> |
| 2106 | <tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. |
| 2107 | |
| 2108 | Matches a node if it equals the node previously bound to ID. |
| 2109 | |
| 2110 | Given |
| 2111 | class X { int a; int b; }; |
| 2112 | recordDecl( |
| 2113 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 2114 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 2115 | matches the class X, as a and b have the same type. |
| 2116 | |
| 2117 | Note that when multiple matches are involved via forEach* matchers, |
| 2118 | equalsBoundNodes acts as a filter. |
| 2119 | For example: |
| 2120 | compoundStmt( |
| 2121 | forEachDescendant(varDecl().bind("d")), |
| 2122 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 2123 | will trigger a match for each combination of variable declaration |
| 2124 | and reference to that variable declaration within a compound statement. |
| 2125 | </pre></td></tr> |
| 2126 | |
| 2127 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2128 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2129 | <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. |
| 2130 | |
| 2131 | Given |
| 2132 | int x; |
| 2133 | int s = sizeof(x) + alignof(x) |
| 2134 | unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) |
| 2135 | matches sizeof(x) |
| 2136 | </pre></td></tr> |
| 2137 | |
| 2138 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2139 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2140 | <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or |
| 2141 | unary). |
| 2142 | |
| 2143 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 2144 | !(a || b) |
| 2145 | </pre></td></tr> |
| 2146 | |
| 2147 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2148 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2149 | <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. |
| 2150 | |
| 2151 | Example matches A, va, fa |
| 2152 | class A {}; |
| 2153 | class B; Doesn't match, as it has no body. |
| 2154 | int va; |
| 2155 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 2156 | void fa() {} |
| 2157 | void fb(); Doesn't match, as it has no body. |
| 2158 | |
| 2159 | 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>> |
| 2160 | </pre></td></tr> |
| 2161 | |
| 2162 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2163 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2164 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or |
| 2165 | static member variable template instantiations. |
| 2166 | |
| 2167 | Given |
| 2168 | template<typename T> void A(T t) { } |
| 2169 | template<> void A(int N) { } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2170 | functionDecl(isExplicitTemplateSpecialization()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2171 | matches the specialization A<int>(). |
| 2172 | |
| 2173 | 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>> |
| 2174 | </pre></td></tr> |
| 2175 | |
| 2176 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2177 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2178 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static |
| 2179 | member variable template instantiations. |
| 2180 | |
| 2181 | Given |
| 2182 | template <typename T> class X {}; class A {}; X<A> x; |
| 2183 | or |
| 2184 | template <typename T> class X {}; class A {}; template class X<A>; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2185 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2186 | matches the template instantiation of X<A>. |
| 2187 | |
| 2188 | But given |
| 2189 | template <typename T> class X {}; class A {}; |
| 2190 | template <> class X<A> {}; X<A> x; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2191 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2192 | does not match, as X<A> is an explicit template specialization. |
| 2193 | |
| 2194 | 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>> |
| 2195 | </pre></td></tr> |
| 2196 | |
| 2197 | <!--END_NARROWING_MATCHERS --> |
| 2198 | </table> |
| 2199 | |
| 2200 | <!-- ======================================================================= --> |
| 2201 | <h2 id="traversal-matchers">AST Traversal Matchers</h2> |
| 2202 | <!-- ======================================================================= --> |
| 2203 | |
| 2204 | <p>Traversal matchers specify the relationship to other nodes that are |
| 2205 | reachable from the current node.</p> |
| 2206 | |
| 2207 | <p>Note that there are special traversal matchers (has, hasDescendant, forEach and |
| 2208 | forEachDescendant) which work on all nodes and allow users to write more generic |
| 2209 | match expressions.</p> |
| 2210 | |
| 2211 | <table> |
| 2212 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| 2213 | <!-- START_TRAVERSAL_MATCHERS --> |
| 2214 | |
Manuel Klimek | 152ea0e | 2013-02-04 10:59:20 +0000 | [diff] [blame] | 2215 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*> P1, Matcher<*> P2</td></tr> |
| 2216 | <tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. |
| 2217 | |
| 2218 | Unlike anyOf, eachOf will generate a match result for each |
| 2219 | matching submatcher. |
| 2220 | |
| 2221 | For example, in: |
| 2222 | class A { int a; int b; }; |
| 2223 | The matcher: |
| 2224 | recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), |
| 2225 | has(fieldDecl(hasName("b")).bind("v")))) |
| 2226 | will generate two results binding "v", the first of which binds |
| 2227 | the field declaration of a, the second the field declaration of |
| 2228 | b. |
| 2229 | |
| 2230 | Usable as: Any Matcher |
| 2231 | </pre></td></tr> |
| 2232 | |
| 2233 | |
| 2234 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<T> Matcher</td></tr> |
| 2235 | <tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. |
| 2236 | |
| 2237 | Generates results for each match. |
| 2238 | |
| 2239 | For example, in: |
| 2240 | class A { class B {}; class C {}; }; |
| 2241 | The matcher: |
| 2242 | recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m"))) |
| 2243 | will generate results for A, B and C. |
| 2244 | |
| 2245 | Usable as: Any Matcher |
| 2246 | </pre></td></tr> |
| 2247 | |
| 2248 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2249 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<ChildT> ChildMatcher</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2250 | <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the |
| 2251 | provided matcher. |
| 2252 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2253 | Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2254 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 2255 | class Y { class X {}; }; |
| 2256 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 2257 | |
| 2258 | ChildT must be an AST base type. |
| 2259 | |
| 2260 | As opposed to 'has', 'forEach' will cause a match for each result that |
| 2261 | matches instead of only on the first one. |
| 2262 | |
| 2263 | Usable as: Any Matcher |
| 2264 | </pre></td></tr> |
| 2265 | |
| 2266 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2267 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<DescendantT> DescendantMatcher</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2268 | <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 2269 | provided matcher. |
| 2270 | |
| 2271 | Example matches X, A, B, C |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2272 | (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2273 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 2274 | class A { class X {}; }; |
| 2275 | class B { class C { class X {}; }; }; |
| 2276 | |
| 2277 | DescendantT must be an AST base type. |
| 2278 | |
| 2279 | As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for |
| 2280 | each result that matches instead of only on the first one. |
| 2281 | |
| 2282 | Note: Recursively combined ForEachDescendant can cause many matches: |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2283 | recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl())))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2284 | will match 10 times (plus injected class name matches) on: |
| 2285 | class A { class B { class C { class D { class E {}; }; }; }; }; |
| 2286 | |
| 2287 | Usable as: Any Matcher |
| 2288 | </pre></td></tr> |
| 2289 | |
| 2290 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2291 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<ChildT> ChildMatcher</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2292 | <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the |
| 2293 | provided matcher. |
| 2294 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2295 | Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2296 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 2297 | class Y { class X {}; }; |
| 2298 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 2299 | |
| 2300 | ChildT must be an AST base type. |
| 2301 | |
| 2302 | Usable as: Any Matcher |
| 2303 | </pre></td></tr> |
| 2304 | |
| 2305 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2306 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<AncestorT> AncestorMatcher</td></tr> |
| 2307 | <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided |
| 2308 | matcher. |
| 2309 | |
| 2310 | Given |
| 2311 | void f() { if (true) { int x = 42; } } |
| 2312 | void g() { for (;;) { int x = 43; } } |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2313 | expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2314 | |
| 2315 | Usable as: Any Matcher |
| 2316 | </pre></td></tr> |
| 2317 | |
| 2318 | |
| 2319 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<DescendantT> DescendantMatcher</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2320 | <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 2321 | provided matcher. |
| 2322 | |
| 2323 | Example matches X, Y, Z |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2324 | (matcher = recordDecl(hasDescendant(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2325 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 2326 | class Y { class X {}; }; |
| 2327 | class Z { class Y { class X {}; }; }; |
| 2328 | |
| 2329 | DescendantT must be an AST base type. |
| 2330 | |
| 2331 | Usable as: Any Matcher |
| 2332 | </pre></td></tr> |
| 2333 | |
| 2334 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2335 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<ParentT> ParentMatcher</td></tr> |
| 2336 | <tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided |
| 2337 | matcher. |
| 2338 | |
| 2339 | Given |
| 2340 | void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } |
| 2341 | compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". |
| 2342 | |
| 2343 | Usable as: Any Matcher |
| 2344 | </pre></td></tr> |
| 2345 | |
| 2346 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2347 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2348 | <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. |
| 2349 | |
| 2350 | Given |
| 2351 | int i[5]; |
| 2352 | void f() { i[1] = 42; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2353 | arraySubscriptExpression(hasBase(implicitCastExpr( |
| 2354 | hasSourceExpression(declRefExpr())))) |
| 2355 | matches i[1] with the declRefExpr() matching i |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2356 | </pre></td></tr> |
| 2357 | |
| 2358 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2359 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2360 | <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. |
| 2361 | |
| 2362 | Given |
| 2363 | int i[5]; |
| 2364 | void f() { i[1] = 42; } |
| 2365 | arraySubscriptExpression(hasIndex(integerLiteral())) |
| 2366 | matches i[1] with the integerLiteral() matching 1 |
| 2367 | </pre></td></tr> |
| 2368 | |
| 2369 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 2370 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayTypeLoc.html">ArrayTypeLoc</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> |
| 2371 | <tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element |
| 2372 | type. |
| 2373 | |
| 2374 | Given |
| 2375 | struct A {}; |
| 2376 | A a[7]; |
| 2377 | int b[7]; |
| 2378 | arrayType(hasElementType(builtinType())) |
| 2379 | matches "int b[7]" |
| 2380 | |
| 2381 | 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>> |
| 2382 | </pre></td></tr> |
| 2383 | |
| 2384 | |
| 2385 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</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> |
| 2386 | <tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element |
| 2387 | type. |
| 2388 | |
| 2389 | Given |
| 2390 | struct A {}; |
| 2391 | A a[7]; |
| 2392 | int b[7]; |
| 2393 | arrayType(hasElementType(builtinType())) |
| 2394 | matches "int b[7]" |
| 2395 | |
| 2396 | 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>> |
| 2397 | </pre></td></tr> |
| 2398 | |
| 2399 | |
| 2400 | <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> |
| 2401 | <tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. |
| 2402 | |
| 2403 | Given |
| 2404 | _Atomic(int) i; |
| 2405 | _Atomic(float) f; |
| 2406 | atomicType(hasValueType(isInteger())) |
| 2407 | matches "_Atomic(int) i" |
| 2408 | |
| 2409 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> |
| 2410 | </pre></td></tr> |
| 2411 | |
| 2412 | |
| 2413 | <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> |
| 2414 | <tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. |
| 2415 | |
| 2416 | Given |
| 2417 | _Atomic(int) i; |
| 2418 | _Atomic(float) f; |
| 2419 | atomicType(hasValueType(isInteger())) |
| 2420 | matches "_Atomic(int) i" |
| 2421 | |
| 2422 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> |
| 2423 | </pre></td></tr> |
| 2424 | |
| 2425 | |
| 2426 | <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> |
| 2427 | <tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. |
| 2428 | |
| 2429 | Note: There is no TypeLoc for the deduced type and thus no |
| 2430 | getDeducedLoc() matcher. |
| 2431 | |
| 2432 | Given |
| 2433 | auto a = 1; |
| 2434 | auto b = 2.0; |
| 2435 | autoType(hasDeducedType(isInteger())) |
| 2436 | matches "auto a" |
| 2437 | |
| 2438 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> |
| 2439 | </pre></td></tr> |
| 2440 | |
| 2441 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2442 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2443 | <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a |
| 2444 | binary operator matches. |
| 2445 | </pre></td></tr> |
| 2446 | |
| 2447 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2448 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2449 | <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. |
| 2450 | |
| 2451 | Example matches a (matcher = binaryOperator(hasLHS())) |
| 2452 | a || b |
| 2453 | </pre></td></tr> |
| 2454 | |
| 2455 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2456 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2457 | <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. |
| 2458 | |
| 2459 | Example matches b (matcher = binaryOperator(hasRHS())) |
| 2460 | a || b |
| 2461 | </pre></td></tr> |
| 2462 | |
| 2463 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 2464 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerTypeLoc.html">BlockPointerTypeLoc</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> |
| 2465 | <tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the |
| 2466 | pointee matches a given matcher. |
| 2467 | |
| 2468 | Given |
| 2469 | int *a; |
| 2470 | int const *b; |
| 2471 | float const *f; |
| 2472 | pointerType(pointee(isConstQualified(), isInteger())) |
| 2473 | matches "int const *b" |
| 2474 | |
| 2475 | 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>>, |
| 2476 | 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>> |
| 2477 | </pre></td></tr> |
| 2478 | |
| 2479 | |
| 2480 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</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> |
| 2481 | <tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the |
| 2482 | pointee matches a given matcher. |
| 2483 | |
| 2484 | Given |
| 2485 | int *a; |
| 2486 | int const *b; |
| 2487 | float const *f; |
| 2488 | pointerType(pointee(isConstQualified(), isInteger())) |
| 2489 | matches "int const *b" |
| 2490 | |
| 2491 | 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>>, |
| 2492 | 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>> |
| 2493 | </pre></td></tr> |
| 2494 | |
| 2495 | |
Samuel Benzaquen | ef7eb02 | 2013-06-21 15:51:31 +0000 | [diff] [blame] | 2496 | <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> |
| 2497 | <tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call |
| 2498 | expression. |
| 2499 | |
| 2500 | Given |
| 2501 | void x(int, int, int) { int y; x(1, y, 42); } |
| 2502 | callExpr(hasAnyArgument(declRefExpr())) |
| 2503 | matches x(1, y, 42) |
| 2504 | with hasAnyArgument(...) |
| 2505 | matching y |
| 2506 | |
| 2507 | FIXME: Currently this will ignore parentheses and implicit casts on |
| 2508 | the argument before applying the inner matcher. We'll want to remove |
| 2509 | this to allow for greater control by the user once ignoreImplicit() |
| 2510 | has been implemented. |
| 2511 | </pre></td></tr> |
| 2512 | |
| 2513 | |
| 2514 | <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> |
| 2515 | <tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor |
| 2516 | call expression. |
| 2517 | |
| 2518 | Example matches y in x(y) |
| 2519 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 2520 | void x(int) { int y; x(y); } |
| 2521 | </pre></td></tr> |
| 2522 | |
| 2523 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 2524 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</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> |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 2525 | <tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node |
| 2526 | matches the given matcher. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2527 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 2528 | The associated declaration is: |
| 2529 | - for type nodes, the declaration of the underlying type |
| 2530 | - for CallExpr, the declaration of the callee |
| 2531 | - for MemberExpr, the declaration of the referenced member |
| 2532 | - for CXXConstructExpr, the declaration of the constructor |
| 2533 | |
| 2534 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 2535 | function. e.g. various subtypes of clang::Type and various expressions. |
| 2536 | FIXME: Add all node types for which this is matcher is usable due to |
| 2537 | getDecl(). |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 2538 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2539 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 2540 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 2541 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2542 | </pre></td></tr> |
| 2543 | |
| 2544 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2545 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2546 | <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. |
| 2547 | |
| 2548 | Given |
| 2549 | struct Foo { |
| 2550 | Foo() : foo_(1) { } |
| 2551 | int foo_; |
| 2552 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2553 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything())))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2554 | record matches Foo, hasAnyConstructorInitializer matches foo_(1) |
| 2555 | </pre></td></tr> |
| 2556 | |
| 2557 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2558 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2559 | <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. |
| 2560 | |
| 2561 | Given |
| 2562 | struct Foo { |
| 2563 | Foo() : foo_(1) { } |
| 2564 | int foo_; |
| 2565 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2566 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2567 | forField(hasName("foo_")))))) |
| 2568 | matches Foo |
| 2569 | with forField matching foo_ |
| 2570 | </pre></td></tr> |
| 2571 | |
| 2572 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2573 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2574 | <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. |
| 2575 | |
| 2576 | Given |
| 2577 | struct Foo { |
| 2578 | Foo() : foo_(1) { } |
| 2579 | int foo_; |
| 2580 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2581 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2582 | withInitializer(integerLiteral(equals(1))))))) |
| 2583 | matches Foo |
| 2584 | with withInitializer matching (1) |
| 2585 | </pre></td></tr> |
| 2586 | |
| 2587 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2588 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2589 | <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. |
| 2590 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2591 | Example matches y.x() (matcher = callExpr(on(hasType(recordDecl(hasName("Y")))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2592 | class Y { public: void x(); }; |
| 2593 | void z() { Y y; y.x(); }", |
| 2594 | |
| 2595 | FIXME: Overload to allow directly matching types? |
| 2596 | </pre></td></tr> |
| 2597 | |
| 2598 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2599 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2600 | <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> |
| 2601 | |
| 2602 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2603 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2604 | <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. |
| 2605 | </pre></td></tr> |
| 2606 | |
| 2607 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2608 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2609 | <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration |
| 2610 | belongs to. |
| 2611 | |
| 2612 | FIXME: Generalize this for other kinds of declarations. |
| 2613 | FIXME: What other kind of declarations would we need to generalize |
| 2614 | this to? |
| 2615 | |
| 2616 | Example matches A() in the last line |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2617 | (matcher = constructExpr(hasDeclaration(methodDecl( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2618 | ofClass(hasName("A")))))) |
| 2619 | class A { |
| 2620 | public: |
| 2621 | A(); |
| 2622 | }; |
| 2623 | A a = A(); |
| 2624 | </pre></td></tr> |
| 2625 | |
| 2626 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 2627 | <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> |
| 2628 | <tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. |
| 2629 | |
| 2630 | Given: |
| 2631 | class A { void func(); }; |
| 2632 | class B { void member(); }; |
| 2633 | |
| 2634 | recordDecl(hasMethod(hasName("func"))) matches the declaration of A |
| 2635 | but not B. |
| 2636 | </pre></td></tr> |
| 2637 | |
| 2638 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2639 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2640 | <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from |
| 2641 | a class matching Base. |
| 2642 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2643 | Note that a class is not considered to be derived from itself. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2644 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2645 | Example matches Y, Z, C (Base == hasName("X")) |
| 2646 | class X; |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2647 | class Y : public X {}; directly derived |
| 2648 | class Z : public Y {}; indirectly derived |
| 2649 | typedef X A; |
| 2650 | typedef A B; |
| 2651 | class C : public B {}; derived from a typedef of X |
| 2652 | |
| 2653 | In the following example, Bar matches isDerivedFrom(hasName("X")): |
| 2654 | class Foo; |
| 2655 | typedef Foo X; |
| 2656 | class Bar : public Foo {}; derived from a type that X is a typedef of |
| 2657 | </pre></td></tr> |
| 2658 | |
| 2659 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2660 | <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> |
| 2661 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly |
| 2662 | match Base. |
| 2663 | </pre></td></tr> |
| 2664 | |
| 2665 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2666 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2667 | <tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the |
| 2668 | given matcher. |
| 2669 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2670 | Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2671 | class Y { public: void x(); }; |
| 2672 | void z() { Y y; y.x(); |
| 2673 | </pre></td></tr> |
| 2674 | |
| 2675 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2676 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2677 | <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call |
| 2678 | expression. |
| 2679 | |
| 2680 | Given |
| 2681 | void x(int, int, int) { int y; x(1, y, 42); } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2682 | callExpr(hasAnyArgument(declRefExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2683 | matches x(1, y, 42) |
| 2684 | with hasAnyArgument(...) |
| 2685 | matching y |
Manuel Klimek | 1a68afd | 2013-06-20 13:08:29 +0000 | [diff] [blame] | 2686 | |
| 2687 | FIXME: Currently this will ignore parentheses and implicit casts on |
| 2688 | the argument before applying the inner matcher. We'll want to remove |
| 2689 | this to allow for greater control by the user once ignoreImplicit() |
| 2690 | has been implemented. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2691 | </pre></td></tr> |
| 2692 | |
| 2693 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2694 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2695 | <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor |
| 2696 | call expression. |
| 2697 | |
| 2698 | Example matches y in x(y) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2699 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2700 | void x(int) { int y; x(y); } |
| 2701 | </pre></td></tr> |
| 2702 | |
| 2703 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 2704 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</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> |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 2705 | <tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node |
| 2706 | matches the given matcher. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2707 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 2708 | The associated declaration is: |
| 2709 | - for type nodes, the declaration of the underlying type |
| 2710 | - for CallExpr, the declaration of the callee |
| 2711 | - for MemberExpr, the declaration of the referenced member |
| 2712 | - for CXXConstructExpr, the declaration of the constructor |
| 2713 | |
| 2714 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 2715 | function. e.g. various subtypes of clang::Type and various expressions. |
| 2716 | FIXME: Add all node types for which this is matcher is usable due to |
| 2717 | getDecl(). |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 2718 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2719 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 2720 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 2721 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2722 | </pre></td></tr> |
| 2723 | |
| 2724 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 2725 | <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> |
| 2726 | <tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range |
| 2727 | extension, matches the constant given in the statement. |
| 2728 | |
| 2729 | Given |
| 2730 | switch (1) { case 1: case 1+1: case 3 ... 4: ; } |
| 2731 | caseStmt(hasCaseConstant(integerLiteral())) |
| 2732 | matches "case 1:" |
| 2733 | </pre></td></tr> |
| 2734 | |
| 2735 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2736 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2737 | <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher. |
| 2738 | |
| 2739 | Example: matches "a string" (matcher = |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2740 | hasSourceExpression(constructExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2741 | class URL { URL(string); }; |
| 2742 | URL url = "a string"; |
| 2743 | </pre></td></tr> |
| 2744 | |
| 2745 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2746 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2747 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one |
| 2748 | TemplateArgument matching the given InnerMatcher. |
| 2749 | |
| 2750 | Given |
| 2751 | template<typename T> class A {}; |
| 2752 | template<> class A<double> {}; |
| 2753 | A<int> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2754 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2755 | refersToType(asString("int")))) |
| 2756 | matches the specialization A<int> |
| 2757 | </pre></td></tr> |
| 2758 | |
| 2759 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2760 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2761 | <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument |
| 2762 | matches the given InnerMatcher. |
| 2763 | |
| 2764 | Given |
| 2765 | template<typename T, typename U> class A {}; |
| 2766 | A<bool, int> b; |
| 2767 | A<int, bool> c; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2768 | classTemplateSpecializationDecl(hasTemplateArgument( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2769 | 1, refersToType(asString("int")))) |
| 2770 | matches the specialization A<bool, int> |
| 2771 | </pre></td></tr> |
| 2772 | |
| 2773 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 2774 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexTypeLoc.html">ComplexTypeLoc</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> |
| 2775 | <tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element |
| 2776 | type. |
| 2777 | |
| 2778 | Given |
| 2779 | struct A {}; |
| 2780 | A a[7]; |
| 2781 | int b[7]; |
| 2782 | arrayType(hasElementType(builtinType())) |
| 2783 | matches "int b[7]" |
| 2784 | |
| 2785 | 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>> |
| 2786 | </pre></td></tr> |
| 2787 | |
| 2788 | |
| 2789 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</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> |
| 2790 | <tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element |
| 2791 | type. |
| 2792 | |
| 2793 | Given |
| 2794 | struct A {}; |
| 2795 | A a[7]; |
| 2796 | int b[7]; |
| 2797 | arrayType(hasElementType(builtinType())) |
| 2798 | matches "int b[7]" |
| 2799 | |
| 2800 | 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>> |
| 2801 | </pre></td></tr> |
| 2802 | |
| 2803 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2804 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2805 | <tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches |
| 2806 | a given matcher. |
| 2807 | |
| 2808 | Given |
| 2809 | { {}; 1+2; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2810 | hasAnySubstatement(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2811 | matches '{ {}; 1+2; }' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2812 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2813 | matching '{}' |
| 2814 | </pre></td></tr> |
| 2815 | |
| 2816 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2817 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2818 | <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, |
| 2819 | or conditional operator. |
| 2820 | |
| 2821 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 2822 | if (true) {} |
| 2823 | </pre></td></tr> |
| 2824 | |
| 2825 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2826 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2827 | <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator. |
| 2828 | |
| 2829 | Example matches b |
| 2830 | condition ? a : b |
| 2831 | </pre></td></tr> |
| 2832 | |
| 2833 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2834 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2835 | <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. |
| 2836 | |
| 2837 | Example matches a |
| 2838 | condition ? a : b |
| 2839 | </pre></td></tr> |
| 2840 | |
| 2841 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2842 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2843 | <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a |
| 2844 | specific using shadow declaration. |
| 2845 | |
| 2846 | FIXME: This currently only works for functions. Fix. |
| 2847 | |
| 2848 | Given |
| 2849 | namespace a { void f() {} } |
| 2850 | using a::f; |
| 2851 | void g() { |
| 2852 | f(); Matches this .. |
| 2853 | a::f(); .. but not this. |
| 2854 | } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2855 | declRefExpr(throughUsingDeclaration(anything())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2856 | matches f() |
| 2857 | </pre></td></tr> |
| 2858 | |
| 2859 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2860 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2861 | <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the |
| 2862 | specified matcher. |
| 2863 | |
| 2864 | Example matches x in if(x) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2865 | (matcher = declRefExpr(to(varDecl(hasName("x"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2866 | bool x; |
| 2867 | if (x) {} |
| 2868 | </pre></td></tr> |
| 2869 | |
| 2870 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2871 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2872 | <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. |
| 2873 | |
| 2874 | Note that this does not work for global declarations because the AST |
| 2875 | breaks up multiple-declaration DeclStmt's into multiple single-declaration |
| 2876 | DeclStmt's. |
| 2877 | Example: Given non-global declarations |
| 2878 | int a, b = 0; |
| 2879 | int c; |
| 2880 | int d = 2, e; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2881 | declStmt(containsDeclaration( |
| 2882 | 0, varDecl(hasInitializer(anything())))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2883 | matches only 'int d = 2, e;', and |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2884 | declStmt(containsDeclaration(1, varDecl())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2885 | matches 'int a, b = 0' as well as 'int d = 2, e;' |
| 2886 | but 'int c;' is not matched. |
| 2887 | </pre></td></tr> |
| 2888 | |
| 2889 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2890 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2891 | <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. |
| 2892 | |
| 2893 | Given |
| 2894 | int a, b; |
| 2895 | int c; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2896 | declStmt(hasSingleDecl(anything())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2897 | matches 'int c;' but not 'int a, b;'. |
| 2898 | </pre></td></tr> |
| 2899 | |
| 2900 | |
Manuel Klimek | 1a68afd | 2013-06-20 13:08:29 +0000 | [diff] [blame] | 2901 | <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> |
| 2902 | <tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches |
| 2903 | the inner matcher. |
| 2904 | |
| 2905 | Given |
| 2906 | int x; |
| 2907 | declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 2908 | matches int x |
| 2909 | </pre></td></tr> |
| 2910 | |
| 2911 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 2912 | <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> |
| 2913 | <tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a |
| 2914 | Decl, matches InnerMatcher. |
| 2915 | |
| 2916 | Given |
| 2917 | namespace N { |
| 2918 | namespace M { |
| 2919 | class D {}; |
| 2920 | } |
| 2921 | } |
| 2922 | |
| 2923 | recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the |
| 2924 | declaration of class D. |
| 2925 | </pre></td></tr> |
| 2926 | |
| 2927 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2928 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2929 | <tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 2930 | a given body. |
| 2931 | |
| 2932 | Given |
| 2933 | for (;;) {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2934 | hasBody(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2935 | matches 'for (;;) {}' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2936 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2937 | matching '{}' |
| 2938 | </pre></td></tr> |
| 2939 | |
| 2940 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2941 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2942 | <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, |
| 2943 | or conditional operator. |
| 2944 | |
| 2945 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 2946 | if (true) {} |
| 2947 | </pre></td></tr> |
| 2948 | |
| 2949 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 2950 | <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> |
| 2951 | <tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, |
Edwin Vane | aec89ac | 2013-03-04 17:51:00 +0000 | [diff] [blame] | 2952 | matches InnerMatcher if the qualifier exists. |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 2953 | |
| 2954 | Given |
| 2955 | namespace N { |
| 2956 | namespace M { |
| 2957 | class D {}; |
| 2958 | } |
| 2959 | } |
| 2960 | N::M::D d; |
| 2961 | |
| 2962 | elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) |
| 2963 | matches the type of the variable declaration of d. |
| 2964 | </pre></td></tr> |
| 2965 | |
| 2966 | |
| 2967 | <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> |
| 2968 | <tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. |
| 2969 | |
| 2970 | Given |
| 2971 | namespace N { |
| 2972 | namespace M { |
| 2973 | class D {}; |
| 2974 | } |
| 2975 | } |
| 2976 | N::M::D d; |
| 2977 | |
| 2978 | elaboratedType(namesType(recordType( |
| 2979 | hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable |
| 2980 | declaration of d. |
| 2981 | </pre></td></tr> |
| 2982 | |
| 2983 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2984 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2985 | <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. |
| 2986 | |
| 2987 | (Note: Clang's AST refers to other conversions as "casts" too, and calls |
| 2988 | actual casts "explicit" casts.) |
| 2989 | </pre></td></tr> |
| 2990 | |
| 2991 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2992 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2993 | <tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value |
| 2994 | declaration's type. |
| 2995 | |
| 2996 | In case of a value declaration (for example a variable declaration), |
| 2997 | this resolves one layer of indirection. For example, in the value |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2998 | declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, |
| 2999 | while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3000 | of x." |
| 3001 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3002 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) |
| 3003 | and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3004 | class X {}; |
| 3005 | void y(X &x) { x; X z; } |
| 3006 | |
| 3007 | 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>> |
| 3008 | </pre></td></tr> |
| 3009 | |
| 3010 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3011 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3012 | <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts |
| 3013 | are stripped off. |
| 3014 | |
| 3015 | Parentheses and explicit casts are not discarded. |
| 3016 | Given |
| 3017 | int arr[5]; |
| 3018 | int a = 0; |
| 3019 | char b = 0; |
| 3020 | const int c = a; |
| 3021 | int *d = arr; |
| 3022 | long e = (long) 0l; |
| 3023 | The matchers |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3024 | varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) |
| 3025 | varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3026 | would match the declarations for a, b, c, and d, but not e. |
| 3027 | While |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3028 | varDecl(hasInitializer(integerLiteral())) |
| 3029 | varDecl(hasInitializer(declRefExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3030 | only match the declarations for b, c, and d. |
| 3031 | </pre></td></tr> |
| 3032 | |
| 3033 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3034 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3035 | <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and |
| 3036 | casts are stripped off. |
| 3037 | |
| 3038 | Implicit and non-C Style casts are also discarded. |
| 3039 | Given |
| 3040 | int a = 0; |
| 3041 | char b = (0); |
| 3042 | void* c = reinterpret_cast<char*>(0); |
| 3043 | char d = char(0); |
| 3044 | The matcher |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3045 | varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3046 | would match the declarations for a, b, c, and d. |
| 3047 | while |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3048 | varDecl(hasInitializer(integerLiteral())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3049 | only match the declaration for a. |
| 3050 | </pre></td></tr> |
| 3051 | |
| 3052 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3053 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3054 | <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and |
| 3055 | parentheses are stripped off. |
| 3056 | |
| 3057 | Explicit casts are not discarded. |
| 3058 | Given |
| 3059 | int arr[5]; |
| 3060 | int a = 0; |
| 3061 | char b = (0); |
| 3062 | const int c = a; |
| 3063 | int *d = (arr); |
| 3064 | long e = ((long) 0l); |
| 3065 | The matchers |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3066 | varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) |
| 3067 | varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3068 | would match the declarations for a, b, c, and d, but not e. |
| 3069 | while |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3070 | varDecl(hasInitializer(integerLiteral())) |
| 3071 | varDecl(hasInitializer(declRefExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3072 | would only match the declaration for a. |
| 3073 | </pre></td></tr> |
| 3074 | |
| 3075 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3076 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3077 | <tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 3078 | a given body. |
| 3079 | |
| 3080 | Given |
| 3081 | for (;;) {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3082 | hasBody(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3083 | matches 'for (;;) {}' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3084 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3085 | matching '{}' |
| 3086 | </pre></td></tr> |
| 3087 | |
| 3088 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3089 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3090 | <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, |
| 3091 | or conditional operator. |
| 3092 | |
| 3093 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 3094 | if (true) {} |
| 3095 | </pre></td></tr> |
| 3096 | |
| 3097 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3098 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3099 | <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. |
| 3100 | |
| 3101 | Example: |
| 3102 | forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) |
| 3103 | matches '++x' in |
| 3104 | for (x; x < N; ++x) { } |
| 3105 | </pre></td></tr> |
| 3106 | |
| 3107 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3108 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3109 | <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. |
| 3110 | |
| 3111 | Example: |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3112 | forStmt(hasLoopInit(declStmt())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3113 | matches 'int x = 0' in |
| 3114 | for (int x = 0; x < N; ++x) { } |
| 3115 | </pre></td></tr> |
| 3116 | |
| 3117 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3118 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3119 | <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. |
| 3120 | |
| 3121 | Does not match the 'this' parameter of a method. |
| 3122 | |
| 3123 | Given |
| 3124 | class X { void f(int x, int y, int z) {} }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3125 | methodDecl(hasAnyParameter(hasName("y"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3126 | matches f(int x, int y, int z) {} |
| 3127 | with hasAnyParameter(...) |
| 3128 | matching int y |
| 3129 | </pre></td></tr> |
| 3130 | |
| 3131 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3132 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3133 | <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. |
| 3134 | |
| 3135 | Given |
| 3136 | class X { void f(int x) {} }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3137 | methodDecl(hasParameter(0, hasType(varDecl()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3138 | matches f(int x) {} |
| 3139 | with hasParameter(...) |
| 3140 | matching int x |
| 3141 | </pre></td></tr> |
| 3142 | |
| 3143 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3144 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3145 | <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. |
| 3146 | |
| 3147 | Given: |
| 3148 | class X { int f() { return 1; } }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3149 | methodDecl(returns(asString("int"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3150 | matches int f() { return 1; } |
| 3151 | </pre></td></tr> |
| 3152 | |
| 3153 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3154 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3155 | <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, |
| 3156 | or conditional operator. |
| 3157 | |
| 3158 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 3159 | if (true) {} |
| 3160 | </pre></td></tr> |
| 3161 | |
| 3162 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3163 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3164 | <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. |
| 3165 | |
| 3166 | Given |
| 3167 | if (A* a = GetAPointer()) {} |
| 3168 | hasConditionVariableStatment(...) |
| 3169 | matches 'A* a = GetAPointer()'. |
| 3170 | </pre></td></tr> |
| 3171 | |
| 3172 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3173 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3174 | <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given |
| 3175 | matcher. |
| 3176 | |
| 3177 | FIXME: Unit test this matcher |
| 3178 | </pre></td></tr> |
| 3179 | |
| 3180 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3181 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</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> |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3182 | <tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node |
| 3183 | matches the given matcher. |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3184 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3185 | The associated declaration is: |
| 3186 | - for type nodes, the declaration of the underlying type |
| 3187 | - for CallExpr, the declaration of the callee |
| 3188 | - for MemberExpr, the declaration of the referenced member |
| 3189 | - for CXXConstructExpr, the declaration of the constructor |
| 3190 | |
| 3191 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3192 | function. e.g. various subtypes of clang::Type and various expressions. |
| 3193 | FIXME: Add all node types for which this is matcher is usable due to |
| 3194 | getDecl(). |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 3195 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3196 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3197 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 3198 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3199 | </pre></td></tr> |
| 3200 | |
| 3201 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3202 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3203 | <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is |
| 3204 | matched by a given matcher. |
| 3205 | |
| 3206 | Given |
| 3207 | struct X { int m; }; |
| 3208 | void f(X x) { x.m; m; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3209 | memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X"))))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3210 | matches "x.m" and "m" |
| 3211 | with hasObjectExpression(...) |
| 3212 | matching "x" and the implicit object expression of "m" which has type X*. |
| 3213 | </pre></td></tr> |
| 3214 | |
| 3215 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3216 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3217 | <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a |
| 3218 | given matcher. |
| 3219 | |
| 3220 | Given |
| 3221 | struct { int first, second; } first, second; |
| 3222 | int i(second.first); |
| 3223 | int j(first.second); |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3224 | memberExpr(member(hasName("first"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3225 | matches second.first |
| 3226 | but not first.second (because the member name there is "second"). |
| 3227 | </pre></td></tr> |
| 3228 | |
| 3229 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 3230 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerTypeLoc.html">MemberPointerTypeLoc</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> |
| 3231 | <tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3232 | pointee matches a given matcher. |
| 3233 | |
| 3234 | Given |
| 3235 | int *a; |
| 3236 | int const *b; |
| 3237 | float const *f; |
| 3238 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3239 | matches "int const *b" |
| 3240 | |
| 3241 | 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>>, |
| 3242 | 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>> |
| 3243 | </pre></td></tr> |
| 3244 | |
| 3245 | |
| 3246 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</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> |
| 3247 | <tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3248 | pointee matches a given matcher. |
| 3249 | |
| 3250 | Given |
| 3251 | int *a; |
| 3252 | int const *b; |
| 3253 | float const *f; |
| 3254 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3255 | matches "int const *b" |
| 3256 | |
| 3257 | 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>>, |
| 3258 | 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>> |
| 3259 | </pre></td></tr> |
| 3260 | |
| 3261 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 3262 | <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> |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3263 | <tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. |
| 3264 | |
| 3265 | Given |
| 3266 | struct A { struct B { struct C {}; }; }; |
| 3267 | A::B::C c; |
| 3268 | nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) |
| 3269 | matches "A::" |
| 3270 | </pre></td></tr> |
| 3271 | |
| 3272 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 3273 | <tr><td>Matcher<<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> |
| 3274 | <tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner |
| 3275 | NestedNameSpecifier-matcher matches. |
| 3276 | </pre></td></tr> |
| 3277 | |
| 3278 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3279 | <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> |
| 3280 | <tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the |
| 3281 | given TypeLoc. |
| 3282 | |
| 3283 | Given |
| 3284 | struct A { struct B { struct C {}; }; }; |
| 3285 | A::B::C c; |
| 3286 | nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( |
| 3287 | hasDeclaration(recordDecl(hasName("A"))))))) |
| 3288 | matches "A::" |
| 3289 | </pre></td></tr> |
| 3290 | |
| 3291 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 3292 | <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> |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3293 | <tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. |
| 3294 | |
| 3295 | Given |
| 3296 | struct A { struct B { struct C {}; }; }; |
| 3297 | A::B::C c; |
| 3298 | nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and |
| 3299 | matches "A::" |
| 3300 | </pre></td></tr> |
| 3301 | |
| 3302 | |
| 3303 | <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> |
| 3304 | <tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the |
| 3305 | given namespace matcher. |
| 3306 | |
| 3307 | Given |
| 3308 | namespace ns { struct A {}; } |
| 3309 | ns::A a; |
| 3310 | nestedNameSpecifier(specifiesNamespace(hasName("ns"))) |
| 3311 | matches "ns::" |
| 3312 | </pre></td></tr> |
| 3313 | |
| 3314 | |
| 3315 | <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> |
| 3316 | <tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the |
| 3317 | given QualType matcher without qualifiers. |
| 3318 | |
| 3319 | Given |
| 3320 | struct A { struct B { struct C {}; }; }; |
| 3321 | A::B::C c; |
| 3322 | nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A"))))) |
| 3323 | matches "A::" |
| 3324 | </pre></td></tr> |
| 3325 | |
| 3326 | |
Edwin Vane | 88be2fd | 2013-04-01 18:33:34 +0000 | [diff] [blame] | 3327 | <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> |
| 3328 | <tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. |
| 3329 | |
| 3330 | Given |
| 3331 | int (*ptr_to_array)[4]; |
| 3332 | int (*ptr_to_func)(int); |
| 3333 | |
| 3334 | varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches |
| 3335 | ptr_to_func but not ptr_to_array. |
| 3336 | |
| 3337 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> |
| 3338 | </pre></td></tr> |
| 3339 | |
| 3340 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 3341 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</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> |
| 3342 | <tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3343 | pointee matches a given matcher. |
| 3344 | |
| 3345 | Given |
| 3346 | int *a; |
| 3347 | int const *b; |
| 3348 | float const *f; |
| 3349 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3350 | matches "int const *b" |
| 3351 | |
| 3352 | 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>>, |
| 3353 | 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>> |
| 3354 | </pre></td></tr> |
| 3355 | |
| 3356 | |
| 3357 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</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> |
| 3358 | <tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3359 | pointee matches a given matcher. |
| 3360 | |
| 3361 | Given |
| 3362 | int *a; |
| 3363 | int const *b; |
| 3364 | float const *f; |
| 3365 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3366 | matches "int const *b" |
| 3367 | |
| 3368 | 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>>, |
| 3369 | 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>> |
| 3370 | </pre></td></tr> |
| 3371 | |
| 3372 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 3373 | <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> |
| 3374 | <tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. |
| 3375 | |
| 3376 | Given: |
| 3377 | typedef int &int_ref; |
| 3378 | int a; |
| 3379 | int_ref b = a; |
| 3380 | |
| 3381 | varDecl(hasType(qualType(referenceType()))))) will not match the |
| 3382 | declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. |
| 3383 | </pre></td></tr> |
| 3384 | |
| 3385 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3386 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</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> |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3387 | <tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node |
| 3388 | matches the given matcher. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3389 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3390 | The associated declaration is: |
| 3391 | - for type nodes, the declaration of the underlying type |
| 3392 | - for CallExpr, the declaration of the callee |
| 3393 | - for MemberExpr, the declaration of the referenced member |
| 3394 | - for CXXConstructExpr, the declaration of the constructor |
| 3395 | |
| 3396 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3397 | function. e.g. various subtypes of clang::Type and various expressions. |
| 3398 | FIXME: Add all node types for which this is matcher is usable due to |
| 3399 | getDecl(). |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 3400 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3401 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3402 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 3403 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3404 | </pre></td></tr> |
| 3405 | |
| 3406 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3407 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3408 | <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. |
| 3409 | </pre></td></tr> |
| 3410 | |
| 3411 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3412 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3413 | <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. |
| 3414 | </pre></td></tr> |
| 3415 | |
| 3416 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 3417 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</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> |
| 3418 | <tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3419 | pointee matches a given matcher. |
| 3420 | |
| 3421 | Given |
| 3422 | int *a; |
| 3423 | int const *b; |
| 3424 | float const *f; |
| 3425 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3426 | matches "int const *b" |
| 3427 | |
| 3428 | 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>>, |
| 3429 | 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>> |
| 3430 | </pre></td></tr> |
| 3431 | |
| 3432 | |
| 3433 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</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> |
| 3434 | <tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3435 | pointee matches a given matcher. |
| 3436 | |
| 3437 | Given |
| 3438 | int *a; |
| 3439 | int const *b; |
| 3440 | float const *f; |
| 3441 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3442 | matches "int const *b" |
| 3443 | |
| 3444 | 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>>, |
| 3445 | 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>> |
| 3446 | </pre></td></tr> |
| 3447 | |
| 3448 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3449 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3450 | <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 3451 | alignof. |
| 3452 | </pre></td></tr> |
| 3453 | |
| 3454 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3455 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3456 | <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 3457 | sizeof. |
| 3458 | </pre></td></tr> |
| 3459 | |
| 3460 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3461 | <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> |
| 3462 | <tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch |
| 3463 | statement. This matcher may produce multiple matches. |
| 3464 | |
| 3465 | Given |
| 3466 | switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } |
| 3467 | switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") |
| 3468 | matches four times, with "c" binding each of "case 1:", "case 2:", |
| 3469 | "case 3:" and "case 4:", and "s" respectively binding "switch (1)", |
| 3470 | "switch (1)", "switch (2)" and "switch (2)". |
| 3471 | </pre></td></tr> |
| 3472 | |
| 3473 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3474 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3475 | <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a TemplateArgument that refers to a certain declaration. |
| 3476 | |
| 3477 | Given |
| 3478 | template<typename T> struct A {}; |
| 3479 | struct B { B* next; }; |
| 3480 | A<&B::next> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3481 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 3482 | refersToDeclaration(fieldDecl(hasName("next")))) |
| 3483 | matches the specialization A<&B::next> with fieldDecl(...) matching |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3484 | B::next |
| 3485 | </pre></td></tr> |
| 3486 | |
| 3487 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3488 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3489 | <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. |
| 3490 | |
| 3491 | Given |
| 3492 | struct X {}; |
| 3493 | template<typename T> struct A {}; |
| 3494 | A<X> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3495 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3496 | refersToType(class(hasName("X"))))) |
| 3497 | matches the specialization A<X> |
| 3498 | </pre></td></tr> |
| 3499 | |
| 3500 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3501 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</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> |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3502 | <tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node |
| 3503 | matches the given matcher. |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 3504 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3505 | The associated declaration is: |
| 3506 | - for type nodes, the declaration of the underlying type |
| 3507 | - for CallExpr, the declaration of the callee |
| 3508 | - for MemberExpr, the declaration of the referenced member |
| 3509 | - for CXXConstructExpr, the declaration of the constructor |
| 3510 | |
| 3511 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3512 | function. e.g. various subtypes of clang::Type and various expressions. |
| 3513 | FIXME: Add all node types for which this is matcher is usable due to |
| 3514 | getDecl(). |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 3515 | |
| 3516 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3517 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 3518 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> |
| 3519 | </pre></td></tr> |
| 3520 | |
| 3521 | |
| 3522 | <tr><td>Matcher<<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> |
| 3523 | <tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner |
| 3524 | QualType-matcher matches. |
| 3525 | </pre></td></tr> |
| 3526 | |
| 3527 | |
| 3528 | <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> |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3529 | <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node |
| 3530 | matches the given matcher. |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3531 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3532 | The associated declaration is: |
| 3533 | - for type nodes, the declaration of the underlying type |
| 3534 | - for CallExpr, the declaration of the callee |
| 3535 | - for MemberExpr, the declaration of the referenced member |
| 3536 | - for CXXConstructExpr, the declaration of the constructor |
| 3537 | |
| 3538 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3539 | function. e.g. various subtypes of clang::Type and various expressions. |
| 3540 | FIXME: Add all node types for which this is matcher is usable due to |
| 3541 | getDecl(). |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3542 | |
| 3543 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
| 3544 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 3545 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3546 | </pre></td></tr> |
| 3547 | |
| 3548 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3549 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3550 | <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. |
| 3551 | |
| 3552 | Given |
| 3553 | int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); |
| 3554 | unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) |
| 3555 | matches sizeof(a) and alignof(c) |
| 3556 | </pre></td></tr> |
| 3557 | |
| 3558 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3559 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3560 | <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. |
| 3561 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3562 | Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true)))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3563 | !true |
| 3564 | </pre></td></tr> |
| 3565 | |
| 3566 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3567 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3568 | <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. |
| 3569 | |
| 3570 | Given |
| 3571 | namespace X { void b(); } |
| 3572 | using X::b; |
| 3573 | usingDecl(hasAnyUsingShadowDecl(hasName("b")))) |
| 3574 | matches using X::b </pre></td></tr> |
| 3575 | |
| 3576 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3577 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3578 | <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is |
| 3579 | matched by the given matcher. |
| 3580 | |
| 3581 | Given |
| 3582 | namespace X { int a; void b(); } |
| 3583 | using X::a; |
| 3584 | using X::b; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3585 | usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3586 | matches using X::b but not using X::a </pre></td></tr> |
| 3587 | |
| 3588 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3589 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3590 | <tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value |
| 3591 | declaration's type. |
| 3592 | |
| 3593 | In case of a value declaration (for example a variable declaration), |
| 3594 | this resolves one layer of indirection. For example, in the value |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3595 | declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, |
| 3596 | while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3597 | of x." |
| 3598 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3599 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) |
| 3600 | and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3601 | class X {}; |
| 3602 | void y(X &x) { x; X z; } |
| 3603 | |
| 3604 | 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>> |
| 3605 | </pre></td></tr> |
| 3606 | |
| 3607 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3608 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3609 | <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression |
| 3610 | that matches the given matcher. |
| 3611 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3612 | Example matches x (matcher = varDecl(hasInitializer(callExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3613 | bool y() { return true; } |
| 3614 | bool x = y(); |
| 3615 | </pre></td></tr> |
| 3616 | |
| 3617 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3618 | <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> |
| 3619 | <tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size |
| 3620 | expression. |
| 3621 | |
| 3622 | Given |
| 3623 | void f(int b) { |
| 3624 | int a[b]; |
| 3625 | } |
| 3626 | variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( |
| 3627 | varDecl(hasName("b"))))))) |
| 3628 | matches "int a[b]" |
| 3629 | </pre></td></tr> |
| 3630 | |
| 3631 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3632 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3633 | <tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 3634 | a given body. |
| 3635 | |
| 3636 | Given |
| 3637 | for (;;) {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3638 | hasBody(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3639 | matches 'for (;;) {}' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3640 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3641 | matching '{}' |
| 3642 | </pre></td></tr> |
| 3643 | |
| 3644 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3645 | <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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3646 | <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, |
| 3647 | or conditional operator. |
| 3648 | |
| 3649 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 3650 | if (true) {} |
| 3651 | </pre></td></tr> |
| 3652 | |
| 3653 | <!--END_TRAVERSAL_MATCHERS --> |
| 3654 | </table> |
| 3655 | |
| 3656 | </div> |
| 3657 | </body> |
| 3658 | </html> |
| 3659 | |
| 3660 | |