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 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 933 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('elaboratedTypeLoc0')"><a name="elaboratedTypeLoc0Anchor">elaboratedTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedTypeLoc.html">ElaboratedTypeLoc</a>>...</td></tr> |
| 934 | <tr><td colspan="4" class="doc" id="elaboratedTypeLoc0"><pre>Matches types specified with an elaborated type keyword or with a |
| 935 | qualified name. |
| 936 | |
| 937 | Given |
| 938 | namespace N { |
| 939 | namespace M { |
| 940 | class D {}; |
| 941 | } |
| 942 | } |
| 943 | class C {}; |
| 944 | |
| 945 | class C c; |
| 946 | N::M::D d; |
| 947 | |
| 948 | elaboratedType() matches the type of the variable declarations of both |
| 949 | c and d. |
| 950 | </pre></td></tr> |
| 951 | |
| 952 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 953 | <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> |
| 954 | <tr><td colspan="4" class="doc" id="functionTypeLoc0"><pre>Matches FunctionType nodes. |
| 955 | |
| 956 | Given |
| 957 | int (*f)(int); |
| 958 | void g(); |
| 959 | functionType() |
| 960 | matches "int (*f)(int)" and the type of "g". |
| 961 | </pre></td></tr> |
| 962 | |
| 963 | |
| 964 | <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> |
| 965 | <tr><td colspan="4" class="doc" id="incompleteArrayTypeLoc0"><pre>Matches C arrays with unspecified size. |
| 966 | |
| 967 | Given |
| 968 | int a[] = { 2, 3 }; |
| 969 | int b[42]; |
| 970 | void f(int c[]) { int d[a[0]]; }; |
| 971 | incompleteArrayType() |
| 972 | matches "int a[]" and "int c[]" |
| 973 | </pre></td></tr> |
| 974 | |
| 975 | |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 976 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('lvalueReferenceTypeLoc0')"><a name="lvalueReferenceTypeLoc0Anchor">lvalueReferenceTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LValueReferenceTypeLoc.html">LValueReferenceTypeLoc</a>>...</td></tr> |
| 977 | <tr><td colspan="4" class="doc" id="lvalueReferenceTypeLoc0"><pre>Matches lvalue reference types. |
| 978 | |
| 979 | Given: |
| 980 | int *a; |
| 981 | int &b = *a; |
| 982 | int &&c = 1; |
| 983 | auto &d = b; |
| 984 | auto &&e = c; |
| 985 | auto &&f = 2; |
| 986 | int g = 5; |
| 987 | |
| 988 | lvalueReferenceType() matches the types of b, d, and e. e is |
| 989 | matched since the type is deduced as int& by reference collapsing rules. |
| 990 | </pre></td></tr> |
| 991 | |
| 992 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 993 | <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> |
| 994 | <tr><td colspan="4" class="doc" id="memberPointerTypeLoc0"><pre>Matches member pointer types. |
| 995 | Given |
| 996 | struct A { int i; } |
| 997 | A::* ptr = A::i; |
| 998 | memberPointerType() |
| 999 | matches "A::* ptr" |
| 1000 | </pre></td></tr> |
| 1001 | |
| 1002 | |
| 1003 | <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> |
| 1004 | <tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer types. |
| 1005 | |
| 1006 | Given |
| 1007 | int *a; |
| 1008 | int &b = *a; |
| 1009 | int c = 5; |
| 1010 | pointerType() |
| 1011 | matches "int *a" |
| 1012 | </pre></td></tr> |
| 1013 | |
| 1014 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 1015 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('recordTypeLoc0')"><a name="recordTypeLoc0Anchor">recordTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordTypeLoc.html">RecordTypeLoc</a>>...</td></tr> |
| 1016 | <tr><td colspan="4" class="doc" id="recordTypeLoc0"><pre>Matches record types (e.g. structs, classes). |
| 1017 | |
| 1018 | Given |
| 1019 | class C {}; |
| 1020 | struct S {}; |
| 1021 | |
| 1022 | C c; |
| 1023 | S s; |
| 1024 | |
| 1025 | recordType() matches the type of the variable declarations of both c |
| 1026 | and s. |
| 1027 | </pre></td></tr> |
| 1028 | |
| 1029 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1030 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('referenceTypeLoc0')"><a name="referenceTypeLoc0Anchor">referenceTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>>...</td></tr> |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1031 | <tr><td colspan="4" class="doc" id="referenceTypeLoc0"><pre>Matches both lvalue and rvalue reference types. |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1032 | |
| 1033 | Given |
| 1034 | int *a; |
| 1035 | int &b = *a; |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1036 | int &&c = 1; |
| 1037 | auto &d = b; |
| 1038 | auto &&e = c; |
| 1039 | auto &&f = 2; |
| 1040 | int g = 5; |
| 1041 | |
| 1042 | referenceType() matches the types of b, c, d, e, and f. |
| 1043 | </pre></td></tr> |
| 1044 | |
| 1045 | |
| 1046 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('rvalueReferenceTypeLoc0')"><a name="rvalueReferenceTypeLoc0Anchor">rvalueReferenceTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RValueReferenceTypeLoc.html">RValueReferenceTypeLoc</a>>...</td></tr> |
| 1047 | <tr><td colspan="4" class="doc" id="rvalueReferenceTypeLoc0"><pre>Matches rvalue reference types. |
| 1048 | |
| 1049 | Given: |
| 1050 | int *a; |
| 1051 | int &b = *a; |
| 1052 | int &&c = 1; |
| 1053 | auto &d = b; |
| 1054 | auto &&e = c; |
| 1055 | auto &&f = 2; |
| 1056 | int g = 5; |
| 1057 | |
| 1058 | lvalueReferenceType() matches the types of c and f. e is not |
| 1059 | matched as it is deduced to int& by reference collapsing rules. |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1060 | </pre></td></tr> |
| 1061 | |
| 1062 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 1063 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('templateSpecializationTypeLoc0')"><a name="templateSpecializationTypeLoc0Anchor">templateSpecializationTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>>...</td></tr> |
| 1064 | <tr><td colspan="4" class="doc" id="templateSpecializationTypeLoc0"><pre>Matches template specialization types. |
| 1065 | |
| 1066 | Given |
| 1067 | template <typename T> |
| 1068 | class C { }; |
| 1069 | |
| 1070 | template class C<int>; A |
| 1071 | C<char> var; B |
| 1072 | |
| 1073 | templateSpecializationType() matches the type of the explicit |
| 1074 | instantiation in A and the type of the variable declaration in B. |
| 1075 | </pre></td></tr> |
| 1076 | |
| 1077 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1078 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('typeLoc0')"><a name="typeLoc0Anchor">typeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>...</td></tr> |
| 1079 | <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. |
| 1080 | </pre></td></tr> |
| 1081 | |
| 1082 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1083 | <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> |
| 1084 | <tr><td colspan="4" class="doc" id="typedefTypeLoc0"><pre>Matches typedef types. |
| 1085 | |
| 1086 | Given |
| 1087 | typedef int X; |
| 1088 | typedefType() |
| 1089 | matches "typedef int X" |
| 1090 | </pre></td></tr> |
| 1091 | |
| 1092 | |
| 1093 | <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> |
| 1094 | <tr><td colspan="4" class="doc" id="variableArrayTypeLoc0"><pre>Matches C arrays with a specified size that is not an |
| 1095 | integer-constant-expression. |
| 1096 | |
| 1097 | Given |
| 1098 | void f() { |
| 1099 | int a[] = { 2, 3 } |
| 1100 | int b[42]; |
| 1101 | int c[a[0]]; |
| 1102 | variableArrayType() |
| 1103 | matches "int c[a[0]]" |
| 1104 | </pre></td></tr> |
| 1105 | |
| 1106 | |
| 1107 | <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> |
| 1108 | <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. |
| 1109 | |
| 1110 | Given |
| 1111 | int a[] = { 2, 3 }; |
| 1112 | int b[4]; |
| 1113 | void f() { int c[a[0]]; } |
| 1114 | arrayType() |
| 1115 | matches "int a[]", "int b[4]" and "int c[a[0]]"; |
| 1116 | </pre></td></tr> |
| 1117 | |
| 1118 | |
| 1119 | <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> |
| 1120 | <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. |
| 1121 | |
| 1122 | Given |
| 1123 | _Atomic(int) i; |
| 1124 | atomicType() |
| 1125 | matches "_Atomic(int) i" |
| 1126 | </pre></td></tr> |
| 1127 | |
| 1128 | |
| 1129 | <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> |
| 1130 | <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. |
| 1131 | |
| 1132 | Given: |
| 1133 | auto n = 4; |
| 1134 | int v[] = { 2, 3 } |
| 1135 | for (auto i : v) { } |
| 1136 | autoType() |
| 1137 | matches "auto n" and "auto i" |
| 1138 | </pre></td></tr> |
| 1139 | |
| 1140 | |
| 1141 | <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> |
| 1142 | <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as |
| 1143 | "void (^)(int)". |
| 1144 | |
| 1145 | The pointee is always required to be a FunctionType. |
| 1146 | </pre></td></tr> |
| 1147 | |
| 1148 | |
| 1149 | <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> |
| 1150 | <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. |
| 1151 | |
| 1152 | Given |
| 1153 | struct A {}; |
| 1154 | A a; |
| 1155 | int b; |
| 1156 | float c; |
| 1157 | bool d; |
| 1158 | builtinType() |
| 1159 | matches "int b", "float c" and "bool d" |
| 1160 | </pre></td></tr> |
| 1161 | |
| 1162 | |
| 1163 | <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> |
| 1164 | <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. |
| 1165 | |
| 1166 | Given |
| 1167 | _Complex float f; |
| 1168 | complexType() |
| 1169 | matches "_Complex float f" |
| 1170 | </pre></td></tr> |
| 1171 | |
| 1172 | |
| 1173 | <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> |
| 1174 | <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. |
| 1175 | |
| 1176 | Given |
| 1177 | void() { |
| 1178 | int a[2]; |
| 1179 | int b[] = { 2, 3 }; |
| 1180 | int c[b[0]]; |
| 1181 | } |
| 1182 | constantArrayType() |
| 1183 | matches "int a[2]" |
| 1184 | </pre></td></tr> |
| 1185 | |
| 1186 | |
| 1187 | <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> |
| 1188 | <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. |
| 1189 | |
| 1190 | Given |
| 1191 | template<typename T, int Size> |
| 1192 | class array { |
| 1193 | T data[Size]; |
| 1194 | }; |
| 1195 | dependentSizedArrayType |
| 1196 | matches "T data[Size]" |
| 1197 | </pre></td></tr> |
| 1198 | |
| 1199 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 1200 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('elaboratedType0')"><a name="elaboratedType0Anchor">elaboratedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>>...</td></tr> |
| 1201 | <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a |
| 1202 | qualified name. |
| 1203 | |
| 1204 | Given |
| 1205 | namespace N { |
| 1206 | namespace M { |
| 1207 | class D {}; |
| 1208 | } |
| 1209 | } |
| 1210 | class C {}; |
| 1211 | |
| 1212 | class C c; |
| 1213 | N::M::D d; |
| 1214 | |
| 1215 | elaboratedType() matches the type of the variable declarations of both |
| 1216 | c and d. |
| 1217 | </pre></td></tr> |
| 1218 | |
| 1219 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1220 | <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> |
| 1221 | <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. |
| 1222 | |
| 1223 | Given |
| 1224 | int (*f)(int); |
| 1225 | void g(); |
| 1226 | functionType() |
| 1227 | matches "int (*f)(int)" and the type of "g". |
| 1228 | </pre></td></tr> |
| 1229 | |
| 1230 | |
| 1231 | <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> |
| 1232 | <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. |
| 1233 | |
| 1234 | Given |
| 1235 | int a[] = { 2, 3 }; |
| 1236 | int b[42]; |
| 1237 | void f(int c[]) { int d[a[0]]; }; |
| 1238 | incompleteArrayType() |
| 1239 | matches "int a[]" and "int c[]" |
| 1240 | </pre></td></tr> |
| 1241 | |
| 1242 | |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1243 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('lvalueReferenceType0')"><a name="lvalueReferenceType0Anchor">lvalueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType</a>>...</td></tr> |
| 1244 | <tr><td colspan="4" class="doc" id="lvalueReferenceType0"><pre>Matches lvalue reference types. |
| 1245 | |
| 1246 | Given: |
| 1247 | int *a; |
| 1248 | int &b = *a; |
| 1249 | int &&c = 1; |
| 1250 | auto &d = b; |
| 1251 | auto &&e = c; |
| 1252 | auto &&f = 2; |
| 1253 | int g = 5; |
| 1254 | |
| 1255 | lvalueReferenceType() matches the types of b, d, and e. e is |
| 1256 | matched since the type is deduced as int& by reference collapsing rules. |
| 1257 | </pre></td></tr> |
| 1258 | |
| 1259 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1260 | <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> |
| 1261 | <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. |
| 1262 | Given |
| 1263 | struct A { int i; } |
| 1264 | A::* ptr = A::i; |
| 1265 | memberPointerType() |
| 1266 | matches "A::* ptr" |
| 1267 | </pre></td></tr> |
| 1268 | |
| 1269 | |
| 1270 | <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> |
| 1271 | <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types. |
| 1272 | |
| 1273 | Given |
| 1274 | int *a; |
| 1275 | int &b = *a; |
| 1276 | int c = 5; |
| 1277 | pointerType() |
| 1278 | matches "int *a" |
| 1279 | </pre></td></tr> |
| 1280 | |
| 1281 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 1282 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('recordType0')"><a name="recordType0Anchor">recordType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>...</td></tr> |
| 1283 | <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). |
| 1284 | |
| 1285 | Given |
| 1286 | class C {}; |
| 1287 | struct S {}; |
| 1288 | |
| 1289 | C c; |
| 1290 | S s; |
| 1291 | |
| 1292 | recordType() matches the type of the variable declarations of both c |
| 1293 | and s. |
| 1294 | </pre></td></tr> |
| 1295 | |
| 1296 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1297 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('referenceType0')"><a name="referenceType0Anchor">referenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>...</td></tr> |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1298 | <tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1299 | |
| 1300 | Given |
| 1301 | int *a; |
| 1302 | int &b = *a; |
Edwin Vane | f4b4804 | 2013-03-07 15:44:40 +0000 | [diff] [blame] | 1303 | int &&c = 1; |
| 1304 | auto &d = b; |
| 1305 | auto &&e = c; |
| 1306 | auto &&f = 2; |
| 1307 | int g = 5; |
| 1308 | |
| 1309 | referenceType() matches the types of b, c, d, e, and f. |
| 1310 | </pre></td></tr> |
| 1311 | |
| 1312 | |
| 1313 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('rvalueReferenceType0')"><a name="rvalueReferenceType0Anchor">rvalueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType</a>>...</td></tr> |
| 1314 | <tr><td colspan="4" class="doc" id="rvalueReferenceType0"><pre>Matches rvalue reference types. |
| 1315 | |
| 1316 | Given: |
| 1317 | int *a; |
| 1318 | int &b = *a; |
| 1319 | int &&c = 1; |
| 1320 | auto &d = b; |
| 1321 | auto &&e = c; |
| 1322 | auto &&f = 2; |
| 1323 | int g = 5; |
| 1324 | |
| 1325 | lvalueReferenceType() matches the types of c and f. e is not |
| 1326 | matched as it is deduced to int& by reference collapsing rules. |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1327 | </pre></td></tr> |
| 1328 | |
| 1329 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 1330 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('templateSpecializationType0')"><a name="templateSpecializationType0Anchor">templateSpecializationType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>...</td></tr> |
| 1331 | <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. |
| 1332 | |
| 1333 | Given |
| 1334 | template <typename T> |
| 1335 | class C { }; |
| 1336 | |
| 1337 | template class C<int>; A |
| 1338 | C<char> var; B |
| 1339 | |
| 1340 | templateSpecializationType() matches the type of the explicit |
| 1341 | instantiation in A and the type of the variable declaration in B. |
| 1342 | </pre></td></tr> |
| 1343 | |
| 1344 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1345 | <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> |
| 1346 | <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. |
| 1347 | </pre></td></tr> |
| 1348 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 1349 | |
| 1350 | <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> |
| 1351 | <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. |
| 1352 | |
| 1353 | Given |
| 1354 | typedef int X; |
| 1355 | typedefType() |
| 1356 | matches "typedef int X" |
| 1357 | </pre></td></tr> |
| 1358 | |
| 1359 | |
| 1360 | <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> |
| 1361 | <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an |
| 1362 | integer-constant-expression. |
| 1363 | |
| 1364 | Given |
| 1365 | void f() { |
| 1366 | int a[] = { 2, 3 } |
| 1367 | int b[42]; |
| 1368 | int c[a[0]]; |
| 1369 | variableArrayType() |
| 1370 | matches "int c[a[0]]" |
| 1371 | </pre></td></tr> |
| 1372 | |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1373 | <!--END_DECL_MATCHERS --> |
| 1374 | </table> |
| 1375 | |
| 1376 | <!-- ======================================================================= --> |
| 1377 | <h2 id="narrowing-matchers">Narrowing Matchers</h2> |
| 1378 | <!-- ======================================================================= --> |
| 1379 | |
| 1380 | <p>Narrowing matchers match certain attributes on the current node, thus |
| 1381 | narrowing down the set of nodes of the current type to match on.</p> |
| 1382 | |
| 1383 | <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) |
| 1384 | which allow users to create more powerful match expressions.</p> |
| 1385 | |
| 1386 | <table> |
| 1387 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| 1388 | <!-- START_NARROWING_MATCHERS --> |
| 1389 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1390 | <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] | 1391 | <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. |
| 1392 | |
| 1393 | Usable as: Any Matcher |
| 1394 | </pre></td></tr> |
| 1395 | |
| 1396 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1397 | <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] | 1398 | <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. |
| 1399 | |
| 1400 | Usable as: Any Matcher |
| 1401 | </pre></td></tr> |
| 1402 | |
| 1403 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1404 | <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] | 1405 | <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. |
| 1406 | |
| 1407 | Useful when another matcher requires a child matcher, but there's no |
| 1408 | additional constraint. This will often be used with an explicit conversion |
| 1409 | to an internal::Matcher<> type such as TypeMatcher. |
| 1410 | |
| 1411 | Example: DeclarationMatcher(anything()) matches all declarations, e.g., |
| 1412 | "int* p" and "void f()" in |
| 1413 | int* p; |
| 1414 | void f(); |
| 1415 | |
| 1416 | Usable as: Any Matcher |
| 1417 | </pre></td></tr> |
| 1418 | |
| 1419 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1420 | <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] | 1421 | <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. |
| 1422 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1423 | Example matches Y (matcher = recordDecl(unless(hasName("X")))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1424 | class X {}; |
| 1425 | class Y {}; |
| 1426 | |
| 1427 | Usable as: Any Matcher |
| 1428 | </pre></td></tr> |
| 1429 | |
| 1430 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1431 | <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] | 1432 | <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or |
| 1433 | unary). |
| 1434 | |
| 1435 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 1436 | !(a || b) |
| 1437 | </pre></td></tr> |
| 1438 | |
| 1439 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1440 | <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] | 1441 | <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value. |
| 1442 | |
| 1443 | Example matches true (matcher = boolLiteral(equals(true))) |
| 1444 | true |
| 1445 | |
| 1446 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1447 | 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>> |
| 1448 | </pre></td></tr> |
| 1449 | |
| 1450 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1451 | <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] | 1452 | <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a constructor declaration that has been implicitly added |
| 1453 | by the compiler (eg. implicit defaultcopy constructors). |
| 1454 | </pre></td></tr> |
| 1455 | |
| 1456 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1457 | <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] | 1458 | <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a contructor initializer if it is explicitly written in |
| 1459 | code (as opposed to implicitly added by the compiler). |
| 1460 | |
| 1461 | Given |
| 1462 | struct Foo { |
| 1463 | Foo() { } |
| 1464 | Foo(int) : foo_("A") { } |
| 1465 | string foo_; |
| 1466 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1467 | constructorDecl(hasAnyConstructorInitializer(isWritten())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1468 | will match Foo(int), but not Foo() |
| 1469 | </pre></td></tr> |
| 1470 | |
| 1471 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 1472 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1473 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. |
| 1474 | |
| 1475 | Matches overloaded operator names specified in strings without the |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 1476 | "operator" prefix: e.g. "<<". |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1477 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 1478 | Given: |
| 1479 | class A { int operator*(); }; |
| 1480 | const A &operator<<(const A &a, const A &b); |
| 1481 | A a; |
| 1482 | a << a; <-- This matches |
| 1483 | |
| 1484 | operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified |
| 1485 | line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches |
| 1486 | the declaration of A. |
| 1487 | |
| 1488 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> |
| 1489 | </pre></td></tr> |
| 1490 | |
| 1491 | |
| 1492 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName1')"><a name="hasOverloadedOperatorName1Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> |
| 1493 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. |
| 1494 | |
| 1495 | Matches overloaded operator names specified in strings without the |
| 1496 | "operator" prefix: e.g. "<<". |
| 1497 | |
| 1498 | Given: |
| 1499 | class A { int operator*(); }; |
| 1500 | const A &operator<<(const A &a, const A &b); |
| 1501 | A a; |
| 1502 | a << a; <-- This matches |
| 1503 | |
| 1504 | operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified |
| 1505 | line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches |
| 1506 | the declaration of A. |
| 1507 | |
| 1508 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1509 | </pre></td></tr> |
| 1510 | |
| 1511 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1512 | <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] | 1513 | <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). |
| 1514 | </pre></td></tr> |
| 1515 | |
| 1516 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1517 | <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> |
| 1518 | <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] | 1519 | static member variable template instantiations. |
| 1520 | |
| 1521 | Given |
| 1522 | template<typename T> void A(T t) { } |
| 1523 | template<> void A(int N) { } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1524 | functionDecl(isExplicitTemplateSpecialization()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1525 | matches the specialization A<int>(). |
| 1526 | |
| 1527 | 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>> |
| 1528 | </pre></td></tr> |
| 1529 | |
| 1530 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1531 | <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> |
| 1532 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for |
| 1533 | isSameOrDerivedFrom(hasName(...)). |
| 1534 | </pre></td></tr> |
| 1535 | |
| 1536 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1537 | <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> |
| 1538 | <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] | 1539 | member variable template instantiations. |
| 1540 | |
| 1541 | Given |
| 1542 | template <typename T> class X {}; class A {}; X<A> x; |
| 1543 | or |
| 1544 | template <typename T> class X {}; class A {}; template class X<A>; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1545 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1546 | matches the template instantiation of X<A>. |
| 1547 | |
| 1548 | But given |
| 1549 | template <typename T> class X {}; class A {}; |
| 1550 | template <> class X<A> {}; X<A> x; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1551 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1552 | does not match, as X<A> is an explicit template specialization. |
| 1553 | |
| 1554 | 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>> |
| 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_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] | 1559 | <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has |
| 1560 | a specific number of arguments (including absent default arguments). |
| 1561 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1562 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1563 | void f(int x, int y); |
| 1564 | f(0, 0); |
| 1565 | </pre></td></tr> |
| 1566 | |
| 1567 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1568 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 1569 | <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value. |
| 1570 | |
| 1571 | Example matches true (matcher = boolLiteral(equals(true))) |
| 1572 | true |
| 1573 | |
| 1574 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1575 | 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>> |
| 1576 | </pre></td></tr> |
| 1577 | |
| 1578 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1579 | <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] | 1580 | <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of |
| 1581 | child statements. |
| 1582 | |
| 1583 | Example: Given |
| 1584 | { for (;;) {} } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1585 | compoundStmt(statementCountIs(0))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1586 | matches '{}' |
| 1587 | but does not match the outer compound statement. |
| 1588 | </pre></td></tr> |
| 1589 | |
| 1590 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1591 | <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> |
| 1592 | <tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size. |
| 1593 | |
| 1594 | Given |
| 1595 | int a[42]; |
| 1596 | int b[2 * 21]; |
| 1597 | int c[41], d[43]; |
| 1598 | constantArrayType(hasSize(42)) |
| 1599 | matches "int a[42]" and "int b[2 * 21]" |
| 1600 | </pre></td></tr> |
| 1601 | |
| 1602 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1603 | <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] | 1604 | <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of |
| 1605 | declarations. |
| 1606 | |
| 1607 | Example: Given |
| 1608 | int a, b; |
| 1609 | int c; |
| 1610 | int d = 2, e; |
| 1611 | declCountIs(2) |
| 1612 | matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. |
| 1613 | </pre></td></tr> |
| 1614 | |
| 1615 | |
Manuel Klimek | fa37c5c | 2013-02-07 12:42:10 +0000 | [diff] [blame] | 1616 | <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> |
| 1617 | <tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node. |
| 1618 | |
| 1619 | Decl has pointer identity in the AST. |
| 1620 | </pre></td></tr> |
| 1621 | |
| 1622 | |
Daniel Jasper | c7093d9 | 2013-02-25 12:39:41 +0000 | [diff] [blame] | 1623 | <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> |
| 1624 | <tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. |
| 1625 | |
| 1626 | Given |
| 1627 | class C { |
| 1628 | public: int a; |
| 1629 | protected: int b; |
| 1630 | private: int c; |
| 1631 | }; |
| 1632 | fieldDecl(isPrivate()) |
| 1633 | matches 'int c;' |
| 1634 | </pre></td></tr> |
| 1635 | |
| 1636 | |
| 1637 | <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> |
| 1638 | <tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. |
| 1639 | |
| 1640 | Given |
| 1641 | class C { |
| 1642 | public: int a; |
| 1643 | protected: int b; |
| 1644 | private: int c; |
| 1645 | }; |
| 1646 | fieldDecl(isProtected()) |
| 1647 | matches 'int b;' |
| 1648 | </pre></td></tr> |
| 1649 | |
| 1650 | |
| 1651 | <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> |
| 1652 | <tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. |
| 1653 | |
| 1654 | Given |
| 1655 | class C { |
| 1656 | public: int a; |
| 1657 | protected: int b; |
| 1658 | private: int c; |
| 1659 | }; |
| 1660 | fieldDecl(isPublic()) |
| 1661 | matches 'int a;' |
| 1662 | </pre></td></tr> |
| 1663 | |
| 1664 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1665 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 1666 | <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. |
| 1667 | |
| 1668 | Example matches true (matcher = boolLiteral(equals(true))) |
| 1669 | true |
| 1670 | |
| 1671 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1672 | 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>> |
| 1673 | </pre></td></tr> |
| 1674 | |
| 1675 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1676 | <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> |
| 1677 | <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] | 1678 | |
| 1679 | Example matches A, va, fa |
| 1680 | class A {}; |
| 1681 | class B; Doesn't match, as it has no body. |
| 1682 | int va; |
| 1683 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 1684 | void fa() {} |
| 1685 | void fb(); Doesn't match, as it has no body. |
| 1686 | |
| 1687 | 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>> |
| 1688 | </pre></td></tr> |
| 1689 | |
| 1690 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1691 | <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> |
| 1692 | <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] | 1693 | static member variable template instantiations. |
| 1694 | |
| 1695 | Given |
| 1696 | template<typename T> void A(T t) { } |
| 1697 | template<> void A(int N) { } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1698 | functionDecl(isExplicitTemplateSpecialization()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1699 | matches the specialization A<int>(). |
| 1700 | |
| 1701 | 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>> |
| 1702 | </pre></td></tr> |
| 1703 | |
| 1704 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1705 | <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] | 1706 | <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. |
| 1707 | |
| 1708 | Given: |
| 1709 | extern "C" void f() {} |
| 1710 | extern "C" { void g() {} } |
| 1711 | void h() {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1712 | functionDecl(isExternC()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1713 | matches the declaration of f and g, but not the declaration h |
| 1714 | </pre></td></tr> |
| 1715 | |
| 1716 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1717 | <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> |
| 1718 | <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] | 1719 | member variable template instantiations. |
| 1720 | |
| 1721 | Given |
| 1722 | template <typename T> class X {}; class A {}; X<A> x; |
| 1723 | or |
| 1724 | template <typename T> class X {}; class A {}; template class X<A>; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1725 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1726 | matches the template instantiation of X<A>. |
| 1727 | |
| 1728 | But given |
| 1729 | template <typename T> class X {}; class A {}; |
| 1730 | template <> class X<A> {}; X<A> x; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1731 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1732 | does not match, as X<A> is an explicit template specialization. |
| 1733 | |
| 1734 | 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>> |
| 1735 | </pre></td></tr> |
| 1736 | |
| 1737 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 1738 | <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> |
| 1739 | <tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count. |
| 1740 | |
| 1741 | Given |
| 1742 | void f(int i) {} |
| 1743 | void g(int i, int j) {} |
| 1744 | functionDecl(parameterCountIs(2)) |
| 1745 | matches g(int i, int j) {} |
| 1746 | </pre></td></tr> |
| 1747 | |
| 1748 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1749 | <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] | 1750 | <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. |
| 1751 | |
| 1752 | Example matches true (matcher = boolLiteral(equals(true))) |
| 1753 | true |
| 1754 | |
| 1755 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1756 | 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>> |
| 1757 | </pre></td></tr> |
| 1758 | |
| 1759 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1760 | <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] | 1761 | <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed |
| 1762 | to '.'. |
| 1763 | |
| 1764 | Member calls on the implicit this pointer match as called with '->'. |
| 1765 | |
| 1766 | Given |
| 1767 | class Y { |
| 1768 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 1769 | int a; |
| 1770 | static int b; |
| 1771 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1772 | memberExpr(isArrow()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1773 | matches this->x, x, y.x, a, this->b |
| 1774 | </pre></td></tr> |
| 1775 | |
| 1776 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1777 | <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] | 1778 | <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. |
| 1779 | |
| 1780 | Supports specifying enclosing namespaces or classes by prefixing the name |
| 1781 | with '<enclosing>::'. |
| 1782 | Does not match typedefs of an underlying type with the given name. |
| 1783 | |
| 1784 | Example matches X (Name == "X") |
| 1785 | class X; |
| 1786 | |
| 1787 | Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") |
| 1788 | namespace a { namespace b { class X; } } |
| 1789 | </pre></td></tr> |
| 1790 | |
| 1791 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1792 | <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] | 1793 | <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain |
| 1794 | a substring matched by the given RegExp. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1795 | |
| 1796 | Supports specifying enclosing namespaces or classes by |
| 1797 | prefixing the name with '<enclosing>::'. Does not match typedefs |
| 1798 | of an underlying type with the given name. |
| 1799 | |
| 1800 | Example matches X (regexp == "::X") |
| 1801 | class X; |
| 1802 | |
| 1803 | Example matches X (regexp is one of "::X", "^foo::.*X", among others) |
| 1804 | namespace foo { namespace bar { class X; } } |
| 1805 | </pre></td></tr> |
| 1806 | |
| 1807 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1808 | <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] | 1809 | <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. |
| 1810 | |
| 1811 | Given |
| 1812 | class Y { public: void x(); }; |
| 1813 | void z() { Y* y; y->x(); } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1814 | callExpr(on(hasType(asString("class Y *")))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1815 | matches y->x() |
| 1816 | </pre></td></tr> |
| 1817 | |
| 1818 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1819 | <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] | 1820 | <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that |
| 1821 | include "top-level" const. |
| 1822 | |
| 1823 | Given |
| 1824 | void a(int); |
| 1825 | void b(int const); |
| 1826 | void c(const int); |
| 1827 | void d(const int*); |
| 1828 | void e(int const) {}; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1829 | functionDecl(hasAnyParameter(hasType(isConstQualified()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1830 | matches "void b(int const)", "void c(const int)" and |
| 1831 | "void e(int const) {}". It does not match d as there |
| 1832 | is no top-level const on the parameter type "const int *". |
| 1833 | </pre></td></tr> |
| 1834 | |
| 1835 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1836 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isInteger0')"><a name="isInteger0Anchor">isInteger</a></td><td></td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1837 | <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. |
| 1838 | |
| 1839 | Given |
| 1840 | void a(int); |
| 1841 | void b(long); |
| 1842 | void c(double); |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1843 | functionDecl(hasAnyParameter(hasType(isInteger()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1844 | matches "a(int)", "b(long)", but not "c(double)". |
| 1845 | </pre></td></tr> |
| 1846 | |
| 1847 | |
Manuel Klimek | fa37c5c | 2013-02-07 12:42:10 +0000 | [diff] [blame] | 1848 | <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> |
| 1849 | <tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. |
| 1850 | |
| 1851 | Stmt has pointer identity in the AST. |
| 1852 | |
| 1853 | </pre></td></tr> |
| 1854 | |
| 1855 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 1856 | <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> |
| 1857 | <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] | 1858 | |
| 1859 | Example matches A, va, fa |
| 1860 | class A {}; |
| 1861 | class B; Doesn't match, as it has no body. |
| 1862 | int va; |
| 1863 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 1864 | void fa() {} |
| 1865 | void fb(); Doesn't match, as it has no body. |
| 1866 | |
| 1867 | 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>> |
| 1868 | </pre></td></tr> |
| 1869 | |
| 1870 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1871 | <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] | 1872 | <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. |
| 1873 | |
| 1874 | Given |
| 1875 | int x; |
| 1876 | int s = sizeof(x) + alignof(x) |
| 1877 | unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) |
| 1878 | matches sizeof(x) |
| 1879 | </pre></td></tr> |
| 1880 | |
| 1881 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1882 | <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] | 1883 | <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or |
| 1884 | unary). |
| 1885 | |
| 1886 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 1887 | !(a || b) |
| 1888 | </pre></td></tr> |
| 1889 | |
| 1890 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1891 | <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] | 1892 | <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. |
| 1893 | |
| 1894 | Example matches A, va, fa |
| 1895 | class A {}; |
| 1896 | class B; Doesn't match, as it has no body. |
| 1897 | int va; |
| 1898 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 1899 | void fa() {} |
| 1900 | void fb(); Doesn't match, as it has no body. |
| 1901 | |
| 1902 | 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>> |
| 1903 | </pre></td></tr> |
| 1904 | |
| 1905 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1906 | <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] | 1907 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or |
| 1908 | static member variable template instantiations. |
| 1909 | |
| 1910 | Given |
| 1911 | template<typename T> void A(T t) { } |
| 1912 | template<> void A(int N) { } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1913 | functionDecl(isExplicitTemplateSpecialization()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1914 | matches the specialization A<int>(). |
| 1915 | |
| 1916 | 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>> |
| 1917 | </pre></td></tr> |
| 1918 | |
| 1919 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1920 | <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] | 1921 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static |
| 1922 | member variable template instantiations. |
| 1923 | |
| 1924 | Given |
| 1925 | template <typename T> class X {}; class A {}; X<A> x; |
| 1926 | or |
| 1927 | template <typename T> class X {}; class A {}; template class X<A>; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1928 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1929 | matches the template instantiation of X<A>. |
| 1930 | |
| 1931 | But given |
| 1932 | template <typename T> class X {}; class A {}; |
| 1933 | template <> class X<A> {}; X<A> x; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1934 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1935 | does not match, as X<A> is an explicit template specialization. |
| 1936 | |
| 1937 | 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>> |
| 1938 | </pre></td></tr> |
| 1939 | |
| 1940 | <!--END_NARROWING_MATCHERS --> |
| 1941 | </table> |
| 1942 | |
| 1943 | <!-- ======================================================================= --> |
| 1944 | <h2 id="traversal-matchers">AST Traversal Matchers</h2> |
| 1945 | <!-- ======================================================================= --> |
| 1946 | |
| 1947 | <p>Traversal matchers specify the relationship to other nodes that are |
| 1948 | reachable from the current node.</p> |
| 1949 | |
| 1950 | <p>Note that there are special traversal matchers (has, hasDescendant, forEach and |
| 1951 | forEachDescendant) which work on all nodes and allow users to write more generic |
| 1952 | match expressions.</p> |
| 1953 | |
| 1954 | <table> |
| 1955 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| 1956 | <!-- START_TRAVERSAL_MATCHERS --> |
| 1957 | |
Manuel Klimek | 152ea0e | 2013-02-04 10:59:20 +0000 | [diff] [blame] | 1958 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*> P1, Matcher<*> P2</td></tr> |
| 1959 | <tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. |
| 1960 | |
| 1961 | Unlike anyOf, eachOf will generate a match result for each |
| 1962 | matching submatcher. |
| 1963 | |
| 1964 | For example, in: |
| 1965 | class A { int a; int b; }; |
| 1966 | The matcher: |
| 1967 | recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), |
| 1968 | has(fieldDecl(hasName("b")).bind("v")))) |
| 1969 | will generate two results binding "v", the first of which binds |
| 1970 | the field declaration of a, the second the field declaration of |
| 1971 | b. |
| 1972 | |
| 1973 | Usable as: Any Matcher |
| 1974 | </pre></td></tr> |
| 1975 | |
| 1976 | |
| 1977 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<T> Matcher</td></tr> |
| 1978 | <tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. |
| 1979 | |
| 1980 | Generates results for each match. |
| 1981 | |
| 1982 | For example, in: |
| 1983 | class A { class B {}; class C {}; }; |
| 1984 | The matcher: |
| 1985 | recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m"))) |
| 1986 | will generate results for A, B and C. |
| 1987 | |
| 1988 | Usable as: Any Matcher |
| 1989 | </pre></td></tr> |
| 1990 | |
| 1991 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1992 | <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] | 1993 | <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the |
| 1994 | provided matcher. |
| 1995 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1996 | Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1997 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 1998 | class Y { class X {}; }; |
| 1999 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 2000 | |
| 2001 | ChildT must be an AST base type. |
| 2002 | |
| 2003 | As opposed to 'has', 'forEach' will cause a match for each result that |
| 2004 | matches instead of only on the first one. |
| 2005 | |
| 2006 | Usable as: Any Matcher |
| 2007 | </pre></td></tr> |
| 2008 | |
| 2009 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2010 | <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] | 2011 | <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 2012 | provided matcher. |
| 2013 | |
| 2014 | Example matches X, A, B, C |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2015 | (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2016 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 2017 | class A { class X {}; }; |
| 2018 | class B { class C { class X {}; }; }; |
| 2019 | |
| 2020 | DescendantT must be an AST base type. |
| 2021 | |
| 2022 | As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for |
| 2023 | each result that matches instead of only on the first one. |
| 2024 | |
| 2025 | Note: Recursively combined ForEachDescendant can cause many matches: |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2026 | recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl())))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2027 | will match 10 times (plus injected class name matches) on: |
| 2028 | class A { class B { class C { class D { class E {}; }; }; }; }; |
| 2029 | |
| 2030 | Usable as: Any Matcher |
| 2031 | </pre></td></tr> |
| 2032 | |
| 2033 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2034 | <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] | 2035 | <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the |
| 2036 | provided matcher. |
| 2037 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2038 | Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2039 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 2040 | class Y { class X {}; }; |
| 2041 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 2042 | |
| 2043 | ChildT must be an AST base type. |
| 2044 | |
| 2045 | Usable as: Any Matcher |
| 2046 | </pre></td></tr> |
| 2047 | |
| 2048 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2049 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<AncestorT> AncestorMatcher</td></tr> |
| 2050 | <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided |
| 2051 | matcher. |
| 2052 | |
| 2053 | Given |
| 2054 | void f() { if (true) { int x = 42; } } |
| 2055 | void g() { for (;;) { int x = 43; } } |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2056 | expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2057 | |
| 2058 | Usable as: Any Matcher |
| 2059 | </pre></td></tr> |
| 2060 | |
| 2061 | |
| 2062 | <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] | 2063 | <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 2064 | provided matcher. |
| 2065 | |
| 2066 | Example matches X, Y, Z |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2067 | (matcher = recordDecl(hasDescendant(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2068 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 2069 | class Y { class X {}; }; |
| 2070 | class Z { class Y { class X {}; }; }; |
| 2071 | |
| 2072 | DescendantT must be an AST base type. |
| 2073 | |
| 2074 | Usable as: Any Matcher |
| 2075 | </pre></td></tr> |
| 2076 | |
| 2077 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2078 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<ParentT> ParentMatcher</td></tr> |
| 2079 | <tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided |
| 2080 | matcher. |
| 2081 | |
| 2082 | Given |
| 2083 | void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } |
| 2084 | compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". |
| 2085 | |
| 2086 | Usable as: Any Matcher |
| 2087 | </pre></td></tr> |
| 2088 | |
| 2089 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2090 | <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] | 2091 | <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. |
| 2092 | |
| 2093 | Given |
| 2094 | int i[5]; |
| 2095 | void f() { i[1] = 42; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2096 | arraySubscriptExpression(hasBase(implicitCastExpr( |
| 2097 | hasSourceExpression(declRefExpr())))) |
| 2098 | matches i[1] with the declRefExpr() matching i |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2099 | </pre></td></tr> |
| 2100 | |
| 2101 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2102 | <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] | 2103 | <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. |
| 2104 | |
| 2105 | Given |
| 2106 | int i[5]; |
| 2107 | void f() { i[1] = 42; } |
| 2108 | arraySubscriptExpression(hasIndex(integerLiteral())) |
| 2109 | matches i[1] with the integerLiteral() matching 1 |
| 2110 | </pre></td></tr> |
| 2111 | |
| 2112 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 2113 | <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> |
| 2114 | <tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element |
| 2115 | type. |
| 2116 | |
| 2117 | Given |
| 2118 | struct A {}; |
| 2119 | A a[7]; |
| 2120 | int b[7]; |
| 2121 | arrayType(hasElementType(builtinType())) |
| 2122 | matches "int b[7]" |
| 2123 | |
| 2124 | 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>> |
| 2125 | </pre></td></tr> |
| 2126 | |
| 2127 | |
| 2128 | <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> |
| 2129 | <tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element |
| 2130 | type. |
| 2131 | |
| 2132 | Given |
| 2133 | struct A {}; |
| 2134 | A a[7]; |
| 2135 | int b[7]; |
| 2136 | arrayType(hasElementType(builtinType())) |
| 2137 | matches "int b[7]" |
| 2138 | |
| 2139 | 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>> |
| 2140 | </pre></td></tr> |
| 2141 | |
| 2142 | |
| 2143 | <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> |
| 2144 | <tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. |
| 2145 | |
| 2146 | Given |
| 2147 | _Atomic(int) i; |
| 2148 | _Atomic(float) f; |
| 2149 | atomicType(hasValueType(isInteger())) |
| 2150 | matches "_Atomic(int) i" |
| 2151 | |
| 2152 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> |
| 2153 | </pre></td></tr> |
| 2154 | |
| 2155 | |
| 2156 | <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> |
| 2157 | <tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. |
| 2158 | |
| 2159 | Given |
| 2160 | _Atomic(int) i; |
| 2161 | _Atomic(float) f; |
| 2162 | atomicType(hasValueType(isInteger())) |
| 2163 | matches "_Atomic(int) i" |
| 2164 | |
| 2165 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> |
| 2166 | </pre></td></tr> |
| 2167 | |
| 2168 | |
| 2169 | <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> |
| 2170 | <tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. |
| 2171 | |
| 2172 | Note: There is no TypeLoc for the deduced type and thus no |
| 2173 | getDeducedLoc() matcher. |
| 2174 | |
| 2175 | Given |
| 2176 | auto a = 1; |
| 2177 | auto b = 2.0; |
| 2178 | autoType(hasDeducedType(isInteger())) |
| 2179 | matches "auto a" |
| 2180 | |
| 2181 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> |
| 2182 | </pre></td></tr> |
| 2183 | |
| 2184 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2185 | <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] | 2186 | <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a |
| 2187 | binary operator matches. |
| 2188 | </pre></td></tr> |
| 2189 | |
| 2190 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2191 | <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] | 2192 | <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. |
| 2193 | |
| 2194 | Example matches a (matcher = binaryOperator(hasLHS())) |
| 2195 | a || b |
| 2196 | </pre></td></tr> |
| 2197 | |
| 2198 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2199 | <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] | 2200 | <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. |
| 2201 | |
| 2202 | Example matches b (matcher = binaryOperator(hasRHS())) |
| 2203 | a || b |
| 2204 | </pre></td></tr> |
| 2205 | |
| 2206 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 2207 | <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> |
| 2208 | <tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the |
| 2209 | pointee matches a given matcher. |
| 2210 | |
| 2211 | Given |
| 2212 | int *a; |
| 2213 | int const *b; |
| 2214 | float const *f; |
| 2215 | pointerType(pointee(isConstQualified(), isInteger())) |
| 2216 | matches "int const *b" |
| 2217 | |
| 2218 | 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>>, |
| 2219 | 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>> |
| 2220 | </pre></td></tr> |
| 2221 | |
| 2222 | |
| 2223 | <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> |
| 2224 | <tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the |
| 2225 | pointee matches a given matcher. |
| 2226 | |
| 2227 | Given |
| 2228 | int *a; |
| 2229 | int const *b; |
| 2230 | float const *f; |
| 2231 | pointerType(pointee(isConstQualified(), isInteger())) |
| 2232 | matches "int const *b" |
| 2233 | |
| 2234 | 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>>, |
| 2235 | 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>> |
| 2236 | </pre></td></tr> |
| 2237 | |
| 2238 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 2239 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasDeclaration3')"><a name="hasDeclaration3Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 2240 | <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] | 2241 | matcher. |
| 2242 | |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 2243 | In addition to being usable as Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, also usable as |
| 2244 | Matcher<T> for any T supporting the getDecl() member function. e.g. various |
| 2245 | subtypes of clang::Type. |
| 2246 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2247 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 2248 | 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>>, |
| 2249 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2250 | </pre></td></tr> |
| 2251 | |
| 2252 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2253 | <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] | 2254 | <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. |
| 2255 | |
| 2256 | Given |
| 2257 | struct Foo { |
| 2258 | Foo() : foo_(1) { } |
| 2259 | int foo_; |
| 2260 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2261 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything())))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2262 | record matches Foo, hasAnyConstructorInitializer matches foo_(1) |
| 2263 | </pre></td></tr> |
| 2264 | |
| 2265 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2266 | <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] | 2267 | <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. |
| 2268 | |
| 2269 | Given |
| 2270 | struct Foo { |
| 2271 | Foo() : foo_(1) { } |
| 2272 | int foo_; |
| 2273 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2274 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2275 | forField(hasName("foo_")))))) |
| 2276 | matches Foo |
| 2277 | with forField matching foo_ |
| 2278 | </pre></td></tr> |
| 2279 | |
| 2280 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2281 | <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] | 2282 | <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. |
| 2283 | |
| 2284 | Given |
| 2285 | struct Foo { |
| 2286 | Foo() : foo_(1) { } |
| 2287 | int foo_; |
| 2288 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2289 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2290 | withInitializer(integerLiteral(equals(1))))))) |
| 2291 | matches Foo |
| 2292 | with withInitializer matching (1) |
| 2293 | </pre></td></tr> |
| 2294 | |
| 2295 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2296 | <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] | 2297 | <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. |
| 2298 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2299 | Example matches y.x() (matcher = callExpr(on(hasType(recordDecl(hasName("Y")))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2300 | class Y { public: void x(); }; |
| 2301 | void z() { Y y; y.x(); }", |
| 2302 | |
| 2303 | FIXME: Overload to allow directly matching types? |
| 2304 | </pre></td></tr> |
| 2305 | |
| 2306 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2307 | <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] | 2308 | <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></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_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] | 2312 | <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. |
| 2313 | </pre></td></tr> |
| 2314 | |
| 2315 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2316 | <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] | 2317 | <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration |
| 2318 | belongs to. |
| 2319 | |
| 2320 | FIXME: Generalize this for other kinds of declarations. |
| 2321 | FIXME: What other kind of declarations would we need to generalize |
| 2322 | this to? |
| 2323 | |
| 2324 | Example matches A() in the last line |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2325 | (matcher = constructExpr(hasDeclaration(methodDecl( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2326 | ofClass(hasName("A")))))) |
| 2327 | class A { |
| 2328 | public: |
| 2329 | A(); |
| 2330 | }; |
| 2331 | A a = A(); |
| 2332 | </pre></td></tr> |
| 2333 | |
| 2334 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 2335 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('hasMethod0')"><a name="hasMethod0Anchor">hasMethod</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> InnerMatcher</td></tr> |
| 2336 | <tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. |
| 2337 | |
| 2338 | Given: |
| 2339 | class A { void func(); }; |
| 2340 | class B { void member(); }; |
| 2341 | |
| 2342 | recordDecl(hasMethod(hasName("func"))) matches the declaration of A |
| 2343 | but not B. |
| 2344 | </pre></td></tr> |
| 2345 | |
| 2346 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2347 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 2348 | <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from |
| 2349 | a class matching Base. |
| 2350 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2351 | Note that a class is not considered to be derived from itself. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2352 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2353 | Example matches Y, Z, C (Base == hasName("X")) |
| 2354 | class X; |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2355 | class Y : public X {}; directly derived |
| 2356 | class Z : public Y {}; indirectly derived |
| 2357 | typedef X A; |
| 2358 | typedef A B; |
| 2359 | class C : public B {}; derived from a typedef of X |
| 2360 | |
| 2361 | In the following example, Bar matches isDerivedFrom(hasName("X")): |
| 2362 | class Foo; |
| 2363 | typedef Foo X; |
| 2364 | class Bar : public Foo {}; derived from a type that X is a typedef of |
| 2365 | </pre></td></tr> |
| 2366 | |
| 2367 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2368 | <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> |
| 2369 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly |
| 2370 | match Base. |
| 2371 | </pre></td></tr> |
| 2372 | |
| 2373 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2374 | <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] | 2375 | <tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the |
| 2376 | given matcher. |
| 2377 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2378 | Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2379 | class Y { public: void x(); }; |
| 2380 | void z() { Y y; y.x(); |
| 2381 | </pre></td></tr> |
| 2382 | |
| 2383 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2384 | <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] | 2385 | <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call |
| 2386 | expression. |
| 2387 | |
| 2388 | Given |
| 2389 | void x(int, int, int) { int y; x(1, y, 42); } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2390 | callExpr(hasAnyArgument(declRefExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2391 | matches x(1, y, 42) |
| 2392 | with hasAnyArgument(...) |
| 2393 | matching y |
| 2394 | </pre></td></tr> |
| 2395 | |
| 2396 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2397 | <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] | 2398 | <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor |
| 2399 | call expression. |
| 2400 | |
| 2401 | Example matches y in x(y) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2402 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2403 | void x(int) { int y; x(y); } |
| 2404 | </pre></td></tr> |
| 2405 | |
| 2406 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 2407 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasDeclaration4')"><a name="hasDeclaration4Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 2408 | <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] | 2409 | matcher. |
| 2410 | |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 2411 | In addition to being usable as Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, also usable as |
| 2412 | Matcher<T> for any T supporting the getDecl() member function. e.g. various |
| 2413 | subtypes of clang::Type. |
| 2414 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2415 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 2416 | 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>>, |
| 2417 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2418 | </pre></td></tr> |
| 2419 | |
| 2420 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2421 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 2422 | <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher. |
| 2423 | |
| 2424 | Example: matches "a string" (matcher = |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2425 | hasSourceExpression(constructExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2426 | class URL { URL(string); }; |
| 2427 | URL url = "a string"; |
| 2428 | </pre></td></tr> |
| 2429 | |
| 2430 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2431 | <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] | 2432 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one |
| 2433 | TemplateArgument matching the given InnerMatcher. |
| 2434 | |
| 2435 | Given |
| 2436 | template<typename T> class A {}; |
| 2437 | template<> class A<double> {}; |
| 2438 | A<int> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2439 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2440 | refersToType(asString("int")))) |
| 2441 | matches the specialization A<int> |
| 2442 | </pre></td></tr> |
| 2443 | |
| 2444 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2445 | <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] | 2446 | <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument |
| 2447 | matches the given InnerMatcher. |
| 2448 | |
| 2449 | Given |
| 2450 | template<typename T, typename U> class A {}; |
| 2451 | A<bool, int> b; |
| 2452 | A<int, bool> c; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2453 | classTemplateSpecializationDecl(hasTemplateArgument( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2454 | 1, refersToType(asString("int")))) |
| 2455 | matches the specialization A<bool, int> |
| 2456 | </pre></td></tr> |
| 2457 | |
| 2458 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 2459 | <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> |
| 2460 | <tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element |
| 2461 | type. |
| 2462 | |
| 2463 | Given |
| 2464 | struct A {}; |
| 2465 | A a[7]; |
| 2466 | int b[7]; |
| 2467 | arrayType(hasElementType(builtinType())) |
| 2468 | matches "int b[7]" |
| 2469 | |
| 2470 | 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>> |
| 2471 | </pre></td></tr> |
| 2472 | |
| 2473 | |
| 2474 | <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> |
| 2475 | <tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element |
| 2476 | type. |
| 2477 | |
| 2478 | Given |
| 2479 | struct A {}; |
| 2480 | A a[7]; |
| 2481 | int b[7]; |
| 2482 | arrayType(hasElementType(builtinType())) |
| 2483 | matches "int b[7]" |
| 2484 | |
| 2485 | 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>> |
| 2486 | </pre></td></tr> |
| 2487 | |
| 2488 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2489 | <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] | 2490 | <tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches |
| 2491 | a given matcher. |
| 2492 | |
| 2493 | Given |
| 2494 | { {}; 1+2; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2495 | hasAnySubstatement(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2496 | matches '{ {}; 1+2; }' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2497 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2498 | matching '{}' |
| 2499 | </pre></td></tr> |
| 2500 | |
| 2501 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2502 | <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] | 2503 | <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, |
| 2504 | or conditional operator. |
| 2505 | |
| 2506 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 2507 | if (true) {} |
| 2508 | </pre></td></tr> |
| 2509 | |
| 2510 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2511 | <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] | 2512 | <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator. |
| 2513 | |
| 2514 | Example matches b |
| 2515 | condition ? a : b |
| 2516 | </pre></td></tr> |
| 2517 | |
| 2518 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2519 | <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] | 2520 | <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. |
| 2521 | |
| 2522 | Example matches a |
| 2523 | condition ? a : b |
| 2524 | </pre></td></tr> |
| 2525 | |
| 2526 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2527 | <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] | 2528 | <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a |
| 2529 | specific using shadow declaration. |
| 2530 | |
| 2531 | FIXME: This currently only works for functions. Fix. |
| 2532 | |
| 2533 | Given |
| 2534 | namespace a { void f() {} } |
| 2535 | using a::f; |
| 2536 | void g() { |
| 2537 | f(); Matches this .. |
| 2538 | a::f(); .. but not this. |
| 2539 | } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2540 | declRefExpr(throughUsingDeclaration(anything())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2541 | matches f() |
| 2542 | </pre></td></tr> |
| 2543 | |
| 2544 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2545 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 2546 | <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the |
| 2547 | specified matcher. |
| 2548 | |
| 2549 | Example matches x in if(x) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2550 | (matcher = declRefExpr(to(varDecl(hasName("x"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2551 | bool x; |
| 2552 | if (x) {} |
| 2553 | </pre></td></tr> |
| 2554 | |
| 2555 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2556 | <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] | 2557 | <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. |
| 2558 | |
| 2559 | Note that this does not work for global declarations because the AST |
| 2560 | breaks up multiple-declaration DeclStmt's into multiple single-declaration |
| 2561 | DeclStmt's. |
| 2562 | Example: Given non-global declarations |
| 2563 | int a, b = 0; |
| 2564 | int c; |
| 2565 | int d = 2, e; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2566 | declStmt(containsDeclaration( |
| 2567 | 0, varDecl(hasInitializer(anything())))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2568 | matches only 'int d = 2, e;', and |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2569 | declStmt(containsDeclaration(1, varDecl())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2570 | matches 'int a, b = 0' as well as 'int d = 2, e;' |
| 2571 | but 'int c;' is not matched. |
| 2572 | </pre></td></tr> |
| 2573 | |
| 2574 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2575 | <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] | 2576 | <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. |
| 2577 | |
| 2578 | Given |
| 2579 | int a, b; |
| 2580 | int c; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2581 | declStmt(hasSingleDecl(anything())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2582 | matches 'int c;' but not 'int a, b;'. |
| 2583 | </pre></td></tr> |
| 2584 | |
| 2585 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 2586 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('hasDeclContext0')"><a name="hasDeclContext0Anchor">hasDeclContext</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 2587 | <tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a |
| 2588 | Decl, matches InnerMatcher. |
| 2589 | |
| 2590 | Given |
| 2591 | namespace N { |
| 2592 | namespace M { |
| 2593 | class D {}; |
| 2594 | } |
| 2595 | } |
| 2596 | |
| 2597 | recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the |
| 2598 | declaration of class D. |
| 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_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] | 2603 | <tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 2604 | a given body. |
| 2605 | |
| 2606 | Given |
| 2607 | for (;;) {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2608 | hasBody(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2609 | matches 'for (;;) {}' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2610 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2611 | matching '{}' |
| 2612 | </pre></td></tr> |
| 2613 | |
| 2614 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2615 | <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] | 2616 | <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, |
| 2617 | or conditional operator. |
| 2618 | |
| 2619 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 2620 | if (true) {} |
| 2621 | </pre></td></tr> |
| 2622 | |
| 2623 | |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 2624 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>></td><td class="name" onclick="toggle('hasQualifier0')"><a name="hasQualifier0Anchor">hasQualifier</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr> |
| 2625 | <tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, |
Edwin Vane | aec89ac | 2013-03-04 17:51:00 +0000 | [diff] [blame] | 2626 | matches InnerMatcher if the qualifier exists. |
Edwin Vane | 742d9e7 | 2013-02-25 20:43:32 +0000 | [diff] [blame] | 2627 | |
| 2628 | Given |
| 2629 | namespace N { |
| 2630 | namespace M { |
| 2631 | class D {}; |
| 2632 | } |
| 2633 | } |
| 2634 | N::M::D d; |
| 2635 | |
| 2636 | elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) |
| 2637 | matches the type of the variable declaration of d. |
| 2638 | </pre></td></tr> |
| 2639 | |
| 2640 | |
| 2641 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>></td><td class="name" onclick="toggle('namesType0')"><a name="namesType0Anchor">namesType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
| 2642 | <tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. |
| 2643 | |
| 2644 | Given |
| 2645 | namespace N { |
| 2646 | namespace M { |
| 2647 | class D {}; |
| 2648 | } |
| 2649 | } |
| 2650 | N::M::D d; |
| 2651 | |
| 2652 | elaboratedType(namesType(recordType( |
| 2653 | hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable |
| 2654 | declaration of d. |
| 2655 | </pre></td></tr> |
| 2656 | |
| 2657 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2658 | <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] | 2659 | <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. |
| 2660 | |
| 2661 | (Note: Clang's AST refers to other conversions as "casts" too, and calls |
| 2662 | actual casts "explicit" casts.) |
| 2663 | </pre></td></tr> |
| 2664 | |
| 2665 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2666 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 2667 | <tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value |
| 2668 | declaration's type. |
| 2669 | |
| 2670 | In case of a value declaration (for example a variable declaration), |
| 2671 | this resolves one layer of indirection. For example, in the value |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2672 | declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, |
| 2673 | while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2674 | of x." |
| 2675 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2676 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) |
| 2677 | and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2678 | class X {}; |
| 2679 | void y(X &x) { x; X z; } |
| 2680 | |
| 2681 | 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>> |
| 2682 | </pre></td></tr> |
| 2683 | |
| 2684 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2685 | <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] | 2686 | <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts |
| 2687 | are stripped off. |
| 2688 | |
| 2689 | Parentheses and explicit casts are not discarded. |
| 2690 | Given |
| 2691 | int arr[5]; |
| 2692 | int a = 0; |
| 2693 | char b = 0; |
| 2694 | const int c = a; |
| 2695 | int *d = arr; |
| 2696 | long e = (long) 0l; |
| 2697 | The matchers |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2698 | varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) |
| 2699 | varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2700 | would match the declarations for a, b, c, and d, but not e. |
| 2701 | While |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2702 | varDecl(hasInitializer(integerLiteral())) |
| 2703 | varDecl(hasInitializer(declRefExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2704 | only match the declarations for b, c, and d. |
| 2705 | </pre></td></tr> |
| 2706 | |
| 2707 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2708 | <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] | 2709 | <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and |
| 2710 | casts are stripped off. |
| 2711 | |
| 2712 | Implicit and non-C Style casts are also discarded. |
| 2713 | Given |
| 2714 | int a = 0; |
| 2715 | char b = (0); |
| 2716 | void* c = reinterpret_cast<char*>(0); |
| 2717 | char d = char(0); |
| 2718 | The matcher |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2719 | varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2720 | would match the declarations for a, b, c, and d. |
| 2721 | while |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2722 | varDecl(hasInitializer(integerLiteral())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2723 | only match the declaration for a. |
| 2724 | </pre></td></tr> |
| 2725 | |
| 2726 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2727 | <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] | 2728 | <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and |
| 2729 | parentheses are stripped off. |
| 2730 | |
| 2731 | Explicit casts are not discarded. |
| 2732 | Given |
| 2733 | int arr[5]; |
| 2734 | int a = 0; |
| 2735 | char b = (0); |
| 2736 | const int c = a; |
| 2737 | int *d = (arr); |
| 2738 | long e = ((long) 0l); |
| 2739 | The matchers |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2740 | varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) |
| 2741 | varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2742 | would match the declarations for a, b, c, and d, but not e. |
| 2743 | while |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2744 | varDecl(hasInitializer(integerLiteral())) |
| 2745 | varDecl(hasInitializer(declRefExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2746 | would only match the declaration for a. |
| 2747 | </pre></td></tr> |
| 2748 | |
| 2749 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2750 | <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] | 2751 | <tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 2752 | a given body. |
| 2753 | |
| 2754 | Given |
| 2755 | for (;;) {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2756 | hasBody(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2757 | matches 'for (;;) {}' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2758 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2759 | matching '{}' |
| 2760 | </pre></td></tr> |
| 2761 | |
| 2762 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2763 | <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] | 2764 | <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, |
| 2765 | or conditional operator. |
| 2766 | |
| 2767 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 2768 | if (true) {} |
| 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_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] | 2773 | <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. |
| 2774 | |
| 2775 | Example: |
| 2776 | forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) |
| 2777 | matches '++x' in |
| 2778 | for (x; x < N; ++x) { } |
| 2779 | </pre></td></tr> |
| 2780 | |
| 2781 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2782 | <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] | 2783 | <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. |
| 2784 | |
| 2785 | Example: |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2786 | forStmt(hasLoopInit(declStmt())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2787 | matches 'int x = 0' in |
| 2788 | for (int x = 0; x < N; ++x) { } |
| 2789 | </pre></td></tr> |
| 2790 | |
| 2791 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2792 | <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] | 2793 | <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. |
| 2794 | |
| 2795 | Does not match the 'this' parameter of a method. |
| 2796 | |
| 2797 | Given |
| 2798 | class X { void f(int x, int y, int z) {} }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2799 | methodDecl(hasAnyParameter(hasName("y"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2800 | matches f(int x, int y, int z) {} |
| 2801 | with hasAnyParameter(...) |
| 2802 | matching int y |
| 2803 | </pre></td></tr> |
| 2804 | |
| 2805 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2806 | <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] | 2807 | <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. |
| 2808 | |
| 2809 | Given |
| 2810 | class X { void f(int x) {} }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2811 | methodDecl(hasParameter(0, hasType(varDecl()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2812 | matches f(int x) {} |
| 2813 | with hasParameter(...) |
| 2814 | matching int x |
| 2815 | </pre></td></tr> |
| 2816 | |
| 2817 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2818 | <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] | 2819 | <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. |
| 2820 | |
| 2821 | Given: |
| 2822 | class X { int f() { return 1; } }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2823 | methodDecl(returns(asString("int"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2824 | matches int f() { return 1; } |
| 2825 | </pre></td></tr> |
| 2826 | |
| 2827 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2828 | <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] | 2829 | <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, |
| 2830 | or conditional operator. |
| 2831 | |
| 2832 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 2833 | if (true) {} |
| 2834 | </pre></td></tr> |
| 2835 | |
| 2836 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2837 | <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] | 2838 | <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. |
| 2839 | |
| 2840 | Given |
| 2841 | if (A* a = GetAPointer()) {} |
| 2842 | hasConditionVariableStatment(...) |
| 2843 | matches 'A* a = GetAPointer()'. |
| 2844 | </pre></td></tr> |
| 2845 | |
| 2846 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2847 | <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] | 2848 | <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given |
| 2849 | matcher. |
| 2850 | |
| 2851 | FIXME: Unit test this matcher |
| 2852 | </pre></td></tr> |
| 2853 | |
| 2854 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 2855 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('hasDeclaration2')"><a name="hasDeclaration2Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 2856 | <tr><td colspan="4" class="doc" id="hasDeclaration2"><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] | 2857 | matcher. |
| 2858 | |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 2859 | In addition to being usable as Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, also usable as |
| 2860 | Matcher<T> for any T supporting the getDecl() member function. e.g. various |
| 2861 | subtypes of clang::Type. |
| 2862 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2863 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 2864 | 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>>, |
| 2865 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2866 | </pre></td></tr> |
| 2867 | |
| 2868 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2869 | <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] | 2870 | <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is |
| 2871 | matched by a given matcher. |
| 2872 | |
| 2873 | Given |
| 2874 | struct X { int m; }; |
| 2875 | void f(X x) { x.m; m; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2876 | memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X"))))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2877 | matches "x.m" and "m" |
| 2878 | with hasObjectExpression(...) |
| 2879 | matching "x" and the implicit object expression of "m" which has type X*. |
| 2880 | </pre></td></tr> |
| 2881 | |
| 2882 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 2883 | <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] | 2884 | <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a |
| 2885 | given matcher. |
| 2886 | |
| 2887 | Given |
| 2888 | struct { int first, second; } first, second; |
| 2889 | int i(second.first); |
| 2890 | int j(first.second); |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 2891 | memberExpr(member(hasName("first"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 2892 | matches second.first |
| 2893 | but not first.second (because the member name there is "second"). |
| 2894 | </pre></td></tr> |
| 2895 | |
| 2896 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 2897 | <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> |
| 2898 | <tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the |
| 2899 | pointee matches a given matcher. |
| 2900 | |
| 2901 | Given |
| 2902 | int *a; |
| 2903 | int const *b; |
| 2904 | float const *f; |
| 2905 | pointerType(pointee(isConstQualified(), isInteger())) |
| 2906 | matches "int const *b" |
| 2907 | |
| 2908 | 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>>, |
| 2909 | 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>> |
| 2910 | </pre></td></tr> |
| 2911 | |
| 2912 | |
| 2913 | <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> |
| 2914 | <tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the |
| 2915 | pointee matches a given matcher. |
| 2916 | |
| 2917 | Given |
| 2918 | int *a; |
| 2919 | int const *b; |
| 2920 | float const *f; |
| 2921 | pointerType(pointee(isConstQualified(), isInteger())) |
| 2922 | matches "int const *b" |
| 2923 | |
| 2924 | 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>>, |
| 2925 | 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>> |
| 2926 | </pre></td></tr> |
| 2927 | |
| 2928 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 2929 | <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] | 2930 | <tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. |
| 2931 | |
| 2932 | Given |
| 2933 | struct A { struct B { struct C {}; }; }; |
| 2934 | A::B::C c; |
| 2935 | nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) |
| 2936 | matches "A::" |
| 2937 | </pre></td></tr> |
| 2938 | |
| 2939 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 2940 | <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> |
| 2941 | <tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner |
| 2942 | NestedNameSpecifier-matcher matches. |
| 2943 | </pre></td></tr> |
| 2944 | |
| 2945 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 2946 | <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> |
| 2947 | <tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the |
| 2948 | given TypeLoc. |
| 2949 | |
| 2950 | Given |
| 2951 | struct A { struct B { struct C {}; }; }; |
| 2952 | A::B::C c; |
| 2953 | nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( |
| 2954 | hasDeclaration(recordDecl(hasName("A"))))))) |
| 2955 | matches "A::" |
| 2956 | </pre></td></tr> |
| 2957 | |
| 2958 | |
Manuel Klimek | 415514d | 2013-02-06 20:36:22 +0000 | [diff] [blame] | 2959 | <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] | 2960 | <tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. |
| 2961 | |
| 2962 | Given |
| 2963 | struct A { struct B { struct C {}; }; }; |
| 2964 | A::B::C c; |
| 2965 | nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and |
| 2966 | matches "A::" |
| 2967 | </pre></td></tr> |
| 2968 | |
| 2969 | |
| 2970 | <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> |
| 2971 | <tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the |
| 2972 | given namespace matcher. |
| 2973 | |
| 2974 | Given |
| 2975 | namespace ns { struct A {}; } |
| 2976 | ns::A a; |
| 2977 | nestedNameSpecifier(specifiesNamespace(hasName("ns"))) |
| 2978 | matches "ns::" |
| 2979 | </pre></td></tr> |
| 2980 | |
| 2981 | |
| 2982 | <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> |
| 2983 | <tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the |
| 2984 | given QualType matcher without qualifiers. |
| 2985 | |
| 2986 | Given |
| 2987 | struct A { struct B { struct C {}; }; }; |
| 2988 | A::B::C c; |
| 2989 | nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A"))))) |
| 2990 | matches "A::" |
| 2991 | </pre></td></tr> |
| 2992 | |
| 2993 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 2994 | <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> |
| 2995 | <tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the |
| 2996 | pointee matches a given matcher. |
| 2997 | |
| 2998 | Given |
| 2999 | int *a; |
| 3000 | int const *b; |
| 3001 | float const *f; |
| 3002 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3003 | matches "int const *b" |
| 3004 | |
| 3005 | 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>>, |
| 3006 | 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>> |
| 3007 | </pre></td></tr> |
| 3008 | |
| 3009 | |
| 3010 | <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> |
| 3011 | <tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3012 | pointee matches a given matcher. |
| 3013 | |
| 3014 | Given |
| 3015 | int *a; |
| 3016 | int const *b; |
| 3017 | float const *f; |
| 3018 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3019 | matches "int const *b" |
| 3020 | |
| 3021 | 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>>, |
| 3022 | 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>> |
| 3023 | </pre></td></tr> |
| 3024 | |
| 3025 | |
Edwin Vane | 6a19a97 | 2013-03-06 17:02:57 +0000 | [diff] [blame] | 3026 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasCanonicalType0')"><a name="hasCanonicalType0Anchor">hasCanonicalType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
| 3027 | <tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. |
| 3028 | |
| 3029 | Given: |
| 3030 | typedef int &int_ref; |
| 3031 | int a; |
| 3032 | int_ref b = a; |
| 3033 | |
| 3034 | varDecl(hasType(qualType(referenceType()))))) will not match the |
| 3035 | declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. |
| 3036 | </pre></td></tr> |
| 3037 | |
| 3038 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3039 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasDeclaration5')"><a name="hasDeclaration5Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 3040 | <tr><td colspan="4" class="doc" id="hasDeclaration5"><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] | 3041 | matcher. |
| 3042 | |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 3043 | In addition to being usable as Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, also usable as |
| 3044 | Matcher<T> for any T supporting the getDecl() member function. e.g. various |
| 3045 | subtypes of clang::Type. |
| 3046 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3047 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3048 | 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>>, |
| 3049 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3050 | </pre></td></tr> |
| 3051 | |
| 3052 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3053 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 3054 | <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. |
| 3055 | </pre></td></tr> |
| 3056 | |
| 3057 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3058 | <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] | 3059 | <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. |
| 3060 | </pre></td></tr> |
| 3061 | |
| 3062 | |
Manuel Klimek | 41df16e | 2013-01-09 09:38:21 +0000 | [diff] [blame] | 3063 | <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> |
| 3064 | <tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3065 | pointee matches a given matcher. |
| 3066 | |
| 3067 | Given |
| 3068 | int *a; |
| 3069 | int const *b; |
| 3070 | float const *f; |
| 3071 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3072 | matches "int const *b" |
| 3073 | |
| 3074 | 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>>, |
| 3075 | 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>> |
| 3076 | </pre></td></tr> |
| 3077 | |
| 3078 | |
| 3079 | <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> |
| 3080 | <tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3081 | pointee matches a given matcher. |
| 3082 | |
| 3083 | Given |
| 3084 | int *a; |
| 3085 | int const *b; |
| 3086 | float const *f; |
| 3087 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3088 | matches "int const *b" |
| 3089 | |
| 3090 | 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>>, |
| 3091 | 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>> |
| 3092 | </pre></td></tr> |
| 3093 | |
| 3094 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3095 | <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] | 3096 | <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 3097 | alignof. |
| 3098 | </pre></td></tr> |
| 3099 | |
| 3100 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3101 | <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] | 3102 | <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 3103 | sizeof. |
| 3104 | </pre></td></tr> |
| 3105 | |
| 3106 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3107 | <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] | 3108 | <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a TemplateArgument that refers to a certain declaration. |
| 3109 | |
| 3110 | Given |
| 3111 | template<typename T> struct A {}; |
| 3112 | struct B { B* next; }; |
| 3113 | A<&B::next> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3114 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 3115 | refersToDeclaration(fieldDecl(hasName("next")))) |
| 3116 | matches the specialization A<&B::next> with fieldDecl(...) matching |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3117 | B::next |
| 3118 | </pre></td></tr> |
| 3119 | |
| 3120 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3121 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 3122 | <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. |
| 3123 | |
| 3124 | Given |
| 3125 | struct X {}; |
| 3126 | template<typename T> struct A {}; |
| 3127 | A<X> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3128 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3129 | refersToType(class(hasName("X"))))) |
| 3130 | matches the specialization A<X> |
| 3131 | </pre></td></tr> |
| 3132 | |
| 3133 | |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3134 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasDeclaration0')"><a name="hasDeclaration0Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Edwin Vane | 5238060 | 2013-02-19 17:14:34 +0000 | [diff] [blame] | 3135 | <tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a type if the declaration of the type matches the given |
| 3136 | matcher. |
| 3137 | |
| 3138 | In addition to being usable as Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, also usable as |
| 3139 | Matcher<T> for any T supporting the getDecl() member function. e.g. various |
| 3140 | subtypes of clang::Type. |
| 3141 | |
| 3142 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, |
Edwin Vane | 3abf778 | 2013-02-25 14:49:29 +0000 | [diff] [blame] | 3143 | 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>>, |
| 3144 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> |
| 3145 | </pre></td></tr> |
| 3146 | |
| 3147 | |
| 3148 | <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> |
| 3149 | <tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner |
| 3150 | QualType-matcher matches. |
| 3151 | </pre></td></tr> |
| 3152 | |
| 3153 | |
| 3154 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>></td><td class="name" onclick="toggle('hasDeclaration1')"><a name="hasDeclaration1Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 3155 | <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a type if the declaration of the type matches the given |
| 3156 | matcher. |
| 3157 | |
| 3158 | In addition to being usable as Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, also usable as |
| 3159 | Matcher<T> for any T supporting the getDecl() member function. e.g. various |
| 3160 | subtypes of clang::Type. |
| 3161 | |
| 3162 | 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>>, |
| 3163 | 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>>, |
| 3164 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3165 | </pre></td></tr> |
| 3166 | |
| 3167 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3168 | <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] | 3169 | <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. |
| 3170 | |
| 3171 | Given |
| 3172 | int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); |
| 3173 | unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) |
| 3174 | matches sizeof(a) and alignof(c) |
| 3175 | </pre></td></tr> |
| 3176 | |
| 3177 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3178 | <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] | 3179 | <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. |
| 3180 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3181 | Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true)))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3182 | !true |
| 3183 | </pre></td></tr> |
| 3184 | |
| 3185 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3186 | <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] | 3187 | <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. |
| 3188 | |
| 3189 | Given |
| 3190 | namespace X { void b(); } |
| 3191 | using X::b; |
| 3192 | usingDecl(hasAnyUsingShadowDecl(hasName("b")))) |
| 3193 | matches using X::b </pre></td></tr> |
| 3194 | |
| 3195 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3196 | <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] | 3197 | <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is |
| 3198 | matched by the given matcher. |
| 3199 | |
| 3200 | Given |
| 3201 | namespace X { int a; void b(); } |
| 3202 | using X::a; |
| 3203 | using X::b; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3204 | usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3205 | matches using X::b but not using X::a </pre></td></tr> |
| 3206 | |
| 3207 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3208 | <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] | 3209 | <tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value |
| 3210 | declaration's type. |
| 3211 | |
| 3212 | In case of a value declaration (for example a variable declaration), |
| 3213 | this resolves one layer of indirection. For example, in the value |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3214 | declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, |
| 3215 | while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3216 | of x." |
| 3217 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3218 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) |
| 3219 | and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3220 | class X {}; |
| 3221 | void y(X &x) { x; X z; } |
| 3222 | |
| 3223 | 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>> |
| 3224 | </pre></td></tr> |
| 3225 | |
| 3226 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3227 | <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] | 3228 | <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression |
| 3229 | that matches the given matcher. |
| 3230 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3231 | Example matches x (matcher = varDecl(hasInitializer(callExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3232 | bool y() { return true; } |
| 3233 | bool x = y(); |
| 3234 | </pre></td></tr> |
| 3235 | |
| 3236 | |
Daniel Jasper | e0b8997 | 2012-12-04 12:08:08 +0000 | [diff] [blame] | 3237 | <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> |
| 3238 | <tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size |
| 3239 | expression. |
| 3240 | |
| 3241 | Given |
| 3242 | void f(int b) { |
| 3243 | int a[b]; |
| 3244 | } |
| 3245 | variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( |
| 3246 | varDecl(hasName("b"))))))) |
| 3247 | matches "int a[b]" |
| 3248 | </pre></td></tr> |
| 3249 | |
| 3250 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3251 | <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] | 3252 | <tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 3253 | a given body. |
| 3254 | |
| 3255 | Given |
| 3256 | for (;;) {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3257 | hasBody(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3258 | matches 'for (;;) {}' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 3259 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 3260 | matching '{}' |
| 3261 | </pre></td></tr> |
| 3262 | |
| 3263 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 3264 | <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] | 3265 | <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, |
| 3266 | or conditional operator. |
| 3267 | |
| 3268 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 3269 | if (true) {} |
| 3270 | </pre></td></tr> |
| 3271 | |
| 3272 | <!--END_TRAVERSAL_MATCHERS --> |
| 3273 | </table> |
| 3274 | |
| 3275 | </div> |
| 3276 | </body> |
| 3277 | </html> |
| 3278 | |
| 3279 | |