Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +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) { |
| 23 | if (!id) return; |
| 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> |
| 32 | <body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))"> |
| 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 | <p>Note that the categorization of matchers is a great help when you combine |
| 61 | them into matcher expressions. You will usually want to form matcher expressions |
| 62 | that read like english sentences by alternating between node matchers and |
| 63 | narrowing or traversal matchers, like this: |
| 64 | <pre> |
| 65 | recordDecl(hasDescendant( |
| 66 | ifStmt(hasTrueExpression( |
| 67 | expr(hasDescendant( |
| 68 | ifStmt())))))) |
| 69 | </pre> |
| 70 | </p> |
| 71 | |
| 72 | <!-- ======================================================================= --> |
| 73 | <h2 id="decl-matchers">Node Matchers</h2> |
| 74 | <!-- ======================================================================= --> |
| 75 | |
| 76 | <p>Node matchers are at the core of matcher expressions - they specify the type |
| 77 | of node that is expected. Every match expression starts with a node matcher, |
| 78 | which can then be further refined with a narrowing or traversal matcher. All |
| 79 | traversal matchers take node matchers as their arguments.</p> |
| 80 | |
| 81 | <p>For convenience, all node matchers take an arbitrary number of arguments |
| 82 | and implicitly act as allOf matchers.</p> |
| 83 | |
| 84 | <p>Node matchers are the only matchers that support the bind("id") call to |
| 85 | bind the matched node to the given string, to be later retrieved from the |
| 86 | match callback.</p> |
| 87 | |
| 88 | <p>It is important to remember that the arguments to node matchers are |
| 89 | predicates on the same node, just with additional information about the type. |
| 90 | This is often useful to make matcher expression more readable by inlining bind |
| 91 | calls into redundant node matchers inside another node matcher: |
| 92 | <pre> |
| 93 | // This binds the CXXRecordDecl to "id", as the decl() matcher will stay on |
| 94 | // the same node. |
| 95 | recordDecl(decl().bind("id"), hasName("::MyClass")) |
| 96 | </pre> |
| 97 | </p> |
| 98 | |
| 99 | <table> |
| 100 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 101 | <!-- START_DECL_MATCHERS --> |
| 102 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 103 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('cxxCtorInitializer0')"><a name="cxxCtorInitializer0Anchor">cxxCtorInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 104 | <tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers. |
| 105 | |
| 106 | Examples matches i(42). |
| 107 | class C { |
| 108 | C() : i(42) {} |
| 109 | int i; |
| 110 | }; |
| 111 | </pre></td></tr> |
| 112 | |
| 113 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 114 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('accessSpecDecl0')"><a name="accessSpecDecl0Anchor">accessSpecDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AccessSpecDecl.html">AccessSpecDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 115 | <tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations. |
| 116 | |
| 117 | Given |
| 118 | class C { |
| 119 | public: |
| 120 | int a; |
| 121 | }; |
| 122 | accessSpecDecl() |
| 123 | matches 'public:' |
| 124 | </pre></td></tr> |
| 125 | |
| 126 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 127 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 128 | <tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations. |
| 129 | |
| 130 | Example matches Z |
| 131 | template<class T> class Z {}; |
| 132 | </pre></td></tr> |
| 133 | |
| 134 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +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('classTemplateSpecializationDecl0')"><a name="classTemplateSpecializationDecl0Anchor">classTemplateSpecializationDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 136 | <tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations. |
| 137 | |
| 138 | Given |
| 139 | template<typename T> class A {}; |
| 140 | template<> class A<double> {}; |
| 141 | A<int> a; |
| 142 | classTemplateSpecializationDecl() |
| 143 | matches the specializations A<int> and A<double> |
| 144 | </pre></td></tr> |
| 145 | |
| 146 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 147 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxConstructorDecl0')"><a name="cxxConstructorDecl0Anchor">cxxConstructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 148 | <tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations. |
| 149 | |
| 150 | Example matches Foo::Foo() and Foo::Foo(int) |
| 151 | class Foo { |
| 152 | public: |
| 153 | Foo(); |
| 154 | Foo(int); |
| 155 | int DoSomething(); |
| 156 | }; |
| 157 | </pre></td></tr> |
| 158 | |
| 159 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 160 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxConversionDecl0')"><a name="cxxConversionDecl0Anchor">cxxConversionDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 161 | <tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations. |
| 162 | |
| 163 | Example matches the operator. |
| 164 | class X { operator int() const; }; |
| 165 | </pre></td></tr> |
| 166 | |
| 167 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 168 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxDestructorDecl0')"><a name="cxxDestructorDecl0Anchor">cxxDestructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 169 | <tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations. |
| 170 | |
| 171 | Example matches Foo::~Foo() |
| 172 | class Foo { |
| 173 | public: |
| 174 | virtual ~Foo(); |
| 175 | }; |
| 176 | </pre></td></tr> |
| 177 | |
| 178 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 179 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxMethodDecl0')"><a name="cxxMethodDecl0Anchor">cxxMethodDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 180 | <tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations. |
| 181 | |
| 182 | Example matches y |
| 183 | class X { void y(); }; |
| 184 | </pre></td></tr> |
| 185 | |
| 186 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 187 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxRecordDecl0')"><a name="cxxRecordDecl0Anchor">cxxRecordDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 188 | <tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations. |
| 189 | |
| 190 | Example matches X, Z |
| 191 | class X; |
| 192 | template<class T> class Z {}; |
| 193 | </pre></td></tr> |
| 194 | |
| 195 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 196 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 197 | <tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. |
| 198 | |
| 199 | Examples matches X, C, and the friend declaration inside C; |
| 200 | void X(); |
| 201 | class C { |
| 202 | friend X; |
| 203 | }; |
| 204 | </pre></td></tr> |
| 205 | |
| 206 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 207 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('declaratorDecl0')"><a name="declaratorDecl0Anchor">declaratorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 208 | <tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function |
| 209 | and non-type template parameter declarations). |
| 210 | |
| 211 | Given |
| 212 | class X { int y; }; |
| 213 | declaratorDecl() |
| 214 | matches int y. |
| 215 | </pre></td></tr> |
| 216 | |
| 217 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 218 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 219 | <tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. |
| 220 | |
| 221 | Example matches A, B, C |
| 222 | enum X { |
| 223 | A, B, C |
| 224 | }; |
| 225 | </pre></td></tr> |
| 226 | |
| 227 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 228 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 229 | <tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. |
| 230 | |
| 231 | Example matches X |
| 232 | enum X { |
| 233 | A, B, C |
| 234 | }; |
| 235 | </pre></td></tr> |
| 236 | |
| 237 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 238 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 239 | <tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. |
| 240 | |
| 241 | Given |
| 242 | class X { int m; }; |
| 243 | fieldDecl() |
| 244 | matches 'm'. |
| 245 | </pre></td></tr> |
| 246 | |
| 247 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 248 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('friendDecl0')"><a name="friendDecl0Anchor">friendDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 249 | <tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations. |
| 250 | |
| 251 | Given |
| 252 | class X { friend void foo(); }; |
| 253 | friendDecl() |
| 254 | matches 'friend void foo()'. |
| 255 | </pre></td></tr> |
| 256 | |
| 257 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 258 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 259 | <tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. |
| 260 | |
| 261 | Example matches f |
| 262 | void f(); |
| 263 | </pre></td></tr> |
| 264 | |
| 265 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 266 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 267 | <tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. |
| 268 | |
| 269 | Example matches f |
| 270 | template<class T> void f(T t) {} |
| 271 | </pre></td></tr> |
| 272 | |
| 273 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 274 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('linkageSpecDecl0')"><a name="linkageSpecDecl0Anchor">linkageSpecDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LinkageSpecDecl.html">LinkageSpecDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 275 | <tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification. |
| 276 | |
| 277 | Given |
| 278 | extern "C" {} |
| 279 | linkageSpecDecl() |
| 280 | matches "extern "C" {}" |
| 281 | </pre></td></tr> |
| 282 | |
| 283 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 284 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 285 | <tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. |
| 286 | |
| 287 | Example matches X, S, the anonymous union type, i, and U; |
| 288 | typedef int X; |
| 289 | struct S { |
| 290 | union { |
| 291 | int i; |
| 292 | } U; |
| 293 | }; |
| 294 | </pre></td></tr> |
| 295 | |
| 296 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 297 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('namespaceAliasDecl0')"><a name="namespaceAliasDecl0Anchor">namespaceAliasDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceAliasDecl.html">NamespaceAliasDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 298 | <tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias. |
| 299 | |
| 300 | Given |
| 301 | namespace test {} |
| 302 | namespace alias = ::test; |
| 303 | namespaceAliasDecl() |
| 304 | matches "namespace alias" but not "namespace test" |
| 305 | </pre></td></tr> |
| 306 | |
| 307 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 308 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('namespaceDecl0')"><a name="namespaceDecl0Anchor">namespaceDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 309 | <tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. |
| 310 | |
| 311 | Given |
| 312 | namespace {} |
| 313 | namespace test {} |
| 314 | namespaceDecl() |
| 315 | matches "namespace {}" and "namespace test {}" |
| 316 | </pre></td></tr> |
| 317 | |
| 318 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 319 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('nonTypeTemplateParmDecl0')"><a name="nonTypeTemplateParmDecl0Anchor">nonTypeTemplateParmDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NonTypeTemplateParmDecl.html">NonTypeTemplateParmDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 320 | <tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations. |
| 321 | |
| 322 | Given |
| 323 | template <typename T, int N> struct C {}; |
| 324 | nonTypeTemplateParmDecl() |
| 325 | matches 'N', but not 'T'. |
| 326 | </pre></td></tr> |
| 327 | |
| 328 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 329 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcInterfaceDecl0')"><a name="objcInterfaceDecl0Anchor">objcInterfaceDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 330 | <tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations. |
| 331 | |
| 332 | Example matches Foo |
| 333 | @interface Foo |
| 334 | @end |
| 335 | </pre></td></tr> |
| 336 | |
| 337 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 338 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('parmVarDecl0')"><a name="parmVarDecl0Anchor">parmVarDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 339 | <tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. |
| 340 | |
| 341 | Given |
| 342 | void f(int x); |
| 343 | parmVarDecl() |
| 344 | matches int x. |
| 345 | </pre></td></tr> |
| 346 | |
| 347 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 348 | <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_1RecordDecl.html">RecordDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 349 | <tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations. |
| 350 | |
| 351 | Example matches X, Z, U, and S |
| 352 | class X; |
| 353 | template<class T> class Z {}; |
| 354 | struct S {}; |
| 355 | union U {}; |
| 356 | </pre></td></tr> |
| 357 | |
| 358 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 359 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('staticAssertDecl0')"><a name="staticAssertDecl0Anchor">staticAssertDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StaticAssertDecl.html">StaticAssertDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 360 | <tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration. |
| 361 | |
| 362 | Example: |
| 363 | staticAssertExpr() |
| 364 | matches |
| 365 | static_assert(sizeof(S) == sizeof(int)) |
| 366 | in |
| 367 | struct S { |
| 368 | int x; |
| 369 | }; |
| 370 | static_assert(sizeof(S) == sizeof(int)); |
| 371 | </pre></td></tr> |
| 372 | |
| 373 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 374 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('templateTypeParmDecl0')"><a name="templateTypeParmDecl0Anchor">templateTypeParmDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmDecl.html">TemplateTypeParmDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 375 | <tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations. |
| 376 | |
| 377 | Given |
| 378 | template <typename T, int N> struct C {}; |
| 379 | templateTypeParmDecl() |
| 380 | matches 'T', but not 'N'. |
| 381 | </pre></td></tr> |
| 382 | |
| 383 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 384 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('translationUnitDecl0')"><a name="translationUnitDecl0Anchor">translationUnitDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TranslationUnitDecl.html">TranslationUnitDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 385 | <tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context. |
| 386 | |
| 387 | Given |
| 388 | int X; |
| 389 | namespace NS { |
| 390 | int Y; |
| 391 | } namespace NS |
| 392 | decl(hasDeclContext(translationUnitDecl())) |
| 393 | matches "int X", but not "int Y". |
| 394 | </pre></td></tr> |
| 395 | |
| 396 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 397 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typedefDecl0')"><a name="typedefDecl0Anchor">typedefDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html">TypedefDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 398 | <tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations. |
| 399 | |
| 400 | Given |
| 401 | typedef int X; |
| 402 | typedefDecl() |
| 403 | matches "typedef int X" |
| 404 | </pre></td></tr> |
| 405 | |
| 406 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 407 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('unresolvedUsingTypenameDecl0')"><a name="unresolvedUsingTypenameDecl0Anchor">unresolvedUsingTypenameDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingTypenameDecl.html">UnresolvedUsingTypenameDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 408 | <tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the |
| 409 | typename. |
| 410 | |
| 411 | Given |
| 412 | template <typename T> |
| 413 | struct Base { typedef T Foo; }; |
| 414 | |
| 415 | template<typename T> |
| 416 | struct S : private Base<T> { |
| 417 | using typename Base<T>::Foo; |
| 418 | }; |
| 419 | unresolvedUsingTypenameDecl() |
| 420 | matches using Base<T>::Foo </pre></td></tr> |
| 421 | |
| 422 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 423 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('unresolvedUsingValueDecl0')"><a name="unresolvedUsingValueDecl0Anchor">unresolvedUsingValueDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingValueDecl.html">UnresolvedUsingValueDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 424 | <tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations. |
| 425 | |
| 426 | Given |
| 427 | template<typename X> |
| 428 | class C : private X { |
| 429 | using X::x; |
| 430 | }; |
| 431 | unresolvedUsingValueDecl() |
| 432 | matches using X::x </pre></td></tr> |
| 433 | |
| 434 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 435 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 436 | <tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. |
| 437 | |
| 438 | Given |
| 439 | namespace X { int x; } |
| 440 | using X::x; |
| 441 | usingDecl() |
| 442 | matches using X::x </pre></td></tr> |
| 443 | |
| 444 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 445 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('usingDirectiveDecl0')"><a name="usingDirectiveDecl0Anchor">usingDirectiveDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDirectiveDecl.html">UsingDirectiveDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 446 | <tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations. |
| 447 | |
| 448 | Given |
| 449 | namespace X { int x; } |
| 450 | using namespace X; |
| 451 | usingDirectiveDecl() |
| 452 | matches using namespace X </pre></td></tr> |
| 453 | |
| 454 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 455 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('valueDecl0')"><a name="valueDecl0Anchor">valueDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 456 | <tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration. |
| 457 | |
| 458 | Example matches A, B, C and F |
| 459 | enum X { A, B, C }; |
| 460 | void F(); |
| 461 | </pre></td></tr> |
| 462 | |
| 463 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 464 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 465 | <tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. |
| 466 | |
| 467 | Note: this does not match declarations of member variables, which are |
| 468 | "field" declarations in Clang parlance. |
| 469 | |
| 470 | Example matches a |
| 471 | int a; |
| 472 | </pre></td></tr> |
| 473 | |
| 474 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 475 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>></td><td class="name" onclick="toggle('nestedNameSpecifierLoc0')"><a name="nestedNameSpecifierLoc0Anchor">nestedNameSpecifierLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 476 | <tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. |
| 477 | </pre></td></tr> |
| 478 | |
| 479 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 480 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>></td><td class="name" onclick="toggle('nestedNameSpecifier0')"><a name="nestedNameSpecifier0Anchor">nestedNameSpecifier</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 481 | <tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. |
| 482 | |
| 483 | Given |
| 484 | namespace ns { |
| 485 | struct A { static void f(); }; |
| 486 | void A::f() {} |
| 487 | void g() { A::f(); } |
| 488 | } |
| 489 | ns::A a; |
| 490 | nestedNameSpecifier() |
| 491 | matches "ns::" and both "A::" |
| 492 | </pre></td></tr> |
| 493 | |
| 494 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 495 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('qualType0')"><a name="qualType0Anchor">qualType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 496 | <tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. |
| 497 | </pre></td></tr> |
| 498 | |
| 499 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 500 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 501 | <tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. |
| 502 | |
| 503 | Given |
| 504 | int i = a[1]; |
| 505 | arraySubscriptExpr() |
| 506 | matches "a[1]" |
| 507 | </pre></td></tr> |
| 508 | |
| 509 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 510 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 511 | <tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. |
| 512 | |
| 513 | int i = 100; |
| 514 | __asm("mov al, 2"); |
| 515 | asmStmt() |
| 516 | matches '__asm("mov al, 2")' |
| 517 | </pre></td></tr> |
| 518 | |
| 519 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 520 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 521 | <tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. |
| 522 | |
| 523 | Example matches a || b |
| 524 | !(a || b) |
| 525 | </pre></td></tr> |
| 526 | |
| 527 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 528 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 529 | <tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. |
| 530 | |
| 531 | Given |
| 532 | while (true) { break; } |
| 533 | breakStmt() |
| 534 | matches 'break' |
| 535 | </pre></td></tr> |
| 536 | |
| 537 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 538 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 539 | <tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. |
| 540 | |
| 541 | Example: Matches (int*) 2.2f in |
| 542 | int i = (int) 2.2f; |
| 543 | </pre></td></tr> |
| 544 | |
| 545 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 546 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 547 | <tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. |
| 548 | |
| 549 | Example matches x.y() and y() |
| 550 | X x; |
| 551 | x.y(); |
| 552 | y(); |
| 553 | </pre></td></tr> |
| 554 | |
| 555 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 556 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('caseStmt0')"><a name="caseStmt0Anchor">caseStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 557 | <tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. |
| 558 | |
| 559 | Given |
| 560 | switch(a) { case 42: break; default: break; } |
| 561 | caseStmt() |
| 562 | matches 'case 42: break;'. |
| 563 | </pre></td></tr> |
| 564 | |
| 565 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 566 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 567 | <tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. |
| 568 | |
| 569 | Example: castExpr() matches each of the following: |
| 570 | (int) 3; |
| 571 | const_cast<Expr *>(SubExpr); |
| 572 | char c = 0; |
| 573 | but does not match |
| 574 | int i = (0); |
| 575 | int k = 0; |
| 576 | </pre></td></tr> |
| 577 | |
| 578 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 579 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 580 | <tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). |
| 581 | |
| 582 | Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), |
| 583 | though. |
| 584 | |
| 585 | Example matches 'a', L'a' |
| 586 | char ch = 'a'; wchar_t chw = L'a'; |
| 587 | </pre></td></tr> |
| 588 | |
| 589 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 590 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('compoundLiteralExpr0')"><a name="compoundLiteralExpr0Anchor">compoundLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 591 | <tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals |
| 592 | |
| 593 | Example match: {1}, (1, 2) |
| 594 | int array[4] = {1}; vector int myvec = (vector int)(1, 2); |
| 595 | </pre></td></tr> |
| 596 | |
| 597 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 598 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 599 | <tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. |
| 600 | |
| 601 | Example matches '{}' and '{{}}'in 'for (;;) {{}}' |
| 602 | for (;;) {{}} |
| 603 | </pre></td></tr> |
| 604 | |
| 605 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 606 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 607 | <tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. |
| 608 | |
| 609 | Example matches a ? b : c |
| 610 | (a ? b : c) + 42 |
| 611 | </pre></td></tr> |
| 612 | |
| 613 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 614 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 615 | <tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. |
| 616 | |
| 617 | Given |
| 618 | while (true) { continue; } |
| 619 | continueStmt() |
| 620 | matches 'continue' |
| 621 | </pre></td></tr> |
| 622 | |
| 623 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 624 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cudaKernelCallExpr0')"><a name="cudaKernelCallExpr0Anchor">cudaKernelCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 625 | <tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression. |
| 626 | |
| 627 | Example matches, |
| 628 | kernel<<<i,j>>>(); |
| 629 | </pre></td></tr> |
| 630 | |
| 631 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 632 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxBindTemporaryExpr0')"><a name="cxxBindTemporaryExpr0Anchor">cxxBindTemporaryExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 633 | <tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created. |
| 634 | |
| 635 | Example matches FunctionTakesString(GetStringByValue()) |
| 636 | (matcher = cxxBindTemporaryExpr()) |
| 637 | FunctionTakesString(GetStringByValue()); |
| 638 | FunctionTakesStringByPointer(GetStringPointer()); |
| 639 | </pre></td></tr> |
| 640 | |
| 641 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 642 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxBoolLiteral0')"><a name="cxxBoolLiteral0Anchor">cxxBoolLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 643 | <tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals. |
| 644 | |
| 645 | Example matches true |
| 646 | true |
| 647 | </pre></td></tr> |
| 648 | |
| 649 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 650 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxCatchStmt0')"><a name="cxxCatchStmt0Anchor">cxxCatchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 651 | <tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements. |
| 652 | |
| 653 | try {} catch(int i) {} |
| 654 | cxxCatchStmt() |
| 655 | matches 'catch(int i)' |
| 656 | </pre></td></tr> |
| 657 | |
| 658 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 659 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxConstCastExpr0')"><a name="cxxConstCastExpr0Anchor">cxxConstCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 660 | <tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression. |
| 661 | |
| 662 | Example: Matches const_cast<int*>(&r) in |
| 663 | int n = 42; |
| 664 | const int &r(n); |
| 665 | int* p = const_cast<int*>(&r); |
| 666 | </pre></td></tr> |
| 667 | |
| 668 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 669 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxConstructExpr0')"><a name="cxxConstructExpr0Anchor">cxxConstructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 670 | <tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones). |
| 671 | |
| 672 | Example matches string(ptr, n) and ptr within arguments of f |
| 673 | (matcher = cxxConstructExpr()) |
| 674 | void f(const string &a, const string &b); |
| 675 | char *ptr; |
| 676 | int n; |
| 677 | f(string(ptr, n), ptr); |
| 678 | </pre></td></tr> |
| 679 | |
| 680 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 681 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDefaultArgExpr0')"><a name="cxxDefaultArgExpr0Anchor">cxxDefaultArgExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 682 | <tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site. |
| 683 | |
| 684 | Example matches the CXXDefaultArgExpr placeholder inserted for the |
| 685 | default value of the second parameter in the call expression f(42) |
| 686 | (matcher = cxxDefaultArgExpr()) |
| 687 | void f(int x, int y = 0); |
| 688 | f(42); |
| 689 | </pre></td></tr> |
| 690 | |
| 691 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 692 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDeleteExpr0')"><a name="cxxDeleteExpr0Anchor">cxxDeleteExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 693 | <tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions. |
| 694 | |
| 695 | Given |
| 696 | delete X; |
| 697 | cxxDeleteExpr() |
| 698 | matches 'delete X'. |
| 699 | </pre></td></tr> |
| 700 | |
| 701 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 702 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDynamicCastExpr0')"><a name="cxxDynamicCastExpr0Anchor">cxxDynamicCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 703 | <tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression. |
| 704 | |
| 705 | Example: |
| 706 | cxxDynamicCastExpr() |
| 707 | matches |
| 708 | dynamic_cast<D*>(&b); |
| 709 | in |
| 710 | struct B { virtual ~B() {} }; struct D : B {}; |
| 711 | B b; |
| 712 | D* p = dynamic_cast<D*>(&b); |
| 713 | </pre></td></tr> |
| 714 | |
| 715 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 716 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxForRangeStmt0')"><a name="cxxForRangeStmt0Anchor">cxxForRangeStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 717 | <tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements. |
| 718 | |
| 719 | cxxForRangeStmt() matches 'for (auto a : i)' |
| 720 | int i[] = {1, 2, 3}; for (auto a : i); |
| 721 | for(int j = 0; j < 5; ++j); |
| 722 | </pre></td></tr> |
| 723 | |
| 724 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 725 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxFunctionalCastExpr0')"><a name="cxxFunctionalCastExpr0Anchor">cxxFunctionalCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 726 | <tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions |
| 727 | |
| 728 | Example: Matches Foo(bar); |
| 729 | Foo f = bar; |
| 730 | Foo g = (Foo) bar; |
| 731 | Foo h = Foo(bar); |
| 732 | </pre></td></tr> |
| 733 | |
| 734 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 735 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxMemberCallExpr0')"><a name="cxxMemberCallExpr0Anchor">cxxMemberCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 736 | <tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions. |
| 737 | |
| 738 | Example matches x.y() |
| 739 | X x; |
| 740 | x.y(); |
| 741 | </pre></td></tr> |
| 742 | |
| 743 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 744 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxNewExpr0')"><a name="cxxNewExpr0Anchor">cxxNewExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 745 | <tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions. |
| 746 | |
| 747 | Given |
| 748 | new X; |
| 749 | cxxNewExpr() |
| 750 | matches 'new X'. |
| 751 | </pre></td></tr> |
| 752 | |
| 753 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 754 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxNullPtrLiteralExpr0')"><a name="cxxNullPtrLiteralExpr0Anchor">cxxNullPtrLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 755 | <tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal. |
| 756 | </pre></td></tr> |
| 757 | |
| 758 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 759 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxOperatorCallExpr0')"><a name="cxxOperatorCallExpr0Anchor">cxxOperatorCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 760 | <tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls. |
| 761 | |
| 762 | Note that if an operator isn't overloaded, it won't match. Instead, use |
| 763 | binaryOperator matcher. |
| 764 | Currently it does not match operators such as new delete. |
| 765 | FIXME: figure out why these do not match? |
| 766 | |
| 767 | Example matches both operator<<((o << b), c) and operator<<(o, b) |
| 768 | (matcher = cxxOperatorCallExpr()) |
| 769 | ostream &operator<< (ostream &out, int i) { }; |
| 770 | ostream &o; int b = 1, c = 1; |
| 771 | o << b << c; |
| 772 | </pre></td></tr> |
| 773 | |
| 774 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 775 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxReinterpretCastExpr0')"><a name="cxxReinterpretCastExpr0Anchor">cxxReinterpretCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 776 | <tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. |
| 777 | |
| 778 | Either the source expression or the destination type can be matched |
| 779 | using has(), but hasDestinationType() is more specific and can be |
| 780 | more readable. |
| 781 | |
| 782 | Example matches reinterpret_cast<char*>(&p) in |
| 783 | void* p = reinterpret_cast<char*>(&p); |
| 784 | </pre></td></tr> |
| 785 | |
| 786 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 787 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxStaticCastExpr0')"><a name="cxxStaticCastExpr0Anchor">cxxStaticCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 788 | <tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression. |
| 789 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 790 | See also: hasDestinationType |
| 791 | See also: reinterpretCast |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 792 | |
| 793 | Example: |
| 794 | cxxStaticCastExpr() |
| 795 | matches |
| 796 | static_cast<long>(8) |
| 797 | in |
| 798 | long eight(static_cast<long>(8)); |
| 799 | </pre></td></tr> |
| 800 | |
| 801 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 802 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxTemporaryObjectExpr0')"><a name="cxxTemporaryObjectExpr0Anchor">cxxTemporaryObjectExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 803 | <tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments |
| 804 | |
| 805 | Example: Matches Foo(bar, bar) |
| 806 | Foo h = Foo(bar, bar); |
| 807 | </pre></td></tr> |
| 808 | |
| 809 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 810 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxThisExpr0')"><a name="cxxThisExpr0Anchor">cxxThisExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 811 | <tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions. |
| 812 | |
| 813 | Example matches the implicit this expression in "return i". |
| 814 | (matcher = cxxThisExpr()) |
| 815 | struct foo { |
| 816 | int i; |
| 817 | int f() { return i; } |
| 818 | }; |
| 819 | </pre></td></tr> |
| 820 | |
| 821 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 822 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxThrowExpr0')"><a name="cxxThrowExpr0Anchor">cxxThrowExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 823 | <tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions. |
| 824 | |
| 825 | try { throw 5; } catch(int i) {} |
| 826 | cxxThrowExpr() |
| 827 | matches 'throw 5' |
| 828 | </pre></td></tr> |
| 829 | |
| 830 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 831 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxTryStmt0')"><a name="cxxTryStmt0Anchor">cxxTryStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 832 | <tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements. |
| 833 | |
| 834 | try {} catch(int i) {} |
| 835 | cxxTryStmt() |
| 836 | matches 'try {}' |
| 837 | </pre></td></tr> |
| 838 | |
| 839 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 840 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxUnresolvedConstructExpr0')"><a name="cxxUnresolvedConstructExpr0Anchor">cxxUnresolvedConstructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 841 | <tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. |
| 842 | |
| 843 | Example matches T(t) in return statement of f |
| 844 | (matcher = cxxUnresolvedConstructExpr()) |
| 845 | template <typename T> |
| 846 | void f(const T& t) { return T(t); } |
| 847 | </pre></td></tr> |
| 848 | |
| 849 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 850 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 851 | <tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. |
| 852 | |
| 853 | Example matches x in if (x) |
| 854 | bool x; |
| 855 | if (x) {} |
| 856 | </pre></td></tr> |
| 857 | |
| 858 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 859 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 860 | <tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. |
| 861 | |
| 862 | Given |
| 863 | int a; |
| 864 | declStmt() |
| 865 | matches 'int a'. |
| 866 | </pre></td></tr> |
| 867 | |
| 868 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 869 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('defaultStmt0')"><a name="defaultStmt0Anchor">defaultStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DefaultStmt.html">DefaultStmt</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 870 | <tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. |
| 871 | |
| 872 | Given |
| 873 | switch(a) { case 42: break; default: break; } |
| 874 | defaultStmt() |
| 875 | matches 'default: break;'. |
| 876 | </pre></td></tr> |
| 877 | |
| 878 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 879 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 880 | <tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. |
| 881 | |
| 882 | Given |
| 883 | do {} while (true); |
| 884 | doStmt() |
| 885 | matches 'do {} while(true)' |
| 886 | </pre></td></tr> |
| 887 | |
| 888 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 889 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 890 | <tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. |
| 891 | |
| 892 | Matches any cast expression written in user code, whether it be a |
| 893 | C-style cast, a functional-style cast, or a keyword cast. |
| 894 | |
| 895 | Does not match implicit conversions. |
| 896 | |
| 897 | Note: the name "explicitCast" is chosen to match Clang's terminology, as |
| 898 | Clang uses the term "cast" to apply to implicit conversions as well as to |
| 899 | actual cast expressions. |
| 900 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 901 | See also: hasDestinationType. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 902 | |
| 903 | Example: matches all five of the casts in |
| 904 | int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) |
| 905 | but does not match the implicit conversion in |
| 906 | long ell = 42; |
| 907 | </pre></td></tr> |
| 908 | |
| 909 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 910 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 911 | <tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. |
| 912 | |
| 913 | Example matches x() |
| 914 | void f() { x(); } |
| 915 | </pre></td></tr> |
| 916 | |
| 917 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 918 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('exprWithCleanups0')"><a name="exprWithCleanups0Anchor">exprWithCleanups</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ExprWithCleanups.html">ExprWithCleanups</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 919 | <tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end |
| 920 | of the sub-expression's evaluation. |
| 921 | |
| 922 | Example matches std::string() |
| 923 | const std::string str = std::string(); |
| 924 | </pre></td></tr> |
| 925 | |
| 926 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 927 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('floatLiteral0')"><a name="floatLiteral0Anchor">floatLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 928 | <tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g. |
| 929 | 1.0, 1.0f, 1.0L and 1e10. |
| 930 | |
| 931 | Does not match implicit conversions such as |
| 932 | float a = 10; |
| 933 | </pre></td></tr> |
| 934 | |
| 935 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 936 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 937 | <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. |
| 938 | |
| 939 | Example matches 'for (;;) {}' |
| 940 | for (;;) {} |
| 941 | int i[] = {1, 2, 3}; for (auto a : i); |
| 942 | </pre></td></tr> |
| 943 | |
| 944 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 945 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('gnuNullExpr0')"><a name="gnuNullExpr0Anchor">gnuNullExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1GNUNullExpr.html">GNUNullExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 946 | <tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. |
| 947 | </pre></td></tr> |
| 948 | |
| 949 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 950 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 951 | <tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. |
| 952 | |
| 953 | Given |
| 954 | goto FOO; |
| 955 | FOO: bar(); |
| 956 | gotoStmt() |
| 957 | matches 'goto FOO' |
| 958 | </pre></td></tr> |
| 959 | |
| 960 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 961 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 962 | <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. |
| 963 | |
| 964 | Example matches 'if (x) {}' |
| 965 | if (x) {} |
| 966 | </pre></td></tr> |
| 967 | |
| 968 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 969 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 970 | <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. |
| 971 | |
| 972 | This matches many different places, including function call return value |
| 973 | eliding, as well as any type conversions. |
| 974 | </pre></td></tr> |
| 975 | |
| 976 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 977 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 978 | <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. |
| 979 | |
| 980 | Given |
| 981 | int a[] = { 1, 2 }; |
| 982 | struct B { int x, y; }; |
| 983 | B b = { 5, 6 }; |
| 984 | initListExpr() |
| 985 | matches "{ 1, 2 }" and "{ 5, 6 }" |
| 986 | </pre></td></tr> |
| 987 | |
| 988 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 989 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 990 | <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g. |
| 991 | 1, 1L, 0x1 and 1U. |
| 992 | |
| 993 | Does not match character-encoded integers such as L'a'. |
| 994 | </pre></td></tr> |
| 995 | |
| 996 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 997 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 998 | <tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. |
| 999 | |
| 1000 | Given |
| 1001 | goto FOO; |
| 1002 | FOO: bar(); |
| 1003 | labelStmt() |
| 1004 | matches 'FOO:' |
| 1005 | </pre></td></tr> |
| 1006 | |
| 1007 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1008 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1009 | <tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. |
| 1010 | |
| 1011 | Example matches [&](){return 5;} |
| 1012 | [&](){return 5;} |
| 1013 | </pre></td></tr> |
| 1014 | |
| 1015 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1016 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1017 | <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. |
| 1018 | |
| 1019 | Example: Given |
| 1020 | struct T {void func()}; |
| 1021 | T f(); |
| 1022 | void g(T); |
| 1023 | materializeTemporaryExpr() matches 'f()' in these statements |
| 1024 | T u(f()); |
| 1025 | g(f()); |
| 1026 | but does not match |
| 1027 | f(); |
| 1028 | f().func(); |
| 1029 | </pre></td></tr> |
| 1030 | |
| 1031 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1032 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1033 | <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. |
| 1034 | |
| 1035 | Given |
| 1036 | class Y { |
| 1037 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 1038 | int a; static int b; |
| 1039 | }; |
| 1040 | memberExpr() |
| 1041 | matches this->x, x, y.x, a, this->b |
| 1042 | </pre></td></tr> |
| 1043 | |
| 1044 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1045 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1046 | <tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. |
| 1047 | |
| 1048 | foo();; |
| 1049 | nullStmt() |
| 1050 | matches the second ';' |
| 1051 | </pre></td></tr> |
| 1052 | |
| 1053 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1054 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcMessageExpr0')"><a name="objcMessageExpr0Anchor">objcMessageExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1055 | <tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions. |
| 1056 | |
| 1057 | The innermost message send invokes the "alloc" class method on the |
| 1058 | NSString class, while the outermost message send invokes the |
| 1059 | "initWithString" instance method on the object returned from |
| 1060 | NSString's "alloc". This matcher should match both message sends. |
| 1061 | [[NSString alloc] initWithString:@"Hello"] |
| 1062 | </pre></td></tr> |
| 1063 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1064 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1065 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('parenExpr0')"><a name="parenExpr0Anchor">parenExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenExpr.html">ParenExpr</a>>...</td></tr> |
Aaron Ballman | e8295d7 | 2016-01-20 16:17:39 +0000 | [diff] [blame] | 1066 | <tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions. |
| 1067 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1068 | Example matches (foo() + 1) |
Aaron Ballman | e8295d7 | 2016-01-20 16:17:39 +0000 | [diff] [blame] | 1069 | int foo() { return 1; } |
| 1070 | int a = (foo() + 1); |
Aaron Ballman | e8295d7 | 2016-01-20 16:17:39 +0000 | [diff] [blame] | 1071 | </pre></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1072 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1073 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1074 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1075 | <tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. |
| 1076 | |
| 1077 | Given |
| 1078 | return 1; |
| 1079 | returnStmt() |
| 1080 | matches 'return 1' |
| 1081 | </pre></td></tr> |
| 1082 | |
| 1083 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1084 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1085 | <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. |
| 1086 | |
| 1087 | Given |
| 1088 | { ++a; } |
| 1089 | stmt() |
| 1090 | matches both the compound statement '{ ++a; }' and '++a'. |
| 1091 | </pre></td></tr> |
| 1092 | |
| 1093 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1094 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1095 | <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). |
| 1096 | |
| 1097 | Example matches "abcd", L"abcd" |
| 1098 | char *s = "abcd"; wchar_t *ws = L"abcd" |
| 1099 | </pre></td></tr> |
| 1100 | |
| 1101 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1102 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('substNonTypeTemplateParmExpr0')"><a name="substNonTypeTemplateParmExpr0Anchor">substNonTypeTemplateParmExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstNonTypeTemplateParmExpr.html">SubstNonTypeTemplateParmExpr</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1103 | <tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. |
| 1104 | |
| 1105 | Given |
| 1106 | template <int N> |
| 1107 | struct A { static const int n = N; }; |
| 1108 | struct B : public A<42> {}; |
| 1109 | substNonTypeTemplateParmExpr() |
| 1110 | matches "N" in the right-hand side of "static const int n = N;" |
| 1111 | </pre></td></tr> |
| 1112 | |
| 1113 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1114 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1115 | <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. |
| 1116 | |
| 1117 | Given |
| 1118 | switch(a) { case 42: break; default: break; } |
| 1119 | switchCase() |
| 1120 | matches 'case 42: break;' and 'default: break;'. |
| 1121 | </pre></td></tr> |
| 1122 | |
| 1123 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1124 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1125 | <tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. |
| 1126 | |
| 1127 | Given |
| 1128 | switch(a) { case 42: break; default: break; } |
| 1129 | switchStmt() |
| 1130 | matches 'switch(a)'. |
| 1131 | </pre></td></tr> |
| 1132 | |
| 1133 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1134 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1135 | <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) |
| 1136 | |
| 1137 | Given |
| 1138 | Foo x = bar; |
| 1139 | int y = sizeof(x) + alignof(x); |
| 1140 | unaryExprOrTypeTraitExpr() |
| 1141 | matches sizeof(x) and alignof(x) |
| 1142 | </pre></td></tr> |
| 1143 | |
| 1144 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1145 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1146 | <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. |
| 1147 | |
| 1148 | Example matches !a |
| 1149 | !a || b |
| 1150 | </pre></td></tr> |
| 1151 | |
| 1152 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1153 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1154 | <tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. |
| 1155 | |
| 1156 | Example match: "foo"_suffix |
| 1157 | </pre></td></tr> |
| 1158 | |
| 1159 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1160 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1161 | <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. |
| 1162 | |
| 1163 | Given |
| 1164 | while (true) {} |
| 1165 | whileStmt() |
| 1166 | matches 'while (true) {}'. |
| 1167 | </pre></td></tr> |
| 1168 | |
| 1169 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1170 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('templateArgument0')"><a name="templateArgument0Anchor">templateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1171 | <tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. |
| 1172 | |
| 1173 | Given |
| 1174 | template <typename T> struct C {}; |
| 1175 | C<int> c; |
| 1176 | templateArgument() |
| 1177 | matches 'int' in C<int>. |
| 1178 | </pre></td></tr> |
| 1179 | |
| 1180 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1181 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1182 | <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. |
| 1183 | </pre></td></tr> |
| 1184 | |
| 1185 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1186 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('arrayType0')"><a name="arrayType0Anchor">arrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1187 | <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. |
| 1188 | |
| 1189 | Given |
| 1190 | int a[] = { 2, 3 }; |
| 1191 | int b[4]; |
| 1192 | void f() { int c[a[0]]; } |
| 1193 | arrayType() |
| 1194 | matches "int a[]", "int b[4]" and "int c[a[0]]"; |
| 1195 | </pre></td></tr> |
| 1196 | |
| 1197 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1198 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('atomicType0')"><a name="atomicType0Anchor">atomicType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1199 | <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. |
| 1200 | |
| 1201 | Given |
| 1202 | _Atomic(int) i; |
| 1203 | atomicType() |
| 1204 | matches "_Atomic(int) i" |
| 1205 | </pre></td></tr> |
| 1206 | |
| 1207 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1208 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('autoType0')"><a name="autoType0Anchor">autoType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1209 | <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. |
| 1210 | |
| 1211 | Given: |
| 1212 | auto n = 4; |
| 1213 | int v[] = { 2, 3 } |
| 1214 | for (auto i : v) { } |
| 1215 | autoType() |
| 1216 | matches "auto n" and "auto i" |
| 1217 | </pre></td></tr> |
| 1218 | |
| 1219 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1220 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('blockPointerType0')"><a name="blockPointerType0Anchor">blockPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1221 | <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as |
| 1222 | "void (^)(int)". |
| 1223 | |
| 1224 | The pointee is always required to be a FunctionType. |
| 1225 | </pre></td></tr> |
| 1226 | |
| 1227 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1228 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('builtinType0')"><a name="builtinType0Anchor">builtinType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BuiltinType.html">BuiltinType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1229 | <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. |
| 1230 | |
| 1231 | Given |
| 1232 | struct A {}; |
| 1233 | A a; |
| 1234 | int b; |
| 1235 | float c; |
| 1236 | bool d; |
| 1237 | builtinType() |
| 1238 | matches "int b", "float c" and "bool d" |
| 1239 | </pre></td></tr> |
| 1240 | |
| 1241 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1242 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('complexType0')"><a name="complexType0Anchor">complexType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1243 | <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. |
| 1244 | |
| 1245 | Given |
| 1246 | _Complex float f; |
| 1247 | complexType() |
| 1248 | matches "_Complex float f" |
| 1249 | </pre></td></tr> |
| 1250 | |
| 1251 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1252 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('constantArrayType0')"><a name="constantArrayType0Anchor">constantArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1253 | <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. |
| 1254 | |
| 1255 | Given |
| 1256 | void() { |
| 1257 | int a[2]; |
| 1258 | int b[] = { 2, 3 }; |
| 1259 | int c[b[0]]; |
| 1260 | } |
| 1261 | constantArrayType() |
| 1262 | matches "int a[2]" |
| 1263 | </pre></td></tr> |
| 1264 | |
| 1265 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1266 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('decayedType0')"><a name="decayedType0Anchor">decayedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1267 | <tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type |
| 1268 | Example matches i[] in declaration of f. |
| 1269 | (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) |
| 1270 | Example matches i[1]. |
| 1271 | (matcher = expr(hasType(decayedType(hasDecayedType(pointerType()))))) |
| 1272 | void f(int i[]) { |
| 1273 | i[1] = 0; |
| 1274 | } |
| 1275 | </pre></td></tr> |
| 1276 | |
| 1277 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1278 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('dependentSizedArrayType0')"><a name="dependentSizedArrayType0Anchor">dependentSizedArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html">DependentSizedArrayType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1279 | <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. |
| 1280 | |
| 1281 | Given |
| 1282 | template<typename T, int Size> |
| 1283 | class array { |
| 1284 | T data[Size]; |
| 1285 | }; |
| 1286 | dependentSizedArrayType |
| 1287 | matches "T data[Size]" |
| 1288 | </pre></td></tr> |
| 1289 | |
| 1290 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1291 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('elaboratedType0')"><a name="elaboratedType0Anchor">elaboratedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1292 | <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a |
| 1293 | qualified name. |
| 1294 | |
| 1295 | Given |
| 1296 | namespace N { |
| 1297 | namespace M { |
| 1298 | class D {}; |
| 1299 | } |
| 1300 | } |
| 1301 | class C {}; |
| 1302 | |
| 1303 | class C c; |
| 1304 | N::M::D d; |
| 1305 | |
| 1306 | elaboratedType() matches the type of the variable declarations of both |
| 1307 | c and d. |
| 1308 | </pre></td></tr> |
| 1309 | |
| 1310 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1311 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('functionType0')"><a name="functionType0Anchor">functionType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionType.html">FunctionType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1312 | <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. |
| 1313 | |
| 1314 | Given |
| 1315 | int (*f)(int); |
| 1316 | void g(); |
| 1317 | functionType() |
| 1318 | matches "int (*f)(int)" and the type of "g". |
| 1319 | </pre></td></tr> |
| 1320 | |
| 1321 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1322 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('incompleteArrayType0')"><a name="incompleteArrayType0Anchor">incompleteArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IncompleteArrayType.html">IncompleteArrayType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1323 | <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. |
| 1324 | |
| 1325 | Given |
| 1326 | int a[] = { 2, 3 }; |
| 1327 | int b[42]; |
| 1328 | void f(int c[]) { int d[a[0]]; }; |
| 1329 | incompleteArrayType() |
| 1330 | matches "int a[]" and "int c[]" |
| 1331 | </pre></td></tr> |
| 1332 | |
| 1333 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1334 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('injectedClassNameType0')"><a name="injectedClassNameType0Anchor">injectedClassNameType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1335 | <tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types. |
| 1336 | |
| 1337 | Example matches S s, but not S<T> s. |
| 1338 | (matcher = parmVarDecl(hasType(injectedClassNameType()))) |
| 1339 | template <typename T> struct S { |
| 1340 | void f(S s); |
| 1341 | void g(S<T> s); |
| 1342 | }; |
| 1343 | </pre></td></tr> |
| 1344 | |
| 1345 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1346 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('lValueReferenceType0')"><a name="lValueReferenceType0Anchor">lValueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1347 | <tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. |
| 1348 | |
| 1349 | Given: |
| 1350 | int *a; |
| 1351 | int &b = *a; |
| 1352 | int &&c = 1; |
| 1353 | auto &d = b; |
| 1354 | auto &&e = c; |
| 1355 | auto &&f = 2; |
| 1356 | int g = 5; |
| 1357 | |
| 1358 | lValueReferenceType() matches the types of b, d, and e. e is |
| 1359 | matched since the type is deduced as int& by reference collapsing rules. |
| 1360 | </pre></td></tr> |
| 1361 | |
| 1362 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1363 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('memberPointerType0')"><a name="memberPointerType0Anchor">memberPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1364 | <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. |
| 1365 | Given |
| 1366 | struct A { int i; } |
| 1367 | A::* ptr = A::i; |
| 1368 | memberPointerType() |
| 1369 | matches "A::* ptr" |
| 1370 | </pre></td></tr> |
| 1371 | |
| 1372 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1373 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('objcObjectPointerType0')"><a name="objcObjectPointerType0Anchor">objcObjectPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1374 | <tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from |
| 1375 | a pointer type, despite being syntactically similar. |
| 1376 | |
| 1377 | Given |
| 1378 | int *a; |
| 1379 | |
| 1380 | @interface Foo |
| 1381 | @end |
| 1382 | Foo *f; |
| 1383 | pointerType() |
| 1384 | matches "Foo *f", but does not match "int *a". |
| 1385 | </pre></td></tr> |
| 1386 | |
| 1387 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1388 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('parenType0')"><a name="parenType0Anchor">parenType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1389 | <tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. |
| 1390 | |
| 1391 | Given |
| 1392 | int (*ptr_to_array)[4]; |
| 1393 | int *array_of_ptrs[4]; |
| 1394 | |
| 1395 | varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not |
| 1396 | array_of_ptrs. |
| 1397 | </pre></td></tr> |
| 1398 | |
| 1399 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1400 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('pointerType0')"><a name="pointerType0Anchor">pointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1401 | <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer |
| 1402 | types. |
| 1403 | |
| 1404 | Given |
| 1405 | int *a; |
| 1406 | int &b = *a; |
| 1407 | int c = 5; |
| 1408 | |
| 1409 | @interface Foo |
| 1410 | @end |
| 1411 | Foo *f; |
| 1412 | pointerType() |
| 1413 | matches "int *a", but does not match "Foo *f". |
| 1414 | </pre></td></tr> |
| 1415 | |
| 1416 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1417 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('rValueReferenceType0')"><a name="rValueReferenceType0Anchor">rValueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1418 | <tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. |
| 1419 | |
| 1420 | Given: |
| 1421 | int *a; |
| 1422 | int &b = *a; |
| 1423 | int &&c = 1; |
| 1424 | auto &d = b; |
| 1425 | auto &&e = c; |
| 1426 | auto &&f = 2; |
| 1427 | int g = 5; |
| 1428 | |
| 1429 | rValueReferenceType() matches the types of c and f. e is not |
| 1430 | matched as it is deduced to int& by reference collapsing rules. |
| 1431 | </pre></td></tr> |
| 1432 | |
| 1433 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1434 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('recordType0')"><a name="recordType0Anchor">recordType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1435 | <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). |
| 1436 | |
| 1437 | Given |
| 1438 | class C {}; |
| 1439 | struct S {}; |
| 1440 | |
| 1441 | C c; |
| 1442 | S s; |
| 1443 | |
| 1444 | recordType() matches the type of the variable declarations of both c |
| 1445 | and s. |
| 1446 | </pre></td></tr> |
| 1447 | |
| 1448 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1449 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('referenceType0')"><a name="referenceType0Anchor">referenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1450 | <tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. |
| 1451 | |
| 1452 | Given |
| 1453 | int *a; |
| 1454 | int &b = *a; |
| 1455 | int &&c = 1; |
| 1456 | auto &d = b; |
| 1457 | auto &&e = c; |
| 1458 | auto &&f = 2; |
| 1459 | int g = 5; |
| 1460 | |
| 1461 | referenceType() matches the types of b, c, d, e, and f. |
| 1462 | </pre></td></tr> |
| 1463 | |
| 1464 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1465 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('substTemplateTypeParmType0')"><a name="substTemplateTypeParmType0Anchor">substTemplateTypeParmType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html">SubstTemplateTypeParmType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1466 | <tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a |
| 1467 | template type parameter. |
| 1468 | |
| 1469 | Given |
| 1470 | template <typename T> |
| 1471 | void F(T t) { |
| 1472 | int i = 1 + t; |
| 1473 | } |
| 1474 | |
| 1475 | substTemplateTypeParmType() matches the type of 't' but not '1' |
| 1476 | </pre></td></tr> |
| 1477 | |
| 1478 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1479 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('templateSpecializationType0')"><a name="templateSpecializationType0Anchor">templateSpecializationType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1480 | <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. |
| 1481 | |
| 1482 | Given |
| 1483 | template <typename T> |
| 1484 | class C { }; |
| 1485 | |
| 1486 | template class C<int>; A |
| 1487 | C<char> var; B |
| 1488 | |
| 1489 | templateSpecializationType() matches the type of the explicit |
| 1490 | instantiation in A and the type of the variable declaration in B. |
| 1491 | </pre></td></tr> |
| 1492 | |
| 1493 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1494 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('templateTypeParmType0')"><a name="templateTypeParmType0Anchor">templateTypeParmType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1495 | <tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types. |
| 1496 | |
| 1497 | Example matches T, but not int. |
| 1498 | (matcher = templateTypeParmType()) |
| 1499 | template <typename T> void f(int i); |
| 1500 | </pre></td></tr> |
| 1501 | |
| 1502 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1503 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1504 | <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. |
| 1505 | </pre></td></tr> |
| 1506 | |
| 1507 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1508 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('typedefType0')"><a name="typedefType0Anchor">typedefType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1509 | <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. |
| 1510 | |
| 1511 | Given |
| 1512 | typedef int X; |
| 1513 | typedefType() |
| 1514 | matches "typedef int X" |
| 1515 | </pre></td></tr> |
| 1516 | |
| 1517 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1518 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('unaryTransformType0')"><a name="unaryTransformType0Anchor">unaryTransformType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryTransformType.html">UnaryTransformType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1519 | <tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. |
| 1520 | |
| 1521 | Given: |
| 1522 | typedef __underlying_type(T) type; |
| 1523 | unaryTransformType() |
| 1524 | matches "__underlying_type(T)" |
| 1525 | </pre></td></tr> |
| 1526 | |
| 1527 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1528 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('variableArrayType0')"><a name="variableArrayType0Anchor">variableArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html">VariableArrayType</a>>...</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1529 | <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an |
| 1530 | integer-constant-expression. |
| 1531 | |
| 1532 | Given |
| 1533 | void f() { |
| 1534 | int a[] = { 2, 3 } |
| 1535 | int b[42]; |
| 1536 | int c[a[0]]; |
| 1537 | } |
| 1538 | variableArrayType() |
| 1539 | matches "int c[a[0]]" |
| 1540 | </pre></td></tr> |
| 1541 | |
Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 1542 | <!--END_DECL_MATCHERS --> |
| 1543 | </table> |
| 1544 | |
| 1545 | <!-- ======================================================================= --> |
| 1546 | <h2 id="narrowing-matchers">Narrowing Matchers</h2> |
| 1547 | <!-- ======================================================================= --> |
| 1548 | |
| 1549 | <p>Narrowing matchers match certain attributes on the current node, thus |
| 1550 | narrowing down the set of nodes of the current type to match on.</p> |
| 1551 | |
| 1552 | <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) |
| 1553 | which allow users to create more powerful match expressions.</p> |
| 1554 | |
| 1555 | <table> |
| 1556 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1557 | <!-- START_NARROWING_MATCHERS --> |
| 1558 | |
| 1559 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 1560 | <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. |
| 1561 | |
| 1562 | Usable as: Any Matcher |
| 1563 | </pre></td></tr> |
| 1564 | |
| 1565 | |
| 1566 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 1567 | <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. |
| 1568 | |
| 1569 | Usable as: Any Matcher |
| 1570 | </pre></td></tr> |
| 1571 | |
| 1572 | |
| 1573 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> |
| 1574 | <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. |
| 1575 | |
| 1576 | Useful when another matcher requires a child matcher, but there's no |
| 1577 | additional constraint. This will often be used with an explicit conversion |
| 1578 | to an internal::Matcher<> type such as TypeMatcher. |
| 1579 | |
| 1580 | Example: DeclarationMatcher(anything()) matches all declarations, e.g., |
| 1581 | "int* p" and "void f()" in |
| 1582 | int* p; |
| 1583 | void f(); |
| 1584 | |
| 1585 | Usable as: Any Matcher |
| 1586 | </pre></td></tr> |
| 1587 | |
| 1588 | |
| 1589 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> |
| 1590 | <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. |
| 1591 | |
| 1592 | Example matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) |
| 1593 | class X {}; |
| 1594 | class Y {}; |
| 1595 | |
| 1596 | Usable as: Any Matcher |
| 1597 | </pre></td></tr> |
| 1598 | |
| 1599 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1600 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1601 | <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or |
| 1602 | unary). |
| 1603 | |
| 1604 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 1605 | !(a || b) |
| 1606 | </pre></td></tr> |
| 1607 | |
| 1608 | |
| 1609 | <tr><td>Matcher<CXXBoolLiteral></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr> |
| 1610 | <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value. |
| 1611 | |
| 1612 | Example matches true (matcher = cxxBoolLiteral(equals(true))) |
| 1613 | true |
| 1614 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1615 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1616 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1617 | </pre></td></tr> |
| 1618 | |
| 1619 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1620 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>></td><td class="name" onclick="toggle('isCatchAll0')"><a name="isCatchAll0Anchor">isCatchAll</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1621 | <tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. |
| 1622 | |
| 1623 | Given |
| 1624 | try { |
| 1625 | ... |
| 1626 | } catch (int) { |
| 1627 | ... |
| 1628 | } catch (...) { |
| 1629 | ... |
| 1630 | } |
| 1631 | endcode |
| 1632 | cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). |
| 1633 | </pre></td></tr> |
| 1634 | |
| 1635 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1636 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('argumentCountIs1')"><a name="argumentCountIs1Anchor">argumentCountIs</a></td><td>unsigned N</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1637 | <tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has |
| 1638 | a specific number of arguments (including absent default arguments). |
| 1639 | |
| 1640 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 1641 | void f(int x, int y); |
| 1642 | f(0, 0); |
| 1643 | </pre></td></tr> |
| 1644 | |
| 1645 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1646 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('isListInitialization0')"><a name="isListInitialization0Anchor">isListInitialization</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1647 | <tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. |
| 1648 | </pre></td></tr> |
| 1649 | |
| 1650 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1651 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isCopyConstructor0')"><a name="isCopyConstructor0Anchor">isCopyConstructor</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1652 | <tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. |
| 1653 | |
| 1654 | Given |
| 1655 | struct S { |
| 1656 | S(); #1 |
| 1657 | S(const S &); #2 |
| 1658 | S(S &&); #3 |
| 1659 | }; |
| 1660 | cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. |
| 1661 | </pre></td></tr> |
| 1662 | |
| 1663 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1664 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isDefaultConstructor0')"><a name="isDefaultConstructor0Anchor">isDefaultConstructor</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1665 | <tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. |
| 1666 | |
| 1667 | Given |
| 1668 | struct S { |
| 1669 | S(); #1 |
| 1670 | S(const S &); #2 |
| 1671 | S(S &&); #3 |
| 1672 | }; |
| 1673 | cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. |
| 1674 | </pre></td></tr> |
| 1675 | |
| 1676 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1677 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isExplicit0')"><a name="isExplicit0Anchor">isExplicit</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1678 | <tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with |
| 1679 | the explicit keyword. |
| 1680 | |
| 1681 | Given |
| 1682 | struct S { |
| 1683 | S(int); #1 |
| 1684 | explicit S(double); #2 |
| 1685 | operator int(); #3 |
| 1686 | explicit operator bool(); #4 |
| 1687 | }; |
| 1688 | cxxConstructorDecl(isExplicit()) will match #2, but not #1. |
| 1689 | cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| 1690 | </pre></td></tr> |
| 1691 | |
| 1692 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1693 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isMoveConstructor0')"><a name="isMoveConstructor0Anchor">isMoveConstructor</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1694 | <tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. |
| 1695 | |
| 1696 | Given |
| 1697 | struct S { |
| 1698 | S(); #1 |
| 1699 | S(const S &); #2 |
| 1700 | S(S &&); #3 |
| 1701 | }; |
| 1702 | cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. |
| 1703 | </pre></td></tr> |
| 1704 | |
| 1705 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1706 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>></td><td class="name" onclick="toggle('isExplicit1')"><a name="isExplicit1Anchor">isExplicit</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1707 | <tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with |
| 1708 | the explicit keyword. |
| 1709 | |
| 1710 | Given |
| 1711 | struct S { |
| 1712 | S(int); #1 |
| 1713 | explicit S(double); #2 |
| 1714 | operator int(); #3 |
| 1715 | explicit operator bool(); #4 |
| 1716 | }; |
| 1717 | cxxConstructorDecl(isExplicit()) will match #2, but not #1. |
| 1718 | cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| 1719 | </pre></td></tr> |
| 1720 | |
| 1721 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1722 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isBaseInitializer0')"><a name="isBaseInitializer0Anchor">isBaseInitializer</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1723 | <tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as |
| 1724 | opposed to a member. |
| 1725 | |
| 1726 | Given |
| 1727 | struct B {}; |
| 1728 | struct D : B { |
| 1729 | int I; |
| 1730 | D(int i) : I(i) {} |
| 1731 | }; |
| 1732 | struct E : B { |
| 1733 | E() : B() {} |
| 1734 | }; |
| 1735 | cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) |
| 1736 | will match E(), but not match D(int). |
| 1737 | </pre></td></tr> |
| 1738 | |
| 1739 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1740 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isMemberInitializer0')"><a name="isMemberInitializer0Anchor">isMemberInitializer</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1741 | <tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as |
| 1742 | opposed to a base. |
| 1743 | |
| 1744 | Given |
| 1745 | struct B {}; |
| 1746 | struct D : B { |
| 1747 | int I; |
| 1748 | D(int i) : I(i) {} |
| 1749 | }; |
| 1750 | struct E : B { |
| 1751 | E() : B() {} |
| 1752 | }; |
| 1753 | cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) |
| 1754 | will match D(int), but not match E(). |
| 1755 | </pre></td></tr> |
| 1756 | |
| 1757 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1758 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1759 | <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in |
| 1760 | code (as opposed to implicitly added by the compiler). |
| 1761 | |
| 1762 | Given |
| 1763 | struct Foo { |
| 1764 | Foo() { } |
| 1765 | Foo(int) : foo_("A") { } |
| 1766 | string foo_; |
| 1767 | }; |
| 1768 | cxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) |
| 1769 | will match Foo(int), but not Foo() |
| 1770 | </pre></td></tr> |
| 1771 | |
| 1772 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1773 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isConst0')"><a name="isConst0Anchor">isConst</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1774 | <tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. |
| 1775 | |
| 1776 | Given |
| 1777 | struct A { |
| 1778 | void foo() const; |
| 1779 | void bar(); |
| 1780 | }; |
| 1781 | |
| 1782 | cxxMethodDecl(isConst()) matches A::foo() but not A::bar() |
| 1783 | </pre></td></tr> |
| 1784 | |
| 1785 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1786 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isCopyAssignmentOperator0')"><a name="isCopyAssignmentOperator0Anchor">isCopyAssignmentOperator</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1787 | <tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment |
| 1788 | operator. |
| 1789 | |
| 1790 | Given |
| 1791 | struct A { |
| 1792 | A &operator=(const A &); |
| 1793 | A &operator=(A &&); |
| 1794 | }; |
| 1795 | |
| 1796 | cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not |
| 1797 | the second one. |
| 1798 | </pre></td></tr> |
| 1799 | |
| 1800 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1801 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isFinal1')"><a name="isFinal1Anchor">isFinal</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1802 | <tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. |
| 1803 | |
| 1804 | Given: |
| 1805 | class A final {}; |
| 1806 | |
| 1807 | struct B { |
| 1808 | virtual void f(); |
| 1809 | }; |
| 1810 | |
| 1811 | struct C : B { |
| 1812 | void f() final; |
| 1813 | }; |
| 1814 | matches A and C::f, but not B, C, or B::f |
| 1815 | </pre></td></tr> |
| 1816 | |
| 1817 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1818 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isMoveAssignmentOperator0')"><a name="isMoveAssignmentOperator0Anchor">isMoveAssignmentOperator</a></td><td></td></tr> |
Aaron Ballman | 31bde87 | 2016-01-22 22:37:09 +0000 | [diff] [blame] | 1819 | <tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment |
| 1820 | operator. |
| 1821 | |
| 1822 | Given |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1823 | struct S { |
| 1824 | S(const S &); #1 |
| 1825 | S& operator=(S &&); #2 |
| 1826 | }; |
| 1827 | cxxMethodDecl(isMoveAssignmentOperator()) will match #2, but not #1. |
Aaron Ballman | 31bde87 | 2016-01-22 22:37:09 +0000 | [diff] [blame] | 1828 | </pre></td></tr> |
| 1829 | |
| 1830 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1831 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isOverride0')"><a name="isOverride0Anchor">isOverride</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1832 | <tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. |
| 1833 | |
| 1834 | Given |
| 1835 | class A { |
| 1836 | public: |
| 1837 | virtual void x(); |
| 1838 | }; |
| 1839 | class B : public A { |
| 1840 | public: |
| 1841 | virtual void x(); |
| 1842 | }; |
| 1843 | matches B::x |
| 1844 | </pre></td></tr> |
| 1845 | |
| 1846 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1847 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isPure0')"><a name="isPure0Anchor">isPure</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1848 | <tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. |
| 1849 | |
| 1850 | Given |
| 1851 | class A { |
| 1852 | public: |
| 1853 | virtual void x() = 0; |
| 1854 | }; |
| 1855 | matches A::x |
| 1856 | </pre></td></tr> |
| 1857 | |
| 1858 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1859 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isVirtual0')"><a name="isVirtual0Anchor">isVirtual</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1860 | <tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. |
| 1861 | |
| 1862 | Given |
| 1863 | class A { |
| 1864 | public: |
| 1865 | virtual void x(); |
| 1866 | }; |
| 1867 | matches A::x |
| 1868 | </pre></td></tr> |
| 1869 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1870 | |
| 1871 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isVirtualAsWritten0')"><a name="isVirtualAsWritten0Anchor">isVirtualAsWritten</a></td><td></td></tr> |
Nico Weber | a415a1d | 2016-01-21 17:56:24 +0000 | [diff] [blame] | 1872 | <tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual". |
| 1873 | |
| 1874 | Given |
| 1875 | class A { |
| 1876 | public: |
| 1877 | virtual void x(); |
| 1878 | }; |
| 1879 | class B : public A { |
| 1880 | public: |
| 1881 | void x(); |
| 1882 | }; |
| 1883 | matches A::x but not B::x |
| 1884 | </pre></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1885 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1886 | |
| 1887 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName1')"><a name="hasOverloadedOperatorName1Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1888 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. |
| 1889 | |
| 1890 | Matches overloaded operator names specified in strings without the |
| 1891 | "operator" prefix: e.g. "<<". |
| 1892 | |
| 1893 | Given: |
| 1894 | class A { int operator*(); }; |
| 1895 | const A &operator<<(const A &a, const A &b); |
| 1896 | A a; |
| 1897 | a << a; <-- This matches |
| 1898 | |
| 1899 | cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the |
| 1900 | specified line and |
| 1901 | cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) |
| 1902 | matches the declaration of A. |
| 1903 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1904 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1905 | </pre></td></tr> |
| 1906 | |
| 1907 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1908 | <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>std::string BaseName</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1909 | <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). |
| 1910 | </pre></td></tr> |
| 1911 | |
| 1912 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1913 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization2')"><a name="isExplicitTemplateSpecialization2Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1914 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or |
| 1915 | static member variable template instantiations. |
| 1916 | |
| 1917 | Given |
| 1918 | template<typename T> void A(T t) { } |
| 1919 | template<> void A(int N) { } |
| 1920 | functionDecl(isExplicitTemplateSpecialization()) |
| 1921 | matches the specialization A<int>(). |
| 1922 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1923 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1924 | </pre></td></tr> |
| 1925 | |
| 1926 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1927 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isFinal0')"><a name="isFinal0Anchor">isFinal</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1928 | <tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. |
| 1929 | |
| 1930 | Given: |
| 1931 | class A final {}; |
| 1932 | |
| 1933 | struct B { |
| 1934 | virtual void f(); |
| 1935 | }; |
| 1936 | |
| 1937 | struct C : B { |
| 1938 | void f() final; |
| 1939 | }; |
| 1940 | matches A and C::f, but not B, C, or B::f |
| 1941 | </pre></td></tr> |
| 1942 | |
| 1943 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1944 | <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>std::string BaseName</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1945 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for |
| 1946 | isSameOrDerivedFrom(hasName(...)). |
| 1947 | </pre></td></tr> |
| 1948 | |
| 1949 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1950 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation2')"><a name="isTemplateInstantiation2Anchor">isTemplateInstantiation</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1951 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static |
| 1952 | member variable template instantiations. |
| 1953 | |
| 1954 | Given |
| 1955 | template <typename T> class X {}; class A {}; X<A> x; |
| 1956 | or |
| 1957 | template <typename T> class X {}; class A {}; template class X<A>; |
| 1958 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 1959 | matches the template instantiation of X<A>. |
| 1960 | |
| 1961 | But given |
| 1962 | template <typename T> class X {}; class A {}; |
| 1963 | template <> class X<A> {}; X<A> x; |
| 1964 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 1965 | does not match, as X<A> is an explicit template specialization. |
| 1966 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1967 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1968 | </pre></td></tr> |
| 1969 | |
| 1970 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1971 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1972 | <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has |
| 1973 | a specific number of arguments (including absent default arguments). |
| 1974 | |
| 1975 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 1976 | void f(int x, int y); |
| 1977 | f(0, 0); |
| 1978 | </pre></td></tr> |
| 1979 | |
| 1980 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1981 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1982 | <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value. |
| 1983 | |
| 1984 | Example matches true (matcher = cxxBoolLiteral(equals(true))) |
| 1985 | true |
| 1986 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1987 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1988 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1989 | </pre></td></tr> |
| 1990 | |
| 1991 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1992 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('templateArgumentCountIs0')"><a name="templateArgumentCountIs0Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1993 | <tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. |
| 1994 | |
| 1995 | Given |
| 1996 | template<typename T> struct C {}; |
| 1997 | C<int> c; |
| 1998 | classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
| 1999 | matches C<int>. |
| 2000 | </pre></td></tr> |
| 2001 | |
| 2002 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2003 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2004 | <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of |
| 2005 | child statements. |
| 2006 | |
| 2007 | Example: Given |
| 2008 | { for (;;) {} } |
| 2009 | compoundStmt(statementCountIs(0))) |
| 2010 | matches '{}' |
| 2011 | but does not match the outer compound statement. |
| 2012 | </pre></td></tr> |
| 2013 | |
| 2014 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2015 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2016 | <tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size. |
| 2017 | |
| 2018 | Given |
| 2019 | int a[42]; |
| 2020 | int b[2 * 21]; |
| 2021 | int c[41], d[43]; |
| 2022 | constantArrayType(hasSize(42)) |
| 2023 | matches "int a[42]" and "int b[2 * 21]" |
| 2024 | </pre></td></tr> |
| 2025 | |
| 2026 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2027 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2028 | <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of |
| 2029 | declarations. |
| 2030 | |
| 2031 | Example: Given |
| 2032 | int a, b; |
| 2033 | int c; |
| 2034 | int d = 2, e; |
| 2035 | declCountIs(2) |
| 2036 | matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. |
| 2037 | </pre></td></tr> |
| 2038 | |
| 2039 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2040 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('equalsBoundNode1')"><a name="equalsBoundNode1Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2041 | <tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. |
| 2042 | |
| 2043 | Matches a node if it equals the node previously bound to ID. |
| 2044 | |
| 2045 | Given |
| 2046 | class X { int a; int b; }; |
| 2047 | cxxRecordDecl( |
| 2048 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 2049 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 2050 | matches the class X, as a and b have the same type. |
| 2051 | |
| 2052 | Note that when multiple matches are involved via forEach* matchers, |
| 2053 | equalsBoundNodes acts as a filter. |
| 2054 | For example: |
| 2055 | compoundStmt( |
| 2056 | forEachDescendant(varDecl().bind("d")), |
| 2057 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 2058 | will trigger a match for each combination of variable declaration |
| 2059 | and reference to that variable declaration within a compound statement. |
| 2060 | </pre></td></tr> |
| 2061 | |
| 2062 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2063 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('hasAttr0')"><a name="hasAttr0Anchor">hasAttr</a></td><td>attr::Kind AttrKind</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2064 | <tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. |
| 2065 | |
| 2066 | Given |
| 2067 | __attribute__((device)) void f() { ... } |
| 2068 | decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of |
| 2069 | f. If the matcher is use from clang-query, attr::Kind parameter should be |
| 2070 | passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). |
| 2071 | </pre></td></tr> |
| 2072 | |
| 2073 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2074 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching0')"><a name="isExpansionInFileMatching0Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2075 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is |
| 2076 | partially matching a given regex. |
| 2077 | |
| 2078 | Example matches Y but not X |
| 2079 | (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 2080 | #include "ASTMatcher.h" |
| 2081 | class X {}; |
| 2082 | ASTMatcher.h: |
| 2083 | class Y {}; |
| 2084 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2085 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2086 | </pre></td></tr> |
| 2087 | |
| 2088 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2089 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInMainFile0')"><a name="isExpansionInMainFile0Anchor">isExpansionInMainFile</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2090 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. |
| 2091 | |
| 2092 | Example matches X but not Y |
| 2093 | (matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 2094 | #include <Y.h> |
| 2095 | class X {}; |
| 2096 | Y.h: |
| 2097 | class Y {}; |
| 2098 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2099 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2100 | </pre></td></tr> |
| 2101 | |
| 2102 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2103 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader0')"><a name="isExpansionInSystemHeader0Anchor">isExpansionInSystemHeader</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2104 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. |
| 2105 | |
| 2106 | Example matches Y but not X |
| 2107 | (matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 2108 | #include <SystemHeader.h> |
| 2109 | class X {}; |
| 2110 | SystemHeader.h: |
| 2111 | class Y {}; |
| 2112 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2113 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2114 | </pre></td></tr> |
| 2115 | |
| 2116 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2117 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2118 | <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added |
| 2119 | by the compiler (eg. implicit defaultcopy constructors). |
| 2120 | </pre></td></tr> |
| 2121 | |
| 2122 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2123 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isPrivate0')"><a name="isPrivate0Anchor">isPrivate</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2124 | <tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. |
| 2125 | |
| 2126 | Given |
| 2127 | class C { |
| 2128 | public: int a; |
| 2129 | protected: int b; |
| 2130 | private: int c; |
| 2131 | }; |
| 2132 | fieldDecl(isPrivate()) |
| 2133 | matches 'int c;' |
| 2134 | </pre></td></tr> |
| 2135 | |
| 2136 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2137 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isProtected0')"><a name="isProtected0Anchor">isProtected</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2138 | <tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. |
| 2139 | |
| 2140 | Given |
| 2141 | class C { |
| 2142 | public: int a; |
| 2143 | protected: int b; |
| 2144 | private: int c; |
| 2145 | }; |
| 2146 | fieldDecl(isProtected()) |
| 2147 | matches 'int b;' |
| 2148 | </pre></td></tr> |
| 2149 | |
| 2150 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2151 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isPublic0')"><a name="isPublic0Anchor">isPublic</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2152 | <tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. |
| 2153 | |
| 2154 | Given |
| 2155 | class C { |
| 2156 | public: int a; |
| 2157 | protected: int b; |
| 2158 | private: int c; |
| 2159 | }; |
| 2160 | fieldDecl(isPublic()) |
| 2161 | matches 'int a;' |
| 2162 | </pre></td></tr> |
| 2163 | |
| 2164 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2165 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2166 | <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. |
| 2167 | |
| 2168 | Example matches true (matcher = cxxBoolLiteral(equals(true))) |
| 2169 | true |
| 2170 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2171 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 2172 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2173 | </pre></td></tr> |
| 2174 | |
| 2175 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2176 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2177 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. |
| 2178 | |
| 2179 | Matches overloaded operator names specified in strings without the |
| 2180 | "operator" prefix: e.g. "<<". |
| 2181 | |
| 2182 | Given: |
| 2183 | class A { int operator*(); }; |
| 2184 | const A &operator<<(const A &a, const A &b); |
| 2185 | A a; |
| 2186 | a << a; <-- This matches |
| 2187 | |
| 2188 | cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the |
| 2189 | specified line and |
| 2190 | cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) |
| 2191 | matches the declaration of A. |
| 2192 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2193 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2194 | </pre></td></tr> |
| 2195 | |
| 2196 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2197 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isConstexpr1')"><a name="isConstexpr1Anchor">isConstexpr</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2198 | <tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations. |
| 2199 | |
| 2200 | Given: |
| 2201 | constexpr int foo = 42; |
| 2202 | constexpr int bar(); |
| 2203 | varDecl(isConstexpr()) |
| 2204 | matches the declaration of foo. |
| 2205 | functionDecl(isConstexpr()) |
| 2206 | matches the declaration of bar. |
| 2207 | </pre></td></tr> |
| 2208 | |
| 2209 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2210 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDefaulted0')"><a name="isDefaulted0Anchor">isDefaulted</a></td><td></td></tr> |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 2211 | <tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations. |
| 2212 | |
| 2213 | Given: |
| 2214 | class A { ~A(); }; |
| 2215 | class B { ~B() = default; }; |
| 2216 | functionDecl(isDefaulted()) |
| 2217 | matches the declaration of ~B, but not ~A. |
| 2218 | </pre></td></tr> |
| 2219 | |
| 2220 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2221 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDefinition2')"><a name="isDefinition2Anchor">isDefinition</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2222 | <tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. |
| 2223 | |
| 2224 | Example matches A, va, fa |
| 2225 | class A {}; |
| 2226 | class B; Doesn't match, as it has no body. |
| 2227 | int va; |
| 2228 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 2229 | void fa() {} |
| 2230 | void fb(); Doesn't match, as it has no body. |
| 2231 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2232 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2233 | </pre></td></tr> |
| 2234 | |
| 2235 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2236 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDeleted0')"><a name="isDeleted0Anchor">isDeleted</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2237 | <tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. |
| 2238 | |
| 2239 | Given: |
| 2240 | void Func(); |
| 2241 | void DeletedFunc() = delete; |
| 2242 | functionDecl(isDeleted()) |
| 2243 | matches the declaration of DeletedFunc, but not Func. |
| 2244 | </pre></td></tr> |
| 2245 | |
| 2246 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2247 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization0')"><a name="isExplicitTemplateSpecialization0Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2248 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or |
| 2249 | static member variable template instantiations. |
| 2250 | |
| 2251 | Given |
| 2252 | template<typename T> void A(T t) { } |
| 2253 | template<> void A(int N) { } |
| 2254 | functionDecl(isExplicitTemplateSpecialization()) |
| 2255 | matches the specialization A<int>(). |
| 2256 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2257 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2258 | </pre></td></tr> |
| 2259 | |
| 2260 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2261 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2262 | <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. |
| 2263 | |
| 2264 | Given: |
| 2265 | extern "C" void f() {} |
| 2266 | extern "C" { void g() {} } |
| 2267 | void h() {} |
| 2268 | functionDecl(isExternC()) |
| 2269 | matches the declaration of f and g, but not the declaration h |
| 2270 | </pre></td></tr> |
| 2271 | |
| 2272 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2273 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isInline1')"><a name="isInline1Anchor">isInline</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2274 | <tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with |
| 2275 | the inline keyword. |
| 2276 | |
| 2277 | Given |
| 2278 | inline void f(); |
| 2279 | void g(); |
| 2280 | namespace n { |
| 2281 | inline namespace m {} |
| 2282 | } |
| 2283 | functionDecl(isInline()) will match ::f(). |
| 2284 | namespaceDecl(isInline()) will match n::m. |
| 2285 | </pre></td></tr> |
| 2286 | |
| 2287 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2288 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isNoThrow0')"><a name="isNoThrow0Anchor">isNoThrow</a></td><td></td></tr> |
Aaron Ballman | a60bcda | 2015-12-02 15:23:59 +0000 | [diff] [blame] | 2289 | <tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification. |
| 2290 | |
| 2291 | Given: |
| 2292 | void f(); |
| 2293 | void g() noexcept; |
| 2294 | void h() throw(); |
| 2295 | void i() throw(int); |
| 2296 | void j() noexcept(false); |
| 2297 | functionDecl(isNoThrow()) |
| 2298 | matches the declarations of g, and h, but not f, i or j. |
| 2299 | </pre></td></tr> |
| 2300 | |
| 2301 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2302 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation0')"><a name="isTemplateInstantiation0Anchor">isTemplateInstantiation</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2303 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static |
| 2304 | member variable template instantiations. |
| 2305 | |
| 2306 | Given |
| 2307 | template <typename T> class X {}; class A {}; X<A> x; |
| 2308 | or |
| 2309 | template <typename T> class X {}; class A {}; template class X<A>; |
| 2310 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 2311 | matches the template instantiation of X<A>. |
| 2312 | |
| 2313 | But given |
| 2314 | template <typename T> class X {}; class A {}; |
| 2315 | template <> class X<A> {}; X<A> x; |
| 2316 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 2317 | does not match, as X<A> is an explicit template specialization. |
| 2318 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2319 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2320 | </pre></td></tr> |
| 2321 | |
| 2322 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2323 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isVariadic0')"><a name="isVariadic0Anchor">isVariadic</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2324 | <tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. |
| 2325 | |
| 2326 | Example matches f, but not g or h. The function i will not match, even when |
| 2327 | compiled in C mode. |
| 2328 | void f(...); |
| 2329 | void g(int); |
| 2330 | template <typename... Ts> void h(Ts...); |
| 2331 | void i(); |
| 2332 | </pre></td></tr> |
| 2333 | |
| 2334 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2335 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2336 | <tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count. |
| 2337 | |
| 2338 | Given |
| 2339 | void f(int i) {} |
| 2340 | void g(int i, int j) {} |
| 2341 | functionDecl(parameterCountIs(2)) |
| 2342 | matches g(int i, int j) {} |
| 2343 | </pre></td></tr> |
| 2344 | |
| 2345 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2346 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2347 | <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. |
| 2348 | |
| 2349 | Example matches true (matcher = cxxBoolLiteral(equals(true))) |
| 2350 | true |
| 2351 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2352 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 2353 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2354 | </pre></td></tr> |
| 2355 | |
| 2356 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2357 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2358 | <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed |
| 2359 | to '.'. |
| 2360 | |
| 2361 | Member calls on the implicit this pointer match as called with '->'. |
| 2362 | |
| 2363 | Given |
| 2364 | class Y { |
| 2365 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 2366 | int a; |
| 2367 | static int b; |
| 2368 | }; |
| 2369 | memberExpr(isArrow()) |
| 2370 | matches this->x, x, y.x, a, this->b |
| 2371 | </pre></td></tr> |
| 2372 | |
| 2373 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2374 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2375 | <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. |
| 2376 | |
| 2377 | Supports specifying enclosing namespaces or classes by prefixing the name |
| 2378 | with '<enclosing>::'. |
| 2379 | Does not match typedefs of an underlying type with the given name. |
| 2380 | |
| 2381 | Example matches X (Name == "X") |
| 2382 | class X; |
| 2383 | |
| 2384 | Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") |
| 2385 | namespace a { namespace b { class X; } } |
| 2386 | </pre></td></tr> |
| 2387 | |
| 2388 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2389 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2390 | <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain |
| 2391 | a substring matched by the given RegExp. |
| 2392 | |
| 2393 | Supports specifying enclosing namespaces or classes by |
| 2394 | prefixing the name with '<enclosing>::'. Does not match typedefs |
| 2395 | of an underlying type with the given name. |
| 2396 | |
| 2397 | Example matches X (regexp == "::X") |
| 2398 | class X; |
| 2399 | |
| 2400 | Example matches X (regexp is one of "::X", "^foo::.*X", among others) |
| 2401 | namespace foo { namespace bar { class X; } } |
| 2402 | </pre></td></tr> |
| 2403 | |
| 2404 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2405 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>></td><td class="name" onclick="toggle('isAnonymous0')"><a name="isAnonymous0Anchor">isAnonymous</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2406 | <tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. |
| 2407 | |
| 2408 | Given |
| 2409 | namespace n { |
| 2410 | namespace {} #1 |
| 2411 | } |
| 2412 | namespaceDecl(isAnonymous()) will match #1 but not ::n. |
| 2413 | </pre></td></tr> |
| 2414 | |
| 2415 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2416 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>></td><td class="name" onclick="toggle('isInline0')"><a name="isInline0Anchor">isInline</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2417 | <tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with |
| 2418 | the inline keyword. |
| 2419 | |
| 2420 | Given |
| 2421 | inline void f(); |
| 2422 | void g(); |
| 2423 | namespace n { |
| 2424 | inline namespace m {} |
| 2425 | } |
| 2426 | functionDecl(isInline()) will match ::f(). |
| 2427 | namespaceDecl(isInline()) will match n::m. |
| 2428 | </pre></td></tr> |
| 2429 | |
| 2430 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2431 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('argumentCountIs2')"><a name="argumentCountIs2Anchor">argumentCountIs</a></td><td>unsigned N</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2432 | <tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has |
| 2433 | a specific number of arguments (including absent default arguments). |
| 2434 | |
| 2435 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 2436 | void f(int x, int y); |
| 2437 | f(0, 0); |
| 2438 | </pre></td></tr> |
| 2439 | |
| 2440 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2441 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasKeywordSelector0')"><a name="hasKeywordSelector0Anchor">hasKeywordSelector</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2442 | <tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector |
| 2443 | |
| 2444 | objCMessageExpr(hasKeywordSelector()) matches the generated setFrame |
| 2445 | message expression in |
| 2446 | |
| 2447 | UIWebView *webView = ...; |
| 2448 | CGRect bodyFrame = webView.frame; |
| 2449 | bodyFrame.size.height = self.bodyContentHeight; |
| 2450 | webView.frame = bodyFrame; |
| 2451 | ^---- matches here |
| 2452 | </pre></td></tr> |
| 2453 | |
| 2454 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2455 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasNullSelector0')"><a name="hasNullSelector0Anchor">hasNullSelector</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2456 | <tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector |
| 2457 | |
| 2458 | Matches only when the selector of the objCMessageExpr is NULL. This may |
| 2459 | represent an error condition in the tree! |
| 2460 | </pre></td></tr> |
| 2461 | |
| 2462 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2463 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasSelector0')"><a name="hasSelector0Anchor">hasSelector</a></td><td>std::string BaseName</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2464 | <tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() |
| 2465 | |
| 2466 | matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); |
| 2467 | matches the outer message expr in the code below, but NOT the message |
| 2468 | invocation for self.bodyView. |
| 2469 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 2470 | </pre></td></tr> |
| 2471 | |
| 2472 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2473 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasUnarySelector0')"><a name="hasUnarySelector0Anchor">hasUnarySelector</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2474 | <tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector |
| 2475 | |
| 2476 | matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); |
| 2477 | matches self.bodyView in the code below, but NOT the outer message |
| 2478 | invocation of "loadHTMLString:baseURL:". |
| 2479 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 2480 | </pre></td></tr> |
| 2481 | |
| 2482 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2483 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('matchesSelector0')"><a name="matchesSelector0Anchor">matchesSelector</a></td><td>std::string RegExp</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2484 | <tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains |
| 2485 | a substring matched by the given RegExp. |
| 2486 | matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message |
| 2487 | invocation for self.bodyView. |
| 2488 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 2489 | </pre></td></tr> |
| 2490 | |
| 2491 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2492 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('numSelectorArgs0')"><a name="numSelectorArgs0Anchor">numSelectorArgs</a></td><td>unsigned N</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2493 | <tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments |
| 2494 | |
| 2495 | matcher = objCMessageExpr(numSelectorArgs(0)); |
| 2496 | matches self.bodyView in the code below |
| 2497 | |
| 2498 | matcher = objCMessageExpr(numSelectorArgs(2)); |
| 2499 | matches the invocation of "loadHTMLString:baseURL:" but not that |
| 2500 | of self.bodyView |
| 2501 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 2502 | </pre></td></tr> |
| 2503 | |
| 2504 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2505 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2506 | <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. |
| 2507 | |
| 2508 | Given |
| 2509 | class Y { public: void x(); }; |
| 2510 | void z() { Y* y; y->x(); } |
| 2511 | cxxMemberCallExpr(on(hasType(asString("class Y *")))) |
| 2512 | matches y->x() |
| 2513 | </pre></td></tr> |
| 2514 | |
| 2515 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2516 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('equalsBoundNode3')"><a name="equalsBoundNode3Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2517 | <tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. |
| 2518 | |
| 2519 | Matches a node if it equals the node previously bound to ID. |
| 2520 | |
| 2521 | Given |
| 2522 | class X { int a; int b; }; |
| 2523 | cxxRecordDecl( |
| 2524 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 2525 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 2526 | matches the class X, as a and b have the same type. |
| 2527 | |
| 2528 | Note that when multiple matches are involved via forEach* matchers, |
| 2529 | equalsBoundNodes acts as a filter. |
| 2530 | For example: |
| 2531 | compoundStmt( |
| 2532 | forEachDescendant(varDecl().bind("d")), |
| 2533 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 2534 | will trigger a match for each combination of variable declaration |
| 2535 | and reference to that variable declaration within a compound statement. |
| 2536 | </pre></td></tr> |
| 2537 | |
| 2538 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2539 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasLocalQualifiers0')"><a name="hasLocalQualifiers0Anchor">hasLocalQualifiers</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2540 | <tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to |
| 2541 | the node, not hidden within a typedef. |
| 2542 | |
| 2543 | Given |
| 2544 | typedef const int const_int; |
| 2545 | const_int i; |
| 2546 | int *const j; |
| 2547 | int *volatile k; |
| 2548 | int m; |
| 2549 | varDecl(hasType(hasLocalQualifiers())) matches only j and k. |
| 2550 | i is const-qualified but the qualifier is not local. |
| 2551 | </pre></td></tr> |
| 2552 | |
| 2553 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2554 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isAnyCharacter0')"><a name="isAnyCharacter0Anchor">isAnyCharacter</a></td><td></td></tr> |
Samuel Benzaquen | 30747f7 | 2015-12-22 21:06:36 +0000 | [diff] [blame] | 2555 | <tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type. |
| 2556 | |
| 2557 | Given |
| 2558 | void a(char); |
| 2559 | void b(wchar_t); |
| 2560 | void c(double); |
| 2561 | functionDecl(hasAnyParameter(hasType(isAnyCharacter()))) |
| 2562 | matches "a(char)", "b(wchar_t)", but not "c(double)". |
| 2563 | </pre></td></tr> |
| 2564 | |
| 2565 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2566 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2567 | <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that |
| 2568 | include "top-level" const. |
| 2569 | |
| 2570 | Given |
| 2571 | void a(int); |
| 2572 | void b(int const); |
| 2573 | void c(const int); |
| 2574 | void d(const int*); |
| 2575 | void e(int const) {}; |
| 2576 | functionDecl(hasAnyParameter(hasType(isConstQualified()))) |
| 2577 | matches "void b(int const)", "void c(const int)" and |
| 2578 | "void e(int const) {}". It does not match d as there |
| 2579 | is no top-level const on the parameter type "const int *". |
| 2580 | </pre></td></tr> |
| 2581 | |
| 2582 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2583 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2584 | <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. |
| 2585 | |
| 2586 | Given |
| 2587 | void a(int); |
| 2588 | void b(long); |
| 2589 | void c(double); |
| 2590 | functionDecl(hasAnyParameter(hasType(isInteger()))) |
| 2591 | matches "a(int)", "b(long)", but not "c(double)". |
| 2592 | </pre></td></tr> |
| 2593 | |
| 2594 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2595 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isVolatileQualified0')"><a name="isVolatileQualified0Anchor">isVolatileQualified</a></td><td></td></tr> |
Aaron Ballman | 6290fc9 | 2015-11-23 17:09:24 +0000 | [diff] [blame] | 2596 | <tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that |
| 2597 | include "top-level" volatile. |
| 2598 | |
| 2599 | Given |
| 2600 | void a(int); |
| 2601 | void b(int volatile); |
| 2602 | void c(volatile int); |
| 2603 | void d(volatile int*); |
| 2604 | void e(int volatile) {}; |
| 2605 | functionDecl(hasAnyParameter(hasType(isVolatileQualified()))) |
| 2606 | matches "void b(int volatile)", "void c(volatile int)" and |
| 2607 | "void e(int volatile) {}". It does not match d as there |
| 2608 | is no top-level volatile on the parameter type "volatile int *". |
| 2609 | </pre></td></tr> |
| 2610 | |
| 2611 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2612 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>></td><td class="name" onclick="toggle('isClass0')"><a name="isClass0Anchor">isClass</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2613 | <tr><td colspan="4" class="doc" id="isClass0"><pre>Matches RecordDecl object that are spelled with "class." |
| 2614 | |
| 2615 | Example matches C, but not S or U. |
| 2616 | struct S {}; |
| 2617 | class C {}; |
| 2618 | union U {}; |
| 2619 | </pre></td></tr> |
| 2620 | |
| 2621 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2622 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>></td><td class="name" onclick="toggle('isStruct0')"><a name="isStruct0Anchor">isStruct</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2623 | <tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches RecordDecl object that are spelled with "struct." |
| 2624 | |
| 2625 | Example matches S, but not C or U. |
| 2626 | struct S {}; |
| 2627 | class C {}; |
| 2628 | union U {}; |
| 2629 | </pre></td></tr> |
| 2630 | |
| 2631 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2632 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>></td><td class="name" onclick="toggle('isUnion0')"><a name="isUnion0Anchor">isUnion</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2633 | <tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches RecordDecl object that are spelled with "union." |
| 2634 | |
| 2635 | Example matches U, but not C or S. |
| 2636 | struct S {}; |
| 2637 | class C {}; |
| 2638 | union U {}; |
| 2639 | </pre></td></tr> |
| 2640 | |
| 2641 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2642 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('equalsBoundNode0')"><a name="equalsBoundNode0Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2643 | <tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. |
| 2644 | |
| 2645 | Matches a node if it equals the node previously bound to ID. |
| 2646 | |
| 2647 | Given |
| 2648 | class X { int a; int b; }; |
| 2649 | cxxRecordDecl( |
| 2650 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 2651 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 2652 | matches the class X, as a and b have the same type. |
| 2653 | |
| 2654 | Note that when multiple matches are involved via forEach* matchers, |
| 2655 | equalsBoundNodes acts as a filter. |
| 2656 | For example: |
| 2657 | compoundStmt( |
| 2658 | forEachDescendant(varDecl().bind("d")), |
| 2659 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 2660 | will trigger a match for each combination of variable declaration |
| 2661 | and reference to that variable declaration within a compound statement. |
| 2662 | </pre></td></tr> |
| 2663 | |
| 2664 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2665 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching1')"><a name="isExpansionInFileMatching1Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2666 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is |
| 2667 | partially matching a given regex. |
| 2668 | |
| 2669 | Example matches Y but not X |
| 2670 | (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 2671 | #include "ASTMatcher.h" |
| 2672 | class X {}; |
| 2673 | ASTMatcher.h: |
| 2674 | class Y {}; |
| 2675 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2676 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2677 | </pre></td></tr> |
| 2678 | |
| 2679 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2680 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInMainFile1')"><a name="isExpansionInMainFile1Anchor">isExpansionInMainFile</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2681 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. |
| 2682 | |
| 2683 | Example matches X but not Y |
| 2684 | (matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 2685 | #include <Y.h> |
| 2686 | class X {}; |
| 2687 | Y.h: |
| 2688 | class Y {}; |
| 2689 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2690 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2691 | </pre></td></tr> |
| 2692 | |
| 2693 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2694 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader1')"><a name="isExpansionInSystemHeader1Anchor">isExpansionInSystemHeader</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2695 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. |
| 2696 | |
| 2697 | Example matches Y but not X |
| 2698 | (matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 2699 | #include <SystemHeader.h> |
| 2700 | class X {}; |
| 2701 | SystemHeader.h: |
| 2702 | class Y {}; |
| 2703 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2704 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2705 | </pre></td></tr> |
| 2706 | |
| 2707 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2708 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>></td><td class="name" onclick="toggle('isDefinition0')"><a name="isDefinition0Anchor">isDefinition</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2709 | <tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. |
| 2710 | |
| 2711 | Example matches A, va, fa |
| 2712 | class A {}; |
| 2713 | class B; Doesn't match, as it has no body. |
| 2714 | int va; |
| 2715 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 2716 | void fa() {} |
| 2717 | void fb(); Doesn't match, as it has no body. |
| 2718 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2719 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2720 | </pre></td></tr> |
| 2721 | |
| 2722 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2723 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('equalsIntegralValue0')"><a name="equalsIntegralValue0Anchor">equalsIntegralValue</a></td><td>std::string Value</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2724 | <tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. |
| 2725 | |
| 2726 | Note that 'Value' is a string as the template argument's value is |
| 2727 | an arbitrary precision integer. 'Value' must be euqal to the canonical |
| 2728 | representation of that integral value in base 10. |
| 2729 | |
| 2730 | Given |
| 2731 | template<int T> struct A {}; |
| 2732 | C<42> c; |
| 2733 | classTemplateSpecializationDecl( |
| 2734 | hasAnyTemplateArgument(equalsIntegralValue("42"))) |
| 2735 | matches the implicit instantiation of C in C<42>. |
| 2736 | </pre></td></tr> |
| 2737 | |
| 2738 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2739 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('isIntegral0')"><a name="isIntegral0Anchor">isIntegral</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2740 | <tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. |
| 2741 | |
| 2742 | Given |
| 2743 | template<int T> struct A {}; |
| 2744 | C<42> c; |
| 2745 | classTemplateSpecializationDecl( |
| 2746 | hasAnyTemplateArgument(isIntegral())) |
| 2747 | matches the implicit instantiation of C in C<42> |
| 2748 | with isIntegral() matching 42. |
| 2749 | </pre></td></tr> |
| 2750 | |
| 2751 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2752 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('templateArgumentCountIs1')"><a name="templateArgumentCountIs1Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2753 | <tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. |
| 2754 | |
| 2755 | Given |
| 2756 | template<typename T> struct C {}; |
| 2757 | C<int> c; |
| 2758 | classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
| 2759 | matches C<int>. |
| 2760 | </pre></td></tr> |
| 2761 | |
| 2762 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2763 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching2')"><a name="isExpansionInFileMatching2Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2764 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is |
| 2765 | partially matching a given regex. |
| 2766 | |
| 2767 | Example matches Y but not X |
| 2768 | (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 2769 | #include "ASTMatcher.h" |
| 2770 | class X {}; |
| 2771 | ASTMatcher.h: |
| 2772 | class Y {}; |
| 2773 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2774 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2775 | </pre></td></tr> |
| 2776 | |
| 2777 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2778 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInMainFile2')"><a name="isExpansionInMainFile2Anchor">isExpansionInMainFile</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2779 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. |
| 2780 | |
| 2781 | Example matches X but not Y |
| 2782 | (matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 2783 | #include <Y.h> |
| 2784 | class X {}; |
| 2785 | Y.h: |
| 2786 | class Y {}; |
| 2787 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2788 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2789 | </pre></td></tr> |
| 2790 | |
| 2791 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2792 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader2')"><a name="isExpansionInSystemHeader2Anchor">isExpansionInSystemHeader</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2793 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. |
| 2794 | |
| 2795 | Example matches Y but not X |
| 2796 | (matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 2797 | #include <SystemHeader.h> |
| 2798 | class X {}; |
| 2799 | SystemHeader.h: |
| 2800 | class Y {}; |
| 2801 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2802 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2803 | </pre></td></tr> |
| 2804 | |
| 2805 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2806 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('booleanType0')"><a name="booleanType0Anchor">booleanType</a></td><td></td></tr> |
Samuel Benzaquen | 30747f7 | 2015-12-22 21:06:36 +0000 | [diff] [blame] | 2807 | <tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool. |
| 2808 | |
| 2809 | Given |
| 2810 | struct S { bool func(); }; |
| 2811 | functionDecl(returns(booleanType())) |
| 2812 | matches "bool func();" |
| 2813 | </pre></td></tr> |
| 2814 | |
| 2815 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2816 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('equalsBoundNode2')"><a name="equalsBoundNode2Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2817 | <tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. |
| 2818 | |
| 2819 | Matches a node if it equals the node previously bound to ID. |
| 2820 | |
| 2821 | Given |
| 2822 | class X { int a; int b; }; |
| 2823 | cxxRecordDecl( |
| 2824 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 2825 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 2826 | matches the class X, as a and b have the same type. |
| 2827 | |
| 2828 | Note that when multiple matches are involved via forEach* matchers, |
| 2829 | equalsBoundNodes acts as a filter. |
| 2830 | For example: |
| 2831 | compoundStmt( |
| 2832 | forEachDescendant(varDecl().bind("d")), |
| 2833 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 2834 | will trigger a match for each combination of variable declaration |
| 2835 | and reference to that variable declaration within a compound statement. |
| 2836 | </pre></td></tr> |
| 2837 | |
| 2838 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2839 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('voidType0')"><a name="voidType0Anchor">voidType</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2840 | <tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. |
| 2841 | |
| 2842 | Given |
| 2843 | struct S { void func(); }; |
| 2844 | functionDecl(returns(voidType())) |
| 2845 | matches "void func();" |
| 2846 | </pre></td></tr> |
| 2847 | |
| 2848 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2849 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2850 | <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. |
| 2851 | |
| 2852 | Given |
| 2853 | int x; |
| 2854 | int s = sizeof(x) + alignof(x) |
| 2855 | unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) |
| 2856 | matches sizeof(x) |
| 2857 | </pre></td></tr> |
| 2858 | |
| 2859 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2860 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2861 | <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or |
| 2862 | unary). |
| 2863 | |
| 2864 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 2865 | !(a || b) |
| 2866 | </pre></td></tr> |
| 2867 | |
| 2868 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2869 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasAutomaticStorageDuration0')"><a name="hasAutomaticStorageDuration0Anchor">hasAutomaticStorageDuration</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2870 | <tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration. |
| 2871 | |
| 2872 | Example matches x, but not y, z, or a. |
| 2873 | (matcher = varDecl(hasAutomaticStorageDuration()) |
| 2874 | void f() { |
| 2875 | int x; |
| 2876 | static int y; |
| 2877 | thread_local int z; |
| 2878 | } |
| 2879 | int a; |
| 2880 | </pre></td></tr> |
| 2881 | |
| 2882 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2883 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasGlobalStorage0')"><a name="hasGlobalStorage0Anchor">hasGlobalStorage</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2884 | <tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. |
| 2885 | |
| 2886 | Example matches y and z (matcher = varDecl(hasGlobalStorage()) |
| 2887 | void f() { |
| 2888 | int x; |
| 2889 | static int y; |
| 2890 | } |
| 2891 | int z; |
| 2892 | </pre></td></tr> |
| 2893 | |
| 2894 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2895 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasLocalStorage0')"><a name="hasLocalStorage0Anchor">hasLocalStorage</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2896 | <tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a |
| 2897 | non-static local variable. |
| 2898 | |
| 2899 | Example matches x (matcher = varDecl(hasLocalStorage()) |
| 2900 | void f() { |
| 2901 | int x; |
| 2902 | static int y; |
| 2903 | } |
| 2904 | int z; |
| 2905 | </pre></td></tr> |
| 2906 | |
| 2907 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2908 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasStaticStorageDuration0')"><a name="hasStaticStorageDuration0Anchor">hasStaticStorageDuration</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2909 | <tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration. |
| 2910 | |
| 2911 | Example matches y and a, but not x or z. |
| 2912 | (matcher = varDecl(hasStaticStorageDuration()) |
| 2913 | void f() { |
| 2914 | int x; |
| 2915 | static int y; |
| 2916 | thread_local int z; |
| 2917 | } |
| 2918 | int a; |
| 2919 | </pre></td></tr> |
| 2920 | |
| 2921 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2922 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasThreadStorageDuration0')"><a name="hasThreadStorageDuration0Anchor">hasThreadStorageDuration</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2923 | <tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration. |
| 2924 | |
| 2925 | Example matches z, but not x, z, or a. |
| 2926 | (matcher = varDecl(hasThreadStorageDuration()) |
| 2927 | void f() { |
| 2928 | int x; |
| 2929 | static int y; |
| 2930 | thread_local int z; |
| 2931 | } |
| 2932 | int a; |
| 2933 | </pre></td></tr> |
| 2934 | |
| 2935 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2936 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isConstexpr0')"><a name="isConstexpr0Anchor">isConstexpr</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2937 | <tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations. |
| 2938 | |
| 2939 | Given: |
| 2940 | constexpr int foo = 42; |
| 2941 | constexpr int bar(); |
| 2942 | varDecl(isConstexpr()) |
| 2943 | matches the declaration of foo. |
| 2944 | functionDecl(isConstexpr()) |
| 2945 | matches the declaration of bar. |
| 2946 | </pre></td></tr> |
| 2947 | |
| 2948 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2949 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2950 | <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. |
| 2951 | |
| 2952 | Example matches A, va, fa |
| 2953 | class A {}; |
| 2954 | class B; Doesn't match, as it has no body. |
| 2955 | int va; |
| 2956 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 2957 | void fa() {} |
| 2958 | void fb(); Doesn't match, as it has no body. |
| 2959 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2960 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2961 | </pre></td></tr> |
| 2962 | |
| 2963 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2964 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isExceptionVariable0')"><a name="isExceptionVariable0Anchor">isExceptionVariable</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2965 | <tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from |
| 2966 | a C++ catch block, or an Objective-C statement. |
| 2967 | |
| 2968 | Example matches x (matcher = varDecl(isExceptionVariable()) |
| 2969 | void f(int y) { |
| 2970 | try { |
| 2971 | } catch (int x) { |
| 2972 | } |
| 2973 | } |
| 2974 | </pre></td></tr> |
| 2975 | |
| 2976 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2977 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2978 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or |
| 2979 | static member variable template instantiations. |
| 2980 | |
| 2981 | Given |
| 2982 | template<typename T> void A(T t) { } |
| 2983 | template<> void A(int N) { } |
| 2984 | functionDecl(isExplicitTemplateSpecialization()) |
| 2985 | matches the specialization A<int>(). |
| 2986 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2987 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2988 | </pre></td></tr> |
| 2989 | |
| 2990 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2991 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2992 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static |
| 2993 | member variable template instantiations. |
| 2994 | |
| 2995 | Given |
| 2996 | template <typename T> class X {}; class A {}; X<A> x; |
| 2997 | or |
| 2998 | template <typename T> class X {}; class A {}; template class X<A>; |
| 2999 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 3000 | matches the template instantiation of X<A>. |
| 3001 | |
| 3002 | But given |
| 3003 | template <typename T> class X {}; class A {}; |
| 3004 | template <> class X<A> {}; X<A> x; |
| 3005 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 3006 | does not match, as X<A> is an explicit template specialization. |
| 3007 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3008 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3009 | </pre></td></tr> |
| 3010 | |
| 3011 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3012 | <tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>></td><td class="name" onclick="toggle('isInstantiated0')"><a name="isInstantiated0Anchor">isInstantiated</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3013 | <tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside |
| 3014 | template instantiations. |
| 3015 | |
| 3016 | Given |
| 3017 | template<typename T> void A(T t) { T i; } |
| 3018 | A(0); |
| 3019 | A(0U); |
| 3020 | functionDecl(isInstantiated()) |
| 3021 | matches 'A(int) {...};' and 'A(unsigned) {...}'. |
| 3022 | </pre></td></tr> |
| 3023 | |
| 3024 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3025 | <tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>></td><td class="name" onclick="toggle('isInTemplateInstantiation0')"><a name="isInTemplateInstantiation0Anchor">isInTemplateInstantiation</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3026 | <tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. |
| 3027 | |
| 3028 | Given |
| 3029 | int j; |
| 3030 | template<typename T> void A(T t) { T i; j += 42;} |
| 3031 | A(0); |
| 3032 | A(0U); |
| 3033 | declStmt(isInTemplateInstantiation()) |
| 3034 | matches 'int i;' and 'unsigned i'. |
| 3035 | unless(stmt(isInTemplateInstantiation())) |
| 3036 | will NOT match j += 42; as it's shared between the template definition and |
| 3037 | instantiation. |
| 3038 | </pre></td></tr> |
| 3039 | |
Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 3040 | <!--END_NARROWING_MATCHERS --> |
| 3041 | </table> |
| 3042 | |
| 3043 | <!-- ======================================================================= --> |
| 3044 | <h2 id="traversal-matchers">AST Traversal Matchers</h2> |
| 3045 | <!-- ======================================================================= --> |
| 3046 | |
| 3047 | <p>Traversal matchers specify the relationship to other nodes that are |
| 3048 | reachable from the current node.</p> |
| 3049 | |
| 3050 | <p>Note that there are special traversal matchers (has, hasDescendant, forEach and |
| 3051 | forEachDescendant) which work on all nodes and allow users to write more generic |
| 3052 | match expressions.</p> |
| 3053 | |
| 3054 | <table> |
| 3055 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3056 | <!-- START_TRAVERSAL_MATCHERS --> |
| 3057 | |
| 3058 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 3059 | <tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. |
| 3060 | |
| 3061 | Unlike anyOf, eachOf will generate a match result for each |
| 3062 | matching submatcher. |
| 3063 | |
| 3064 | For example, in: |
| 3065 | class A { int a; int b; }; |
| 3066 | The matcher: |
| 3067 | cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), |
| 3068 | has(fieldDecl(hasName("b")).bind("v")))) |
| 3069 | will generate two results binding "v", the first of which binds |
| 3070 | the field declaration of a, the second the field declaration of |
| 3071 | b. |
| 3072 | |
| 3073 | Usable as: Any Matcher |
| 3074 | </pre></td></tr> |
| 3075 | |
| 3076 | |
| 3077 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> |
| 3078 | <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 3079 | provided matcher. |
| 3080 | |
| 3081 | Example matches X, A, B, C |
| 3082 | (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) |
| 3083 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 3084 | class A { class X {}; }; |
| 3085 | class B { class C { class X {}; }; }; |
| 3086 | |
| 3087 | DescendantT must be an AST base type. |
| 3088 | |
| 3089 | As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for |
| 3090 | each result that matches instead of only on the first one. |
| 3091 | |
| 3092 | Note: Recursively combined ForEachDescendant can cause many matches: |
| 3093 | cxxRecordDecl(forEachDescendant(cxxRecordDecl( |
| 3094 | forEachDescendant(cxxRecordDecl()) |
| 3095 | ))) |
| 3096 | will match 10 times (plus injected class name matches) on: |
| 3097 | class A { class B { class C { class D { class E {}; }; }; }; }; |
| 3098 | |
| 3099 | Usable as: Any Matcher |
| 3100 | </pre></td></tr> |
| 3101 | |
| 3102 | |
| 3103 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> |
| 3104 | <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the |
| 3105 | provided matcher. |
| 3106 | |
| 3107 | Example matches X, Y |
| 3108 | (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) |
| 3109 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 3110 | class Y { class X {}; }; |
| 3111 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 3112 | |
| 3113 | ChildT must be an AST base type. |
| 3114 | |
| 3115 | As opposed to 'has', 'forEach' will cause a match for each result that |
| 3116 | matches instead of only on the first one. |
| 3117 | |
| 3118 | Usable as: Any Matcher |
| 3119 | </pre></td></tr> |
| 3120 | |
| 3121 | |
| 3122 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> |
| 3123 | <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided |
| 3124 | matcher. |
| 3125 | |
| 3126 | Given |
| 3127 | void f() { if (true) { int x = 42; } } |
| 3128 | void g() { for (;;) { int x = 43; } } |
| 3129 | expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. |
| 3130 | |
| 3131 | Usable as: Any Matcher |
| 3132 | </pre></td></tr> |
| 3133 | |
| 3134 | |
| 3135 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> |
| 3136 | <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 3137 | provided matcher. |
| 3138 | |
| 3139 | Example matches X, Y, Z |
| 3140 | (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) |
| 3141 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 3142 | class Y { class X {}; }; |
| 3143 | class Z { class Y { class X {}; }; }; |
| 3144 | |
| 3145 | DescendantT must be an AST base type. |
| 3146 | |
| 3147 | Usable as: Any Matcher |
| 3148 | </pre></td></tr> |
| 3149 | |
| 3150 | |
| 3151 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> |
| 3152 | <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the |
| 3153 | provided matcher. |
| 3154 | |
| 3155 | Example matches X, Y |
| 3156 | (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) |
| 3157 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 3158 | class Y { class X {}; }; |
| 3159 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 3160 | |
| 3161 | ChildT must be an AST base type. |
| 3162 | |
| 3163 | Usable as: Any Matcher |
| 3164 | </pre></td></tr> |
| 3165 | |
| 3166 | |
| 3167 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> |
| 3168 | <tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided |
| 3169 | matcher. |
| 3170 | |
| 3171 | Given |
| 3172 | void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } |
| 3173 | compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". |
| 3174 | |
| 3175 | Usable as: Any Matcher |
| 3176 | </pre></td></tr> |
| 3177 | |
| 3178 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3179 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3180 | <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. |
| 3181 | |
| 3182 | Given |
| 3183 | int i[5]; |
| 3184 | void f() { i[1] = 42; } |
| 3185 | arraySubscriptExpression(hasBase(implicitCastExpr( |
| 3186 | hasSourceExpression(declRefExpr())))) |
| 3187 | matches i[1] with the declRefExpr() matching i |
| 3188 | </pre></td></tr> |
| 3189 | |
| 3190 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3191 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3192 | <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. |
| 3193 | |
| 3194 | Given |
| 3195 | int i[5]; |
| 3196 | void f() { i[1] = 42; } |
| 3197 | arraySubscriptExpression(hasIndex(integerLiteral())) |
| 3198 | matches i[1] with the integerLiteral() matching 1 |
| 3199 | </pre></td></tr> |
| 3200 | |
| 3201 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3202 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>></td><td class="name" onclick="toggle('hasLHS1')"><a name="hasLHS1Anchor">hasLHS</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3203 | <tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions. |
| 3204 | |
| 3205 | Example matches a (matcher = binaryOperator(hasLHS())) |
| 3206 | a || b |
| 3207 | </pre></td></tr> |
| 3208 | |
| 3209 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3210 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>></td><td class="name" onclick="toggle('hasRHS1')"><a name="hasRHS1Anchor">hasRHS</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3211 | <tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions. |
| 3212 | |
| 3213 | Example matches b (matcher = binaryOperator(hasRHS())) |
| 3214 | a || b |
| 3215 | </pre></td></tr> |
| 3216 | |
| 3217 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3218 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayTypeLoc.html">ArrayTypeLoc</a>></td><td class="name" onclick="toggle('hasElementTypeLoc0')"><a name="hasElementTypeLoc0Anchor">hasElementTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3219 | <tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element |
| 3220 | type. |
| 3221 | |
| 3222 | Given |
| 3223 | struct A {}; |
| 3224 | A a[7]; |
| 3225 | int b[7]; |
| 3226 | arrayType(hasElementType(builtinType())) |
| 3227 | matches "int b[7]" |
| 3228 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3229 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3230 | </pre></td></tr> |
| 3231 | |
| 3232 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3233 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>></td><td class="name" onclick="toggle('hasElementType0')"><a name="hasElementType0Anchor">hasElementType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3234 | <tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element |
| 3235 | type. |
| 3236 | |
| 3237 | Given |
| 3238 | struct A {}; |
| 3239 | A a[7]; |
| 3240 | int b[7]; |
| 3241 | arrayType(hasElementType(builtinType())) |
| 3242 | matches "int b[7]" |
| 3243 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3244 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3245 | </pre></td></tr> |
| 3246 | |
| 3247 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3248 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicTypeLoc.html">AtomicTypeLoc</a>></td><td class="name" onclick="toggle('hasValueTypeLoc0')"><a name="hasValueTypeLoc0Anchor">hasValueTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3249 | <tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. |
| 3250 | |
| 3251 | Given |
| 3252 | _Atomic(int) i; |
| 3253 | _Atomic(float) f; |
| 3254 | atomicType(hasValueType(isInteger())) |
| 3255 | matches "_Atomic(int) i" |
| 3256 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3257 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3258 | </pre></td></tr> |
| 3259 | |
| 3260 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3261 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>></td><td class="name" onclick="toggle('hasValueType0')"><a name="hasValueType0Anchor">hasValueType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3262 | <tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. |
| 3263 | |
| 3264 | Given |
| 3265 | _Atomic(int) i; |
| 3266 | _Atomic(float) f; |
| 3267 | atomicType(hasValueType(isInteger())) |
| 3268 | matches "_Atomic(int) i" |
| 3269 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3270 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3271 | </pre></td></tr> |
| 3272 | |
| 3273 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3274 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>></td><td class="name" onclick="toggle('hasDeducedType0')"><a name="hasDeducedType0Anchor">hasDeducedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3275 | <tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. |
| 3276 | |
| 3277 | Note: There is no TypeLoc for the deduced type and thus no |
| 3278 | getDeducedLoc() matcher. |
| 3279 | |
| 3280 | Given |
| 3281 | auto a = 1; |
| 3282 | auto b = 2.0; |
| 3283 | autoType(hasDeducedType(isInteger())) |
| 3284 | matches "auto a" |
| 3285 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3286 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3287 | </pre></td></tr> |
| 3288 | |
| 3289 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3290 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3291 | <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a |
| 3292 | binary operator matches. |
| 3293 | </pre></td></tr> |
| 3294 | |
| 3295 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3296 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3297 | <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. |
| 3298 | |
| 3299 | Example matches a (matcher = binaryOperator(hasLHS())) |
| 3300 | a || b |
| 3301 | </pre></td></tr> |
| 3302 | |
| 3303 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3304 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3305 | <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. |
| 3306 | |
| 3307 | Example matches b (matcher = binaryOperator(hasRHS())) |
| 3308 | a || b |
| 3309 | </pre></td></tr> |
| 3310 | |
| 3311 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3312 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerTypeLoc.html">BlockPointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc0')"><a name="pointeeLoc0Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3313 | <tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3314 | pointee matches a given matcher. |
| 3315 | |
| 3316 | Given |
| 3317 | int *a; |
| 3318 | int const *b; |
| 3319 | float const *f; |
| 3320 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3321 | matches "int const *b" |
| 3322 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3323 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, |
| 3324 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3325 | </pre></td></tr> |
| 3326 | |
| 3327 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3328 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>></td><td class="name" onclick="toggle('pointee0')"><a name="pointee0Anchor">pointee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3329 | <tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3330 | pointee matches a given matcher. |
| 3331 | |
| 3332 | Given |
| 3333 | int *a; |
| 3334 | int const *b; |
| 3335 | float const *f; |
| 3336 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3337 | matches "int const *b" |
| 3338 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3339 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, |
| 3340 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3341 | </pre></td></tr> |
| 3342 | |
| 3343 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3344 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('forEachArgumentWithParam1')"><a name="forEachArgumentWithParam1Anchor">forEachArgumentWithParam</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> ArgMatcher, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> ParamMatcher</td></tr> |
Aaron Ballman | d7b18b9 | 2016-01-18 20:28:57 +0000 | [diff] [blame] | 3345 | <tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl. |
| 3346 | |
| 3347 | Given |
| 3348 | void f(int i); |
| 3349 | int y; |
| 3350 | f(y); |
| 3351 | callExpr(declRefExpr(to(varDecl(hasName("y")))), |
| 3352 | parmVarDecl(hasType(isInteger()))) |
| 3353 | matches f(y); |
| 3354 | with declRefExpr(...) |
| 3355 | matching int y |
| 3356 | and parmVarDecl(...) |
| 3357 | matching int i |
| 3358 | </pre></td></tr> |
| 3359 | |
| 3360 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3361 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasAnyArgument1')"><a name="hasAnyArgument1Anchor">hasAnyArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3362 | <tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call |
| 3363 | expression. |
| 3364 | |
| 3365 | Given |
| 3366 | void x(int, int, int) { int y; x(1, y, 42); } |
| 3367 | callExpr(hasAnyArgument(declRefExpr())) |
| 3368 | matches x(1, y, 42) |
| 3369 | with hasAnyArgument(...) |
| 3370 | matching y |
| 3371 | |
| 3372 | FIXME: Currently this will ignore parentheses and implicit casts on |
| 3373 | the argument before applying the inner matcher. We'll want to remove |
| 3374 | this to allow for greater control by the user once ignoreImplicit() |
| 3375 | has been implemented. |
| 3376 | </pre></td></tr> |
| 3377 | |
| 3378 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3379 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasArgument1')"><a name="hasArgument1Anchor">hasArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3380 | <tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor |
| 3381 | call expression. |
| 3382 | |
| 3383 | Example matches y in x(y) |
| 3384 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 3385 | void x(int) { int y; x(y); } |
| 3386 | </pre></td></tr> |
| 3387 | |
| 3388 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3389 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasDeclaration12')"><a name="hasDeclaration12Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3390 | <tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node |
| 3391 | matches the given matcher. |
| 3392 | |
| 3393 | The associated declaration is: |
| 3394 | - for type nodes, the declaration of the underlying type |
| 3395 | - for CallExpr, the declaration of the callee |
| 3396 | - for MemberExpr, the declaration of the referenced member |
| 3397 | - for CXXConstructExpr, the declaration of the constructor |
| 3398 | |
| 3399 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3400 | function. e.g. various subtypes of clang::Type and various expressions. |
| 3401 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3402 | Usable as: 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>>, |
| 3403 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3404 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3405 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3406 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3407 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3408 | </pre></td></tr> |
| 3409 | |
| 3410 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3411 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('forEachConstructorInitializer0')"><a name="forEachConstructorInitializer0Anchor">forEachConstructorInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3412 | <tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. |
| 3413 | |
| 3414 | Given |
| 3415 | class A { A() : i(42), j(42) {} int i; int j; }; |
| 3416 | cxxConstructorDecl(forEachConstructorInitializer( |
| 3417 | forField(decl().bind("x")) |
| 3418 | )) |
| 3419 | will trigger two matches, binding for 'i' and 'j' respectively. |
| 3420 | </pre></td></tr> |
| 3421 | |
| 3422 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3423 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3424 | <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. |
| 3425 | |
| 3426 | Given |
| 3427 | struct Foo { |
| 3428 | Foo() : foo_(1) { } |
| 3429 | int foo_; |
| 3430 | }; |
| 3431 | cxxRecordDecl(has(cxxConstructorDecl( |
| 3432 | hasAnyConstructorInitializer(anything()) |
| 3433 | ))) |
| 3434 | record matches Foo, hasAnyConstructorInitializer matches foo_(1) |
| 3435 | </pre></td></tr> |
| 3436 | |
| 3437 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3438 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3439 | <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. |
| 3440 | |
| 3441 | Given |
| 3442 | struct Foo { |
| 3443 | Foo() : foo_(1) { } |
| 3444 | int foo_; |
| 3445 | }; |
| 3446 | cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( |
| 3447 | forField(hasName("foo_")))))) |
| 3448 | matches Foo |
| 3449 | with forField matching foo_ |
| 3450 | </pre></td></tr> |
| 3451 | |
| 3452 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3453 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3454 | <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. |
| 3455 | |
| 3456 | Given |
| 3457 | struct Foo { |
| 3458 | Foo() : foo_(1) { } |
| 3459 | int foo_; |
| 3460 | }; |
| 3461 | cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( |
| 3462 | withInitializer(integerLiteral(equals(1))))))) |
| 3463 | matches Foo |
| 3464 | with withInitializer matching (1) |
| 3465 | </pre></td></tr> |
| 3466 | |
| 3467 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3468 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasBody3')"><a name="hasBody3Anchor">hasBody</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> |
Aaron Ballman | 2b6963f | 2016-01-20 16:26:48 +0000 | [diff] [blame] | 3469 | <tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 3470 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3471 | |
| 3472 | Given |
| 3473 | for (;;) {} |
| 3474 | hasBody(compoundStmt()) |
| 3475 | matches 'for (;;) {}' |
| 3476 | with compoundStmt() |
| 3477 | matching '{}' |
| 3478 | </pre></td></tr> |
| 3479 | |
| 3480 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3481 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasLoopVariable0')"><a name="hasLoopVariable0Anchor">hasLoopVariable</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3482 | <tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. |
| 3483 | |
| 3484 | Example: |
| 3485 | forStmt(hasLoopVariable(anything())) |
| 3486 | matches 'int x' in |
| 3487 | for (int x : a) { } |
| 3488 | </pre></td></tr> |
| 3489 | |
| 3490 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3491 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasRangeInit0')"><a name="hasRangeInit0Anchor">hasRangeInit</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3492 | <tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. |
| 3493 | |
| 3494 | Example: |
| 3495 | forStmt(hasRangeInit(anything())) |
| 3496 | matches 'a' in |
| 3497 | for (int x : a) { } |
| 3498 | </pre></td></tr> |
| 3499 | |
| 3500 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3501 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3502 | <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> |
| 3503 | |
| 3504 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3505 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3506 | <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. |
| 3507 | |
| 3508 | Example matches y.x() |
| 3509 | (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))) |
| 3510 | class Y { public: void x(); }; |
| 3511 | void z() { Y y; y.x(); }", |
| 3512 | |
| 3513 | FIXME: Overload to allow directly matching types? |
| 3514 | </pre></td></tr> |
| 3515 | |
| 3516 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3517 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3518 | <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. |
| 3519 | </pre></td></tr> |
| 3520 | |
| 3521 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3522 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>></td><td class="name" onclick="toggle('thisPointerType0')"><a name="thisPointerType0Anchor">thisPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3523 | <tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified |
| 3524 | matcher, or is a pointer to a type that matches the InnerMatcher. |
| 3525 | </pre></td></tr> |
| 3526 | |
| 3527 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3528 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3529 | <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration |
| 3530 | belongs to. |
| 3531 | |
| 3532 | FIXME: Generalize this for other kinds of declarations. |
| 3533 | FIXME: What other kind of declarations would we need to generalize |
| 3534 | this to? |
| 3535 | |
| 3536 | Example matches A() in the last line |
| 3537 | (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( |
| 3538 | ofClass(hasName("A")))))) |
| 3539 | class A { |
| 3540 | public: |
| 3541 | A(); |
| 3542 | }; |
| 3543 | A a = A(); |
| 3544 | </pre></td></tr> |
| 3545 | |
| 3546 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3547 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('hasMethod0')"><a name="hasMethod0Anchor">hasMethod</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3548 | <tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. |
| 3549 | |
| 3550 | Given: |
| 3551 | class A { void func(); }; |
| 3552 | class B { void member(); }; |
| 3553 | |
| 3554 | cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of |
| 3555 | A but not B. |
| 3556 | </pre></td></tr> |
| 3557 | |
| 3558 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3559 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3560 | <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from |
| 3561 | a class matching Base. |
| 3562 | |
| 3563 | Note that a class is not considered to be derived from itself. |
| 3564 | |
| 3565 | Example matches Y, Z, C (Base == hasName("X")) |
| 3566 | class X; |
| 3567 | class Y : public X {}; directly derived |
| 3568 | class Z : public Y {}; indirectly derived |
| 3569 | typedef X A; |
| 3570 | typedef A B; |
| 3571 | class C : public B {}; derived from a typedef of X |
| 3572 | |
| 3573 | In the following example, Bar matches isDerivedFrom(hasName("X")): |
| 3574 | class Foo; |
| 3575 | typedef Foo X; |
| 3576 | class Bar : public Foo {}; derived from a type that X is a typedef of |
| 3577 | </pre></td></tr> |
| 3578 | |
| 3579 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3580 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3581 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly |
| 3582 | match Base. |
| 3583 | </pre></td></tr> |
| 3584 | |
| 3585 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3586 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3587 | <tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the |
| 3588 | given matcher. |
| 3589 | |
| 3590 | Example matches y.x() (matcher = callExpr(callee( |
| 3591 | cxxMethodDecl(hasName("x"))))) |
| 3592 | class Y { public: void x(); }; |
| 3593 | void z() { Y y; y.x(); } |
| 3594 | </pre></td></tr> |
| 3595 | |
| 3596 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3597 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('callee0')"><a name="callee0Anchor">callee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3598 | <tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. |
| 3599 | |
| 3600 | Given |
| 3601 | class Y { void x() { this->x(); x(); Y y; y.x(); } }; |
| 3602 | void f() { f(); } |
| 3603 | callExpr(callee(expr())) |
| 3604 | matches this->x(), x(), y.x(), f() |
| 3605 | with callee(...) |
| 3606 | matching this->x, x, y.x, f respectively |
| 3607 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3608 | Note: Callee cannot take the more general internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3609 | because this introduces ambiguous overloads with calls to Callee taking a |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3610 | internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3611 | implemented in terms of implicit casts. |
| 3612 | </pre></td></tr> |
| 3613 | |
| 3614 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3615 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('forEachArgumentWithParam0')"><a name="forEachArgumentWithParam0Anchor">forEachArgumentWithParam</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> ArgMatcher, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> ParamMatcher</td></tr> |
Aaron Ballman | d7b18b9 | 2016-01-18 20:28:57 +0000 | [diff] [blame] | 3616 | <tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl. |
| 3617 | |
| 3618 | Given |
| 3619 | void f(int i); |
| 3620 | int y; |
| 3621 | f(y); |
| 3622 | callExpr(declRefExpr(to(varDecl(hasName("y")))), |
| 3623 | parmVarDecl(hasType(isInteger()))) |
| 3624 | matches f(y); |
| 3625 | with declRefExpr(...) |
| 3626 | matching int y |
| 3627 | and parmVarDecl(...) |
| 3628 | matching int i |
| 3629 | </pre></td></tr> |
| 3630 | |
| 3631 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3632 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3633 | <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call |
| 3634 | expression. |
| 3635 | |
| 3636 | Given |
| 3637 | void x(int, int, int) { int y; x(1, y, 42); } |
| 3638 | callExpr(hasAnyArgument(declRefExpr())) |
| 3639 | matches x(1, y, 42) |
| 3640 | with hasAnyArgument(...) |
| 3641 | matching y |
| 3642 | |
| 3643 | FIXME: Currently this will ignore parentheses and implicit casts on |
| 3644 | the argument before applying the inner matcher. We'll want to remove |
| 3645 | this to allow for greater control by the user once ignoreImplicit() |
| 3646 | has been implemented. |
| 3647 | </pre></td></tr> |
| 3648 | |
| 3649 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3650 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3651 | <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor |
| 3652 | call expression. |
| 3653 | |
| 3654 | Example matches y in x(y) |
| 3655 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 3656 | void x(int) { int y; x(y); } |
| 3657 | </pre></td></tr> |
| 3658 | |
| 3659 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3660 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasDeclaration13')"><a name="hasDeclaration13Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3661 | <tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node |
| 3662 | matches the given matcher. |
| 3663 | |
| 3664 | The associated declaration is: |
| 3665 | - for type nodes, the declaration of the underlying type |
| 3666 | - for CallExpr, the declaration of the callee |
| 3667 | - for MemberExpr, the declaration of the referenced member |
| 3668 | - for CXXConstructExpr, the declaration of the constructor |
| 3669 | |
| 3670 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3671 | function. e.g. various subtypes of clang::Type and various expressions. |
| 3672 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3673 | Usable as: 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>>, |
| 3674 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3675 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3676 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3677 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3678 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3679 | </pre></td></tr> |
| 3680 | |
| 3681 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3682 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>></td><td class="name" onclick="toggle('hasCaseConstant0')"><a name="hasCaseConstant0Anchor">hasCaseConstant</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3683 | <tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range |
| 3684 | extension, matches the constant given in the statement. |
| 3685 | |
| 3686 | Given |
| 3687 | switch (1) { case 1: case 1+1: case 3 ... 4: ; } |
| 3688 | caseStmt(hasCaseConstant(integerLiteral())) |
| 3689 | matches "case 1:" |
| 3690 | </pre></td></tr> |
| 3691 | |
| 3692 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3693 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3694 | <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher. |
| 3695 | |
| 3696 | Example: matches "a string" (matcher = |
| 3697 | hasSourceExpression(cxxConstructExpr())) |
| 3698 | class URL { URL(string); }; |
| 3699 | URL url = "a string"; |
| 3700 | </pre></td></tr> |
| 3701 | |
| 3702 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3703 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3704 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one |
| 3705 | TemplateArgument matching the given InnerMatcher. |
| 3706 | |
| 3707 | Given |
| 3708 | template<typename T> class A {}; |
| 3709 | template<> class A<double> {}; |
| 3710 | A<int> a; |
| 3711 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 3712 | refersToType(asString("int")))) |
| 3713 | matches the specialization A<int> |
| 3714 | </pre></td></tr> |
| 3715 | |
| 3716 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3717 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3718 | <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument |
| 3719 | matches the given InnerMatcher. |
| 3720 | |
| 3721 | Given |
| 3722 | template<typename T, typename U> class A {}; |
| 3723 | A<bool, int> b; |
| 3724 | A<int, bool> c; |
| 3725 | classTemplateSpecializationDecl(hasTemplateArgument( |
| 3726 | 1, refersToType(asString("int")))) |
| 3727 | matches the specialization A<bool, int> |
| 3728 | </pre></td></tr> |
| 3729 | |
| 3730 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3731 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexTypeLoc.html">ComplexTypeLoc</a>></td><td class="name" onclick="toggle('hasElementTypeLoc1')"><a name="hasElementTypeLoc1Anchor">hasElementTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3732 | <tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element |
| 3733 | type. |
| 3734 | |
| 3735 | Given |
| 3736 | struct A {}; |
| 3737 | A a[7]; |
| 3738 | int b[7]; |
| 3739 | arrayType(hasElementType(builtinType())) |
| 3740 | matches "int b[7]" |
| 3741 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3742 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3743 | </pre></td></tr> |
| 3744 | |
| 3745 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3746 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>></td><td class="name" onclick="toggle('hasElementType1')"><a name="hasElementType1Anchor">hasElementType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3747 | <tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element |
| 3748 | type. |
| 3749 | |
| 3750 | Given |
| 3751 | struct A {}; |
| 3752 | A a[7]; |
| 3753 | int b[7]; |
| 3754 | arrayType(hasElementType(builtinType())) |
| 3755 | matches "int b[7]" |
| 3756 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3757 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3758 | </pre></td></tr> |
| 3759 | |
| 3760 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3761 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3762 | <tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches |
| 3763 | a given matcher. |
| 3764 | |
| 3765 | Given |
| 3766 | { {}; 1+2; } |
| 3767 | hasAnySubstatement(compoundStmt()) |
| 3768 | matches '{ {}; 1+2; }' |
| 3769 | with compoundStmt() |
| 3770 | matching '{}' |
| 3771 | </pre></td></tr> |
| 3772 | |
| 3773 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3774 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3775 | <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, |
| 3776 | or conditional operator. |
| 3777 | |
| 3778 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 3779 | if (true) {} |
| 3780 | </pre></td></tr> |
| 3781 | |
| 3782 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3783 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3784 | <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator. |
| 3785 | |
| 3786 | Example matches b |
| 3787 | condition ? a : b |
| 3788 | </pre></td></tr> |
| 3789 | |
| 3790 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3791 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3792 | <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. |
| 3793 | |
| 3794 | Example matches a |
| 3795 | condition ? a : b |
| 3796 | </pre></td></tr> |
| 3797 | |
| 3798 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3799 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>></td><td class="name" onclick="toggle('hasDecayedType0')"><a name="hasDecayedType0Anchor">hasDecayedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerType</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3800 | <tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whos decayed type matches InnerMatcher |
| 3801 | </pre></td></tr> |
| 3802 | |
| 3803 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3804 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('hasDeclaration11')"><a name="hasDeclaration11Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3805 | <tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node |
| 3806 | matches the given matcher. |
| 3807 | |
| 3808 | The associated declaration is: |
| 3809 | - for type nodes, the declaration of the underlying type |
| 3810 | - for CallExpr, the declaration of the callee |
| 3811 | - for MemberExpr, the declaration of the referenced member |
| 3812 | - for CXXConstructExpr, the declaration of the constructor |
| 3813 | |
| 3814 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3815 | function. e.g. various subtypes of clang::Type and various expressions. |
| 3816 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3817 | Usable as: 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>>, |
| 3818 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3819 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3820 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3821 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3822 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3823 | </pre></td></tr> |
| 3824 | |
| 3825 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3826 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3827 | <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a |
| 3828 | specific using shadow declaration. |
| 3829 | |
| 3830 | Given |
| 3831 | namespace a { void f() {} } |
| 3832 | using a::f; |
| 3833 | void g() { |
| 3834 | f(); Matches this .. |
| 3835 | a::f(); .. but not this. |
| 3836 | } |
| 3837 | declRefExpr(throughUsingDecl(anything())) |
| 3838 | matches f() |
| 3839 | </pre></td></tr> |
| 3840 | |
| 3841 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3842 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3843 | <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the |
| 3844 | specified matcher. |
| 3845 | |
| 3846 | Example matches x in if(x) |
| 3847 | (matcher = declRefExpr(to(varDecl(hasName("x"))))) |
| 3848 | bool x; |
| 3849 | if (x) {} |
| 3850 | </pre></td></tr> |
| 3851 | |
| 3852 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3853 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3854 | <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. |
| 3855 | |
| 3856 | Note that this does not work for global declarations because the AST |
| 3857 | breaks up multiple-declaration DeclStmt's into multiple single-declaration |
| 3858 | DeclStmt's. |
| 3859 | Example: Given non-global declarations |
| 3860 | int a, b = 0; |
| 3861 | int c; |
| 3862 | int d = 2, e; |
| 3863 | declStmt(containsDeclaration( |
| 3864 | 0, varDecl(hasInitializer(anything())))) |
| 3865 | matches only 'int d = 2, e;', and |
| 3866 | declStmt(containsDeclaration(1, varDecl())) |
| 3867 | matches 'int a, b = 0' as well as 'int d = 2, e;' |
| 3868 | but 'int c;' is not matched. |
| 3869 | </pre></td></tr> |
| 3870 | |
| 3871 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3872 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3873 | <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. |
| 3874 | |
| 3875 | Given |
| 3876 | int a, b; |
| 3877 | int c; |
| 3878 | declStmt(hasSingleDecl(anything())) |
| 3879 | matches 'int c;' but not 'int a, b;'. |
| 3880 | </pre></td></tr> |
| 3881 | |
| 3882 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3883 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>></td><td class="name" onclick="toggle('hasTypeLoc0')"><a name="hasTypeLoc0Anchor">hasTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3884 | <tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches |
| 3885 | the inner matcher. |
| 3886 | |
| 3887 | Given |
| 3888 | int x; |
| 3889 | declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 3890 | matches int x |
| 3891 | </pre></td></tr> |
| 3892 | |
| 3893 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3894 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('hasDeclContext0')"><a name="hasDeclContext0Anchor">hasDeclContext</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3895 | <tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a |
| 3896 | Decl, matches InnerMatcher. |
| 3897 | |
| 3898 | Given |
| 3899 | namespace N { |
| 3900 | namespace M { |
| 3901 | class D {}; |
| 3902 | } |
| 3903 | } |
| 3904 | |
| 3905 | cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the |
| 3906 | declaration of class D. |
| 3907 | </pre></td></tr> |
| 3908 | |
| 3909 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3910 | <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> |
Aaron Ballman | 2b6963f | 2016-01-20 16:26:48 +0000 | [diff] [blame] | 3911 | <tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 3912 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3913 | |
| 3914 | Given |
| 3915 | for (;;) {} |
| 3916 | hasBody(compoundStmt()) |
| 3917 | matches 'for (;;) {}' |
| 3918 | with compoundStmt() |
| 3919 | matching '{}' |
| 3920 | </pre></td></tr> |
| 3921 | |
| 3922 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3923 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3924 | <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, |
| 3925 | or conditional operator. |
| 3926 | |
| 3927 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 3928 | if (true) {} |
| 3929 | </pre></td></tr> |
| 3930 | |
| 3931 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3932 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>></td><td class="name" onclick="toggle('hasQualifier0')"><a name="hasQualifier0Anchor">hasQualifier</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3933 | <tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, |
| 3934 | matches InnerMatcher if the qualifier exists. |
| 3935 | |
| 3936 | Given |
| 3937 | namespace N { |
| 3938 | namespace M { |
| 3939 | class D {}; |
| 3940 | } |
| 3941 | } |
| 3942 | N::M::D d; |
| 3943 | |
| 3944 | elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) |
| 3945 | matches the type of the variable declaration of d. |
| 3946 | </pre></td></tr> |
| 3947 | |
| 3948 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3949 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>></td><td class="name" onclick="toggle('namesType0')"><a name="namesType0Anchor">namesType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3950 | <tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. |
| 3951 | |
| 3952 | Given |
| 3953 | namespace N { |
| 3954 | namespace M { |
| 3955 | class D {}; |
| 3956 | } |
| 3957 | } |
| 3958 | N::M::D d; |
| 3959 | |
| 3960 | elaboratedType(namesType(recordType( |
| 3961 | hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable |
| 3962 | declaration of d. |
| 3963 | </pre></td></tr> |
| 3964 | |
| 3965 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3966 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>></td><td class="name" onclick="toggle('hasDeclaration10')"><a name="hasDeclaration10Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3967 | <tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node |
| 3968 | matches the given matcher. |
| 3969 | |
| 3970 | The associated declaration is: |
| 3971 | - for type nodes, the declaration of the underlying type |
| 3972 | - for CallExpr, the declaration of the callee |
| 3973 | - for MemberExpr, the declaration of the referenced member |
| 3974 | - for CXXConstructExpr, the declaration of the constructor |
| 3975 | |
| 3976 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3977 | function. e.g. various subtypes of clang::Type and various expressions. |
| 3978 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3979 | Usable as: 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>>, |
| 3980 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 3981 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 3982 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 3983 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 3984 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3985 | </pre></td></tr> |
| 3986 | |
| 3987 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3988 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3989 | <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. |
| 3990 | |
| 3991 | (Note: Clang's AST refers to other conversions as "casts" too, and calls |
| 3992 | actual casts "explicit" casts.) |
| 3993 | </pre></td></tr> |
| 3994 | |
| 3995 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3996 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3997 | <tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value |
| 3998 | declaration's type. |
| 3999 | |
| 4000 | In case of a value declaration (for example a variable declaration), |
| 4001 | this resolves one layer of indirection. For example, in the value |
| 4002 | declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 4003 | X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 4004 | declaration of x. |
| 4005 | |
| 4006 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 4007 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 4008 | class X {}; |
| 4009 | void y(X &x) { x; X z; } |
| 4010 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4011 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4012 | </pre></td></tr> |
| 4013 | |
| 4014 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4015 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('hasType0')"><a name="hasType0Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4016 | <tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type |
| 4017 | matcher. |
| 4018 | |
| 4019 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 4020 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 4021 | class X {}; |
| 4022 | void y(X &x) { x; X z; } |
| 4023 | </pre></td></tr> |
| 4024 | |
| 4025 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4026 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4027 | <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts |
| 4028 | are stripped off. |
| 4029 | |
| 4030 | Parentheses and explicit casts are not discarded. |
| 4031 | Given |
| 4032 | int arr[5]; |
| 4033 | int a = 0; |
| 4034 | char b = 0; |
| 4035 | const int c = a; |
| 4036 | int *d = arr; |
| 4037 | long e = (long) 0l; |
| 4038 | The matchers |
| 4039 | varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) |
| 4040 | varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) |
| 4041 | would match the declarations for a, b, c, and d, but not e. |
| 4042 | While |
| 4043 | varDecl(hasInitializer(integerLiteral())) |
| 4044 | varDecl(hasInitializer(declRefExpr())) |
| 4045 | only match the declarations for b, c, and d. |
| 4046 | </pre></td></tr> |
| 4047 | |
| 4048 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4049 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4050 | <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and |
| 4051 | casts are stripped off. |
| 4052 | |
| 4053 | Implicit and non-C Style casts are also discarded. |
| 4054 | Given |
| 4055 | int a = 0; |
| 4056 | char b = (0); |
| 4057 | void* c = reinterpret_cast<char*>(0); |
| 4058 | char d = char(0); |
| 4059 | The matcher |
| 4060 | varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) |
| 4061 | would match the declarations for a, b, c, and d. |
| 4062 | while |
| 4063 | varDecl(hasInitializer(integerLiteral())) |
| 4064 | only match the declaration for a. |
| 4065 | </pre></td></tr> |
| 4066 | |
| 4067 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4068 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4069 | <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and |
| 4070 | parentheses are stripped off. |
| 4071 | |
| 4072 | Explicit casts are not discarded. |
| 4073 | Given |
| 4074 | int arr[5]; |
| 4075 | int a = 0; |
| 4076 | char b = (0); |
| 4077 | const int c = a; |
| 4078 | int *d = (arr); |
| 4079 | long e = ((long) 0l); |
| 4080 | The matchers |
| 4081 | varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) |
| 4082 | varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) |
| 4083 | would match the declarations for a, b, c, and d, but not e. |
| 4084 | while |
| 4085 | varDecl(hasInitializer(integerLiteral())) |
| 4086 | varDecl(hasInitializer(declRefExpr())) |
| 4087 | would only match the declaration for a. |
| 4088 | </pre></td></tr> |
| 4089 | |
| 4090 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4091 | <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> |
Aaron Ballman | 2b6963f | 2016-01-20 16:26:48 +0000 | [diff] [blame] | 4092 | <tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 4093 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4094 | |
| 4095 | Given |
| 4096 | for (;;) {} |
| 4097 | hasBody(compoundStmt()) |
| 4098 | matches 'for (;;) {}' |
| 4099 | with compoundStmt() |
| 4100 | matching '{}' |
| 4101 | </pre></td></tr> |
| 4102 | |
| 4103 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4104 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4105 | <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, |
| 4106 | or conditional operator. |
| 4107 | |
| 4108 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 4109 | if (true) {} |
| 4110 | </pre></td></tr> |
| 4111 | |
| 4112 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4113 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4114 | <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. |
| 4115 | |
| 4116 | Example: |
| 4117 | forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) |
| 4118 | matches '++x' in |
| 4119 | for (x; x < N; ++x) { } |
| 4120 | </pre></td></tr> |
| 4121 | |
| 4122 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4123 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4124 | <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. |
| 4125 | |
| 4126 | Example: |
| 4127 | forStmt(hasLoopInit(declStmt())) |
| 4128 | matches 'int x = 0' in |
| 4129 | for (int x = 0; x < N; ++x) { } |
| 4130 | </pre></td></tr> |
| 4131 | |
| 4132 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4133 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4134 | <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. |
| 4135 | |
| 4136 | Does not match the 'this' parameter of a method. |
| 4137 | |
| 4138 | Given |
| 4139 | class X { void f(int x, int y, int z) {} }; |
| 4140 | cxxMethodDecl(hasAnyParameter(hasName("y"))) |
| 4141 | matches f(int x, int y, int z) {} |
| 4142 | with hasAnyParameter(...) |
| 4143 | matching int y |
| 4144 | </pre></td></tr> |
| 4145 | |
| 4146 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4147 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasBody4')"><a name="hasBody4Anchor">hasBody</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> |
Aaron Ballman | 2b6963f | 2016-01-20 16:26:48 +0000 | [diff] [blame] | 4148 | <tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 4149 | definition that has a given body. |
| 4150 | |
| 4151 | Given |
| 4152 | for (;;) {} |
| 4153 | hasBody(compoundStmt()) |
| 4154 | matches 'for (;;) {}' |
| 4155 | with compoundStmt() |
| 4156 | matching '{}' |
| 4157 | </pre></td></tr> |
| 4158 | |
| 4159 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4160 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4161 | <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. |
| 4162 | |
| 4163 | Given |
| 4164 | class X { void f(int x) {} }; |
| 4165 | cxxMethodDecl(hasParameter(0, hasType(varDecl()))) |
| 4166 | matches f(int x) {} |
| 4167 | with hasParameter(...) |
| 4168 | matching int x |
| 4169 | </pre></td></tr> |
| 4170 | |
| 4171 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4172 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4173 | <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. |
| 4174 | |
| 4175 | Given: |
| 4176 | class X { int f() { return 1; } }; |
| 4177 | cxxMethodDecl(returns(asString("int"))) |
| 4178 | matches int f() { return 1; } |
| 4179 | </pre></td></tr> |
| 4180 | |
| 4181 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4182 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4183 | <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, |
| 4184 | or conditional operator. |
| 4185 | |
| 4186 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 4187 | if (true) {} |
| 4188 | </pre></td></tr> |
| 4189 | |
| 4190 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4191 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4192 | <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. |
| 4193 | |
| 4194 | Given |
| 4195 | if (A* a = GetAPointer()) {} |
| 4196 | hasConditionVariableStatement(...) |
| 4197 | matches 'A* a = GetAPointer()'. |
| 4198 | </pre></td></tr> |
| 4199 | |
| 4200 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4201 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasElse0')"><a name="hasElse0Anchor">hasElse</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4202 | <tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. |
| 4203 | |
| 4204 | Examples matches the if statement |
| 4205 | (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) |
| 4206 | if (false) false; else true; |
| 4207 | </pre></td></tr> |
| 4208 | |
| 4209 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4210 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasThen0')"><a name="hasThen0Anchor">hasThen</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4211 | <tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. |
| 4212 | |
| 4213 | Examples matches the if statement |
| 4214 | (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) |
| 4215 | if (false) true; else false; |
| 4216 | </pre></td></tr> |
| 4217 | |
| 4218 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4219 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4220 | <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given |
| 4221 | matcher. |
| 4222 | |
| 4223 | FIXME: Unit test this matcher |
| 4224 | </pre></td></tr> |
| 4225 | |
| 4226 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4227 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>></td><td class="name" onclick="toggle('hasDeclaration9')"><a name="hasDeclaration9Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4228 | <tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node |
| 4229 | matches the given matcher. |
| 4230 | |
| 4231 | The associated declaration is: |
| 4232 | - for type nodes, the declaration of the underlying type |
| 4233 | - for CallExpr, the declaration of the callee |
| 4234 | - for MemberExpr, the declaration of the referenced member |
| 4235 | - for CXXConstructExpr, the declaration of the constructor |
| 4236 | |
| 4237 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4238 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4239 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4240 | Usable as: 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>>, |
| 4241 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 4242 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 4243 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 4244 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 4245 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4246 | </pre></td></tr> |
| 4247 | |
| 4248 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4249 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>></td><td class="name" onclick="toggle('hasDeclaration8')"><a name="hasDeclaration8Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4250 | <tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node |
| 4251 | matches the given matcher. |
| 4252 | |
| 4253 | The associated declaration is: |
| 4254 | - for type nodes, the declaration of the underlying type |
| 4255 | - for CallExpr, the declaration of the callee |
| 4256 | - for MemberExpr, the declaration of the referenced member |
| 4257 | - for CXXConstructExpr, the declaration of the constructor |
| 4258 | |
| 4259 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4260 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4261 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4262 | Usable as: 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>>, |
| 4263 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 4264 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 4265 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 4266 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 4267 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4268 | </pre></td></tr> |
| 4269 | |
| 4270 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4271 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('hasDeclaration7')"><a name="hasDeclaration7Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4272 | <tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node |
| 4273 | matches the given matcher. |
| 4274 | |
| 4275 | The associated declaration is: |
| 4276 | - for type nodes, the declaration of the underlying type |
| 4277 | - for CallExpr, the declaration of the callee |
| 4278 | - for MemberExpr, the declaration of the referenced member |
| 4279 | - for CXXConstructExpr, the declaration of the constructor |
| 4280 | |
| 4281 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4282 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4283 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4284 | Usable as: 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>>, |
| 4285 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 4286 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 4287 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 4288 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 4289 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4290 | </pre></td></tr> |
| 4291 | |
| 4292 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4293 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4294 | <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is |
| 4295 | matched by a given matcher. |
| 4296 | |
| 4297 | Given |
| 4298 | struct X { int m; }; |
| 4299 | void f(X x) { x.m; m; } |
| 4300 | memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))))) |
| 4301 | matches "x.m" and "m" |
| 4302 | with hasObjectExpression(...) |
| 4303 | matching "x" and the implicit object expression of "m" which has type X*. |
| 4304 | </pre></td></tr> |
| 4305 | |
| 4306 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4307 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4308 | <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a |
| 4309 | given matcher. |
| 4310 | |
| 4311 | Given |
| 4312 | struct { int first, second; } first, second; |
| 4313 | int i(second.first); |
| 4314 | int j(first.second); |
| 4315 | memberExpr(member(hasName("first"))) |
| 4316 | matches second.first |
| 4317 | but not first.second (because the member name there is "second"). |
| 4318 | </pre></td></tr> |
| 4319 | |
| 4320 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4321 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerTypeLoc.html">MemberPointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc1')"><a name="pointeeLoc1Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4322 | <tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4323 | pointee matches a given matcher. |
| 4324 | |
| 4325 | Given |
| 4326 | int *a; |
| 4327 | int const *b; |
| 4328 | float const *f; |
| 4329 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4330 | matches "int const *b" |
| 4331 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4332 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, |
| 4333 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4334 | </pre></td></tr> |
| 4335 | |
| 4336 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4337 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>></td><td class="name" onclick="toggle('pointee1')"><a name="pointee1Anchor">pointee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4338 | <tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4339 | pointee matches a given matcher. |
| 4340 | |
| 4341 | Given |
| 4342 | int *a; |
| 4343 | int const *b; |
| 4344 | float const *f; |
| 4345 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4346 | matches "int const *b" |
| 4347 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4348 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, |
| 4349 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4350 | </pre></td></tr> |
| 4351 | |
| 4352 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4353 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4354 | <tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. |
| 4355 | |
| 4356 | Given |
| 4357 | struct A { struct B { struct C {}; }; }; |
| 4358 | A::B::C c; |
| 4359 | nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) |
| 4360 | matches "A::" |
| 4361 | </pre></td></tr> |
| 4362 | |
| 4363 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4364 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4365 | <tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the |
| 4366 | given TypeLoc. |
| 4367 | |
| 4368 | Given |
| 4369 | struct A { struct B { struct C {}; }; }; |
| 4370 | A::B::C c; |
| 4371 | nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( |
| 4372 | hasDeclaration(cxxRecordDecl(hasName("A"))))))) |
| 4373 | matches "A::" |
| 4374 | </pre></td></tr> |
| 4375 | |
| 4376 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4377 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4378 | <tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. |
| 4379 | |
| 4380 | Given |
| 4381 | struct A { struct B { struct C {}; }; }; |
| 4382 | A::B::C c; |
| 4383 | nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and |
| 4384 | matches "A::" |
| 4385 | </pre></td></tr> |
| 4386 | |
| 4387 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4388 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4389 | <tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the |
| 4390 | given namespace matcher. |
| 4391 | |
| 4392 | Given |
| 4393 | namespace ns { struct A {}; } |
| 4394 | ns::A a; |
| 4395 | nestedNameSpecifier(specifiesNamespace(hasName("ns"))) |
| 4396 | matches "ns::" |
| 4397 | </pre></td></tr> |
| 4398 | |
| 4399 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4400 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4401 | <tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the |
| 4402 | given QualType matcher without qualifiers. |
| 4403 | |
| 4404 | Given |
| 4405 | struct A { struct B { struct C {}; }; }; |
| 4406 | A::B::C c; |
| 4407 | nestedNameSpecifier(specifiesType( |
| 4408 | hasDeclaration(cxxRecordDecl(hasName("A"))) |
| 4409 | )) |
| 4410 | matches "A::" |
| 4411 | </pre></td></tr> |
| 4412 | |
| 4413 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4414 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasArgument2')"><a name="hasArgument2Anchor">hasArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4415 | <tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor |
| 4416 | call expression. |
| 4417 | |
| 4418 | Example matches y in x(y) |
| 4419 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 4420 | void x(int) { int y; x(y); } |
| 4421 | </pre></td></tr> |
| 4422 | |
| 4423 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4424 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasReceiverType0')"><a name="hasReceiverType0Anchor">hasReceiverType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4425 | <tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. |
| 4426 | |
| 4427 | Example |
| 4428 | matcher = objCMessageExpr(hasRecieverType(asString("UIWebView *"))); |
| 4429 | matches the [webView ...] message invocation. |
| 4430 | NSString *webViewJavaScript = ... |
| 4431 | UIWebView *webView = ... |
| 4432 | [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; |
| 4433 | </pre></td></tr> |
| 4434 | |
| 4435 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4436 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>></td><td class="name" onclick="toggle('innerType0')"><a name="innerType0Anchor">innerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4437 | <tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. |
| 4438 | |
| 4439 | Given |
| 4440 | int (*ptr_to_array)[4]; |
| 4441 | int (*ptr_to_func)(int); |
| 4442 | |
| 4443 | varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches |
| 4444 | ptr_to_func but not ptr_to_array. |
| 4445 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4446 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4447 | </pre></td></tr> |
| 4448 | |
| 4449 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4450 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc2')"><a name="pointeeLoc2Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4451 | <tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4452 | pointee matches a given matcher. |
| 4453 | |
| 4454 | Given |
| 4455 | int *a; |
| 4456 | int const *b; |
| 4457 | float const *f; |
| 4458 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4459 | matches "int const *b" |
| 4460 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4461 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, |
| 4462 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4463 | </pre></td></tr> |
| 4464 | |
| 4465 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4466 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>></td><td class="name" onclick="toggle('pointee2')"><a name="pointee2Anchor">pointee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4467 | <tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4468 | pointee matches a given matcher. |
| 4469 | |
| 4470 | Given |
| 4471 | int *a; |
| 4472 | int const *b; |
| 4473 | float const *f; |
| 4474 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4475 | matches "int const *b" |
| 4476 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4477 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, |
| 4478 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4479 | </pre></td></tr> |
| 4480 | |
| 4481 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4482 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasCanonicalType0')"><a name="hasCanonicalType0Anchor">hasCanonicalType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4483 | <tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. |
| 4484 | |
| 4485 | Given: |
| 4486 | typedef int &int_ref; |
| 4487 | int a; |
| 4488 | int_ref b = a; |
| 4489 | |
| 4490 | varDecl(hasType(qualType(referenceType()))))) will not match the |
| 4491 | declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. |
| 4492 | </pre></td></tr> |
| 4493 | |
| 4494 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4495 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasDeclaration6')"><a name="hasDeclaration6Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4496 | <tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node |
| 4497 | matches the given matcher. |
| 4498 | |
| 4499 | The associated declaration is: |
| 4500 | - for type nodes, the declaration of the underlying type |
| 4501 | - for CallExpr, the declaration of the callee |
| 4502 | - for MemberExpr, the declaration of the referenced member |
| 4503 | - for CXXConstructExpr, the declaration of the constructor |
| 4504 | |
| 4505 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4506 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4507 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4508 | Usable as: 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>>, |
| 4509 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 4510 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 4511 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 4512 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 4513 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4514 | </pre></td></tr> |
| 4515 | |
| 4516 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4517 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4518 | <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. |
| 4519 | </pre></td></tr> |
| 4520 | |
| 4521 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4522 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('pointsTo0')"><a name="pointsTo0Anchor">pointsTo</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4523 | <tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type |
| 4524 | matches the specified matcher. |
| 4525 | |
| 4526 | Example matches y->x() |
| 4527 | (matcher = cxxMemberCallExpr(on(hasType(pointsTo |
| 4528 | cxxRecordDecl(hasName("Y"))))))) |
| 4529 | class Y { public: void x(); }; |
| 4530 | void z() { Y *y; y->x(); } |
| 4531 | </pre></td></tr> |
| 4532 | |
| 4533 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4534 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4535 | <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. |
| 4536 | </pre></td></tr> |
| 4537 | |
| 4538 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4539 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('references0')"><a name="references0Anchor">references</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4540 | <tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced |
| 4541 | type matches the specified matcher. |
| 4542 | |
| 4543 | Example matches X &x and const X &y |
| 4544 | (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) |
| 4545 | class X { |
| 4546 | void a(X b) { |
| 4547 | X &x = b; |
| 4548 | const X &y = b; |
| 4549 | } |
| 4550 | }; |
| 4551 | </pre></td></tr> |
| 4552 | |
| 4553 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4554 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>></td><td class="name" onclick="toggle('hasDeclaration5')"><a name="hasDeclaration5Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4555 | <tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node |
| 4556 | matches the given matcher. |
| 4557 | |
| 4558 | The associated declaration is: |
| 4559 | - for type nodes, the declaration of the underlying type |
| 4560 | - for CallExpr, the declaration of the callee |
| 4561 | - for MemberExpr, the declaration of the referenced member |
| 4562 | - for CXXConstructExpr, the declaration of the constructor |
| 4563 | |
| 4564 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4565 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4566 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4567 | Usable as: 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>>, |
| 4568 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 4569 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 4570 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 4571 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 4572 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4573 | </pre></td></tr> |
| 4574 | |
| 4575 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4576 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc3')"><a name="pointeeLoc3Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4577 | <tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4578 | pointee matches a given matcher. |
| 4579 | |
| 4580 | Given |
| 4581 | int *a; |
| 4582 | int const *b; |
| 4583 | float const *f; |
| 4584 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4585 | matches "int const *b" |
| 4586 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4587 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, |
| 4588 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4589 | </pre></td></tr> |
| 4590 | |
| 4591 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4592 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>></td><td class="name" onclick="toggle('pointee3')"><a name="pointee3Anchor">pointee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4593 | <tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4594 | pointee matches a given matcher. |
| 4595 | |
| 4596 | Given |
| 4597 | int *a; |
| 4598 | int const *b; |
| 4599 | float const *f; |
| 4600 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4601 | matches "int const *b" |
| 4602 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4603 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, |
| 4604 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4605 | </pre></td></tr> |
| 4606 | |
| 4607 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4608 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4609 | <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 4610 | alignof. |
| 4611 | </pre></td></tr> |
| 4612 | |
| 4613 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4614 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4615 | <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 4616 | sizeof. |
| 4617 | </pre></td></tr> |
| 4618 | |
| 4619 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4620 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>></td><td class="name" onclick="toggle('forEachSwitchCase0')"><a name="forEachSwitchCase0Anchor">forEachSwitchCase</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4621 | <tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch |
| 4622 | statement. This matcher may produce multiple matches. |
| 4623 | |
| 4624 | Given |
| 4625 | switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } |
| 4626 | switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") |
| 4627 | matches four times, with "c" binding each of "case 1:", "case 2:", |
| 4628 | "case 3:" and "case 4:", and "s" respectively binding "switch (1)", |
| 4629 | "switch (1)", "switch (2)" and "switch (2)". |
| 4630 | </pre></td></tr> |
| 4631 | |
| 4632 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4633 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>></td><td class="name" onclick="toggle('hasDeclaration4')"><a name="hasDeclaration4Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4634 | <tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node |
| 4635 | matches the given matcher. |
| 4636 | |
| 4637 | The associated declaration is: |
| 4638 | - for type nodes, the declaration of the underlying type |
| 4639 | - for CallExpr, the declaration of the callee |
| 4640 | - for MemberExpr, the declaration of the referenced member |
| 4641 | - for CXXConstructExpr, the declaration of the constructor |
| 4642 | |
| 4643 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4644 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4645 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4646 | Usable as: 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>>, |
| 4647 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 4648 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 4649 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 4650 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 4651 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4652 | </pre></td></tr> |
| 4653 | |
| 4654 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4655 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('isExpr0')"><a name="isExpr0Anchor">isExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4656 | <tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. |
| 4657 | |
| 4658 | Given |
| 4659 | template<typename T> struct A {}; |
| 4660 | struct B { B* next; }; |
| 4661 | A<&B::next> a; |
| 4662 | templateSpecializationType(hasAnyTemplateArgument( |
| 4663 | isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) |
| 4664 | matches the specialization A<&B::next> with fieldDecl(...) matching |
| 4665 | B::next |
| 4666 | </pre></td></tr> |
| 4667 | |
| 4668 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4669 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4670 | <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain |
| 4671 | declaration. |
| 4672 | |
| 4673 | Given |
| 4674 | template<typename T> struct A {}; |
| 4675 | struct B { B* next; }; |
| 4676 | A<&B::next> a; |
| 4677 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 4678 | refersToDeclaration(fieldDecl(hasName("next")))) |
| 4679 | matches the specialization A<&B::next> with fieldDecl(...) matching |
| 4680 | B::next |
| 4681 | </pre></td></tr> |
| 4682 | |
| 4683 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4684 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('refersToIntegralType0')"><a name="refersToIntegralType0Anchor">refersToIntegralType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4685 | <tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type. |
| 4686 | |
| 4687 | Given |
| 4688 | template<int T> struct A {}; |
| 4689 | C<42> c; |
| 4690 | classTemplateSpecializationDecl( |
| 4691 | hasAnyTemplateArgument(refersToIntegralType(asString("int")))) |
| 4692 | matches the implicit instantiation of C in C<42>. |
| 4693 | </pre></td></tr> |
| 4694 | |
| 4695 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4696 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4697 | <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. |
| 4698 | |
| 4699 | Given |
| 4700 | struct X {}; |
| 4701 | template<typename T> struct A {}; |
| 4702 | A<X> a; |
| 4703 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 4704 | refersToType(class(hasName("X"))))) |
| 4705 | matches the specialization A<X> |
| 4706 | </pre></td></tr> |
| 4707 | |
| 4708 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4709 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgument1')"><a name="hasAnyTemplateArgument1Anchor">hasAnyTemplateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4710 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations that have at least one |
| 4711 | TemplateArgument matching the given InnerMatcher. |
| 4712 | |
| 4713 | Given |
| 4714 | template<typename T> class A {}; |
| 4715 | template<> class A<double> {}; |
| 4716 | A<int> a; |
| 4717 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 4718 | refersToType(asString("int")))) |
| 4719 | matches the specialization A<int> |
| 4720 | </pre></td></tr> |
| 4721 | |
| 4722 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4723 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4724 | <tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node |
| 4725 | matches the given matcher. |
| 4726 | |
| 4727 | The associated declaration is: |
| 4728 | - for type nodes, the declaration of the underlying type |
| 4729 | - for CallExpr, the declaration of the callee |
| 4730 | - for MemberExpr, the declaration of the referenced member |
| 4731 | - for CXXConstructExpr, the declaration of the constructor |
| 4732 | |
| 4733 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4734 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4735 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4736 | Usable as: 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>>, |
| 4737 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 4738 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 4739 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 4740 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 4741 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4742 | </pre></td></tr> |
| 4743 | |
| 4744 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4745 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasTemplateArgument1')"><a name="hasTemplateArgument1Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4746 | <tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument |
| 4747 | matches the given InnerMatcher. |
| 4748 | |
| 4749 | Given |
| 4750 | template<typename T, typename U> class A {}; |
| 4751 | A<bool, int> b; |
| 4752 | A<int, bool> c; |
| 4753 | classTemplateSpecializationDecl(hasTemplateArgument( |
| 4754 | 1, refersToType(asString("int")))) |
| 4755 | matches the specialization A<bool, int> |
| 4756 | </pre></td></tr> |
| 4757 | |
| 4758 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4759 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4760 | <tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node |
| 4761 | matches the given matcher. |
| 4762 | |
| 4763 | The associated declaration is: |
| 4764 | - for type nodes, the declaration of the underlying type |
| 4765 | - for CallExpr, the declaration of the callee |
| 4766 | - for MemberExpr, the declaration of the referenced member |
| 4767 | - for CXXConstructExpr, the declaration of the constructor |
| 4768 | |
| 4769 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4770 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4771 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4772 | Usable as: 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>>, |
| 4773 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 4774 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 4775 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 4776 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 4777 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4778 | </pre></td></tr> |
| 4779 | |
| 4780 | |
| 4781 | <tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<T> Matcher</td></tr> |
| 4782 | <tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. |
| 4783 | |
| 4784 | Generates results for each match. |
| 4785 | |
| 4786 | For example, in: |
| 4787 | class A { class B {}; class C {}; }; |
| 4788 | The matcher: |
| 4789 | cxxRecordDecl(hasName("::A"), |
| 4790 | findAll(cxxRecordDecl(isDefinition()).bind("m"))) |
| 4791 | will generate results for A, B and C. |
| 4792 | |
| 4793 | Usable as: Any Matcher |
| 4794 | </pre></td></tr> |
| 4795 | |
| 4796 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4797 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>></td><td class="name" onclick="toggle('hasDeclaration1')"><a name="hasDeclaration1Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4798 | <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node |
| 4799 | matches the given matcher. |
| 4800 | |
| 4801 | The associated declaration is: |
| 4802 | - for type nodes, the declaration of the underlying type |
| 4803 | - for CallExpr, the declaration of the callee |
| 4804 | - for MemberExpr, the declaration of the referenced member |
| 4805 | - for CXXConstructExpr, the declaration of the constructor |
| 4806 | |
| 4807 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4808 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4809 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4810 | Usable as: 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>>, |
| 4811 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 4812 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 4813 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 4814 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 4815 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4816 | </pre></td></tr> |
| 4817 | |
| 4818 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4819 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4820 | <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. |
| 4821 | |
| 4822 | Given |
| 4823 | int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); |
| 4824 | unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) |
| 4825 | matches sizeof(a) and alignof(c) |
| 4826 | </pre></td></tr> |
| 4827 | |
| 4828 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4829 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4830 | <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. |
| 4831 | |
| 4832 | Example matches true (matcher = hasUnaryOperand( |
| 4833 | cxxBoolLiteral(equals(true)))) |
| 4834 | !true |
| 4835 | </pre></td></tr> |
| 4836 | |
| 4837 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4838 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4839 | <tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node |
| 4840 | matches the given matcher. |
| 4841 | |
| 4842 | The associated declaration is: |
| 4843 | - for type nodes, the declaration of the underlying type |
| 4844 | - for CallExpr, the declaration of the callee |
| 4845 | - for MemberExpr, the declaration of the referenced member |
| 4846 | - for CXXConstructExpr, the declaration of the constructor |
| 4847 | |
| 4848 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4849 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4850 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4851 | Usable as: 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>>, |
| 4852 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, |
| 4853 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, |
| 4854 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, |
| 4855 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, |
| 4856 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4857 | </pre></td></tr> |
| 4858 | |
| 4859 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4860 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4861 | <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. |
| 4862 | |
| 4863 | Given |
| 4864 | namespace X { void b(); } |
| 4865 | using X::b; |
| 4866 | usingDecl(hasAnyUsingShadowDecl(hasName("b")))) |
| 4867 | matches using X::b </pre></td></tr> |
| 4868 | |
| 4869 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4870 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4871 | <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is |
| 4872 | matched by the given matcher. |
| 4873 | |
| 4874 | Given |
| 4875 | namespace X { int a; void b(); } |
| 4876 | using X::a; |
| 4877 | using X::b; |
| 4878 | usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) |
| 4879 | matches using X::b but not using X::a </pre></td></tr> |
| 4880 | |
| 4881 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4882 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4883 | <tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value |
| 4884 | declaration's type. |
| 4885 | |
| 4886 | In case of a value declaration (for example a variable declaration), |
| 4887 | this resolves one layer of indirection. For example, in the value |
| 4888 | declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 4889 | X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 4890 | declaration of x. |
| 4891 | |
| 4892 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 4893 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 4894 | class X {}; |
| 4895 | void y(X &x) { x; X z; } |
| 4896 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4897 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4898 | </pre></td></tr> |
| 4899 | |
| 4900 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4901 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType1')"><a name="hasType1Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4902 | <tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type |
| 4903 | matcher. |
| 4904 | |
| 4905 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 4906 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 4907 | class X {}; |
| 4908 | void y(X &x) { x; X z; } |
| 4909 | </pre></td></tr> |
| 4910 | |
| 4911 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4912 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4913 | <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression |
| 4914 | that matches the given matcher. |
| 4915 | |
| 4916 | Example matches x (matcher = varDecl(hasInitializer(callExpr()))) |
| 4917 | bool y() { return true; } |
| 4918 | bool x = y(); |
| 4919 | </pre></td></tr> |
| 4920 | |
| 4921 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4922 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4923 | <tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size |
| 4924 | expression. |
| 4925 | |
| 4926 | Given |
| 4927 | void f(int b) { |
| 4928 | int a[b]; |
| 4929 | } |
| 4930 | variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( |
| 4931 | varDecl(hasName("b"))))))) |
| 4932 | matches "int a[b]" |
| 4933 | </pre></td></tr> |
| 4934 | |
| 4935 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4936 | <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> |
Aaron Ballman | 2b6963f | 2016-01-20 16:26:48 +0000 | [diff] [blame] | 4937 | <tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 4938 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4939 | |
| 4940 | Given |
| 4941 | for (;;) {} |
| 4942 | hasBody(compoundStmt()) |
| 4943 | matches 'for (;;) {}' |
| 4944 | with compoundStmt() |
| 4945 | matching '{}' |
| 4946 | </pre></td></tr> |
| 4947 | |
| 4948 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4949 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4950 | <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, |
| 4951 | or conditional operator. |
| 4952 | |
| 4953 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 4954 | if (true) {} |
| 4955 | </pre></td></tr> |
| 4956 | |
| 4957 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4958 | <tr><td>Matcher<internal::BindableMatcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>>></td><td class="name" onclick="toggle('loc1')"><a name="loc1Anchor">loc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4959 | <tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner |
| 4960 | NestedNameSpecifier-matcher matches. |
| 4961 | </pre></td></tr> |
| 4962 | |
| 4963 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4964 | <tr><td>Matcher<internal::BindableMatcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>></td><td class="name" onclick="toggle('loc0')"><a name="loc0Anchor">loc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4965 | <tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner |
| 4966 | QualType-matcher matches. |
| 4967 | </pre></td></tr> |
| 4968 | |
Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 4969 | <!--END_TRAVERSAL_MATCHERS --> |
| 4970 | </table> |
| 4971 | |
| 4972 | </div> |
| 4973 | </body> |
| 4974 | </html> |
| 4975 | |
| 4976 | |