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