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