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 |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 253 | class X { void y(); }; |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 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 | |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [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('exprWithCleanups0')"><a name="exprWithCleanups0Anchor">exprWithCleanups</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ExprWithCleanups.html">ExprWithCleanups</a>>...</td></tr> |
| 635 | <tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end |
| 636 | of the sub-expression's evaluation. |
| 637 | |
| 638 | Example matches std::string() |
| 639 | const std::string str = std::string(); |
| 640 | </pre></td></tr> |
| 641 | |
| 642 | |
Samuel Benzaquen | ee0da95 | 2013-08-16 16:19:42 +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('floatLiteral0')"><a name="floatLiteral0Anchor">floatLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>...</td></tr> |
| 644 | <tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g. |
| 645 | 1.0, 1.0f, 1.0L and 1e10. |
| 646 | |
| 647 | Does not match implicit conversions such as |
| 648 | float a = 10; |
| 649 | </pre></td></tr> |
| 650 | |
| 651 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +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('forRangeStmt0')"><a name="forRangeStmt0Anchor">forRangeStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>>...</td></tr> |
| 653 | <tr><td colspan="4" class="doc" id="forRangeStmt0"><pre>Matches range-based for statements. |
| 654 | |
| 655 | forRangeStmt() matches 'for (auto a : i)' |
| 656 | int i[] = {1, 2, 3}; for (auto a : i); |
| 657 | for(int j = 0; j < 5; ++j); |
| 658 | </pre></td></tr> |
| 659 | |
| 660 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 661 | <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] | 662 | <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. |
| 663 | |
| 664 | Example matches 'for (;;) {}' |
| 665 | for (;;) {} |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 666 | int i[] = {1, 2, 3}; for (auto a : i); |
| 667 | </pre></td></tr> |
| 668 | |
| 669 | |
| 670 | <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> |
| 671 | <tr><td colspan="4" class="doc" id="functionalCastExpr0"><pre>Matches functional cast expressions |
| 672 | |
| 673 | Example: Matches Foo(bar); |
| 674 | Foo f = bar; |
| 675 | Foo g = (Foo) bar; |
| 676 | Foo h = Foo(bar); |
| 677 | </pre></td></tr> |
| 678 | |
| 679 | |
| 680 | <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> |
| 681 | <tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. |
| 682 | |
| 683 | Given |
| 684 | goto FOO; |
| 685 | FOO: bar(); |
| 686 | gotoStmt() |
| 687 | matches 'goto FOO' |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 688 | </pre></td></tr> |
| 689 | |
| 690 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 691 | <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] | 692 | <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. |
| 693 | |
| 694 | Example matches 'if (x) {}' |
| 695 | if (x) {} |
| 696 | </pre></td></tr> |
| 697 | |
| 698 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 699 | <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> |
| 700 | <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. |
| 701 | |
| 702 | This matches many different places, including function call return value |
| 703 | eliding, as well as any type conversions. |
| 704 | </pre></td></tr> |
| 705 | |
| 706 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 707 | <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] | 708 | <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. |
| 709 | |
| 710 | Given |
| 711 | int a[] = { 1, 2 }; |
| 712 | struct B { int x, y; }; |
| 713 | B b = { 5, 6 }; |
| 714 | initList() |
| 715 | matches "{ 1, 2 }" and "{ 5, 6 }" |
| 716 | </pre></td></tr> |
| 717 | |
| 718 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 719 | <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] | 720 | <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g. |
| 721 | 1, 1L, 0x1 and 1U. |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 722 | |
Samuel Benzaquen | ee0da95 | 2013-08-16 16:19:42 +0000 | [diff] [blame] | 723 | Does not match character-encoded integers such as L'a'. |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 724 | </pre></td></tr> |
| 725 | |
| 726 | |
| 727 | <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> |
| 728 | <tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. |
| 729 | |
| 730 | Given |
| 731 | goto FOO; |
| 732 | FOO: bar(); |
| 733 | labelStmt() |
| 734 | matches 'FOO:' |
| 735 | </pre></td></tr> |
| 736 | |
| 737 | |
| 738 | <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> |
| 739 | <tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. |
| 740 | |
| 741 | Example matches [&](){return 5;} |
| 742 | [&](){return 5;} |
| 743 | </pre></td></tr> |
| 744 | |
| 745 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 746 | <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] | 747 | <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. |
| 748 | |
| 749 | Example: Given |
| 750 | struct T {void func()}; |
| 751 | T f(); |
| 752 | void g(T); |
| 753 | materializeTemporaryExpr() matches 'f()' in these statements |
| 754 | T u(f()); |
| 755 | g(f()); |
| 756 | but does not match |
| 757 | f(); |
| 758 | f().func(); |
| 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('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] | 763 | <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] | 764 | |
| 765 | Example matches x.y() |
| 766 | X x; |
| 767 | x.y(); |
| 768 | </pre></td></tr> |
| 769 | |
| 770 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 771 | <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] | 772 | <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 773 | |
| 774 | Given |
| 775 | class Y { |
| 776 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 777 | int a; static int b; |
| 778 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 779 | memberExpr() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 780 | matches this->x, x, y.x, a, this->b |
| 781 | </pre></td></tr> |
| 782 | |
| 783 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 784 | <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] | 785 | <tr><td colspan="4" class="doc" id="newExpr0"><pre>Matches new expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 786 | |
| 787 | Given |
| 788 | new X; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 789 | newExpr() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 790 | matches 'new X'. |
| 791 | </pre></td></tr> |
| 792 | |
| 793 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 794 | <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> |
| 795 | <tr><td colspan="4" class="doc" id="nullPtrLiteralExpr0"><pre>Matches nullptr literal. |
| 796 | </pre></td></tr> |
| 797 | |
| 798 | |
| 799 | <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> |
| 800 | <tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. |
| 801 | |
| 802 | foo();; |
| 803 | nullStmt() |
| 804 | matches the second ';' |
| 805 | </pre></td></tr> |
| 806 | |
| 807 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 808 | <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] | 809 | <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] | 810 | |
| 811 | Note that if an operator isn't overloaded, it won't match. Instead, use |
| 812 | binaryOperator matcher. |
| 813 | Currently it does not match operators such as new delete. |
| 814 | FIXME: figure out why these do not match? |
| 815 | |
| 816 | Example matches both operator<<((o << b), c) and operator<<(o, b) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 817 | (matcher = operatorCallExpr()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 818 | ostream &operator<< (ostream &out, int i) { }; |
| 819 | ostream &o; int b = 1, c = 1; |
| 820 | o << b << c; |
| 821 | </pre></td></tr> |
| 822 | |
| 823 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 824 | <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> |
| 825 | <tr><td colspan="4" class="doc" id="reinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. |
| 826 | |
| 827 | Either the source expression or the destination type can be matched |
| 828 | using has(), but hasDestinationType() is more specific and can be |
| 829 | more readable. |
| 830 | |
| 831 | Example matches reinterpret_cast<char*>(&p) in |
| 832 | void* p = reinterpret_cast<char*>(&p); |
| 833 | </pre></td></tr> |
| 834 | |
| 835 | |
| 836 | <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> |
| 837 | <tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. |
| 838 | |
| 839 | Given |
| 840 | return 1; |
| 841 | returnStmt() |
| 842 | matches 'return 1' |
| 843 | </pre></td></tr> |
| 844 | |
| 845 | |
| 846 | <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> |
| 847 | <tr><td colspan="4" class="doc" id="staticCastExpr0"><pre>Matches a C++ static_cast expression. |
| 848 | |
| 849 | hasDestinationType |
| 850 | reinterpretCast |
| 851 | |
| 852 | Example: |
| 853 | staticCastExpr() |
| 854 | matches |
| 855 | static_cast<long>(8) |
| 856 | in |
| 857 | long eight(static_cast<long>(8)); |
| 858 | </pre></td></tr> |
| 859 | |
| 860 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 861 | <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] | 862 | <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 863 | |
| 864 | Given |
| 865 | { ++a; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 866 | stmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 867 | matches both the compound statement '{ ++a; }' and '++a'. |
| 868 | </pre></td></tr> |
| 869 | |
| 870 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 871 | <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> |
| 872 | <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). |
| 873 | |
| 874 | Example matches "abcd", L"abcd" |
| 875 | char *s = "abcd"; wchar_t *ws = L"abcd" |
| 876 | </pre></td></tr> |
| 877 | |
| 878 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 879 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('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] | 880 | <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. |
| 881 | |
| 882 | Given |
| 883 | switch(a) { case 42: break; default: break; } |
| 884 | switchCase() |
| 885 | matches 'case 42: break;' and 'default: break;'. |
| 886 | </pre></td></tr> |
| 887 | |
| 888 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 889 | <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> |
| 890 | <tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. |
| 891 | |
| 892 | Given |
| 893 | switch(a) { case 42: break; default: break; } |
| 894 | switchStmt() |
| 895 | matches 'switch(a)'. |
| 896 | </pre></td></tr> |
| 897 | |
| 898 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 899 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('temporaryObjectExpr0')"><a name="temporaryObjectExpr0Anchor">temporaryObjectExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>...</td></tr> |
| 900 | <tr><td colspan="4" class="doc" id="temporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments |
| 901 | |
| 902 | Example: Matches Foo(bar, bar) |
| 903 | Foo h = Foo(bar, bar); |
| 904 | </pre></td></tr> |
| 905 | |
| 906 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 907 | <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> |
| 908 | <tr><td colspan="4" class="doc" id="thisExpr0"><pre>Matches implicit and explicit this expressions. |
| 909 | |
| 910 | Example matches the implicit this expression in "return i". |
| 911 | (matcher = thisExpr()) |
| 912 | struct foo { |
| 913 | int i; |
| 914 | int f() { return i; } |
| 915 | }; |
| 916 | </pre></td></tr> |
| 917 | |
| 918 | |
| 919 | <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> |
| 920 | <tr><td colspan="4" class="doc" id="throwExpr0"><pre>Matches throw expressions. |
| 921 | |
| 922 | try { throw 5; } catch(int i) {} |
| 923 | throwExpr() |
| 924 | matches 'throw 5' |
| 925 | </pre></td></tr> |
| 926 | |
| 927 | |
| 928 | <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> |
| 929 | <tr><td colspan="4" class="doc" id="tryStmt0"><pre>Matches try statements. |
| 930 | |
| 931 | try {} catch(int i) {} |
| 932 | tryStmt() |
| 933 | matches 'try {}' |
| 934 | </pre></td></tr> |
| 935 | |
| 936 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 937 | <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] | 938 | <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) |
| 939 | |
| 940 | Given |
| 941 | Foo x = bar; |
| 942 | int y = sizeof(x) + alignof(x); |
| 943 | unaryExprOrTypeTraitExpr() |
| 944 | matches sizeof(x) and alignof(x) |
| 945 | </pre></td></tr> |
| 946 | |
| 947 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 948 | <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] | 949 | <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. |
| 950 | |
| 951 | Example matches !a |
| 952 | !a || b |
| 953 | </pre></td></tr> |
| 954 | |
| 955 | |
Manuel Klimek | 532870f | 2013-07-24 05:46:07 +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('unresolvedConstructExpr0')"><a name="unresolvedConstructExpr0Anchor">unresolvedConstructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>...</td></tr> |
| 957 | <tr><td colspan="4" class="doc" id="unresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. |
| 958 | |
| 959 | Example matches T(t) in return statement of f |
| 960 | (matcher = unresolvedConstructExpr()) |
| 961 | template <typename T> |
| 962 | void f(const T& t) { return T(t); } |
| 963 | </pre></td></tr> |
| 964 | |
| 965 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 966 | <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> |
| 967 | <tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. |
| 968 | |
| 969 | Example match: "foo"_suffix |
| 970 | </pre></td></tr> |
| 971 | |
| 972 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 973 | <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] | 974 | <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. |
| 975 | |
| 976 | Given |
| 977 | while (true) {} |
| 978 | whileStmt() |
| 979 | matches 'while (true) {}'. |
| 980 | </pre></td></tr> |
| 981 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 982 | |
| 983 | <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> |
| 984 | <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. |
| 985 | </pre></td></tr> |
| 986 | |
| 987 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 988 | <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> |
| 989 | <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. |
| 990 | |
| 991 | Given |
| 992 | int a[] = { 2, 3 }; |
| 993 | int b[4]; |
| 994 | void f() { int c[a[0]]; } |
| 995 | arrayType() |
| 996 | matches "int a[]", "int b[4]" and "int c[a[0]]"; |
| 997 | </pre></td></tr> |
| 998 | |
| 999 | |
| 1000 | <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> |
| 1001 | <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. |
| 1002 | |
| 1003 | Given |
| 1004 | _Atomic(int) i; |
| 1005 | atomicType() |
| 1006 | matches "_Atomic(int) i" |
| 1007 | </pre></td></tr> |
| 1008 | |
| 1009 | |
| 1010 | <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> |
| 1011 | <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. |
| 1012 | |
| 1013 | Given: |
| 1014 | auto n = 4; |
| 1015 | int v[] = { 2, 3 } |
| 1016 | for (auto i : v) { } |
| 1017 | autoType() |
| 1018 | matches "auto n" and "auto i" |
| 1019 | </pre></td></tr> |
| 1020 | |
| 1021 | |
| 1022 | <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> |
| 1023 | <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as |
| 1024 | "void (^)(int)". |
| 1025 | |
| 1026 | The pointee is always required to be a FunctionType. |
| 1027 | </pre></td></tr> |
| 1028 | |
| 1029 | |
| 1030 | <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> |
| 1031 | <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. |
| 1032 | |
| 1033 | Given |
| 1034 | struct A {}; |
| 1035 | A a; |
| 1036 | int b; |
| 1037 | float c; |
| 1038 | bool d; |
| 1039 | builtinType() |
| 1040 | matches "int b", "float c" and "bool d" |
| 1041 | </pre></td></tr> |
| 1042 | |
| 1043 | |
| 1044 | <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> |
| 1045 | <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. |
| 1046 | |
| 1047 | Given |
| 1048 | _Complex float f; |
| 1049 | complexType() |
| 1050 | matches "_Complex float f" |
| 1051 | </pre></td></tr> |
| 1052 | |
| 1053 | |
| 1054 | <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> |
| 1055 | <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. |
| 1056 | |
| 1057 | Given |
| 1058 | void() { |
| 1059 | int a[2]; |
| 1060 | int b[] = { 2, 3 }; |
| 1061 | int c[b[0]]; |
| 1062 | } |
| 1063 | constantArrayType() |
| 1064 | matches "int a[2]" |
| 1065 | </pre></td></tr> |
| 1066 | |
| 1067 | |
| 1068 | <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> |
| 1069 | <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. |
| 1070 | |
| 1071 | Given |
| 1072 | template<typename T, int Size> |
| 1073 | class array { |
| 1074 | T data[Size]; |
| 1075 | }; |
| 1076 | dependentSizedArrayType |
| 1077 | matches "T data[Size]" |
| 1078 | </pre></td></tr> |
| 1079 | |
| 1080 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 1081 | <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> |
| 1082 | <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a |
| 1083 | qualified name. |
| 1084 | |
| 1085 | Given |
| 1086 | namespace N { |
| 1087 | namespace M { |
| 1088 | class D {}; |
| 1089 | } |
| 1090 | } |
| 1091 | class C {}; |
| 1092 | |
| 1093 | class C c; |
| 1094 | N::M::D d; |
| 1095 | |
| 1096 | elaboratedType() matches the type of the variable declarations of both |
| 1097 | c and d. |
| 1098 | </pre></td></tr> |
| 1099 | |
| 1100 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1101 | <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> |
| 1102 | <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. |
| 1103 | |
| 1104 | Given |
| 1105 | int (*f)(int); |
| 1106 | void g(); |
| 1107 | functionType() |
| 1108 | matches "int (*f)(int)" and the type of "g". |
| 1109 | </pre></td></tr> |
| 1110 | |
| 1111 | |
| 1112 | <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> |
| 1113 | <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. |
| 1114 | |
| 1115 | Given |
| 1116 | int a[] = { 2, 3 }; |
| 1117 | int b[42]; |
| 1118 | void f(int c[]) { int d[a[0]]; }; |
| 1119 | incompleteArrayType() |
| 1120 | matches "int a[]" and "int c[]" |
| 1121 | </pre></td></tr> |
| 1122 | |
| 1123 | |
Edwin Vane | 8203d9f | 2013-03-28 13:50:22 +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('lValueReferenceType0')"><a name="lValueReferenceType0Anchor">lValueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType</a>>...</td></tr> |
| 1125 | <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] | 1126 | |
| 1127 | Given: |
| 1128 | int *a; |
| 1129 | int &b = *a; |
| 1130 | int &&c = 1; |
| 1131 | auto &d = b; |
| 1132 | auto &&e = c; |
| 1133 | auto &&f = 2; |
| 1134 | int g = 5; |
| 1135 | |
Edwin Vane | 8203d9f | 2013-03-28 13:50:22 +0000 | [diff] [blame] | 1136 | lValueReferenceType() matches the types of b, d, and e. e is |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1137 | matched since the type is deduced as int& by reference collapsing rules. |
| 1138 | </pre></td></tr> |
| 1139 | |
| 1140 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1141 | <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> |
| 1142 | <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. |
| 1143 | Given |
| 1144 | struct A { int i; } |
| 1145 | A::* ptr = A::i; |
| 1146 | memberPointerType() |
| 1147 | matches "A::* ptr" |
| 1148 | </pre></td></tr> |
| 1149 | |
| 1150 | |
Edwin Vane | 88be2fd | 2013-04-01 18:33:34 +0000 | [diff] [blame] | 1151 | <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> |
| 1152 | <tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. |
| 1153 | |
| 1154 | Given |
| 1155 | int (*ptr_to_array)[4]; |
| 1156 | int *array_of_ptrs[4]; |
| 1157 | |
| 1158 | varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not |
| 1159 | array_of_ptrs. |
| 1160 | </pre></td></tr> |
| 1161 | |
| 1162 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1163 | <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> |
| 1164 | <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types. |
| 1165 | |
| 1166 | Given |
| 1167 | int *a; |
| 1168 | int &b = *a; |
| 1169 | int c = 5; |
| 1170 | pointerType() |
| 1171 | matches "int *a" |
| 1172 | </pre></td></tr> |
| 1173 | |
| 1174 | |
Edwin Vane | 8203d9f | 2013-03-28 13:50:22 +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('rValueReferenceType0')"><a name="rValueReferenceType0Anchor">rValueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType</a>>...</td></tr> |
| 1176 | <tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. |
| 1177 | |
| 1178 | Given: |
| 1179 | int *a; |
| 1180 | int &b = *a; |
| 1181 | int &&c = 1; |
| 1182 | auto &d = b; |
| 1183 | auto &&e = c; |
| 1184 | auto &&f = 2; |
| 1185 | int g = 5; |
| 1186 | |
| 1187 | rValueReferenceType() matches the types of c and f. e is not |
| 1188 | matched as it is deduced to int& by reference collapsing rules. |
| 1189 | </pre></td></tr> |
| 1190 | |
| 1191 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 1192 | <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> |
| 1193 | <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). |
| 1194 | |
| 1195 | Given |
| 1196 | class C {}; |
| 1197 | struct S {}; |
| 1198 | |
| 1199 | C c; |
| 1200 | S s; |
| 1201 | |
| 1202 | recordType() matches the type of the variable declarations of both c |
| 1203 | and s. |
| 1204 | </pre></td></tr> |
| 1205 | |
| 1206 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1207 | <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] | 1208 | <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] | 1209 | |
| 1210 | Given |
| 1211 | int *a; |
| 1212 | int &b = *a; |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1213 | int &&c = 1; |
| 1214 | auto &d = b; |
| 1215 | auto &&e = c; |
| 1216 | auto &&f = 2; |
| 1217 | int g = 5; |
| 1218 | |
| 1219 | referenceType() matches the types of b, c, d, e, and f. |
| 1220 | </pre></td></tr> |
| 1221 | |
| 1222 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 1223 | <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> |
| 1224 | <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. |
| 1225 | |
| 1226 | Given |
| 1227 | template <typename T> |
| 1228 | class C { }; |
| 1229 | |
| 1230 | template class C<int>; A |
| 1231 | C<char> var; B |
| 1232 | |
| 1233 | templateSpecializationType() matches the type of the explicit |
| 1234 | instantiation in A and the type of the variable declaration in B. |
| 1235 | </pre></td></tr> |
| 1236 | |
| 1237 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1238 | <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> |
| 1239 | <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. |
| 1240 | </pre></td></tr> |
| 1241 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1242 | |
| 1243 | <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> |
| 1244 | <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. |
| 1245 | |
| 1246 | Given |
| 1247 | typedef int X; |
| 1248 | typedefType() |
| 1249 | matches "typedef int X" |
| 1250 | </pre></td></tr> |
| 1251 | |
| 1252 | |
Manuel Klimek | 532870f | 2013-07-24 05:46:07 +0000 | [diff] [blame] | 1253 | <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> |
| 1254 | <tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. |
| 1255 | |
| 1256 | Given: |
| 1257 | typedef __underlying_type(T) type; |
| 1258 | unaryTransformType() |
| 1259 | matches "__underlying_type(T)" |
| 1260 | </pre></td></tr> |
| 1261 | |
| 1262 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1263 | <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> |
| 1264 | <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an |
| 1265 | integer-constant-expression. |
| 1266 | |
| 1267 | Given |
| 1268 | void f() { |
| 1269 | int a[] = { 2, 3 } |
| 1270 | int b[42]; |
| 1271 | int c[a[0]]; |
| 1272 | variableArrayType() |
| 1273 | matches "int c[a[0]]" |
| 1274 | </pre></td></tr> |
| 1275 | |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1276 | <!--END_DECL_MATCHERS --> |
| 1277 | </table> |
| 1278 | |
| 1279 | <!-- ======================================================================= --> |
| 1280 | <h2 id="narrowing-matchers">Narrowing Matchers</h2> |
| 1281 | <!-- ======================================================================= --> |
| 1282 | |
| 1283 | <p>Narrowing matchers match certain attributes on the current node, thus |
| 1284 | narrowing down the set of nodes of the current type to match on.</p> |
| 1285 | |
| 1286 | <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) |
| 1287 | which allow users to create more powerful match expressions.</p> |
| 1288 | |
| 1289 | <table> |
| 1290 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| 1291 | <!-- START_NARROWING_MATCHERS --> |
| 1292 | |
Samuel Benzaquen | d36e463 | 2013-08-27 15:11:16 +0000 | [diff] [blame] | 1293 | <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] | 1294 | <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. |
| 1295 | |
| 1296 | Usable as: Any Matcher |
| 1297 | </pre></td></tr> |
| 1298 | |
| 1299 | |
Samuel Benzaquen | d36e463 | 2013-08-27 15:11:16 +0000 | [diff] [blame] | 1300 | <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] | 1301 | <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. |
| 1302 | |
| 1303 | Usable as: Any Matcher |
| 1304 | </pre></td></tr> |
| 1305 | |
| 1306 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1307 | <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] | 1308 | <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. |
| 1309 | |
| 1310 | Useful when another matcher requires a child matcher, but there's no |
| 1311 | additional constraint. This will often be used with an explicit conversion |
| 1312 | to an internal::Matcher<> type such as TypeMatcher. |
| 1313 | |
| 1314 | Example: DeclarationMatcher(anything()) matches all declarations, e.g., |
| 1315 | "int* p" and "void f()" in |
| 1316 | int* p; |
| 1317 | void f(); |
| 1318 | |
| 1319 | Usable as: Any Matcher |
| 1320 | </pre></td></tr> |
| 1321 | |
| 1322 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 1323 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1324 | <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. |
| 1325 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1326 | Example matches Y (matcher = recordDecl(unless(hasName("X")))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1327 | class X {}; |
| 1328 | class Y {}; |
| 1329 | |
| 1330 | Usable as: Any Matcher |
| 1331 | </pre></td></tr> |
| 1332 | |
| 1333 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1334 | <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] | 1335 | <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or |
| 1336 | unary). |
| 1337 | |
| 1338 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 1339 | !(a || b) |
| 1340 | </pre></td></tr> |
| 1341 | |
| 1342 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1343 | <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] | 1344 | <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value. |
| 1345 | |
| 1346 | Example matches true (matcher = boolLiteral(equals(true))) |
| 1347 | true |
| 1348 | |
| 1349 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1350 | 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>> |
| 1351 | </pre></td></tr> |
| 1352 | |
| 1353 | |
Samuel Benzaquen | ef7eb02 | 2013-06-21 15:51:31 +0000 | [diff] [blame] | 1354 | <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> |
| 1355 | <tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has |
| 1356 | a specific number of arguments (including absent default arguments). |
| 1357 | |
| 1358 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 1359 | void f(int x, int y); |
| 1360 | f(0, 0); |
| 1361 | </pre></td></tr> |
| 1362 | |
| 1363 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 1364 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('isListInitialization0')"><a name="isListInitialization0Anchor">isListInitialization</a></td><td></td></tr> |
| 1365 | <tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. |
| 1366 | </pre></td></tr> |
| 1367 | |
| 1368 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1369 | <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] | 1370 | <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] | 1371 | code (as opposed to implicitly added by the compiler). |
| 1372 | |
| 1373 | Given |
| 1374 | struct Foo { |
| 1375 | Foo() { } |
| 1376 | Foo(int) : foo_("A") { } |
| 1377 | string foo_; |
| 1378 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1379 | constructorDecl(hasAnyConstructorInitializer(isWritten())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1380 | will match Foo(int), but not Foo() |
| 1381 | </pre></td></tr> |
| 1382 | |
| 1383 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 1384 | <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] | 1385 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. |
| 1386 | |
| 1387 | Matches overloaded operator names specified in strings without the |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 1388 | "operator" prefix: e.g. "<<". |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1389 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 1390 | Given: |
| 1391 | class A { int operator*(); }; |
| 1392 | const A &operator<<(const A &a, const A &b); |
| 1393 | A a; |
| 1394 | a << a; <-- This matches |
| 1395 | |
| 1396 | operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified |
| 1397 | line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches |
| 1398 | the declaration of A. |
| 1399 | |
| 1400 | 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>> |
| 1401 | </pre></td></tr> |
| 1402 | |
| 1403 | |
Edwin Vane | 32a6ebc | 2013-05-09 17:00:17 +0000 | [diff] [blame] | 1404 | <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> |
| 1405 | <tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. |
| 1406 | |
| 1407 | Given |
| 1408 | struct A { |
| 1409 | void foo() const; |
| 1410 | void bar(); |
| 1411 | }; |
| 1412 | |
| 1413 | methodDecl(isConst()) matches A::foo() but not A::bar() |
| 1414 | </pre></td></tr> |
| 1415 | |
| 1416 | |
Edwin Vane | 5771a2f | 2013-04-09 20:46:36 +0000 | [diff] [blame] | 1417 | <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> |
| 1418 | <tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. |
| 1419 | |
| 1420 | Given |
| 1421 | class A { |
| 1422 | public: |
| 1423 | virtual void x(); |
| 1424 | }; |
| 1425 | class B : public A { |
| 1426 | public: |
| 1427 | virtual void x(); |
| 1428 | }; |
| 1429 | matches B::x |
| 1430 | </pre></td></tr> |
| 1431 | |
| 1432 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 1433 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isPure0')"><a name="isPure0Anchor">isPure</a></td><td></td></tr> |
| 1434 | <tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. |
| 1435 | |
| 1436 | Given |
| 1437 | class A { |
| 1438 | public: |
| 1439 | virtual void x() = 0; |
| 1440 | }; |
| 1441 | matches A::x |
| 1442 | </pre></td></tr> |
| 1443 | |
| 1444 | |
Edwin Vane | 5771a2f | 2013-04-09 20:46:36 +0000 | [diff] [blame] | 1445 | <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> |
| 1446 | <tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. |
| 1447 | |
| 1448 | Given |
| 1449 | class A { |
| 1450 | public: |
| 1451 | virtual void x(); |
| 1452 | }; |
| 1453 | matches A::x |
| 1454 | </pre></td></tr> |
| 1455 | |
| 1456 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 1457 | <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> |
| 1458 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. |
| 1459 | |
| 1460 | Matches overloaded operator names specified in strings without the |
| 1461 | "operator" prefix: e.g. "<<". |
| 1462 | |
| 1463 | Given: |
| 1464 | class A { int operator*(); }; |
| 1465 | const A &operator<<(const A &a, const A &b); |
| 1466 | A a; |
| 1467 | a << a; <-- This matches |
| 1468 | |
| 1469 | operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified |
| 1470 | line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches |
| 1471 | the declaration of A. |
| 1472 | |
| 1473 | 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] | 1474 | </pre></td></tr> |
| 1475 | |
| 1476 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1477 | <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] | 1478 | <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). |
| 1479 | </pre></td></tr> |
| 1480 | |
| 1481 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1482 | <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> |
| 1483 | <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] | 1484 | static member variable template instantiations. |
| 1485 | |
| 1486 | Given |
| 1487 | template<typename T> void A(T t) { } |
| 1488 | template<> void A(int N) { } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1489 | functionDecl(isExplicitTemplateSpecialization()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1490 | matches the specialization A<int>(). |
| 1491 | |
| 1492 | 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>> |
| 1493 | </pre></td></tr> |
| 1494 | |
| 1495 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1496 | <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> |
| 1497 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for |
| 1498 | isSameOrDerivedFrom(hasName(...)). |
| 1499 | </pre></td></tr> |
| 1500 | |
| 1501 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1502 | <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> |
| 1503 | <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] | 1504 | member variable template instantiations. |
| 1505 | |
| 1506 | Given |
| 1507 | template <typename T> class X {}; class A {}; X<A> x; |
| 1508 | or |
| 1509 | template <typename T> class X {}; class A {}; template class X<A>; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1510 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1511 | matches the template instantiation of X<A>. |
| 1512 | |
| 1513 | But given |
| 1514 | template <typename T> class X {}; class A {}; |
| 1515 | template <> class X<A> {}; X<A> x; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1516 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1517 | does not match, as X<A> is an explicit template specialization. |
| 1518 | |
| 1519 | 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>> |
| 1520 | </pre></td></tr> |
| 1521 | |
| 1522 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1523 | <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] | 1524 | <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has |
| 1525 | a specific number of arguments (including absent default arguments). |
| 1526 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1527 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1528 | void f(int x, int y); |
| 1529 | f(0, 0); |
| 1530 | </pre></td></tr> |
| 1531 | |
| 1532 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1533 | <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] | 1534 | <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value. |
| 1535 | |
| 1536 | Example matches true (matcher = boolLiteral(equals(true))) |
| 1537 | true |
| 1538 | |
| 1539 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1540 | 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>> |
| 1541 | </pre></td></tr> |
| 1542 | |
| 1543 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1544 | <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] | 1545 | <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of |
| 1546 | child statements. |
| 1547 | |
| 1548 | Example: Given |
| 1549 | { for (;;) {} } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1550 | compoundStmt(statementCountIs(0))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1551 | matches '{}' |
| 1552 | but does not match the outer compound statement. |
| 1553 | </pre></td></tr> |
| 1554 | |
| 1555 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1556 | <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> |
| 1557 | <tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size. |
| 1558 | |
| 1559 | Given |
| 1560 | int a[42]; |
| 1561 | int b[2 * 21]; |
| 1562 | int c[41], d[43]; |
| 1563 | constantArrayType(hasSize(42)) |
| 1564 | matches "int a[42]" and "int b[2 * 21]" |
| 1565 | </pre></td></tr> |
| 1566 | |
| 1567 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1568 | <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] | 1569 | <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of |
| 1570 | declarations. |
| 1571 | |
| 1572 | Example: Given |
| 1573 | int a, b; |
| 1574 | int c; |
| 1575 | int d = 2, e; |
| 1576 | declCountIs(2) |
| 1577 | matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. |
| 1578 | </pre></td></tr> |
| 1579 | |
| 1580 | |
Manuel Klimek | cf52ca6 | 2013-06-20 14:06:32 +0000 | [diff] [blame] | 1581 | <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> |
| 1582 | <tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. |
| 1583 | |
| 1584 | Matches a node if it equals the node previously bound to ID. |
| 1585 | |
| 1586 | Given |
| 1587 | class X { int a; int b; }; |
| 1588 | recordDecl( |
| 1589 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 1590 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 1591 | matches the class X, as a and b have the same type. |
| 1592 | |
| 1593 | Note that when multiple matches are involved via forEach* matchers, |
| 1594 | equalsBoundNodes acts as a filter. |
| 1595 | For example: |
| 1596 | compoundStmt( |
| 1597 | forEachDescendant(varDecl().bind("d")), |
| 1598 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 1599 | will trigger a match for each combination of variable declaration |
| 1600 | and reference to that variable declaration within a compound statement. |
| 1601 | </pre></td></tr> |
| 1602 | |
| 1603 | |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 1604 | <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 *Node</td></tr> |
Manuel Klimek | fa37c5c | 2013-02-07 12:42:10 +0000 | [diff] [blame] | 1605 | <tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node. |
| 1606 | |
| 1607 | Decl has pointer identity in the AST. |
| 1608 | </pre></td></tr> |
| 1609 | |
| 1610 | |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 1611 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr> |
| 1612 | <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added |
| 1613 | by the compiler (eg. implicit defaultcopy constructors). |
| 1614 | </pre></td></tr> |
| 1615 | |
| 1616 | |
Daniel Jasper | c7093d9 | 2013-02-25 12:39:41 +0000 | [diff] [blame] | 1617 | <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> |
| 1618 | <tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. |
| 1619 | |
| 1620 | Given |
| 1621 | class C { |
| 1622 | public: int a; |
| 1623 | protected: int b; |
| 1624 | private: int c; |
| 1625 | }; |
| 1626 | fieldDecl(isPrivate()) |
| 1627 | matches 'int c;' |
| 1628 | </pre></td></tr> |
| 1629 | |
| 1630 | |
| 1631 | <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> |
| 1632 | <tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. |
| 1633 | |
| 1634 | Given |
| 1635 | class C { |
| 1636 | public: int a; |
| 1637 | protected: int b; |
| 1638 | private: int c; |
| 1639 | }; |
| 1640 | fieldDecl(isProtected()) |
| 1641 | matches 'int b;' |
| 1642 | </pre></td></tr> |
| 1643 | |
| 1644 | |
| 1645 | <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> |
| 1646 | <tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. |
| 1647 | |
| 1648 | Given |
| 1649 | class C { |
| 1650 | public: int a; |
| 1651 | protected: int b; |
| 1652 | private: int c; |
| 1653 | }; |
| 1654 | fieldDecl(isPublic()) |
| 1655 | matches 'int a;' |
| 1656 | </pre></td></tr> |
| 1657 | |
| 1658 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1659 | <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] | 1660 | <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. |
| 1661 | |
| 1662 | Example matches true (matcher = boolLiteral(equals(true))) |
| 1663 | true |
| 1664 | |
| 1665 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1666 | 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>> |
| 1667 | </pre></td></tr> |
| 1668 | |
| 1669 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1670 | <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> |
| 1671 | <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] | 1672 | |
| 1673 | Example matches A, va, fa |
| 1674 | class A {}; |
| 1675 | class B; Doesn't match, as it has no body. |
| 1676 | int va; |
| 1677 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 1678 | void fa() {} |
| 1679 | void fb(); Doesn't match, as it has no body. |
| 1680 | |
| 1681 | 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>> |
| 1682 | </pre></td></tr> |
| 1683 | |
| 1684 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1685 | <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> |
| 1686 | <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] | 1687 | static member variable template instantiations. |
| 1688 | |
| 1689 | Given |
| 1690 | template<typename T> void A(T t) { } |
| 1691 | template<> void A(int N) { } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1692 | functionDecl(isExplicitTemplateSpecialization()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1693 | matches the specialization A<int>(). |
| 1694 | |
| 1695 | 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>> |
| 1696 | </pre></td></tr> |
| 1697 | |
| 1698 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1699 | <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] | 1700 | <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. |
| 1701 | |
| 1702 | Given: |
| 1703 | extern "C" void f() {} |
| 1704 | extern "C" { void g() {} } |
| 1705 | void h() {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1706 | functionDecl(isExternC()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1707 | matches the declaration of f and g, but not the declaration h |
| 1708 | </pre></td></tr> |
| 1709 | |
| 1710 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1711 | <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> |
| 1712 | <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] | 1713 | member variable template instantiations. |
| 1714 | |
| 1715 | Given |
| 1716 | template <typename T> class X {}; class A {}; X<A> x; |
| 1717 | or |
| 1718 | template <typename T> class X {}; class A {}; template class X<A>; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1719 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1720 | matches the template instantiation of X<A>. |
| 1721 | |
| 1722 | But given |
| 1723 | template <typename T> class X {}; class A {}; |
| 1724 | template <> class X<A> {}; X<A> x; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1725 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1726 | does not match, as X<A> is an explicit template specialization. |
| 1727 | |
| 1728 | 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>> |
| 1729 | </pre></td></tr> |
| 1730 | |
| 1731 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1732 | <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> |
| 1733 | <tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count. |
| 1734 | |
| 1735 | Given |
| 1736 | void f(int i) {} |
| 1737 | void g(int i, int j) {} |
| 1738 | functionDecl(parameterCountIs(2)) |
| 1739 | matches g(int i, int j) {} |
| 1740 | </pre></td></tr> |
| 1741 | |
| 1742 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1743 | <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] | 1744 | <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. |
| 1745 | |
| 1746 | Example matches true (matcher = boolLiteral(equals(true))) |
| 1747 | true |
| 1748 | |
| 1749 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1750 | 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>> |
| 1751 | </pre></td></tr> |
| 1752 | |
| 1753 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1754 | <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] | 1755 | <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed |
| 1756 | to '.'. |
| 1757 | |
| 1758 | Member calls on the implicit this pointer match as called with '->'. |
| 1759 | |
| 1760 | Given |
| 1761 | class Y { |
| 1762 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 1763 | int a; |
| 1764 | static int b; |
| 1765 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1766 | memberExpr(isArrow()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1767 | matches this->x, x, y.x, a, this->b |
| 1768 | </pre></td></tr> |
| 1769 | |
| 1770 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1771 | <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] | 1772 | <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. |
| 1773 | |
| 1774 | Supports specifying enclosing namespaces or classes by prefixing the name |
| 1775 | with '<enclosing>::'. |
| 1776 | Does not match typedefs of an underlying type with the given name. |
| 1777 | |
| 1778 | Example matches X (Name == "X") |
| 1779 | class X; |
| 1780 | |
| 1781 | Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") |
| 1782 | namespace a { namespace b { class X; } } |
| 1783 | </pre></td></tr> |
| 1784 | |
| 1785 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1786 | <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] | 1787 | <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain |
| 1788 | a substring matched by the given RegExp. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1789 | |
| 1790 | Supports specifying enclosing namespaces or classes by |
| 1791 | prefixing the name with '<enclosing>::'. Does not match typedefs |
| 1792 | of an underlying type with the given name. |
| 1793 | |
| 1794 | Example matches X (regexp == "::X") |
| 1795 | class X; |
| 1796 | |
| 1797 | Example matches X (regexp is one of "::X", "^foo::.*X", among others) |
| 1798 | namespace foo { namespace bar { class X; } } |
| 1799 | </pre></td></tr> |
| 1800 | |
| 1801 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +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('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] | 1803 | <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. |
| 1804 | |
| 1805 | Given |
| 1806 | class Y { public: void x(); }; |
| 1807 | void z() { Y* y; y->x(); } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1808 | callExpr(on(hasType(asString("class Y *")))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1809 | matches y->x() |
| 1810 | </pre></td></tr> |
| 1811 | |
| 1812 | |
Manuel Klimek | cf52ca6 | 2013-06-20 14:06:32 +0000 | [diff] [blame] | 1813 | <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> |
| 1814 | <tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. |
| 1815 | |
| 1816 | Matches a node if it equals the node previously bound to ID. |
| 1817 | |
| 1818 | Given |
| 1819 | class X { int a; int b; }; |
| 1820 | recordDecl( |
| 1821 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 1822 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 1823 | matches the class X, as a and b have the same type. |
| 1824 | |
| 1825 | Note that when multiple matches are involved via forEach* matchers, |
| 1826 | equalsBoundNodes acts as a filter. |
| 1827 | For example: |
| 1828 | compoundStmt( |
| 1829 | forEachDescendant(varDecl().bind("d")), |
| 1830 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 1831 | will trigger a match for each combination of variable declaration |
| 1832 | and reference to that variable declaration within a compound statement. |
| 1833 | </pre></td></tr> |
| 1834 | |
| 1835 | |
Edwin Vane | 7b69cd0 | 2013-04-02 18:15:55 +0000 | [diff] [blame] | 1836 | <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> |
| 1837 | <tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to |
| 1838 | the node, not hidden within a typedef. |
| 1839 | |
| 1840 | Given |
| 1841 | typedef const int const_int; |
| 1842 | const_int i; |
| 1843 | int *const j; |
| 1844 | int *volatile k; |
| 1845 | int m; |
| 1846 | varDecl(hasType(hasLocalQualifiers())) matches only j and k. |
| 1847 | i is const-qualified but the qualifier is not local. |
| 1848 | </pre></td></tr> |
| 1849 | |
| 1850 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1851 | <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] | 1852 | <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that |
| 1853 | include "top-level" const. |
| 1854 | |
| 1855 | Given |
| 1856 | void a(int); |
| 1857 | void b(int const); |
| 1858 | void c(const int); |
| 1859 | void d(const int*); |
| 1860 | void e(int const) {}; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1861 | functionDecl(hasAnyParameter(hasType(isConstQualified()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1862 | matches "void b(int const)", "void c(const int)" and |
| 1863 | "void e(int const) {}". It does not match d as there |
| 1864 | is no top-level const on the parameter type "const int *". |
| 1865 | </pre></td></tr> |
| 1866 | |
| 1867 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1868 | <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] | 1869 | <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. |
| 1870 | |
| 1871 | Given |
| 1872 | void a(int); |
| 1873 | void b(long); |
| 1874 | void c(double); |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1875 | functionDecl(hasAnyParameter(hasType(isInteger()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1876 | matches "a(int)", "b(long)", but not "c(double)". |
| 1877 | </pre></td></tr> |
| 1878 | |
| 1879 | |
Manuel Klimek | cf52ca6 | 2013-06-20 14:06:32 +0000 | [diff] [blame] | 1880 | <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> |
| 1881 | <tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. |
| 1882 | |
| 1883 | Matches a node if it equals the node previously bound to ID. |
| 1884 | |
| 1885 | Given |
| 1886 | class X { int a; int b; }; |
| 1887 | recordDecl( |
| 1888 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 1889 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 1890 | matches the class X, as a and b have the same type. |
| 1891 | |
| 1892 | Note that when multiple matches are involved via forEach* matchers, |
| 1893 | equalsBoundNodes acts as a filter. |
| 1894 | For example: |
| 1895 | compoundStmt( |
| 1896 | forEachDescendant(varDecl().bind("d")), |
| 1897 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 1898 | will trigger a match for each combination of variable declaration |
| 1899 | and reference to that variable declaration within a compound statement. |
| 1900 | </pre></td></tr> |
| 1901 | |
| 1902 | |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 1903 | <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 *Node</td></tr> |
Manuel Klimek | fa37c5c | 2013-02-07 12:42:10 +0000 | [diff] [blame] | 1904 | <tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. |
| 1905 | |
| 1906 | Stmt has pointer identity in the AST. |
| 1907 | |
| 1908 | </pre></td></tr> |
| 1909 | |
| 1910 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1911 | <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> |
| 1912 | <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] | 1913 | |
| 1914 | Example matches A, va, fa |
| 1915 | class A {}; |
| 1916 | class B; Doesn't match, as it has no body. |
| 1917 | int va; |
| 1918 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 1919 | void fa() {} |
| 1920 | void fb(); Doesn't match, as it has no body. |
| 1921 | |
| 1922 | 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>> |
| 1923 | </pre></td></tr> |
| 1924 | |
| 1925 | |
Manuel Klimek | cf52ca6 | 2013-06-20 14:06:32 +0000 | [diff] [blame] | 1926 | <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> |
| 1927 | <tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. |
| 1928 | |
| 1929 | Matches a node if it equals the node previously bound to ID. |
| 1930 | |
| 1931 | Given |
| 1932 | class X { int a; int b; }; |
| 1933 | recordDecl( |
| 1934 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 1935 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 1936 | matches the class X, as a and b have the same type. |
| 1937 | |
| 1938 | Note that when multiple matches are involved via forEach* matchers, |
| 1939 | equalsBoundNodes acts as a filter. |
| 1940 | For example: |
| 1941 | compoundStmt( |
| 1942 | forEachDescendant(varDecl().bind("d")), |
| 1943 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 1944 | will trigger a match for each combination of variable declaration |
| 1945 | and reference to that variable declaration within a compound statement. |
| 1946 | </pre></td></tr> |
| 1947 | |
| 1948 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1949 | <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] | 1950 | <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. |
| 1951 | |
| 1952 | Given |
| 1953 | int x; |
| 1954 | int s = sizeof(x) + alignof(x) |
| 1955 | unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) |
| 1956 | matches sizeof(x) |
| 1957 | </pre></td></tr> |
| 1958 | |
| 1959 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1960 | <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] | 1961 | <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or |
| 1962 | unary). |
| 1963 | |
| 1964 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 1965 | !(a || b) |
| 1966 | </pre></td></tr> |
| 1967 | |
| 1968 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1969 | <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] | 1970 | <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. |
| 1971 | |
| 1972 | Example matches A, va, fa |
| 1973 | class A {}; |
| 1974 | class B; Doesn't match, as it has no body. |
| 1975 | int va; |
| 1976 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 1977 | void fa() {} |
| 1978 | void fb(); Doesn't match, as it has no body. |
| 1979 | |
| 1980 | 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>> |
| 1981 | </pre></td></tr> |
| 1982 | |
| 1983 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1984 | <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] | 1985 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or |
| 1986 | static member variable template instantiations. |
| 1987 | |
| 1988 | Given |
| 1989 | template<typename T> void A(T t) { } |
| 1990 | template<> void A(int N) { } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1991 | functionDecl(isExplicitTemplateSpecialization()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1992 | matches the specialization A<int>(). |
| 1993 | |
| 1994 | 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>> |
| 1995 | </pre></td></tr> |
| 1996 | |
| 1997 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1998 | <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] | 1999 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static |
| 2000 | member variable template instantiations. |
| 2001 | |
| 2002 | Given |
| 2003 | template <typename T> class X {}; class A {}; X<A> x; |
| 2004 | or |
| 2005 | template <typename T> class X {}; class A {}; template class X<A>; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2006 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2007 | matches the template instantiation of X<A>. |
| 2008 | |
| 2009 | But given |
| 2010 | template <typename T> class X {}; class A {}; |
| 2011 | template <> class X<A> {}; X<A> x; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2012 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2013 | does not match, as X<A> is an explicit template specialization. |
| 2014 | |
| 2015 | 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>> |
| 2016 | </pre></td></tr> |
| 2017 | |
| 2018 | <!--END_NARROWING_MATCHERS --> |
| 2019 | </table> |
| 2020 | |
| 2021 | <!-- ======================================================================= --> |
| 2022 | <h2 id="traversal-matchers">AST Traversal Matchers</h2> |
| 2023 | <!-- ======================================================================= --> |
| 2024 | |
| 2025 | <p>Traversal matchers specify the relationship to other nodes that are |
| 2026 | reachable from the current node.</p> |
| 2027 | |
| 2028 | <p>Note that there are special traversal matchers (has, hasDescendant, forEach and |
| 2029 | forEachDescendant) which work on all nodes and allow users to write more generic |
| 2030 | match expressions.</p> |
| 2031 | |
| 2032 | <table> |
| 2033 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| 2034 | <!-- START_TRAVERSAL_MATCHERS --> |
| 2035 | |
Samuel Benzaquen | d36e463 | 2013-08-27 15:11:16 +0000 | [diff] [blame] | 2036 | <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] | 2037 | <tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. |
| 2038 | |
| 2039 | Unlike anyOf, eachOf will generate a match result for each |
| 2040 | matching submatcher. |
| 2041 | |
| 2042 | For example, in: |
| 2043 | class A { int a; int b; }; |
| 2044 | The matcher: |
| 2045 | recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), |
| 2046 | has(fieldDecl(hasName("b")).bind("v")))) |
| 2047 | will generate two results binding "v", the first of which binds |
| 2048 | the field declaration of a, the second the field declaration of |
| 2049 | b. |
| 2050 | |
| 2051 | Usable as: Any Matcher |
| 2052 | </pre></td></tr> |
| 2053 | |
| 2054 | |
Samuel Benzaquen | ee0da95 | 2013-08-16 16:19:42 +0000 | [diff] [blame] | 2055 | <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] | 2056 | <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 2057 | provided matcher. |
| 2058 | |
| 2059 | Example matches X, A, B, C |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2060 | (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2061 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 2062 | class A { class X {}; }; |
| 2063 | class B { class C { class X {}; }; }; |
| 2064 | |
| 2065 | DescendantT must be an AST base type. |
| 2066 | |
| 2067 | As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for |
| 2068 | each result that matches instead of only on the first one. |
| 2069 | |
| 2070 | Note: Recursively combined ForEachDescendant can cause many matches: |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2071 | recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl())))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2072 | will match 10 times (plus injected class name matches) on: |
| 2073 | class A { class B { class C { class D { class E {}; }; }; }; }; |
| 2074 | |
| 2075 | Usable as: Any Matcher |
| 2076 | </pre></td></tr> |
| 2077 | |
| 2078 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 2079 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> |
| 2080 | <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2081 | provided matcher. |
| 2082 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 2083 | Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2084 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 2085 | class Y { class X {}; }; |
| 2086 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 2087 | |
| 2088 | ChildT must be an AST base type. |
| 2089 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 2090 | As opposed to 'has', 'forEach' will cause a match for each result that |
| 2091 | matches instead of only on the first one. |
| 2092 | |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2093 | Usable as: Any Matcher |
| 2094 | </pre></td></tr> |
| 2095 | |
| 2096 | |
Samuel Benzaquen | ee0da95 | 2013-08-16 16:19:42 +0000 | [diff] [blame] | 2097 | <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] | 2098 | <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided |
| 2099 | matcher. |
| 2100 | |
| 2101 | Given |
| 2102 | void f() { if (true) { int x = 42; } } |
| 2103 | void g() { for (;;) { int x = 43; } } |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2104 | expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2105 | |
| 2106 | Usable as: Any Matcher |
| 2107 | </pre></td></tr> |
| 2108 | |
| 2109 | |
Samuel Benzaquen | ee0da95 | 2013-08-16 16:19:42 +0000 | [diff] [blame] | 2110 | <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] | 2111 | <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 2112 | provided matcher. |
| 2113 | |
| 2114 | Example matches X, Y, Z |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2115 | (matcher = recordDecl(hasDescendant(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2116 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 2117 | class Y { class X {}; }; |
| 2118 | class Z { class Y { class X {}; }; }; |
| 2119 | |
| 2120 | DescendantT must be an AST base type. |
| 2121 | |
| 2122 | Usable as: Any Matcher |
| 2123 | </pre></td></tr> |
| 2124 | |
| 2125 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 2126 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> |
| 2127 | <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the |
| 2128 | provided matcher. |
| 2129 | |
| 2130 | Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X"))) |
| 2131 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 2132 | class Y { class X {}; }; |
| 2133 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 2134 | |
| 2135 | ChildT must be an AST base type. |
| 2136 | |
| 2137 | Usable as: Any Matcher |
| 2138 | </pre></td></tr> |
| 2139 | |
| 2140 | |
Samuel Benzaquen | ee0da95 | 2013-08-16 16:19:42 +0000 | [diff] [blame] | 2141 | <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] | 2142 | <tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided |
| 2143 | matcher. |
| 2144 | |
| 2145 | Given |
| 2146 | void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } |
| 2147 | compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". |
| 2148 | |
| 2149 | Usable as: Any Matcher |
| 2150 | </pre></td></tr> |
| 2151 | |
| 2152 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2153 | <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] | 2154 | <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. |
| 2155 | |
| 2156 | Given |
| 2157 | int i[5]; |
| 2158 | void f() { i[1] = 42; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2159 | arraySubscriptExpression(hasBase(implicitCastExpr( |
| 2160 | hasSourceExpression(declRefExpr())))) |
| 2161 | matches i[1] with the declRefExpr() matching i |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2162 | </pre></td></tr> |
| 2163 | |
| 2164 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2165 | <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] | 2166 | <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. |
| 2167 | |
| 2168 | Given |
| 2169 | int i[5]; |
| 2170 | void f() { i[1] = 42; } |
| 2171 | arraySubscriptExpression(hasIndex(integerLiteral())) |
| 2172 | matches i[1] with the integerLiteral() matching 1 |
| 2173 | </pre></td></tr> |
| 2174 | |
| 2175 | |
Samuel Benzaquen | 3f84bb3 | 2013-07-15 19:25:06 +0000 | [diff] [blame] | 2176 | <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> |
| 2177 | <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] | 2178 | type. |
| 2179 | |
| 2180 | Given |
| 2181 | struct A {}; |
| 2182 | A a[7]; |
| 2183 | int b[7]; |
| 2184 | arrayType(hasElementType(builtinType())) |
| 2185 | matches "int b[7]" |
| 2186 | |
| 2187 | 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>> |
| 2188 | </pre></td></tr> |
| 2189 | |
| 2190 | |
Samuel Benzaquen | 3f84bb3 | 2013-07-15 19:25:06 +0000 | [diff] [blame] | 2191 | <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> |
| 2192 | <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] | 2193 | type. |
| 2194 | |
| 2195 | Given |
| 2196 | struct A {}; |
| 2197 | A a[7]; |
| 2198 | int b[7]; |
| 2199 | arrayType(hasElementType(builtinType())) |
| 2200 | matches "int b[7]" |
| 2201 | |
| 2202 | 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>> |
| 2203 | </pre></td></tr> |
| 2204 | |
| 2205 | |
| 2206 | <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> |
| 2207 | <tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. |
| 2208 | |
| 2209 | Given |
| 2210 | _Atomic(int) i; |
| 2211 | _Atomic(float) f; |
| 2212 | atomicType(hasValueType(isInteger())) |
| 2213 | matches "_Atomic(int) i" |
| 2214 | |
| 2215 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> |
| 2216 | </pre></td></tr> |
| 2217 | |
| 2218 | |
| 2219 | <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> |
| 2220 | <tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. |
| 2221 | |
| 2222 | Given |
| 2223 | _Atomic(int) i; |
| 2224 | _Atomic(float) f; |
| 2225 | atomicType(hasValueType(isInteger())) |
| 2226 | matches "_Atomic(int) i" |
| 2227 | |
| 2228 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> |
| 2229 | </pre></td></tr> |
| 2230 | |
| 2231 | |
| 2232 | <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> |
| 2233 | <tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. |
| 2234 | |
| 2235 | Note: There is no TypeLoc for the deduced type and thus no |
| 2236 | getDeducedLoc() matcher. |
| 2237 | |
| 2238 | Given |
| 2239 | auto a = 1; |
| 2240 | auto b = 2.0; |
| 2241 | autoType(hasDeducedType(isInteger())) |
| 2242 | matches "auto a" |
| 2243 | |
| 2244 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> |
| 2245 | </pre></td></tr> |
| 2246 | |
| 2247 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2248 | <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] | 2249 | <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a |
| 2250 | binary operator matches. |
| 2251 | </pre></td></tr> |
| 2252 | |
| 2253 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2254 | <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] | 2255 | <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. |
| 2256 | |
| 2257 | Example matches a (matcher = binaryOperator(hasLHS())) |
| 2258 | a || b |
| 2259 | </pre></td></tr> |
| 2260 | |
| 2261 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2262 | <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] | 2263 | <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. |
| 2264 | |
| 2265 | Example matches b (matcher = binaryOperator(hasRHS())) |
| 2266 | a || b |
| 2267 | </pre></td></tr> |
| 2268 | |
| 2269 | |
Samuel Benzaquen | 3f84bb3 | 2013-07-15 19:25:06 +0000 | [diff] [blame] | 2270 | <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> |
| 2271 | <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] | 2272 | pointee matches a given matcher. |
| 2273 | |
| 2274 | Given |
| 2275 | int *a; |
| 2276 | int const *b; |
| 2277 | float const *f; |
| 2278 | pointerType(pointee(isConstQualified(), isInteger())) |
| 2279 | matches "int const *b" |
| 2280 | |
| 2281 | 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>>, |
| 2282 | 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>> |
| 2283 | </pre></td></tr> |
| 2284 | |
| 2285 | |
Samuel Benzaquen | 3f84bb3 | 2013-07-15 19:25:06 +0000 | [diff] [blame] | 2286 | <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> |
| 2287 | <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] | 2288 | pointee matches a given matcher. |
| 2289 | |
| 2290 | Given |
| 2291 | int *a; |
| 2292 | int const *b; |
| 2293 | float const *f; |
| 2294 | pointerType(pointee(isConstQualified(), isInteger())) |
| 2295 | matches "int const *b" |
| 2296 | |
| 2297 | 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>>, |
| 2298 | 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>> |
| 2299 | </pre></td></tr> |
| 2300 | |
| 2301 | |
Samuel Benzaquen | ef7eb02 | 2013-06-21 15:51:31 +0000 | [diff] [blame] | 2302 | <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> |
| 2303 | <tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call |
| 2304 | expression. |
| 2305 | |
| 2306 | Given |
| 2307 | void x(int, int, int) { int y; x(1, y, 42); } |
| 2308 | callExpr(hasAnyArgument(declRefExpr())) |
| 2309 | matches x(1, y, 42) |
| 2310 | with hasAnyArgument(...) |
| 2311 | matching y |
| 2312 | |
| 2313 | FIXME: Currently this will ignore parentheses and implicit casts on |
| 2314 | the argument before applying the inner matcher. We'll want to remove |
| 2315 | this to allow for greater control by the user once ignoreImplicit() |
| 2316 | has been implemented. |
| 2317 | </pre></td></tr> |
| 2318 | |
| 2319 | |
| 2320 | <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> |
| 2321 | <tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor |
| 2322 | call expression. |
| 2323 | |
| 2324 | Example matches y in x(y) |
| 2325 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 2326 | void x(int) { int y; x(y); } |
| 2327 | </pre></td></tr> |
| 2328 | |
| 2329 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 2330 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasDeclaration12')"><a name="hasDeclaration12Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 2331 | <tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 2332 | matches the given matcher. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2333 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 2334 | The associated declaration is: |
| 2335 | - for type nodes, the declaration of the underlying type |
| 2336 | - for CallExpr, the declaration of the callee |
| 2337 | - for MemberExpr, the declaration of the referenced member |
| 2338 | - for CXXConstructExpr, the declaration of the constructor |
| 2339 | |
| 2340 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 2341 | function. e.g. various subtypes of clang::Type and various expressions. |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 2342 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 2343 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 2344 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 2345 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 2346 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 2347 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 2348 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2349 | </pre></td></tr> |
| 2350 | |
| 2351 | |
Manuel Klimek | 532870f | 2013-07-24 05:46:07 +0000 | [diff] [blame] | 2352 | <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> |
| 2353 | <tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. |
| 2354 | |
| 2355 | Given |
| 2356 | class A { A() : i(42), j(42) {} int i; int j; }; |
| 2357 | constructorDecl(forEachConstructorInitializer(forField(decl().bind("x")))) |
| 2358 | will trigger two matches, binding for 'i' and 'j' respectively. |
| 2359 | </pre></td></tr> |
| 2360 | |
| 2361 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2362 | <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] | 2363 | <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. |
| 2364 | |
| 2365 | Given |
| 2366 | struct Foo { |
| 2367 | Foo() : foo_(1) { } |
| 2368 | int foo_; |
| 2369 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2370 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything())))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2371 | record matches Foo, hasAnyConstructorInitializer matches foo_(1) |
| 2372 | </pre></td></tr> |
| 2373 | |
| 2374 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2375 | <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] | 2376 | <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. |
| 2377 | |
| 2378 | Given |
| 2379 | struct Foo { |
| 2380 | Foo() : foo_(1) { } |
| 2381 | int foo_; |
| 2382 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2383 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2384 | forField(hasName("foo_")))))) |
| 2385 | matches Foo |
| 2386 | with forField matching foo_ |
| 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_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] | 2391 | <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. |
| 2392 | |
| 2393 | Given |
| 2394 | struct Foo { |
| 2395 | Foo() : foo_(1) { } |
| 2396 | int foo_; |
| 2397 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2398 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2399 | withInitializer(integerLiteral(equals(1))))))) |
| 2400 | matches Foo |
| 2401 | with withInitializer matching (1) |
| 2402 | </pre></td></tr> |
| 2403 | |
| 2404 | |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 2405 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasBody3')"><a name="hasBody3Anchor">hasBody</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> |
| 2406 | <tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 2407 | a given body. |
| 2408 | |
| 2409 | Given |
| 2410 | for (;;) {} |
| 2411 | hasBody(compoundStmt()) |
| 2412 | matches 'for (;;) {}' |
| 2413 | with compoundStmt() |
| 2414 | matching '{}' |
| 2415 | </pre></td></tr> |
| 2416 | |
| 2417 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 2418 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasLoopVariable0')"><a name="hasLoopVariable0Anchor">hasLoopVariable</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>> InnerMatcher</td></tr> |
| 2419 | <tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. |
| 2420 | |
| 2421 | Example: |
| 2422 | forStmt(hasLoopVariable(anything())) |
| 2423 | matches 'int x' in |
| 2424 | for (int x : a) { } |
| 2425 | </pre></td></tr> |
| 2426 | |
| 2427 | |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 2428 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasRangeInit0')"><a name="hasRangeInit0Anchor">hasRangeInit</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 2429 | <tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. |
| 2430 | |
| 2431 | Example: |
| 2432 | forStmt(hasRangeInit(anything())) |
| 2433 | matches 'a' in |
| 2434 | for (int x : a) { } |
| 2435 | </pre></td></tr> |
| 2436 | |
| 2437 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 2438 | <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> |
| 2439 | <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> |
| 2440 | |
| 2441 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2442 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 2443 | <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. |
| 2444 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2445 | Example matches y.x() (matcher = callExpr(on(hasType(recordDecl(hasName("Y")))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2446 | class Y { public: void x(); }; |
| 2447 | void z() { Y y; y.x(); }", |
| 2448 | |
| 2449 | FIXME: Overload to allow directly matching types? |
| 2450 | </pre></td></tr> |
| 2451 | |
| 2452 | |
Manuel Klimek | 532870f | 2013-07-24 05:46:07 +0000 | [diff] [blame] | 2453 | <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] | 2454 | <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. |
| 2455 | </pre></td></tr> |
| 2456 | |
| 2457 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 2458 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>></td><td class="name" onclick="toggle('thisPointerType0')"><a name="thisPointerType0Anchor">thisPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
| 2459 | <tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified |
| 2460 | matcher, or is a pointer to a type that matches the InnerMatcher. |
| 2461 | </pre></td></tr> |
| 2462 | |
| 2463 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2464 | <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] | 2465 | <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration |
| 2466 | belongs to. |
| 2467 | |
| 2468 | FIXME: Generalize this for other kinds of declarations. |
| 2469 | FIXME: What other kind of declarations would we need to generalize |
| 2470 | this to? |
| 2471 | |
| 2472 | Example matches A() in the last line |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2473 | (matcher = constructExpr(hasDeclaration(methodDecl( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2474 | ofClass(hasName("A")))))) |
| 2475 | class A { |
| 2476 | public: |
| 2477 | A(); |
| 2478 | }; |
| 2479 | A a = A(); |
| 2480 | </pre></td></tr> |
| 2481 | |
| 2482 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 2483 | <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> |
| 2484 | <tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. |
| 2485 | |
| 2486 | Given: |
| 2487 | class A { void func(); }; |
| 2488 | class B { void member(); }; |
| 2489 | |
| 2490 | recordDecl(hasMethod(hasName("func"))) matches the declaration of A |
| 2491 | but not B. |
| 2492 | </pre></td></tr> |
| 2493 | |
| 2494 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2495 | <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] | 2496 | <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from |
| 2497 | a class matching Base. |
| 2498 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2499 | Note that a class is not considered to be derived from itself. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2500 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2501 | Example matches Y, Z, C (Base == hasName("X")) |
| 2502 | class X; |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2503 | class Y : public X {}; directly derived |
| 2504 | class Z : public Y {}; indirectly derived |
| 2505 | typedef X A; |
| 2506 | typedef A B; |
| 2507 | class C : public B {}; derived from a typedef of X |
| 2508 | |
| 2509 | In the following example, Bar matches isDerivedFrom(hasName("X")): |
| 2510 | class Foo; |
| 2511 | typedef Foo X; |
| 2512 | class Bar : public Foo {}; derived from a type that X is a typedef of |
| 2513 | </pre></td></tr> |
| 2514 | |
| 2515 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2516 | <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> |
| 2517 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly |
| 2518 | match Base. |
| 2519 | </pre></td></tr> |
| 2520 | |
| 2521 | |
Manuel Klimek | 532870f | 2013-07-24 05:46:07 +0000 | [diff] [blame] | 2522 | <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] | 2523 | <tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the |
| 2524 | given matcher. |
| 2525 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2526 | Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2527 | class Y { public: void x(); }; |
| 2528 | void z() { Y y; y.x(); |
| 2529 | </pre></td></tr> |
| 2530 | |
| 2531 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 2532 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('callee0')"><a name="callee0Anchor">callee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> |
| 2533 | <tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. |
| 2534 | |
| 2535 | Given |
| 2536 | class Y { void x() { this->x(); x(); Y y; y.x(); } }; |
| 2537 | void f() { f(); } |
| 2538 | callExpr(callee(expr())) |
| 2539 | matches this->x(), x(), y.x(), f() |
| 2540 | with callee(...) |
| 2541 | matching this->x, x, y.x, f respectively |
| 2542 | |
| 2543 | Note: Callee cannot take the more general internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> |
| 2544 | because this introduces ambiguous overloads with calls to Callee taking a |
| 2545 | internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely |
| 2546 | implemented in terms of implicit casts. |
| 2547 | </pre></td></tr> |
| 2548 | |
| 2549 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2550 | <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] | 2551 | <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call |
| 2552 | expression. |
| 2553 | |
| 2554 | Given |
| 2555 | void x(int, int, int) { int y; x(1, y, 42); } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2556 | callExpr(hasAnyArgument(declRefExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2557 | matches x(1, y, 42) |
| 2558 | with hasAnyArgument(...) |
| 2559 | matching y |
Manuel Klimek | 1a68afd | 2013-06-20 13:08:29 +0000 | [diff] [blame] | 2560 | |
| 2561 | FIXME: Currently this will ignore parentheses and implicit casts on |
| 2562 | the argument before applying the inner matcher. We'll want to remove |
| 2563 | this to allow for greater control by the user once ignoreImplicit() |
| 2564 | has been implemented. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2565 | </pre></td></tr> |
| 2566 | |
| 2567 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2568 | <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] | 2569 | <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor |
| 2570 | call expression. |
| 2571 | |
| 2572 | Example matches y in x(y) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2573 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2574 | void x(int) { int y; x(y); } |
| 2575 | </pre></td></tr> |
| 2576 | |
| 2577 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 2578 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasDeclaration13')"><a name="hasDeclaration13Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 2579 | <tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 2580 | matches the given matcher. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2581 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 2582 | The associated declaration is: |
| 2583 | - for type nodes, the declaration of the underlying type |
| 2584 | - for CallExpr, the declaration of the callee |
| 2585 | - for MemberExpr, the declaration of the referenced member |
| 2586 | - for CXXConstructExpr, the declaration of the constructor |
| 2587 | |
| 2588 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 2589 | function. e.g. various subtypes of clang::Type and various expressions. |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 2590 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 2591 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 2592 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 2593 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 2594 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 2595 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 2596 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2597 | </pre></td></tr> |
| 2598 | |
| 2599 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 2600 | <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> |
| 2601 | <tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range |
| 2602 | extension, matches the constant given in the statement. |
| 2603 | |
| 2604 | Given |
| 2605 | switch (1) { case 1: case 1+1: case 3 ... 4: ; } |
| 2606 | caseStmt(hasCaseConstant(integerLiteral())) |
| 2607 | matches "case 1:" |
| 2608 | </pre></td></tr> |
| 2609 | |
| 2610 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2611 | <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] | 2612 | <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher. |
| 2613 | |
| 2614 | Example: matches "a string" (matcher = |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2615 | hasSourceExpression(constructExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2616 | class URL { URL(string); }; |
| 2617 | URL url = "a string"; |
| 2618 | </pre></td></tr> |
| 2619 | |
| 2620 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2621 | <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] | 2622 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one |
| 2623 | TemplateArgument matching the given InnerMatcher. |
| 2624 | |
| 2625 | Given |
| 2626 | template<typename T> class A {}; |
| 2627 | template<> class A<double> {}; |
| 2628 | A<int> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2629 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2630 | refersToType(asString("int")))) |
| 2631 | matches the specialization A<int> |
| 2632 | </pre></td></tr> |
| 2633 | |
| 2634 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2635 | <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] | 2636 | <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument |
| 2637 | matches the given InnerMatcher. |
| 2638 | |
| 2639 | Given |
| 2640 | template<typename T, typename U> class A {}; |
| 2641 | A<bool, int> b; |
| 2642 | A<int, bool> c; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2643 | classTemplateSpecializationDecl(hasTemplateArgument( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2644 | 1, refersToType(asString("int")))) |
| 2645 | matches the specialization A<bool, int> |
| 2646 | </pre></td></tr> |
| 2647 | |
| 2648 | |
Samuel Benzaquen | 3f84bb3 | 2013-07-15 19:25:06 +0000 | [diff] [blame] | 2649 | <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> |
| 2650 | <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] | 2651 | type. |
| 2652 | |
| 2653 | Given |
| 2654 | struct A {}; |
| 2655 | A a[7]; |
| 2656 | int b[7]; |
| 2657 | arrayType(hasElementType(builtinType())) |
| 2658 | matches "int b[7]" |
| 2659 | |
| 2660 | 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>> |
| 2661 | </pre></td></tr> |
| 2662 | |
| 2663 | |
Samuel Benzaquen | 3f84bb3 | 2013-07-15 19:25:06 +0000 | [diff] [blame] | 2664 | <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> |
| 2665 | <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] | 2666 | type. |
| 2667 | |
| 2668 | Given |
| 2669 | struct A {}; |
| 2670 | A a[7]; |
| 2671 | int b[7]; |
| 2672 | arrayType(hasElementType(builtinType())) |
| 2673 | matches "int b[7]" |
| 2674 | |
| 2675 | 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>> |
| 2676 | </pre></td></tr> |
| 2677 | |
| 2678 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2679 | <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] | 2680 | <tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches |
| 2681 | a given matcher. |
| 2682 | |
| 2683 | Given |
| 2684 | { {}; 1+2; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2685 | hasAnySubstatement(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2686 | matches '{ {}; 1+2; }' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2687 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2688 | matching '{}' |
| 2689 | </pre></td></tr> |
| 2690 | |
| 2691 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2692 | <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] | 2693 | <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, |
| 2694 | or conditional operator. |
| 2695 | |
| 2696 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 2697 | if (true) {} |
| 2698 | </pre></td></tr> |
| 2699 | |
| 2700 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2701 | <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] | 2702 | <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator. |
| 2703 | |
| 2704 | Example matches b |
| 2705 | condition ? a : b |
| 2706 | </pre></td></tr> |
| 2707 | |
| 2708 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2709 | <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] | 2710 | <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. |
| 2711 | |
| 2712 | Example matches a |
| 2713 | condition ? a : b |
| 2714 | </pre></td></tr> |
| 2715 | |
| 2716 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 2717 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('hasDeclaration11')"><a name="hasDeclaration11Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 2718 | <tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node |
| 2719 | matches the given matcher. |
| 2720 | |
| 2721 | The associated declaration is: |
| 2722 | - for type nodes, the declaration of the underlying type |
| 2723 | - for CallExpr, the declaration of the callee |
| 2724 | - for MemberExpr, the declaration of the referenced member |
| 2725 | - for CXXConstructExpr, the declaration of the constructor |
| 2726 | |
| 2727 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 2728 | function. e.g. various subtypes of clang::Type and various expressions. |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 2729 | |
| 2730 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 2731 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 2732 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 2733 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 2734 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 2735 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
| 2736 | </pre></td></tr> |
| 2737 | |
| 2738 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2739 | <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] | 2740 | <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a |
| 2741 | specific using shadow declaration. |
| 2742 | |
| 2743 | FIXME: This currently only works for functions. Fix. |
| 2744 | |
| 2745 | Given |
| 2746 | namespace a { void f() {} } |
| 2747 | using a::f; |
| 2748 | void g() { |
| 2749 | f(); Matches this .. |
| 2750 | a::f(); .. but not this. |
| 2751 | } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2752 | declRefExpr(throughUsingDeclaration(anything())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2753 | matches f() |
| 2754 | </pre></td></tr> |
| 2755 | |
| 2756 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2757 | <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] | 2758 | <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the |
| 2759 | specified matcher. |
| 2760 | |
| 2761 | Example matches x in if(x) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2762 | (matcher = declRefExpr(to(varDecl(hasName("x"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2763 | bool x; |
| 2764 | if (x) {} |
| 2765 | </pre></td></tr> |
| 2766 | |
| 2767 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2768 | <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] | 2769 | <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. |
| 2770 | |
| 2771 | Note that this does not work for global declarations because the AST |
| 2772 | breaks up multiple-declaration DeclStmt's into multiple single-declaration |
| 2773 | DeclStmt's. |
| 2774 | Example: Given non-global declarations |
| 2775 | int a, b = 0; |
| 2776 | int c; |
| 2777 | int d = 2, e; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2778 | declStmt(containsDeclaration( |
| 2779 | 0, varDecl(hasInitializer(anything())))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2780 | matches only 'int d = 2, e;', and |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2781 | declStmt(containsDeclaration(1, varDecl())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2782 | matches 'int a, b = 0' as well as 'int d = 2, e;' |
| 2783 | but 'int c;' is not matched. |
| 2784 | </pre></td></tr> |
| 2785 | |
| 2786 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2787 | <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] | 2788 | <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. |
| 2789 | |
| 2790 | Given |
| 2791 | int a, b; |
| 2792 | int c; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2793 | declStmt(hasSingleDecl(anything())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2794 | matches 'int c;' but not 'int a, b;'. |
| 2795 | </pre></td></tr> |
| 2796 | |
| 2797 | |
Manuel Klimek | 1a68afd | 2013-06-20 13:08:29 +0000 | [diff] [blame] | 2798 | <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> |
| 2799 | <tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches |
| 2800 | the inner matcher. |
| 2801 | |
| 2802 | Given |
| 2803 | int x; |
| 2804 | declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 2805 | matches int x |
| 2806 | </pre></td></tr> |
| 2807 | |
| 2808 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 2809 | <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> |
| 2810 | <tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a |
| 2811 | Decl, matches InnerMatcher. |
| 2812 | |
| 2813 | Given |
| 2814 | namespace N { |
| 2815 | namespace M { |
| 2816 | class D {}; |
| 2817 | } |
| 2818 | } |
| 2819 | |
| 2820 | recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the |
| 2821 | declaration of class D. |
| 2822 | </pre></td></tr> |
| 2823 | |
| 2824 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2825 | <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] | 2826 | <tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 2827 | a given body. |
| 2828 | |
| 2829 | Given |
| 2830 | for (;;) {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2831 | hasBody(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2832 | matches 'for (;;) {}' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2833 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2834 | matching '{}' |
| 2835 | </pre></td></tr> |
| 2836 | |
| 2837 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2838 | <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] | 2839 | <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, |
| 2840 | or conditional operator. |
| 2841 | |
| 2842 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 2843 | if (true) {} |
| 2844 | </pre></td></tr> |
| 2845 | |
| 2846 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 2847 | <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> |
| 2848 | <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] | 2849 | matches InnerMatcher if the qualifier exists. |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 2850 | |
| 2851 | Given |
| 2852 | namespace N { |
| 2853 | namespace M { |
| 2854 | class D {}; |
| 2855 | } |
| 2856 | } |
| 2857 | N::M::D d; |
| 2858 | |
| 2859 | elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) |
| 2860 | matches the type of the variable declaration of d. |
| 2861 | </pre></td></tr> |
| 2862 | |
| 2863 | |
| 2864 | <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> |
| 2865 | <tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. |
| 2866 | |
| 2867 | Given |
| 2868 | namespace N { |
| 2869 | namespace M { |
| 2870 | class D {}; |
| 2871 | } |
| 2872 | } |
| 2873 | N::M::D d; |
| 2874 | |
| 2875 | elaboratedType(namesType(recordType( |
| 2876 | hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable |
| 2877 | declaration of d. |
| 2878 | </pre></td></tr> |
| 2879 | |
| 2880 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 2881 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>></td><td class="name" onclick="toggle('hasDeclaration10')"><a name="hasDeclaration10Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 2882 | <tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node |
| 2883 | matches the given matcher. |
| 2884 | |
| 2885 | The associated declaration is: |
| 2886 | - for type nodes, the declaration of the underlying type |
| 2887 | - for CallExpr, the declaration of the callee |
| 2888 | - for MemberExpr, the declaration of the referenced member |
| 2889 | - for CXXConstructExpr, the declaration of the constructor |
| 2890 | |
| 2891 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 2892 | function. e.g. various subtypes of clang::Type and various expressions. |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 2893 | |
| 2894 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 2895 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 2896 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 2897 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 2898 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 2899 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
| 2900 | </pre></td></tr> |
| 2901 | |
| 2902 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2903 | <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] | 2904 | <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. |
| 2905 | |
| 2906 | (Note: Clang's AST refers to other conversions as "casts" too, and calls |
| 2907 | actual casts "explicit" casts.) |
| 2908 | </pre></td></tr> |
| 2909 | |
| 2910 | |
Manuel Klimek | 532870f | 2013-07-24 05:46:07 +0000 | [diff] [blame] | 2911 | <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> |
| 2912 | <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] | 2913 | declaration's type. |
| 2914 | |
| 2915 | In case of a value declaration (for example a variable declaration), |
| 2916 | this resolves one layer of indirection. For example, in the value |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2917 | declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, |
| 2918 | while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2919 | of x." |
| 2920 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2921 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) |
| 2922 | and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2923 | class X {}; |
| 2924 | void y(X &x) { x; X z; } |
| 2925 | |
| 2926 | 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>> |
| 2927 | </pre></td></tr> |
| 2928 | |
| 2929 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 2930 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('hasType0')"><a name="hasType0Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
| 2931 | <tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type |
| 2932 | matcher. |
| 2933 | |
| 2934 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) |
| 2935 | and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) |
| 2936 | class X {}; |
| 2937 | void y(X &x) { x; X z; } |
| 2938 | </pre></td></tr> |
| 2939 | |
| 2940 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2941 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 2942 | <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts |
| 2943 | are stripped off. |
| 2944 | |
| 2945 | Parentheses and explicit casts are not discarded. |
| 2946 | Given |
| 2947 | int arr[5]; |
| 2948 | int a = 0; |
| 2949 | char b = 0; |
| 2950 | const int c = a; |
| 2951 | int *d = arr; |
| 2952 | long e = (long) 0l; |
| 2953 | The matchers |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2954 | varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) |
| 2955 | varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2956 | would match the declarations for a, b, c, and d, but not e. |
| 2957 | While |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2958 | varDecl(hasInitializer(integerLiteral())) |
| 2959 | varDecl(hasInitializer(declRefExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2960 | only match the declarations for b, c, and d. |
| 2961 | </pre></td></tr> |
| 2962 | |
| 2963 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2964 | <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] | 2965 | <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and |
| 2966 | casts are stripped off. |
| 2967 | |
| 2968 | Implicit and non-C Style casts are also discarded. |
| 2969 | Given |
| 2970 | int a = 0; |
| 2971 | char b = (0); |
| 2972 | void* c = reinterpret_cast<char*>(0); |
| 2973 | char d = char(0); |
| 2974 | The matcher |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2975 | varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2976 | would match the declarations for a, b, c, and d. |
| 2977 | while |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2978 | varDecl(hasInitializer(integerLiteral())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2979 | only match the declaration for a. |
| 2980 | </pre></td></tr> |
| 2981 | |
| 2982 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2983 | <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] | 2984 | <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and |
| 2985 | parentheses are stripped off. |
| 2986 | |
| 2987 | Explicit casts are not discarded. |
| 2988 | Given |
| 2989 | int arr[5]; |
| 2990 | int a = 0; |
| 2991 | char b = (0); |
| 2992 | const int c = a; |
| 2993 | int *d = (arr); |
| 2994 | long e = ((long) 0l); |
| 2995 | The matchers |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2996 | varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) |
| 2997 | varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2998 | would match the declarations for a, b, c, and d, but not e. |
| 2999 | while |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3000 | varDecl(hasInitializer(integerLiteral())) |
| 3001 | varDecl(hasInitializer(declRefExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3002 | would only match the declaration for a. |
| 3003 | </pre></td></tr> |
| 3004 | |
| 3005 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3006 | <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] | 3007 | <tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 3008 | a given body. |
| 3009 | |
| 3010 | Given |
| 3011 | for (;;) {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3012 | hasBody(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3013 | matches 'for (;;) {}' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3014 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3015 | matching '{}' |
| 3016 | </pre></td></tr> |
| 3017 | |
| 3018 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3019 | <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] | 3020 | <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, |
| 3021 | or conditional operator. |
| 3022 | |
| 3023 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 3024 | if (true) {} |
| 3025 | </pre></td></tr> |
| 3026 | |
| 3027 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3028 | <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] | 3029 | <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. |
| 3030 | |
| 3031 | Example: |
| 3032 | forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) |
| 3033 | matches '++x' in |
| 3034 | for (x; x < N; ++x) { } |
| 3035 | </pre></td></tr> |
| 3036 | |
| 3037 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3038 | <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] | 3039 | <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. |
| 3040 | |
| 3041 | Example: |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3042 | forStmt(hasLoopInit(declStmt())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3043 | matches 'int x = 0' in |
| 3044 | for (int x = 0; x < N; ++x) { } |
| 3045 | </pre></td></tr> |
| 3046 | |
| 3047 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3048 | <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] | 3049 | <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. |
| 3050 | |
| 3051 | Does not match the 'this' parameter of a method. |
| 3052 | |
| 3053 | Given |
| 3054 | class X { void f(int x, int y, int z) {} }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3055 | methodDecl(hasAnyParameter(hasName("y"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3056 | matches f(int x, int y, int z) {} |
| 3057 | with hasAnyParameter(...) |
| 3058 | matching int y |
| 3059 | </pre></td></tr> |
| 3060 | |
| 3061 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3062 | <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] | 3063 | <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. |
| 3064 | |
| 3065 | Given |
| 3066 | class X { void f(int x) {} }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3067 | methodDecl(hasParameter(0, hasType(varDecl()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3068 | matches f(int x) {} |
| 3069 | with hasParameter(...) |
| 3070 | matching int x |
| 3071 | </pre></td></tr> |
| 3072 | |
| 3073 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3074 | <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] | 3075 | <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. |
| 3076 | |
| 3077 | Given: |
| 3078 | class X { int f() { return 1; } }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3079 | methodDecl(returns(asString("int"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3080 | matches int f() { return 1; } |
| 3081 | </pre></td></tr> |
| 3082 | |
| 3083 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3084 | <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] | 3085 | <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, |
| 3086 | or conditional operator. |
| 3087 | |
| 3088 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 3089 | if (true) {} |
| 3090 | </pre></td></tr> |
| 3091 | |
| 3092 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3093 | <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] | 3094 | <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. |
| 3095 | |
| 3096 | Given |
| 3097 | if (A* a = GetAPointer()) {} |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3098 | hasConditionVariableStatement(...) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3099 | matches 'A* a = GetAPointer()'. |
| 3100 | </pre></td></tr> |
| 3101 | |
| 3102 | |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 3103 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasElse0')"><a name="hasElse0Anchor">hasElse</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> |
| 3104 | <tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. |
| 3105 | |
| 3106 | Examples matches the if statement |
| 3107 | (matcher = ifStmt(hasElse(boolLiteral(equals(true))))) |
| 3108 | if (false) false; else true; |
| 3109 | </pre></td></tr> |
| 3110 | |
| 3111 | |
| 3112 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasThen0')"><a name="hasThen0Anchor">hasThen</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> |
| 3113 | <tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. |
| 3114 | |
| 3115 | Examples matches the if statement |
| 3116 | (matcher = ifStmt(hasThen(boolLiteral(equals(true))))) |
| 3117 | if (false) true; else false; |
| 3118 | </pre></td></tr> |
| 3119 | |
| 3120 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3121 | <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] | 3122 | <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given |
| 3123 | matcher. |
| 3124 | |
| 3125 | FIXME: Unit test this matcher |
| 3126 | </pre></td></tr> |
| 3127 | |
| 3128 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3129 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>></td><td class="name" onclick="toggle('hasDeclaration9')"><a name="hasDeclaration9Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 3130 | <tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3131 | matches the given matcher. |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3132 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3133 | The associated declaration is: |
| 3134 | - for type nodes, the declaration of the underlying type |
| 3135 | - for CallExpr, the declaration of the callee |
| 3136 | - for MemberExpr, the declaration of the referenced member |
| 3137 | - for CXXConstructExpr, the declaration of the constructor |
| 3138 | |
| 3139 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3140 | function. e.g. various subtypes of clang::Type and various expressions. |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 3141 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3142 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 3143 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3144 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3145 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3146 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3147 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
| 3148 | </pre></td></tr> |
| 3149 | |
| 3150 | |
| 3151 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>></td><td class="name" onclick="toggle('hasDeclaration8')"><a name="hasDeclaration8Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 3152 | <tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node |
| 3153 | matches the given matcher. |
| 3154 | |
| 3155 | The associated declaration is: |
| 3156 | - for type nodes, the declaration of the underlying type |
| 3157 | - for CallExpr, the declaration of the callee |
| 3158 | - for MemberExpr, the declaration of the referenced member |
| 3159 | - for CXXConstructExpr, the declaration of the constructor |
| 3160 | |
| 3161 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3162 | function. e.g. various subtypes of clang::Type and various expressions. |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3163 | |
| 3164 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 3165 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3166 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3167 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3168 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3169 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
| 3170 | </pre></td></tr> |
| 3171 | |
| 3172 | |
| 3173 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('hasDeclaration7')"><a name="hasDeclaration7Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 3174 | <tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node |
| 3175 | matches the given matcher. |
| 3176 | |
| 3177 | The associated declaration is: |
| 3178 | - for type nodes, the declaration of the underlying type |
| 3179 | - for CallExpr, the declaration of the callee |
| 3180 | - for MemberExpr, the declaration of the referenced member |
| 3181 | - for CXXConstructExpr, the declaration of the constructor |
| 3182 | |
| 3183 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3184 | function. e.g. various subtypes of clang::Type and various expressions. |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3185 | |
| 3186 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 3187 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3188 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3189 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3190 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3191 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3192 | </pre></td></tr> |
| 3193 | |
| 3194 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3195 | <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] | 3196 | <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is |
| 3197 | matched by a given matcher. |
| 3198 | |
| 3199 | Given |
| 3200 | struct X { int m; }; |
| 3201 | void f(X x) { x.m; m; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3202 | memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X"))))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3203 | matches "x.m" and "m" |
| 3204 | with hasObjectExpression(...) |
| 3205 | matching "x" and the implicit object expression of "m" which has type X*. |
| 3206 | </pre></td></tr> |
| 3207 | |
| 3208 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3209 | <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] | 3210 | <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a |
| 3211 | given matcher. |
| 3212 | |
| 3213 | Given |
| 3214 | struct { int first, second; } first, second; |
| 3215 | int i(second.first); |
| 3216 | int j(first.second); |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3217 | memberExpr(member(hasName("first"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3218 | matches second.first |
| 3219 | but not first.second (because the member name there is "second"). |
| 3220 | </pre></td></tr> |
| 3221 | |
| 3222 | |
Samuel Benzaquen | 3f84bb3 | 2013-07-15 19:25:06 +0000 | [diff] [blame] | 3223 | <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> |
| 3224 | <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] | 3225 | pointee matches a given matcher. |
| 3226 | |
| 3227 | Given |
| 3228 | int *a; |
| 3229 | int const *b; |
| 3230 | float const *f; |
| 3231 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3232 | matches "int const *b" |
| 3233 | |
| 3234 | 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>>, |
| 3235 | 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>> |
| 3236 | </pre></td></tr> |
| 3237 | |
| 3238 | |
Samuel Benzaquen | 3f84bb3 | 2013-07-15 19:25:06 +0000 | [diff] [blame] | 3239 | <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> |
| 3240 | <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] | 3241 | pointee matches a given matcher. |
| 3242 | |
| 3243 | Given |
| 3244 | int *a; |
| 3245 | int const *b; |
| 3246 | float const *f; |
| 3247 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3248 | matches "int const *b" |
| 3249 | |
| 3250 | 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>>, |
| 3251 | 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>> |
| 3252 | </pre></td></tr> |
| 3253 | |
| 3254 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 3255 | <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] | 3256 | <tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. |
| 3257 | |
| 3258 | Given |
| 3259 | struct A { struct B { struct C {}; }; }; |
| 3260 | A::B::C c; |
| 3261 | nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) |
| 3262 | matches "A::" |
| 3263 | </pre></td></tr> |
| 3264 | |
| 3265 | |
| 3266 | <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> |
| 3267 | <tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the |
| 3268 | given TypeLoc. |
| 3269 | |
| 3270 | Given |
| 3271 | struct A { struct B { struct C {}; }; }; |
| 3272 | A::B::C c; |
| 3273 | nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( |
| 3274 | hasDeclaration(recordDecl(hasName("A"))))))) |
| 3275 | matches "A::" |
| 3276 | </pre></td></tr> |
| 3277 | |
| 3278 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 3279 | <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] | 3280 | <tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. |
| 3281 | |
| 3282 | Given |
| 3283 | struct A { struct B { struct C {}; }; }; |
| 3284 | A::B::C c; |
| 3285 | nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and |
| 3286 | matches "A::" |
| 3287 | </pre></td></tr> |
| 3288 | |
| 3289 | |
| 3290 | <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> |
| 3291 | <tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the |
| 3292 | given namespace matcher. |
| 3293 | |
| 3294 | Given |
| 3295 | namespace ns { struct A {}; } |
| 3296 | ns::A a; |
| 3297 | nestedNameSpecifier(specifiesNamespace(hasName("ns"))) |
| 3298 | matches "ns::" |
| 3299 | </pre></td></tr> |
| 3300 | |
| 3301 | |
| 3302 | <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> |
| 3303 | <tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the |
| 3304 | given QualType matcher without qualifiers. |
| 3305 | |
| 3306 | Given |
| 3307 | struct A { struct B { struct C {}; }; }; |
| 3308 | A::B::C c; |
| 3309 | nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A"))))) |
| 3310 | matches "A::" |
| 3311 | </pre></td></tr> |
| 3312 | |
| 3313 | |
Edwin Vane | 88be2fd | 2013-04-01 18:33:34 +0000 | [diff] [blame] | 3314 | <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> |
| 3315 | <tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. |
| 3316 | |
| 3317 | Given |
| 3318 | int (*ptr_to_array)[4]; |
| 3319 | int (*ptr_to_func)(int); |
| 3320 | |
| 3321 | varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches |
| 3322 | ptr_to_func but not ptr_to_array. |
| 3323 | |
| 3324 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> |
| 3325 | </pre></td></tr> |
| 3326 | |
| 3327 | |
Samuel Benzaquen | 3f84bb3 | 2013-07-15 19:25:06 +0000 | [diff] [blame] | 3328 | <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> |
| 3329 | <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] | 3330 | pointee matches a given matcher. |
| 3331 | |
| 3332 | Given |
| 3333 | int *a; |
| 3334 | int const *b; |
| 3335 | float const *f; |
| 3336 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3337 | matches "int const *b" |
| 3338 | |
| 3339 | 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>>, |
| 3340 | 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>> |
| 3341 | </pre></td></tr> |
| 3342 | |
| 3343 | |
Samuel Benzaquen | 3f84bb3 | 2013-07-15 19:25:06 +0000 | [diff] [blame] | 3344 | <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> |
| 3345 | <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] | 3346 | pointee matches a given matcher. |
| 3347 | |
| 3348 | Given |
| 3349 | int *a; |
| 3350 | int const *b; |
| 3351 | float const *f; |
| 3352 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3353 | matches "int const *b" |
| 3354 | |
| 3355 | 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>>, |
| 3356 | 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>> |
| 3357 | </pre></td></tr> |
| 3358 | |
| 3359 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 3360 | <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> |
| 3361 | <tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. |
| 3362 | |
| 3363 | Given: |
| 3364 | typedef int &int_ref; |
| 3365 | int a; |
| 3366 | int_ref b = a; |
| 3367 | |
| 3368 | varDecl(hasType(qualType(referenceType()))))) will not match the |
| 3369 | declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. |
| 3370 | </pre></td></tr> |
| 3371 | |
| 3372 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3373 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasDeclaration6')"><a name="hasDeclaration6Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 3374 | <tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node |
| 3375 | matches the given matcher. |
| 3376 | |
| 3377 | The associated declaration is: |
| 3378 | - for type nodes, the declaration of the underlying type |
| 3379 | - for CallExpr, the declaration of the callee |
| 3380 | - for MemberExpr, the declaration of the referenced member |
| 3381 | - for CXXConstructExpr, the declaration of the constructor |
| 3382 | |
| 3383 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3384 | function. e.g. various subtypes of clang::Type and various expressions. |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3385 | |
| 3386 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 3387 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3388 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3389 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3390 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3391 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
| 3392 | </pre></td></tr> |
| 3393 | |
| 3394 | |
| 3395 | <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> |
| 3396 | <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. |
| 3397 | </pre></td></tr> |
| 3398 | |
| 3399 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 3400 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('pointsTo0')"><a name="pointsTo0Anchor">pointsTo</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
| 3401 | <tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type |
| 3402 | matches the specified matcher. |
| 3403 | |
| 3404 | Example matches y->x() |
| 3405 | (matcher = callExpr(on(hasType(pointsTo(recordDecl(hasName("Y"))))))) |
| 3406 | class Y { public: void x(); }; |
| 3407 | void z() { Y *y; y->x(); } |
| 3408 | </pre></td></tr> |
| 3409 | |
| 3410 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3411 | <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> |
| 3412 | <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. |
| 3413 | </pre></td></tr> |
| 3414 | |
| 3415 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 3416 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('references0')"><a name="references0Anchor">references</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
| 3417 | <tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced |
| 3418 | type matches the specified matcher. |
| 3419 | |
| 3420 | Example matches X &x and const X &y |
| 3421 | (matcher = varDecl(hasType(references(recordDecl(hasName("X")))))) |
| 3422 | class X { |
| 3423 | void a(X b) { |
| 3424 | X &x = b; |
| 3425 | const X &y = b; |
| 3426 | }; |
| 3427 | </pre></td></tr> |
| 3428 | |
| 3429 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3430 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>></td><td class="name" onclick="toggle('hasDeclaration5')"><a name="hasDeclaration5Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3431 | <tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node |
| 3432 | matches the given matcher. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3433 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3434 | The associated declaration is: |
| 3435 | - for type nodes, the declaration of the underlying type |
| 3436 | - for CallExpr, the declaration of the callee |
| 3437 | - for MemberExpr, the declaration of the referenced member |
| 3438 | - for CXXConstructExpr, the declaration of the constructor |
| 3439 | |
| 3440 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3441 | function. e.g. various subtypes of clang::Type and various expressions. |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 3442 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3443 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 3444 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3445 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3446 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3447 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3448 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3449 | </pre></td></tr> |
| 3450 | |
| 3451 | |
Samuel Benzaquen | 3f84bb3 | 2013-07-15 19:25:06 +0000 | [diff] [blame] | 3452 | <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> |
| 3453 | <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] | 3454 | pointee matches a given matcher. |
| 3455 | |
| 3456 | Given |
| 3457 | int *a; |
| 3458 | int const *b; |
| 3459 | float const *f; |
| 3460 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3461 | matches "int const *b" |
| 3462 | |
| 3463 | 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>>, |
| 3464 | 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>> |
| 3465 | </pre></td></tr> |
| 3466 | |
| 3467 | |
Samuel Benzaquen | 3f84bb3 | 2013-07-15 19:25:06 +0000 | [diff] [blame] | 3468 | <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> |
| 3469 | <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] | 3470 | pointee matches a given matcher. |
| 3471 | |
| 3472 | Given |
| 3473 | int *a; |
| 3474 | int const *b; |
| 3475 | float const *f; |
| 3476 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3477 | matches "int const *b" |
| 3478 | |
| 3479 | 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>>, |
| 3480 | 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>> |
| 3481 | </pre></td></tr> |
| 3482 | |
| 3483 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3484 | <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] | 3485 | <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 3486 | alignof. |
| 3487 | </pre></td></tr> |
| 3488 | |
| 3489 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3490 | <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] | 3491 | <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 3492 | sizeof. |
| 3493 | </pre></td></tr> |
| 3494 | |
| 3495 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3496 | <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> |
| 3497 | <tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch |
| 3498 | statement. This matcher may produce multiple matches. |
| 3499 | |
| 3500 | Given |
| 3501 | switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } |
| 3502 | switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") |
| 3503 | matches four times, with "c" binding each of "case 1:", "case 2:", |
| 3504 | "case 3:" and "case 4:", and "s" respectively binding "switch (1)", |
| 3505 | "switch (1)", "switch (2)" and "switch (2)". |
| 3506 | </pre></td></tr> |
| 3507 | |
| 3508 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3509 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>></td><td class="name" onclick="toggle('hasDeclaration4')"><a name="hasDeclaration4Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 3510 | <tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node |
| 3511 | matches the given matcher. |
| 3512 | |
| 3513 | The associated declaration is: |
| 3514 | - for type nodes, the declaration of the underlying type |
| 3515 | - for CallExpr, the declaration of the callee |
| 3516 | - for MemberExpr, the declaration of the referenced member |
| 3517 | - for CXXConstructExpr, the declaration of the constructor |
| 3518 | |
| 3519 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3520 | function. e.g. various subtypes of clang::Type and various expressions. |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3521 | |
| 3522 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 3523 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3524 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3525 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3526 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3527 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
| 3528 | </pre></td></tr> |
| 3529 | |
| 3530 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 3531 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('isExpr0')"><a name="isExpr0Anchor">isExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 3532 | <tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. |
| 3533 | |
| 3534 | Given |
| 3535 | template<typename T> struct A {}; |
| 3536 | struct B { B* next; }; |
| 3537 | A<&B::next> a; |
| 3538 | templateSpecializationType(hasAnyTemplateArgument( |
| 3539 | isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) |
| 3540 | matches the specialization A<&B::next> with fieldDecl(...) matching |
| 3541 | B::next |
| 3542 | </pre></td></tr> |
| 3543 | |
| 3544 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3545 | <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> |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 3546 | <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain |
| 3547 | declaration. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3548 | |
| 3549 | Given |
| 3550 | template<typename T> struct A {}; |
| 3551 | struct B { B* next; }; |
| 3552 | A<&B::next> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3553 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 3554 | refersToDeclaration(fieldDecl(hasName("next")))) |
| 3555 | matches the specialization A<&B::next> with fieldDecl(...) matching |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3556 | B::next |
| 3557 | </pre></td></tr> |
| 3558 | |
| 3559 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3560 | <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] | 3561 | <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. |
| 3562 | |
| 3563 | Given |
| 3564 | struct X {}; |
| 3565 | template<typename T> struct A {}; |
| 3566 | A<X> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3567 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3568 | refersToType(class(hasName("X"))))) |
| 3569 | matches the specialization A<X> |
| 3570 | </pre></td></tr> |
| 3571 | |
| 3572 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 3573 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgument1')"><a name="hasAnyTemplateArgument1Anchor">hasAnyTemplateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> |
| 3574 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations that have at least one |
| 3575 | TemplateArgument matching the given InnerMatcher. |
| 3576 | |
| 3577 | Given |
| 3578 | template<typename T> class A {}; |
| 3579 | template<> class A<double> {}; |
| 3580 | A<int> a; |
| 3581 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 3582 | refersToType(asString("int")))) |
| 3583 | matches the specialization A<int> |
| 3584 | </pre></td></tr> |
| 3585 | |
| 3586 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3587 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasDeclaration3')"><a name="hasDeclaration3Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 3588 | <tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3589 | matches the given matcher. |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 3590 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3591 | The associated declaration is: |
| 3592 | - for type nodes, the declaration of the underlying type |
| 3593 | - for CallExpr, the declaration of the callee |
| 3594 | - for MemberExpr, the declaration of the referenced member |
| 3595 | - for CXXConstructExpr, the declaration of the constructor |
| 3596 | |
| 3597 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3598 | function. e.g. various subtypes of clang::Type and various expressions. |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 3599 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3600 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 3601 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3602 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3603 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3604 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3605 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
| 3606 | </pre></td></tr> |
| 3607 | |
| 3608 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 3609 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasTemplateArgument1')"><a name="hasTemplateArgument1Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> |
| 3610 | <tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument |
| 3611 | matches the given InnerMatcher. |
| 3612 | |
| 3613 | Given |
| 3614 | template<typename T, typename U> class A {}; |
| 3615 | A<bool, int> b; |
| 3616 | A<int, bool> c; |
| 3617 | classTemplateSpecializationDecl(hasTemplateArgument( |
| 3618 | 1, refersToType(asString("int")))) |
| 3619 | matches the specialization A<bool, int> |
| 3620 | </pre></td></tr> |
| 3621 | |
| 3622 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3623 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>></td><td class="name" onclick="toggle('hasDeclaration2')"><a name="hasDeclaration2Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 3624 | <tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node |
| 3625 | matches the given matcher. |
| 3626 | |
| 3627 | The associated declaration is: |
| 3628 | - for type nodes, the declaration of the underlying type |
| 3629 | - for CallExpr, the declaration of the callee |
| 3630 | - for MemberExpr, the declaration of the referenced member |
| 3631 | - for CXXConstructExpr, the declaration of the constructor |
| 3632 | |
| 3633 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3634 | function. e.g. various subtypes of clang::Type and various expressions. |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3635 | |
| 3636 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 3637 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3638 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3639 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3640 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3641 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3642 | </pre></td></tr> |
| 3643 | |
| 3644 | |
Samuel Benzaquen | d36e463 | 2013-08-27 15:11:16 +0000 | [diff] [blame] | 3645 | <tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<T> Matcher</td></tr> |
| 3646 | <tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. |
| 3647 | |
| 3648 | Generates results for each match. |
| 3649 | |
| 3650 | For example, in: |
| 3651 | class A { class B {}; class C {}; }; |
| 3652 | The matcher: |
| 3653 | recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m"))) |
| 3654 | will generate results for A, B and C. |
| 3655 | |
| 3656 | Usable as: Any Matcher |
| 3657 | </pre></td></tr> |
| 3658 | |
| 3659 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3660 | <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] | 3661 | <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node |
| 3662 | matches the given matcher. |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3663 | |
Manuel Klimek | 03a8323 | 2013-06-10 08:52:15 +0000 | [diff] [blame] | 3664 | The associated declaration is: |
| 3665 | - for type nodes, the declaration of the underlying type |
| 3666 | - for CallExpr, the declaration of the callee |
| 3667 | - for MemberExpr, the declaration of the referenced member |
| 3668 | - for CXXConstructExpr, the declaration of the constructor |
| 3669 | |
| 3670 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3671 | function. e.g. various subtypes of clang::Type and various expressions. |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3672 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3673 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 3674 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3675 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3676 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3677 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3678 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3679 | </pre></td></tr> |
| 3680 | |
| 3681 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3682 | <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] | 3683 | <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. |
| 3684 | |
| 3685 | Given |
| 3686 | int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); |
| 3687 | unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) |
| 3688 | matches sizeof(a) and alignof(c) |
| 3689 | </pre></td></tr> |
| 3690 | |
| 3691 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3692 | <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] | 3693 | <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. |
| 3694 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3695 | Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true)))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3696 | !true |
| 3697 | </pre></td></tr> |
| 3698 | |
| 3699 | |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3700 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>></td><td class="name" onclick="toggle('hasDeclaration0')"><a name="hasDeclaration0Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 3701 | <tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node |
| 3702 | matches the given matcher. |
| 3703 | |
| 3704 | The associated declaration is: |
| 3705 | - for type nodes, the declaration of the underlying type |
| 3706 | - for CallExpr, the declaration of the callee |
| 3707 | - for MemberExpr, the declaration of the referenced member |
| 3708 | - for CXXConstructExpr, the declaration of the constructor |
| 3709 | |
| 3710 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3711 | function. e.g. various subtypes of clang::Type and various expressions. |
Samuel Benzaquen | 6c1dc78 | 2013-11-18 14:53:42 +0000 | [diff] [blame] | 3712 | |
| 3713 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
| 3714 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3715 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3716 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3717 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3718 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
| 3719 | </pre></td></tr> |
| 3720 | |
| 3721 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3722 | <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] | 3723 | <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. |
| 3724 | |
| 3725 | Given |
| 3726 | namespace X { void b(); } |
| 3727 | using X::b; |
| 3728 | usingDecl(hasAnyUsingShadowDecl(hasName("b")))) |
| 3729 | matches using X::b </pre></td></tr> |
| 3730 | |
| 3731 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3732 | <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] | 3733 | <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is |
| 3734 | matched by the given matcher. |
| 3735 | |
| 3736 | Given |
| 3737 | namespace X { int a; void b(); } |
| 3738 | using X::a; |
| 3739 | using X::b; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3740 | usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3741 | matches using X::b but not using X::a </pre></td></tr> |
| 3742 | |
| 3743 | |
Manuel Klimek | 532870f | 2013-07-24 05:46:07 +0000 | [diff] [blame] | 3744 | <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> |
| 3745 | <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] | 3746 | declaration's type. |
| 3747 | |
| 3748 | In case of a value declaration (for example a variable declaration), |
| 3749 | this resolves one layer of indirection. For example, in the value |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3750 | declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, |
| 3751 | while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3752 | of x." |
| 3753 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3754 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) |
| 3755 | and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3756 | class X {}; |
| 3757 | void y(X &x) { x; X z; } |
| 3758 | |
| 3759 | 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>> |
| 3760 | </pre></td></tr> |
| 3761 | |
| 3762 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 3763 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType1')"><a name="hasType1Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
| 3764 | <tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type |
| 3765 | matcher. |
| 3766 | |
| 3767 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) |
| 3768 | and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) |
| 3769 | class X {}; |
| 3770 | void y(X &x) { x; X z; } |
| 3771 | </pre></td></tr> |
| 3772 | |
| 3773 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3774 | <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] | 3775 | <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression |
| 3776 | that matches the given matcher. |
| 3777 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3778 | Example matches x (matcher = varDecl(hasInitializer(callExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3779 | bool y() { return true; } |
| 3780 | bool x = y(); |
| 3781 | </pre></td></tr> |
| 3782 | |
| 3783 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3784 | <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> |
| 3785 | <tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size |
| 3786 | expression. |
| 3787 | |
| 3788 | Given |
| 3789 | void f(int b) { |
| 3790 | int a[b]; |
| 3791 | } |
| 3792 | variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( |
| 3793 | varDecl(hasName("b"))))))) |
| 3794 | matches "int a[b]" |
| 3795 | </pre></td></tr> |
| 3796 | |
| 3797 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3798 | <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] | 3799 | <tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 3800 | a given body. |
| 3801 | |
| 3802 | Given |
| 3803 | for (;;) {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3804 | hasBody(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3805 | matches 'for (;;) {}' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3806 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3807 | matching '{}' |
| 3808 | </pre></td></tr> |
| 3809 | |
| 3810 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3811 | <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] | 3812 | <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, |
| 3813 | or conditional operator. |
| 3814 | |
| 3815 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 3816 | if (true) {} |
| 3817 | </pre></td></tr> |
| 3818 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 3819 | |
| 3820 | <tr><td>Matcher<internal::BindableMatcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>>></td><td class="name" onclick="toggle('loc1')"><a name="loc1Anchor">loc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr> |
| 3821 | <tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner |
| 3822 | NestedNameSpecifier-matcher matches. |
| 3823 | </pre></td></tr> |
| 3824 | |
| 3825 | |
| 3826 | <tr><td>Matcher<internal::BindableMatcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>></td><td class="name" onclick="toggle('loc0')"><a name="loc0Anchor">loc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
| 3827 | <tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner |
| 3828 | QualType-matcher matches. |
| 3829 | </pre></td></tr> |
| 3830 | |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3831 | <!--END_TRAVERSAL_MATCHERS --> |
| 3832 | </table> |
| 3833 | |
| 3834 | </div> |
| 3835 | </body> |
| 3836 | </html> |
| 3837 | |
| 3838 | |