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 | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 232 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 233 | <tr><td colspan="4" class="doc" id="boolLiteral0"><pre>Matches bool literals. |
| 234 | |
| 235 | Example matches true |
| 236 | true |
| 237 | </pre></td></tr> |
| 238 | |
| 239 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 240 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 241 | <tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. |
| 242 | |
| 243 | Example: castExpr() matches each of the following: |
| 244 | (int) 3; |
| 245 | const_cast<Expr *>(SubExpr); |
| 246 | char c = 0; |
| 247 | but does not match |
| 248 | int i = (0); |
| 249 | int k = 0; |
| 250 | </pre></td></tr> |
| 251 | |
| 252 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 253 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 254 | <tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). |
| 255 | |
| 256 | Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), |
| 257 | though. |
| 258 | |
| 259 | Example matches 'a', L'a' |
| 260 | char ch = 'a'; wchar_t chw = L'a'; |
| 261 | </pre></td></tr> |
| 262 | |
| 263 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 264 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 265 | <tr><td colspan="4" class="doc" id="constCastExpr0"><pre>Matches a const_cast expression. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 266 | |
| 267 | Example: Matches const_cast<int*>(&r) in |
| 268 | int n = 42; |
| 269 | const int &r(n); |
| 270 | int* p = const_cast<int*>(&r); |
| 271 | </pre></td></tr> |
| 272 | |
| 273 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 274 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 275 | <tr><td colspan="4" class="doc" id="dynamicCastExpr0"><pre>Matches a dynamic_cast expression. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 276 | |
| 277 | Example: |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 278 | dynamicCastExpr() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 279 | matches |
| 280 | dynamic_cast<D*>(&b); |
| 281 | in |
| 282 | struct B { virtual ~B() {} }; struct D : B {}; |
| 283 | B b; |
| 284 | D* p = dynamic_cast<D*>(&b); |
| 285 | </pre></td></tr> |
| 286 | |
| 287 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 288 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 289 | <tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 290 | |
| 291 | Matches any cast expression written in user code, whether it be a |
| 292 | C-style cast, a functional-style cast, or a keyword cast. |
| 293 | |
| 294 | Does not match implicit conversions. |
| 295 | |
| 296 | Note: the name "explicitCast" is chosen to match Clang's terminology, as |
| 297 | Clang uses the term "cast" to apply to implicit conversions as well as to |
| 298 | actual cast expressions. |
| 299 | |
| 300 | hasDestinationType. |
| 301 | |
| 302 | Example: matches all five of the casts in |
| 303 | int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) |
| 304 | but does not match the implicit conversion in |
| 305 | long ell = 42; |
| 306 | </pre></td></tr> |
| 307 | |
| 308 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 309 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 310 | <tr><td colspan="4" class="doc" id="functionalCastExpr0"><pre>Matches functional cast expressions |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 311 | |
| 312 | Example: Matches Foo(bar); |
| 313 | Foo f = bar; |
| 314 | Foo g = (Foo) bar; |
| 315 | Foo h = Foo(bar); |
| 316 | </pre></td></tr> |
| 317 | |
| 318 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 319 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 320 | <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 321 | |
| 322 | This matches many different places, including function call return value |
| 323 | eliding, as well as any type conversions. |
| 324 | </pre></td></tr> |
| 325 | |
| 326 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 327 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 328 | <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings. |
| 329 | |
| 330 | Not matching character-encoded integers such as L'a'. |
| 331 | |
| 332 | Example matches 1, 1L, 0x1, 1U |
| 333 | </pre></td></tr> |
| 334 | |
| 335 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 336 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 337 | <tr><td colspan="4" class="doc" id="reinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 338 | |
| 339 | Either the source expression or the destination type can be matched |
| 340 | using has(), but hasDestinationType() is more specific and can be |
| 341 | more readable. |
| 342 | |
| 343 | Example matches reinterpret_cast<char*>(&p) in |
| 344 | void* p = reinterpret_cast<char*>(&p); |
| 345 | </pre></td></tr> |
| 346 | |
| 347 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 348 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 349 | <tr><td colspan="4" class="doc" id="staticCastExpr0"><pre>Matches a C++ static_cast expression. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 350 | |
| 351 | hasDestinationType |
| 352 | reinterpretCast |
| 353 | |
| 354 | Example: |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 355 | staticCastExpr() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 356 | matches |
| 357 | static_cast<long>(8) |
| 358 | in |
| 359 | long eight(static_cast<long>(8)); |
| 360 | </pre></td></tr> |
| 361 | |
| 362 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 363 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 364 | <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). |
| 365 | |
| 366 | Example matches "abcd", L"abcd" |
| 367 | char *s = "abcd"; wchar_t *ws = L"abcd" |
| 368 | </pre></td></tr> |
| 369 | |
| 370 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 371 | <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] | 372 | <tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. |
| 373 | |
| 374 | Given |
| 375 | int i = a[1]; |
| 376 | arraySubscriptExpr() |
| 377 | matches "a[1]" |
| 378 | </pre></td></tr> |
| 379 | |
| 380 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 381 | <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] | 382 | <tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. |
| 383 | |
| 384 | Example matches a || b |
| 385 | !(a || b) |
| 386 | </pre></td></tr> |
| 387 | |
| 388 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 389 | <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] | 390 | <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] | 391 | |
| 392 | Example matches FunctionTakesString(GetStringByValue()) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 393 | (matcher = bindTemporaryExpr()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 394 | FunctionTakesString(GetStringByValue()); |
| 395 | FunctionTakesStringByPointer(GetStringPointer()); |
| 396 | </pre></td></tr> |
| 397 | |
| 398 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 399 | <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] | 400 | <tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 401 | |
| 402 | Example matches x.y() and y() |
| 403 | X x; |
| 404 | x.y(); |
| 405 | y(); |
| 406 | </pre></td></tr> |
| 407 | |
| 408 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 409 | <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] | 410 | <tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 411 | |
| 412 | Example matches '{}' and '{{}}'in 'for (;;) {{}}' |
| 413 | for (;;) {{}} |
| 414 | </pre></td></tr> |
| 415 | |
| 416 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 417 | <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] | 418 | <tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. |
| 419 | |
| 420 | Example matches a ? b : c |
| 421 | (a ? b : c) + 42 |
| 422 | </pre></td></tr> |
| 423 | |
| 424 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 425 | <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] | 426 | <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] | 427 | |
| 428 | Example matches string(ptr, n) and ptr within arguments of f |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 429 | (matcher = constructExpr()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 430 | void f(const string &a, const string &b); |
| 431 | char *ptr; |
| 432 | int n; |
| 433 | f(string(ptr, n), ptr); |
| 434 | </pre></td></tr> |
| 435 | |
| 436 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 437 | <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] | 438 | <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] | 439 | |
| 440 | Example matches x in if (x) |
| 441 | bool x; |
| 442 | if (x) {} |
| 443 | </pre></td></tr> |
| 444 | |
| 445 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 446 | <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] | 447 | <tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 448 | |
| 449 | Given |
| 450 | int a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 451 | declStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 452 | matches 'int a'. |
| 453 | </pre></td></tr> |
| 454 | |
| 455 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 456 | <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] | 457 | <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] | 458 | |
| 459 | Example matches the CXXDefaultArgExpr placeholder inserted for the |
| 460 | default value of the second parameter in the call expression f(42) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 461 | (matcher = defaultArgExpr()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 462 | void f(int x, int y = 0); |
| 463 | f(42); |
| 464 | </pre></td></tr> |
| 465 | |
| 466 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 467 | <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] | 468 | <tr><td colspan="4" class="doc" id="deleteExpr0"><pre>Matches delete expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 469 | |
| 470 | Given |
| 471 | delete X; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 472 | deleteExpr() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 473 | matches 'delete X'. |
| 474 | </pre></td></tr> |
| 475 | |
| 476 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 477 | <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] | 478 | <tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. |
| 479 | |
| 480 | Given |
| 481 | do {} while (true); |
| 482 | doStmt() |
| 483 | matches 'do {} while(true)' |
| 484 | </pre></td></tr> |
| 485 | |
| 486 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 487 | <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] | 488 | <tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 489 | |
| 490 | Example matches x() |
| 491 | void f() { x(); } |
| 492 | </pre></td></tr> |
| 493 | |
| 494 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 495 | <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] | 496 | <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. |
| 497 | |
| 498 | Example matches 'for (;;) {}' |
| 499 | for (;;) {} |
| 500 | </pre></td></tr> |
| 501 | |
| 502 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 503 | <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] | 504 | <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. |
| 505 | |
| 506 | Example matches 'if (x) {}' |
| 507 | if (x) {} |
| 508 | </pre></td></tr> |
| 509 | |
| 510 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 511 | <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] | 512 | <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. |
| 513 | |
| 514 | Given |
| 515 | int a[] = { 1, 2 }; |
| 516 | struct B { int x, y; }; |
| 517 | B b = { 5, 6 }; |
| 518 | initList() |
| 519 | matches "{ 1, 2 }" and "{ 5, 6 }" |
| 520 | </pre></td></tr> |
| 521 | |
| 522 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 523 | <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] | 524 | <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. |
| 525 | |
| 526 | Example: Given |
| 527 | struct T {void func()}; |
| 528 | T f(); |
| 529 | void g(T); |
| 530 | materializeTemporaryExpr() matches 'f()' in these statements |
| 531 | T u(f()); |
| 532 | g(f()); |
| 533 | but does not match |
| 534 | f(); |
| 535 | f().func(); |
| 536 | </pre></td></tr> |
| 537 | |
| 538 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 539 | <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] | 540 | <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] | 541 | |
| 542 | Example matches x.y() |
| 543 | X x; |
| 544 | x.y(); |
| 545 | </pre></td></tr> |
| 546 | |
| 547 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 548 | <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] | 549 | <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 550 | |
| 551 | Given |
| 552 | class Y { |
| 553 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 554 | int a; static int b; |
| 555 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 556 | memberExpr() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 557 | matches this->x, x, y.x, a, this->b |
| 558 | </pre></td></tr> |
| 559 | |
| 560 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 561 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('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] | 562 | <tr><td colspan="4" class="doc" id="newExpr0"><pre>Matches new expressions. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 563 | |
| 564 | Given |
| 565 | new X; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 566 | newExpr() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 567 | matches 'new X'. |
| 568 | </pre></td></tr> |
| 569 | |
| 570 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 571 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('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] | 572 | <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] | 573 | |
| 574 | Note that if an operator isn't overloaded, it won't match. Instead, use |
| 575 | binaryOperator matcher. |
| 576 | Currently it does not match operators such as new delete. |
| 577 | FIXME: figure out why these do not match? |
| 578 | |
| 579 | Example matches both operator<<((o << b), c) and operator<<(o, b) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 580 | (matcher = operatorCallExpr()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 581 | ostream &operator<< (ostream &out, int i) { }; |
| 582 | ostream &o; int b = 1, c = 1; |
| 583 | o << b << c; |
| 584 | </pre></td></tr> |
| 585 | |
| 586 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 587 | <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] | 588 | <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 589 | |
| 590 | Given |
| 591 | { ++a; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 592 | stmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 593 | matches both the compound statement '{ ++a; }' and '++a'. |
| 594 | </pre></td></tr> |
| 595 | |
| 596 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 597 | <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] | 598 | <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. |
| 599 | |
| 600 | Given |
| 601 | switch(a) { case 42: break; default: break; } |
| 602 | switchCase() |
| 603 | matches 'case 42: break;' and 'default: break;'. |
| 604 | </pre></td></tr> |
| 605 | |
| 606 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 607 | <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] | 608 | <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) |
| 609 | |
| 610 | Given |
| 611 | Foo x = bar; |
| 612 | int y = sizeof(x) + alignof(x); |
| 613 | unaryExprOrTypeTraitExpr() |
| 614 | matches sizeof(x) and alignof(x) |
| 615 | </pre></td></tr> |
| 616 | |
| 617 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 618 | <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] | 619 | <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. |
| 620 | |
| 621 | Example matches !a |
| 622 | !a || b |
| 623 | </pre></td></tr> |
| 624 | |
| 625 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 626 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('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] | 627 | <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. |
| 628 | |
| 629 | Given |
| 630 | while (true) {} |
| 631 | whileStmt() |
| 632 | matches 'while (true) {}'. |
| 633 | </pre></td></tr> |
| 634 | |
| 635 | <!--END_DECL_MATCHERS --> |
| 636 | </table> |
| 637 | |
| 638 | <!-- ======================================================================= --> |
| 639 | <h2 id="narrowing-matchers">Narrowing Matchers</h2> |
| 640 | <!-- ======================================================================= --> |
| 641 | |
| 642 | <p>Narrowing matchers match certain attributes on the current node, thus |
| 643 | narrowing down the set of nodes of the current type to match on.</p> |
| 644 | |
| 645 | <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) |
| 646 | which allow users to create more powerful match expressions.</p> |
| 647 | |
| 648 | <table> |
| 649 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| 650 | <!-- START_NARROWING_MATCHERS --> |
| 651 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 652 | <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] | 653 | <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. |
| 654 | |
| 655 | Usable as: Any Matcher |
| 656 | </pre></td></tr> |
| 657 | |
| 658 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 659 | <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] | 660 | <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. |
| 661 | |
| 662 | Usable as: Any Matcher |
| 663 | </pre></td></tr> |
| 664 | |
| 665 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 666 | <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] | 667 | <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. |
| 668 | |
| 669 | Useful when another matcher requires a child matcher, but there's no |
| 670 | additional constraint. This will often be used with an explicit conversion |
| 671 | to an internal::Matcher<> type such as TypeMatcher. |
| 672 | |
| 673 | Example: DeclarationMatcher(anything()) matches all declarations, e.g., |
| 674 | "int* p" and "void f()" in |
| 675 | int* p; |
| 676 | void f(); |
| 677 | |
| 678 | Usable as: Any Matcher |
| 679 | </pre></td></tr> |
| 680 | |
| 681 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 682 | <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] | 683 | <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. |
| 684 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 685 | Example matches Y (matcher = recordDecl(unless(hasName("X")))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 686 | class X {}; |
| 687 | class Y {}; |
| 688 | |
| 689 | Usable as: Any Matcher |
| 690 | </pre></td></tr> |
| 691 | |
| 692 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 693 | <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] | 694 | <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or |
| 695 | unary). |
| 696 | |
| 697 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 698 | !(a || b) |
| 699 | </pre></td></tr> |
| 700 | |
| 701 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 702 | <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] | 703 | <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value. |
| 704 | |
| 705 | Example matches true (matcher = boolLiteral(equals(true))) |
| 706 | true |
| 707 | |
| 708 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 709 | 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>> |
| 710 | </pre></td></tr> |
| 711 | |
| 712 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 713 | <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] | 714 | <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a constructor declaration that has been implicitly added |
| 715 | by the compiler (eg. implicit defaultcopy constructors). |
| 716 | </pre></td></tr> |
| 717 | |
| 718 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 719 | <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] | 720 | <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a contructor initializer if it is explicitly written in |
| 721 | code (as opposed to implicitly added by the compiler). |
| 722 | |
| 723 | Given |
| 724 | struct Foo { |
| 725 | Foo() { } |
| 726 | Foo(int) : foo_("A") { } |
| 727 | string foo_; |
| 728 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 729 | constructorDecl(hasAnyConstructorInitializer(isWritten())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 730 | will match Foo(int), but not Foo() |
| 731 | </pre></td></tr> |
| 732 | |
| 733 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 734 | <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] | 735 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. |
| 736 | |
| 737 | Matches overloaded operator names specified in strings without the |
| 738 | "operator" prefix, such as "<<", for OverloadedOperatorCall's. |
| 739 | |
| 740 | Example matches a << b |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 741 | (matcher == operatorCallExpr(hasOverloadedOperatorName("<<"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 742 | a << b; |
| 743 | c && d; assuming both operator<< |
| 744 | and operator&& are overloaded somewhere. |
| 745 | </pre></td></tr> |
| 746 | |
| 747 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 748 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isA1')"><a name="isA1Anchor">isA</a></td><td>StringRef BaseName</td></tr> |
| 749 | <tr><td colspan="4" class="doc" id="isA1"><pre>Overloaded method as shortcut for isA(hasName(...)). |
| 750 | </pre></td></tr> |
| 751 | |
| 752 | |
| 753 | <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] | 754 | <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). |
| 755 | </pre></td></tr> |
| 756 | |
| 757 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 758 | <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] | 759 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or |
| 760 | static member variable template instantiations. |
| 761 | |
| 762 | Given |
| 763 | template<typename T> void A(T t) { } |
| 764 | template<> void A(int N) { } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 765 | functionDecl(isExplicitTemplateSpecialization()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 766 | matches the specialization A<int>(). |
| 767 | |
| 768 | 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>> |
| 769 | </pre></td></tr> |
| 770 | |
| 771 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 772 | <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] | 773 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static |
| 774 | member variable template instantiations. |
| 775 | |
| 776 | Given |
| 777 | template <typename T> class X {}; class A {}; X<A> x; |
| 778 | or |
| 779 | template <typename T> class X {}; class A {}; template class X<A>; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 780 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 781 | matches the template instantiation of X<A>. |
| 782 | |
| 783 | But given |
| 784 | template <typename T> class X {}; class A {}; |
| 785 | template <> class X<A> {}; X<A> x; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 786 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 787 | does not match, as X<A> is an explicit template specialization. |
| 788 | |
| 789 | 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>> |
| 790 | </pre></td></tr> |
| 791 | |
| 792 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 793 | <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] | 794 | <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has |
| 795 | a specific number of arguments (including absent default arguments). |
| 796 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 797 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 798 | void f(int x, int y); |
| 799 | f(0, 0); |
| 800 | </pre></td></tr> |
| 801 | |
| 802 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 803 | <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] | 804 | <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value. |
| 805 | |
| 806 | Example matches true (matcher = boolLiteral(equals(true))) |
| 807 | true |
| 808 | |
| 809 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 810 | 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>> |
| 811 | </pre></td></tr> |
| 812 | |
| 813 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 814 | <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] | 815 | <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of |
| 816 | child statements. |
| 817 | |
| 818 | Example: Given |
| 819 | { for (;;) {} } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 820 | compoundStmt(statementCountIs(0))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 821 | matches '{}' |
| 822 | but does not match the outer compound statement. |
| 823 | </pre></td></tr> |
| 824 | |
| 825 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 826 | <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] | 827 | <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of |
| 828 | declarations. |
| 829 | |
| 830 | Example: Given |
| 831 | int a, b; |
| 832 | int c; |
| 833 | int d = 2, e; |
| 834 | declCountIs(2) |
| 835 | matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. |
| 836 | </pre></td></tr> |
| 837 | |
| 838 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 839 | <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] | 840 | <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. |
| 841 | |
| 842 | Example matches true (matcher = boolLiteral(equals(true))) |
| 843 | true |
| 844 | |
| 845 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 846 | 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>> |
| 847 | </pre></td></tr> |
| 848 | |
| 849 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 850 | <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] | 851 | <tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. |
| 852 | |
| 853 | Example matches A, va, fa |
| 854 | class A {}; |
| 855 | class B; Doesn't match, as it has no body. |
| 856 | int va; |
| 857 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 858 | void fa() {} |
| 859 | void fb(); Doesn't match, as it has no body. |
| 860 | |
| 861 | 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>> |
| 862 | </pre></td></tr> |
| 863 | |
| 864 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 865 | <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] | 866 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or |
| 867 | static member variable template instantiations. |
| 868 | |
| 869 | Given |
| 870 | template<typename T> void A(T t) { } |
| 871 | template<> void A(int N) { } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 872 | functionDecl(isExplicitTemplateSpecialization()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 873 | matches the specialization A<int>(). |
| 874 | |
| 875 | 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>> |
| 876 | </pre></td></tr> |
| 877 | |
| 878 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 879 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 880 | <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. |
| 881 | |
| 882 | Given: |
| 883 | extern "C" void f() {} |
| 884 | extern "C" { void g() {} } |
| 885 | void h() {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 886 | functionDecl(isExternC()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 887 | matches the declaration of f and g, but not the declaration h |
| 888 | </pre></td></tr> |
| 889 | |
| 890 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 891 | <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] | 892 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static |
| 893 | member variable template instantiations. |
| 894 | |
| 895 | Given |
| 896 | template <typename T> class X {}; class A {}; X<A> x; |
| 897 | or |
| 898 | template <typename T> class X {}; class A {}; template class X<A>; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 899 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 900 | matches the template instantiation of X<A>. |
| 901 | |
| 902 | But given |
| 903 | template <typename T> class X {}; class A {}; |
| 904 | template <> class X<A> {}; X<A> x; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 905 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 906 | does not match, as X<A> is an explicit template specialization. |
| 907 | |
| 908 | 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>> |
| 909 | </pre></td></tr> |
| 910 | |
| 911 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 912 | <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] | 913 | <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. |
| 914 | |
| 915 | Example matches true (matcher = boolLiteral(equals(true))) |
| 916 | true |
| 917 | |
| 918 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 919 | 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>> |
| 920 | </pre></td></tr> |
| 921 | |
| 922 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 923 | <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] | 924 | <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed |
| 925 | to '.'. |
| 926 | |
| 927 | Member calls on the implicit this pointer match as called with '->'. |
| 928 | |
| 929 | Given |
| 930 | class Y { |
| 931 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 932 | int a; |
| 933 | static int b; |
| 934 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 935 | memberExpr(isArrow()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 936 | matches this->x, x, y.x, a, this->b |
| 937 | </pre></td></tr> |
| 938 | |
| 939 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 940 | <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] | 941 | <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. |
| 942 | |
| 943 | Supports specifying enclosing namespaces or classes by prefixing the name |
| 944 | with '<enclosing>::'. |
| 945 | Does not match typedefs of an underlying type with the given name. |
| 946 | |
| 947 | Example matches X (Name == "X") |
| 948 | class X; |
| 949 | |
| 950 | Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") |
| 951 | namespace a { namespace b { class X; } } |
| 952 | </pre></td></tr> |
| 953 | |
| 954 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 955 | <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 | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 956 | <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose full names partially match the |
| 957 | given RegExp. |
| 958 | |
| 959 | Supports specifying enclosing namespaces or classes by |
| 960 | prefixing the name with '<enclosing>::'. Does not match typedefs |
| 961 | of an underlying type with the given name. |
| 962 | |
| 963 | Example matches X (regexp == "::X") |
| 964 | class X; |
| 965 | |
| 966 | Example matches X (regexp is one of "::X", "^foo::.*X", among others) |
| 967 | namespace foo { namespace bar { class X; } } |
| 968 | </pre></td></tr> |
| 969 | |
| 970 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 971 | <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] | 972 | <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. |
| 973 | |
| 974 | Given |
| 975 | class Y { public: void x(); }; |
| 976 | void z() { Y* y; y->x(); } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 977 | callExpr(on(hasType(asString("class Y *")))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 978 | matches y->x() |
| 979 | </pre></td></tr> |
| 980 | |
| 981 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 982 | <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] | 983 | <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that |
| 984 | include "top-level" const. |
| 985 | |
| 986 | Given |
| 987 | void a(int); |
| 988 | void b(int const); |
| 989 | void c(const int); |
| 990 | void d(const int*); |
| 991 | void e(int const) {}; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 992 | functionDecl(hasAnyParameter(hasType(isConstQualified()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 993 | matches "void b(int const)", "void c(const int)" and |
| 994 | "void e(int const) {}". It does not match d as there |
| 995 | is no top-level const on the parameter type "const int *". |
| 996 | </pre></td></tr> |
| 997 | |
| 998 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 999 | <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] | 1000 | <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. |
| 1001 | |
| 1002 | Given |
| 1003 | void a(int); |
| 1004 | void b(long); |
| 1005 | void c(double); |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1006 | functionDecl(hasAnyParameter(hasType(isInteger()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1007 | matches "a(int)", "b(long)", but not "c(double)". |
| 1008 | </pre></td></tr> |
| 1009 | |
| 1010 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1011 | <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] | 1012 | <tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. |
| 1013 | |
| 1014 | Example matches A, va, fa |
| 1015 | class A {}; |
| 1016 | class B; Doesn't match, as it has no body. |
| 1017 | int va; |
| 1018 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 1019 | void fa() {} |
| 1020 | void fb(); Doesn't match, as it has no body. |
| 1021 | |
| 1022 | 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>> |
| 1023 | </pre></td></tr> |
| 1024 | |
| 1025 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1026 | <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] | 1027 | <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. |
| 1028 | |
| 1029 | Given |
| 1030 | int x; |
| 1031 | int s = sizeof(x) + alignof(x) |
| 1032 | unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) |
| 1033 | matches sizeof(x) |
| 1034 | </pre></td></tr> |
| 1035 | |
| 1036 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1037 | <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] | 1038 | <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or |
| 1039 | unary). |
| 1040 | |
| 1041 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 1042 | !(a || b) |
| 1043 | </pre></td></tr> |
| 1044 | |
| 1045 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1046 | <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] | 1047 | <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. |
| 1048 | |
| 1049 | Example matches A, va, fa |
| 1050 | class A {}; |
| 1051 | class B; Doesn't match, as it has no body. |
| 1052 | int va; |
| 1053 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 1054 | void fa() {} |
| 1055 | void fb(); Doesn't match, as it has no body. |
| 1056 | |
| 1057 | 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>> |
| 1058 | </pre></td></tr> |
| 1059 | |
| 1060 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1061 | <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] | 1062 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or |
| 1063 | static member variable template instantiations. |
| 1064 | |
| 1065 | Given |
| 1066 | template<typename T> void A(T t) { } |
| 1067 | template<> void A(int N) { } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1068 | functionDecl(isExplicitTemplateSpecialization()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1069 | matches the specialization A<int>(). |
| 1070 | |
| 1071 | 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>> |
| 1072 | </pre></td></tr> |
| 1073 | |
| 1074 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1075 | <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] | 1076 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static |
| 1077 | member variable template instantiations. |
| 1078 | |
| 1079 | Given |
| 1080 | template <typename T> class X {}; class A {}; X<A> x; |
| 1081 | or |
| 1082 | template <typename T> class X {}; class A {}; template class X<A>; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1083 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1084 | matches the template instantiation of X<A>. |
| 1085 | |
| 1086 | But given |
| 1087 | template <typename T> class X {}; class A {}; |
| 1088 | template <> class X<A> {}; X<A> x; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1089 | recordDecl(hasName("::X"), isTemplateInstantiation()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1090 | does not match, as X<A> is an explicit template specialization. |
| 1091 | |
| 1092 | 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>> |
| 1093 | </pre></td></tr> |
| 1094 | |
| 1095 | <!--END_NARROWING_MATCHERS --> |
| 1096 | </table> |
| 1097 | |
| 1098 | <!-- ======================================================================= --> |
| 1099 | <h2 id="traversal-matchers">AST Traversal Matchers</h2> |
| 1100 | <!-- ======================================================================= --> |
| 1101 | |
| 1102 | <p>Traversal matchers specify the relationship to other nodes that are |
| 1103 | reachable from the current node.</p> |
| 1104 | |
| 1105 | <p>Note that there are special traversal matchers (has, hasDescendant, forEach and |
| 1106 | forEachDescendant) which work on all nodes and allow users to write more generic |
| 1107 | match expressions.</p> |
| 1108 | |
| 1109 | <table> |
| 1110 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| 1111 | <!-- START_TRAVERSAL_MATCHERS --> |
| 1112 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1113 | <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] | 1114 | <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the |
| 1115 | provided matcher. |
| 1116 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1117 | Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1118 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 1119 | class Y { class X {}; }; |
| 1120 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 1121 | |
| 1122 | ChildT must be an AST base type. |
| 1123 | |
| 1124 | As opposed to 'has', 'forEach' will cause a match for each result that |
| 1125 | matches instead of only on the first one. |
| 1126 | |
| 1127 | Usable as: Any Matcher |
| 1128 | </pre></td></tr> |
| 1129 | |
| 1130 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1131 | <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] | 1132 | <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 1133 | provided matcher. |
| 1134 | |
| 1135 | Example matches X, A, B, C |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1136 | (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1137 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 1138 | class A { class X {}; }; |
| 1139 | class B { class C { class X {}; }; }; |
| 1140 | |
| 1141 | DescendantT must be an AST base type. |
| 1142 | |
| 1143 | As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for |
| 1144 | each result that matches instead of only on the first one. |
| 1145 | |
| 1146 | Note: Recursively combined ForEachDescendant can cause many matches: |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1147 | recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl())))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1148 | will match 10 times (plus injected class name matches) on: |
| 1149 | class A { class B { class C { class D { class E {}; }; }; }; }; |
| 1150 | |
| 1151 | Usable as: Any Matcher |
| 1152 | </pre></td></tr> |
| 1153 | |
| 1154 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1155 | <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] | 1156 | <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the |
| 1157 | provided matcher. |
| 1158 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1159 | Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1160 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 1161 | class Y { class X {}; }; |
| 1162 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 1163 | |
| 1164 | ChildT must be an AST base type. |
| 1165 | |
| 1166 | Usable as: Any Matcher |
| 1167 | </pre></td></tr> |
| 1168 | |
| 1169 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1170 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<AncestorT> AncestorMatcher</td></tr> |
| 1171 | <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided |
| 1172 | matcher. |
| 1173 | |
| 1174 | Given |
| 1175 | void f() { if (true) { int x = 42; } } |
| 1176 | void g() { for (;;) { int x = 43; } } |
| 1177 | expr(integerLiteral(hasAncsestor(ifStmt()))) matches 42, but not 43. |
| 1178 | |
| 1179 | Usable as: Any Matcher |
| 1180 | </pre></td></tr> |
| 1181 | |
| 1182 | |
| 1183 | <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] | 1184 | <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 1185 | provided matcher. |
| 1186 | |
| 1187 | Example matches X, Y, Z |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1188 | (matcher = recordDecl(hasDescendant(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1189 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 1190 | class Y { class X {}; }; |
| 1191 | class Z { class Y { class X {}; }; }; |
| 1192 | |
| 1193 | DescendantT must be an AST base type. |
| 1194 | |
| 1195 | Usable as: Any Matcher |
| 1196 | </pre></td></tr> |
| 1197 | |
| 1198 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1199 | <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] | 1200 | <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. |
| 1201 | |
| 1202 | Given |
| 1203 | int i[5]; |
| 1204 | void f() { i[1] = 42; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1205 | arraySubscriptExpression(hasBase(implicitCastExpr( |
| 1206 | hasSourceExpression(declRefExpr())))) |
| 1207 | matches i[1] with the declRefExpr() matching i |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1208 | </pre></td></tr> |
| 1209 | |
| 1210 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1211 | <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] | 1212 | <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. |
| 1213 | |
| 1214 | Given |
| 1215 | int i[5]; |
| 1216 | void f() { i[1] = 42; } |
| 1217 | arraySubscriptExpression(hasIndex(integerLiteral())) |
| 1218 | matches i[1] with the integerLiteral() matching 1 |
| 1219 | </pre></td></tr> |
| 1220 | |
| 1221 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1222 | <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] | 1223 | <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a |
| 1224 | binary operator matches. |
| 1225 | </pre></td></tr> |
| 1226 | |
| 1227 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1228 | <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] | 1229 | <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. |
| 1230 | |
| 1231 | Example matches a (matcher = binaryOperator(hasLHS())) |
| 1232 | a || b |
| 1233 | </pre></td></tr> |
| 1234 | |
| 1235 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1236 | <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] | 1237 | <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. |
| 1238 | |
| 1239 | Example matches b (matcher = binaryOperator(hasRHS())) |
| 1240 | a || b |
| 1241 | </pre></td></tr> |
| 1242 | |
| 1243 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1244 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasDeclaration0')"><a name="hasDeclaration0Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1245 | <tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a type if the declaration of the type matches the given |
| 1246 | matcher. |
| 1247 | |
| 1248 | 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>> |
| 1249 | </pre></td></tr> |
| 1250 | |
| 1251 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1252 | <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] | 1253 | <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. |
| 1254 | |
| 1255 | Given |
| 1256 | struct Foo { |
| 1257 | Foo() : foo_(1) { } |
| 1258 | int foo_; |
| 1259 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1260 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything())))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1261 | record matches Foo, hasAnyConstructorInitializer matches foo_(1) |
| 1262 | </pre></td></tr> |
| 1263 | |
| 1264 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1265 | <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] | 1266 | <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. |
| 1267 | |
| 1268 | Given |
| 1269 | struct Foo { |
| 1270 | Foo() : foo_(1) { } |
| 1271 | int foo_; |
| 1272 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1273 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1274 | forField(hasName("foo_")))))) |
| 1275 | matches Foo |
| 1276 | with forField matching foo_ |
| 1277 | </pre></td></tr> |
| 1278 | |
| 1279 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1280 | <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] | 1281 | <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. |
| 1282 | |
| 1283 | Given |
| 1284 | struct Foo { |
| 1285 | Foo() : foo_(1) { } |
| 1286 | int foo_; |
| 1287 | }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1288 | recordDecl(has(constructorDecl(hasAnyConstructorInitializer( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1289 | withInitializer(integerLiteral(equals(1))))))) |
| 1290 | matches Foo |
| 1291 | with withInitializer matching (1) |
| 1292 | </pre></td></tr> |
| 1293 | |
| 1294 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1295 | <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] | 1296 | <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. |
| 1297 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1298 | Example matches y.x() (matcher = callExpr(on(hasType(recordDecl(hasName("Y")))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1299 | class Y { public: void x(); }; |
| 1300 | void z() { Y y; y.x(); }", |
| 1301 | |
| 1302 | FIXME: Overload to allow directly matching types? |
| 1303 | </pre></td></tr> |
| 1304 | |
| 1305 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1306 | <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] | 1307 | <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> |
| 1308 | |
| 1309 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1310 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 1311 | <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. |
| 1312 | </pre></td></tr> |
| 1313 | |
| 1314 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1315 | <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] | 1316 | <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration |
| 1317 | belongs to. |
| 1318 | |
| 1319 | FIXME: Generalize this for other kinds of declarations. |
| 1320 | FIXME: What other kind of declarations would we need to generalize |
| 1321 | this to? |
| 1322 | |
| 1323 | Example matches A() in the last line |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1324 | (matcher = constructExpr(hasDeclaration(methodDecl( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1325 | ofClass(hasName("A")))))) |
| 1326 | class A { |
| 1327 | public: |
| 1328 | A(); |
| 1329 | }; |
| 1330 | A a = A(); |
| 1331 | </pre></td></tr> |
| 1332 | |
| 1333 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1334 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isA0')"><a name="isA0Anchor">isA</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> Base</td></tr> |
| 1335 | <tr><td colspan="4" class="doc" id="isA0"><pre>Similar to isDerivedFrom(), but also matches classes that directly |
| 1336 | match Base. |
| 1337 | </pre></td></tr> |
| 1338 | |
| 1339 | |
| 1340 | <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] | 1341 | <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from |
| 1342 | a class matching Base. |
| 1343 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1344 | Note that a class is not considered to be derived from itself. |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1345 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1346 | Example matches Y, Z, C (Base == hasName("X")) |
| 1347 | class X; |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1348 | class Y : public X {}; directly derived |
| 1349 | class Z : public Y {}; indirectly derived |
| 1350 | typedef X A; |
| 1351 | typedef A B; |
| 1352 | class C : public B {}; derived from a typedef of X |
| 1353 | |
| 1354 | In the following example, Bar matches isDerivedFrom(hasName("X")): |
| 1355 | class Foo; |
| 1356 | typedef Foo X; |
| 1357 | class Bar : public Foo {}; derived from a type that X is a typedef of |
| 1358 | </pre></td></tr> |
| 1359 | |
| 1360 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1361 | <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] | 1362 | <tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the |
| 1363 | given matcher. |
| 1364 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1365 | Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1366 | class Y { public: void x(); }; |
| 1367 | void z() { Y y; y.x(); |
| 1368 | </pre></td></tr> |
| 1369 | |
| 1370 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1371 | <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] | 1372 | <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call |
| 1373 | expression. |
| 1374 | |
| 1375 | Given |
| 1376 | void x(int, int, int) { int y; x(1, y, 42); } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1377 | callExpr(hasAnyArgument(declRefExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1378 | matches x(1, y, 42) |
| 1379 | with hasAnyArgument(...) |
| 1380 | matching y |
| 1381 | </pre></td></tr> |
| 1382 | |
| 1383 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1384 | <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] | 1385 | <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor |
| 1386 | call expression. |
| 1387 | |
| 1388 | Example matches y in x(y) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1389 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1390 | void x(int) { int y; x(y); } |
| 1391 | </pre></td></tr> |
| 1392 | |
| 1393 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1394 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasDeclaration1')"><a name="hasDeclaration1Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1395 | <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a type if the declaration of the type matches the given |
| 1396 | matcher. |
| 1397 | |
| 1398 | 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>> |
| 1399 | </pre></td></tr> |
| 1400 | |
| 1401 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1402 | <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] | 1403 | <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher. |
| 1404 | |
| 1405 | Example: matches "a string" (matcher = |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1406 | hasSourceExpression(constructExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1407 | class URL { URL(string); }; |
| 1408 | URL url = "a string"; |
| 1409 | </pre></td></tr> |
| 1410 | |
| 1411 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1412 | <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] | 1413 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one |
| 1414 | TemplateArgument matching the given InnerMatcher. |
| 1415 | |
| 1416 | Given |
| 1417 | template<typename T> class A {}; |
| 1418 | template<> class A<double> {}; |
| 1419 | A<int> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1420 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1421 | refersToType(asString("int")))) |
| 1422 | matches the specialization A<int> |
| 1423 | </pre></td></tr> |
| 1424 | |
| 1425 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1426 | <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] | 1427 | <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument |
| 1428 | matches the given InnerMatcher. |
| 1429 | |
| 1430 | Given |
| 1431 | template<typename T, typename U> class A {}; |
| 1432 | A<bool, int> b; |
| 1433 | A<int, bool> c; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1434 | classTemplateSpecializationDecl(hasTemplateArgument( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1435 | 1, refersToType(asString("int")))) |
| 1436 | matches the specialization A<bool, int> |
| 1437 | </pre></td></tr> |
| 1438 | |
| 1439 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1440 | <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] | 1441 | <tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches |
| 1442 | a given matcher. |
| 1443 | |
| 1444 | Given |
| 1445 | { {}; 1+2; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1446 | hasAnySubstatement(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1447 | matches '{ {}; 1+2; }' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1448 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1449 | matching '{}' |
| 1450 | </pre></td></tr> |
| 1451 | |
| 1452 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1453 | <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] | 1454 | <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, |
| 1455 | or conditional operator. |
| 1456 | |
| 1457 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 1458 | if (true) {} |
| 1459 | </pre></td></tr> |
| 1460 | |
| 1461 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1462 | <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] | 1463 | <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator. |
| 1464 | |
| 1465 | Example matches b |
| 1466 | condition ? a : b |
| 1467 | </pre></td></tr> |
| 1468 | |
| 1469 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1470 | <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] | 1471 | <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. |
| 1472 | |
| 1473 | Example matches a |
| 1474 | condition ? a : b |
| 1475 | </pre></td></tr> |
| 1476 | |
| 1477 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1478 | <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] | 1479 | <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a |
| 1480 | specific using shadow declaration. |
| 1481 | |
| 1482 | FIXME: This currently only works for functions. Fix. |
| 1483 | |
| 1484 | Given |
| 1485 | namespace a { void f() {} } |
| 1486 | using a::f; |
| 1487 | void g() { |
| 1488 | f(); Matches this .. |
| 1489 | a::f(); .. but not this. |
| 1490 | } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1491 | declRefExpr(throughUsingDeclaration(anything())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1492 | matches f() |
| 1493 | </pre></td></tr> |
| 1494 | |
| 1495 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1496 | <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] | 1497 | <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the |
| 1498 | specified matcher. |
| 1499 | |
| 1500 | Example matches x in if(x) |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1501 | (matcher = declRefExpr(to(varDecl(hasName("x"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1502 | bool x; |
| 1503 | if (x) {} |
| 1504 | </pre></td></tr> |
| 1505 | |
| 1506 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1507 | <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] | 1508 | <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. |
| 1509 | |
| 1510 | Note that this does not work for global declarations because the AST |
| 1511 | breaks up multiple-declaration DeclStmt's into multiple single-declaration |
| 1512 | DeclStmt's. |
| 1513 | Example: Given non-global declarations |
| 1514 | int a, b = 0; |
| 1515 | int c; |
| 1516 | int d = 2, e; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1517 | declStmt(containsDeclaration( |
| 1518 | 0, varDecl(hasInitializer(anything())))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1519 | matches only 'int d = 2, e;', and |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1520 | declStmt(containsDeclaration(1, varDecl())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1521 | matches 'int a, b = 0' as well as 'int d = 2, e;' |
| 1522 | but 'int c;' is not matched. |
| 1523 | </pre></td></tr> |
| 1524 | |
| 1525 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1526 | <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] | 1527 | <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. |
| 1528 | |
| 1529 | Given |
| 1530 | int a, b; |
| 1531 | int c; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1532 | declStmt(hasSingleDecl(anything())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1533 | matches 'int c;' but not 'int a, b;'. |
| 1534 | </pre></td></tr> |
| 1535 | |
| 1536 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1537 | <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] | 1538 | <tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 1539 | a given body. |
| 1540 | |
| 1541 | Given |
| 1542 | for (;;) {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1543 | hasBody(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1544 | matches 'for (;;) {}' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1545 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1546 | matching '{}' |
| 1547 | </pre></td></tr> |
| 1548 | |
| 1549 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1550 | <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] | 1551 | <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, |
| 1552 | or conditional operator. |
| 1553 | |
| 1554 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 1555 | if (true) {} |
| 1556 | </pre></td></tr> |
| 1557 | |
| 1558 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1559 | <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] | 1560 | <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. |
| 1561 | |
| 1562 | (Note: Clang's AST refers to other conversions as "casts" too, and calls |
| 1563 | actual casts "explicit" casts.) |
| 1564 | </pre></td></tr> |
| 1565 | |
| 1566 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1567 | <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] | 1568 | <tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value |
| 1569 | declaration's type. |
| 1570 | |
| 1571 | In case of a value declaration (for example a variable declaration), |
| 1572 | this resolves one layer of indirection. For example, in the value |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1573 | declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, |
| 1574 | while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1575 | of x." |
| 1576 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1577 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) |
| 1578 | and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1579 | class X {}; |
| 1580 | void y(X &x) { x; X z; } |
| 1581 | |
| 1582 | 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>> |
| 1583 | </pre></td></tr> |
| 1584 | |
| 1585 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1586 | <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] | 1587 | <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts |
| 1588 | are stripped off. |
| 1589 | |
| 1590 | Parentheses and explicit casts are not discarded. |
| 1591 | Given |
| 1592 | int arr[5]; |
| 1593 | int a = 0; |
| 1594 | char b = 0; |
| 1595 | const int c = a; |
| 1596 | int *d = arr; |
| 1597 | long e = (long) 0l; |
| 1598 | The matchers |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1599 | varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) |
| 1600 | varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1601 | would match the declarations for a, b, c, and d, but not e. |
| 1602 | While |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1603 | varDecl(hasInitializer(integerLiteral())) |
| 1604 | varDecl(hasInitializer(declRefExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1605 | only match the declarations for b, c, and d. |
| 1606 | </pre></td></tr> |
| 1607 | |
| 1608 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1609 | <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] | 1610 | <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and |
| 1611 | casts are stripped off. |
| 1612 | |
| 1613 | Implicit and non-C Style casts are also discarded. |
| 1614 | Given |
| 1615 | int a = 0; |
| 1616 | char b = (0); |
| 1617 | void* c = reinterpret_cast<char*>(0); |
| 1618 | char d = char(0); |
| 1619 | The matcher |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1620 | varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1621 | would match the declarations for a, b, c, and d. |
| 1622 | while |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1623 | varDecl(hasInitializer(integerLiteral())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1624 | only match the declaration for a. |
| 1625 | </pre></td></tr> |
| 1626 | |
| 1627 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1628 | <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] | 1629 | <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and |
| 1630 | parentheses are stripped off. |
| 1631 | |
| 1632 | Explicit casts are not discarded. |
| 1633 | Given |
| 1634 | int arr[5]; |
| 1635 | int a = 0; |
| 1636 | char b = (0); |
| 1637 | const int c = a; |
| 1638 | int *d = (arr); |
| 1639 | long e = ((long) 0l); |
| 1640 | The matchers |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1641 | varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) |
| 1642 | varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1643 | would match the declarations for a, b, c, and d, but not e. |
| 1644 | while |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1645 | varDecl(hasInitializer(integerLiteral())) |
| 1646 | varDecl(hasInitializer(declRefExpr())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1647 | would only match the declaration for a. |
| 1648 | </pre></td></tr> |
| 1649 | |
| 1650 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1651 | <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] | 1652 | <tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 1653 | a given body. |
| 1654 | |
| 1655 | Given |
| 1656 | for (;;) {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1657 | hasBody(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1658 | matches 'for (;;) {}' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1659 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1660 | matching '{}' |
| 1661 | </pre></td></tr> |
| 1662 | |
| 1663 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1664 | <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] | 1665 | <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, |
| 1666 | or conditional operator. |
| 1667 | |
| 1668 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 1669 | if (true) {} |
| 1670 | </pre></td></tr> |
| 1671 | |
| 1672 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1673 | <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] | 1674 | <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. |
| 1675 | |
| 1676 | Example: |
| 1677 | forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) |
| 1678 | matches '++x' in |
| 1679 | for (x; x < N; ++x) { } |
| 1680 | </pre></td></tr> |
| 1681 | |
| 1682 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1683 | <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] | 1684 | <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. |
| 1685 | |
| 1686 | Example: |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1687 | forStmt(hasLoopInit(declStmt())) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1688 | matches 'int x = 0' in |
| 1689 | for (int x = 0; x < N; ++x) { } |
| 1690 | </pre></td></tr> |
| 1691 | |
| 1692 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1693 | <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] | 1694 | <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. |
| 1695 | |
| 1696 | Does not match the 'this' parameter of a method. |
| 1697 | |
| 1698 | Given |
| 1699 | class X { void f(int x, int y, int z) {} }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1700 | methodDecl(hasAnyParameter(hasName("y"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1701 | matches f(int x, int y, int z) {} |
| 1702 | with hasAnyParameter(...) |
| 1703 | matching int y |
| 1704 | </pre></td></tr> |
| 1705 | |
| 1706 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1707 | <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] | 1708 | <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. |
| 1709 | |
| 1710 | Given |
| 1711 | class X { void f(int x) {} }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1712 | methodDecl(hasParameter(0, hasType(varDecl()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1713 | matches f(int x) {} |
| 1714 | with hasParameter(...) |
| 1715 | matching int x |
| 1716 | </pre></td></tr> |
| 1717 | |
| 1718 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1719 | <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] | 1720 | <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. |
| 1721 | |
| 1722 | Given: |
| 1723 | class X { int f() { return 1; } }; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1724 | methodDecl(returns(asString("int"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1725 | matches int f() { return 1; } |
| 1726 | </pre></td></tr> |
| 1727 | |
| 1728 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1729 | <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] | 1730 | <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, |
| 1731 | or conditional operator. |
| 1732 | |
| 1733 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 1734 | if (true) {} |
| 1735 | </pre></td></tr> |
| 1736 | |
| 1737 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1738 | <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] | 1739 | <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. |
| 1740 | |
| 1741 | Given |
| 1742 | if (A* a = GetAPointer()) {} |
| 1743 | hasConditionVariableStatment(...) |
| 1744 | matches 'A* a = GetAPointer()'. |
| 1745 | </pre></td></tr> |
| 1746 | |
| 1747 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1748 | <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] | 1749 | <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given |
| 1750 | matcher. |
| 1751 | |
| 1752 | FIXME: Unit test this matcher |
| 1753 | </pre></td></tr> |
| 1754 | |
| 1755 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1756 | <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] | 1757 | <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is |
| 1758 | matched by a given matcher. |
| 1759 | |
| 1760 | Given |
| 1761 | struct X { int m; }; |
| 1762 | void f(X x) { x.m; m; } |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1763 | memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X"))))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1764 | matches "x.m" and "m" |
| 1765 | with hasObjectExpression(...) |
| 1766 | matching "x" and the implicit object expression of "m" which has type X*. |
| 1767 | </pre></td></tr> |
| 1768 | |
| 1769 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1770 | <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] | 1771 | <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a |
| 1772 | given matcher. |
| 1773 | |
| 1774 | Given |
| 1775 | struct { int first, second; } first, second; |
| 1776 | int i(second.first); |
| 1777 | int j(first.second); |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1778 | memberExpr(member(hasName("first"))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1779 | matches second.first |
| 1780 | but not first.second (because the member name there is "second"). |
| 1781 | </pre></td></tr> |
| 1782 | |
| 1783 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1784 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasDeclaration2')"><a name="hasDeclaration2Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1785 | <tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a type if the declaration of the type matches the given |
| 1786 | matcher. |
| 1787 | |
| 1788 | 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>> |
| 1789 | </pre></td></tr> |
| 1790 | |
| 1791 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1792 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 1793 | <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. |
| 1794 | </pre></td></tr> |
| 1795 | |
| 1796 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1797 | <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] | 1798 | <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. |
| 1799 | </pre></td></tr> |
| 1800 | |
| 1801 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1802 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 1803 | <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 1804 | alignof. |
| 1805 | </pre></td></tr> |
| 1806 | |
| 1807 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1808 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 1809 | <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 1810 | sizeof. |
| 1811 | </pre></td></tr> |
| 1812 | |
| 1813 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1814 | <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] | 1815 | <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a TemplateArgument that refers to a certain declaration. |
| 1816 | |
| 1817 | Given |
| 1818 | template<typename T> struct A {}; |
| 1819 | struct B { B* next; }; |
| 1820 | A<&B::next> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1821 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 1822 | refersToDeclaration(fieldDecl(hasName("next")))) |
| 1823 | matches the specialization A<&B::next> with fieldDecl(...) matching |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1824 | B::next |
| 1825 | </pre></td></tr> |
| 1826 | |
| 1827 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1828 | <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] | 1829 | <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. |
| 1830 | |
| 1831 | Given |
| 1832 | struct X {}; |
| 1833 | template<typename T> struct A {}; |
| 1834 | A<X> a; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1835 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1836 | refersToType(class(hasName("X"))))) |
| 1837 | matches the specialization A<X> |
| 1838 | </pre></td></tr> |
| 1839 | |
| 1840 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1841 | <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] | 1842 | <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. |
| 1843 | |
| 1844 | Given |
| 1845 | int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); |
| 1846 | unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) |
| 1847 | matches sizeof(a) and alignof(c) |
| 1848 | </pre></td></tr> |
| 1849 | |
| 1850 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1851 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 1852 | <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. |
| 1853 | |
| 1854 | Example matches true (matcher = hasOperand(boolLiteral(equals(true)))) |
| 1855 | !true |
| 1856 | </pre></td></tr> |
| 1857 | |
| 1858 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1859 | <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] | 1860 | <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. |
| 1861 | |
| 1862 | Given |
| 1863 | namespace X { void b(); } |
| 1864 | using X::b; |
| 1865 | usingDecl(hasAnyUsingShadowDecl(hasName("b")))) |
| 1866 | matches using X::b </pre></td></tr> |
| 1867 | |
| 1868 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1869 | <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] | 1870 | <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is |
| 1871 | matched by the given matcher. |
| 1872 | |
| 1873 | Given |
| 1874 | namespace X { int a; void b(); } |
| 1875 | using X::a; |
| 1876 | using X::b; |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1877 | usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1878 | matches using X::b but not using X::a </pre></td></tr> |
| 1879 | |
| 1880 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1881 | <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] | 1882 | <tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value |
| 1883 | declaration's type. |
| 1884 | |
| 1885 | In case of a value declaration (for example a variable declaration), |
| 1886 | this resolves one layer of indirection. For example, in the value |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1887 | declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, |
| 1888 | while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1889 | of x." |
| 1890 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1891 | Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) |
| 1892 | and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1893 | class X {}; |
| 1894 | void y(X &x) { x; X z; } |
| 1895 | |
| 1896 | 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>> |
| 1897 | </pre></td></tr> |
| 1898 | |
| 1899 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1900 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 1901 | <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression |
| 1902 | that matches the given matcher. |
| 1903 | |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1904 | Example matches x (matcher = varDecl(hasInitializer(callExpr()))) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1905 | bool y() { return true; } |
| 1906 | bool x = y(); |
| 1907 | </pre></td></tr> |
| 1908 | |
| 1909 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1910 | <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] | 1911 | <tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has |
| 1912 | a given body. |
| 1913 | |
| 1914 | Given |
| 1915 | for (;;) {} |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1916 | hasBody(compoundStmt()) |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1917 | matches 'for (;;) {}' |
Manuel Klimek | e44a006 | 2012-08-26 23:55:24 +0000 | [diff] [blame] | 1918 | with compoundStmt() |
Manuel Klimek | 1da7933 | 2012-08-20 20:54:03 +0000 | [diff] [blame] | 1919 | matching '{}' |
| 1920 | </pre></td></tr> |
| 1921 | |
| 1922 | |
Manuel Klimek | 67619ff | 2012-09-07 13:10:32 +0000 | [diff] [blame] | 1923 | <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] | 1924 | <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, |
| 1925 | or conditional operator. |
| 1926 | |
| 1927 | Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) |
| 1928 | if (true) {} |
| 1929 | </pre></td></tr> |
| 1930 | |
| 1931 | <!--END_TRAVERSAL_MATCHERS --> |
| 1932 | </table> |
| 1933 | |
| 1934 | </div> |
| 1935 | </body> |
| 1936 | </html> |
| 1937 | |
| 1938 | |