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