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