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 | a35b8fc | 2016-03-09 17:11:51 +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('labelDecl0')"><a name="labelDecl0Anchor">labelDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelDecl.html">LabelDecl</a>>...</td></tr> |
| 275 | <tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label. |
| 276 | |
| 277 | Given |
| 278 | goto FOO; |
| 279 | FOO: bar(); |
| 280 | labelDecl() |
| 281 | matches 'FOO:' |
| 282 | </pre></td></tr> |
| 283 | |
| 284 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 285 | <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] | 286 | <tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification. |
| 287 | |
| 288 | Given |
| 289 | extern "C" {} |
| 290 | linkageSpecDecl() |
| 291 | matches "extern "C" {}" |
| 292 | </pre></td></tr> |
| 293 | |
| 294 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 295 | <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] | 296 | <tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. |
| 297 | |
| 298 | Example matches X, S, the anonymous union type, i, and U; |
| 299 | typedef int X; |
| 300 | struct S { |
| 301 | union { |
| 302 | int i; |
| 303 | } U; |
| 304 | }; |
| 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('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] | 309 | <tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias. |
| 310 | |
| 311 | Given |
| 312 | namespace test {} |
| 313 | namespace alias = ::test; |
| 314 | namespaceAliasDecl() |
| 315 | matches "namespace alias" but not "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('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] | 320 | <tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. |
| 321 | |
| 322 | Given |
| 323 | namespace {} |
| 324 | namespace test {} |
| 325 | namespaceDecl() |
| 326 | matches "namespace {}" and "namespace test {}" |
| 327 | </pre></td></tr> |
| 328 | |
| 329 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 330 | <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] | 331 | <tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations. |
| 332 | |
| 333 | Given |
| 334 | template <typename T, int N> struct C {}; |
| 335 | nonTypeTemplateParmDecl() |
| 336 | matches 'N', but not 'T'. |
| 337 | </pre></td></tr> |
| 338 | |
| 339 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 340 | <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] | 341 | <tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations. |
| 342 | |
| 343 | Example matches Foo |
| 344 | @interface Foo |
| 345 | @end |
| 346 | </pre></td></tr> |
| 347 | |
| 348 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 349 | <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] | 350 | <tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. |
| 351 | |
| 352 | Given |
| 353 | void f(int x); |
| 354 | parmVarDecl() |
| 355 | matches int x. |
| 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('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] | 360 | <tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations. |
| 361 | |
| 362 | Example matches X, Z, U, and S |
| 363 | class X; |
| 364 | template<class T> class Z {}; |
| 365 | struct S {}; |
| 366 | union U {}; |
| 367 | </pre></td></tr> |
| 368 | |
| 369 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 370 | <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] | 371 | <tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration. |
| 372 | |
| 373 | Example: |
| 374 | staticAssertExpr() |
| 375 | matches |
| 376 | static_assert(sizeof(S) == sizeof(int)) |
| 377 | in |
| 378 | struct S { |
| 379 | int x; |
| 380 | }; |
| 381 | static_assert(sizeof(S) == sizeof(int)); |
| 382 | </pre></td></tr> |
| 383 | |
| 384 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 385 | <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] | 386 | <tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations. |
| 387 | |
| 388 | Given |
| 389 | template <typename T, int N> struct C {}; |
| 390 | templateTypeParmDecl() |
| 391 | matches 'T', but not 'N'. |
| 392 | </pre></td></tr> |
| 393 | |
| 394 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 395 | <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] | 396 | <tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context. |
| 397 | |
| 398 | Given |
| 399 | int X; |
| 400 | namespace NS { |
| 401 | int Y; |
| 402 | } namespace NS |
| 403 | decl(hasDeclContext(translationUnitDecl())) |
| 404 | matches "int X", but not "int Y". |
| 405 | </pre></td></tr> |
| 406 | |
| 407 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 408 | <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] | 409 | <tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations. |
| 410 | |
| 411 | Given |
| 412 | typedef int X; |
| 413 | typedefDecl() |
| 414 | matches "typedef int X" |
| 415 | </pre></td></tr> |
| 416 | |
| 417 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 418 | <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] | 419 | <tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the |
| 420 | typename. |
| 421 | |
| 422 | Given |
| 423 | template <typename T> |
| 424 | struct Base { typedef T Foo; }; |
| 425 | |
| 426 | template<typename T> |
| 427 | struct S : private Base<T> { |
| 428 | using typename Base<T>::Foo; |
| 429 | }; |
| 430 | unresolvedUsingTypenameDecl() |
| 431 | matches using Base<T>::Foo </pre></td></tr> |
| 432 | |
| 433 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 434 | <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] | 435 | <tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations. |
| 436 | |
| 437 | Given |
| 438 | template<typename X> |
| 439 | class C : private X { |
| 440 | using X::x; |
| 441 | }; |
| 442 | unresolvedUsingValueDecl() |
| 443 | matches using X::x </pre></td></tr> |
| 444 | |
| 445 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 446 | <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] | 447 | <tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. |
| 448 | |
| 449 | Given |
| 450 | namespace X { int x; } |
| 451 | using X::x; |
| 452 | usingDecl() |
| 453 | matches using X::x </pre></td></tr> |
| 454 | |
| 455 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 456 | <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] | 457 | <tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations. |
| 458 | |
| 459 | Given |
| 460 | namespace X { int x; } |
| 461 | using namespace X; |
| 462 | usingDirectiveDecl() |
| 463 | matches using namespace X </pre></td></tr> |
| 464 | |
| 465 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 466 | <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] | 467 | <tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration. |
| 468 | |
| 469 | Example matches A, B, C and F |
| 470 | enum X { A, B, C }; |
| 471 | void F(); |
| 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_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] | 476 | <tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. |
| 477 | |
| 478 | Note: this does not match declarations of member variables, which are |
| 479 | "field" declarations in Clang parlance. |
| 480 | |
| 481 | Example matches a |
| 482 | int a; |
| 483 | </pre></td></tr> |
| 484 | |
| 485 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 486 | <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] | 487 | <tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. |
| 488 | </pre></td></tr> |
| 489 | |
| 490 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 491 | <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] | 492 | <tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. |
| 493 | |
| 494 | Given |
| 495 | namespace ns { |
| 496 | struct A { static void f(); }; |
| 497 | void A::f() {} |
| 498 | void g() { A::f(); } |
| 499 | } |
| 500 | ns::A a; |
| 501 | nestedNameSpecifier() |
| 502 | matches "ns::" and both "A::" |
| 503 | </pre></td></tr> |
| 504 | |
| 505 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 506 | <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] | 507 | <tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. |
| 508 | </pre></td></tr> |
| 509 | |
| 510 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 511 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('addrLabelExpr0')"><a name="addrLabelExpr0Anchor">addrLabelExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>...</td></tr> |
| 512 | <tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension). |
| 513 | |
| 514 | Given |
| 515 | FOO: bar(); |
| 516 | void *ptr = &&FOO; |
| 517 | goto *bar; |
| 518 | addrLabelExpr() |
| 519 | matches '&&FOO' |
| 520 | </pre></td></tr> |
| 521 | |
| 522 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 523 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('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] | 524 | <tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. |
| 525 | |
| 526 | Given |
| 527 | int i = a[1]; |
| 528 | arraySubscriptExpr() |
| 529 | matches "a[1]" |
| 530 | </pre></td></tr> |
| 531 | |
| 532 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 533 | <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] | 534 | <tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. |
| 535 | |
| 536 | int i = 100; |
| 537 | __asm("mov al, 2"); |
| 538 | asmStmt() |
| 539 | matches '__asm("mov al, 2")' |
| 540 | </pre></td></tr> |
| 541 | |
| 542 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 543 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('atomicExpr0')"><a name="atomicExpr0Anchor">atomicExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicExpr.html">AtomicExpr</a>>...</td></tr> |
| 544 | <tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins. |
| 545 | Example matches __atomic_load_n(ptr, 1) |
| 546 | void foo() { int *ptr; __atomic_load_n(ptr, 1); } |
| 547 | </pre></td></tr> |
| 548 | |
| 549 | |
| 550 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('binaryConditionalOperator0')"><a name="binaryConditionalOperator0Anchor">binaryConditionalOperator</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryConditionalOperator.html">BinaryConditionalOperator</a>>...</td></tr> |
| 551 | <tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension). |
| 552 | |
| 553 | Example matches a ?: b |
| 554 | (a ?: b) + 42; |
| 555 | </pre></td></tr> |
| 556 | |
| 557 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 558 | <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] | 559 | <tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. |
| 560 | |
| 561 | Example matches a || b |
| 562 | !(a || b) |
| 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('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] | 567 | <tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. |
| 568 | |
| 569 | Given |
| 570 | while (true) { break; } |
| 571 | breakStmt() |
| 572 | matches 'break' |
| 573 | </pre></td></tr> |
| 574 | |
| 575 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 576 | <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] | 577 | <tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. |
| 578 | |
| 579 | Example: Matches (int*) 2.2f in |
| 580 | int i = (int) 2.2f; |
| 581 | </pre></td></tr> |
| 582 | |
| 583 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 584 | <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] | 585 | <tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. |
| 586 | |
| 587 | Example matches x.y() and y() |
| 588 | X x; |
| 589 | x.y(); |
| 590 | y(); |
| 591 | </pre></td></tr> |
| 592 | |
| 593 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 594 | <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] | 595 | <tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. |
| 596 | |
| 597 | Given |
| 598 | switch(a) { case 42: break; default: break; } |
| 599 | caseStmt() |
| 600 | matches 'case 42: break;'. |
| 601 | </pre></td></tr> |
| 602 | |
| 603 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 604 | <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] | 605 | <tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. |
| 606 | |
| 607 | Example: castExpr() matches each of the following: |
| 608 | (int) 3; |
| 609 | const_cast<Expr *>(SubExpr); |
| 610 | char c = 0; |
| 611 | but does not match |
| 612 | int i = (0); |
| 613 | int k = 0; |
| 614 | </pre></td></tr> |
| 615 | |
| 616 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 617 | <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] | 618 | <tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). |
| 619 | |
| 620 | Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), |
| 621 | though. |
| 622 | |
| 623 | Example matches 'a', L'a' |
| 624 | char ch = 'a'; wchar_t chw = L'a'; |
| 625 | </pre></td></tr> |
| 626 | |
| 627 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 628 | <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] | 629 | <tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals |
| 630 | |
| 631 | Example match: {1}, (1, 2) |
| 632 | int array[4] = {1}; vector int myvec = (vector int)(1, 2); |
| 633 | </pre></td></tr> |
| 634 | |
| 635 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 636 | <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] | 637 | <tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. |
| 638 | |
| 639 | Example matches '{}' and '{{}}'in 'for (;;) {{}}' |
| 640 | for (;;) {{}} |
| 641 | </pre></td></tr> |
| 642 | |
| 643 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 644 | <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] | 645 | <tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. |
| 646 | |
| 647 | Example matches a ? b : c |
| 648 | (a ? b : c) + 42 |
| 649 | </pre></td></tr> |
| 650 | |
| 651 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 652 | <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] | 653 | <tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. |
| 654 | |
| 655 | Given |
| 656 | while (true) { continue; } |
| 657 | continueStmt() |
| 658 | matches 'continue' |
| 659 | </pre></td></tr> |
| 660 | |
| 661 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 662 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('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] | 663 | <tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression. |
| 664 | |
| 665 | Example matches, |
| 666 | kernel<<<i,j>>>(); |
| 667 | </pre></td></tr> |
| 668 | |
| 669 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 670 | <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] | 671 | <tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created. |
| 672 | |
| 673 | Example matches FunctionTakesString(GetStringByValue()) |
| 674 | (matcher = cxxBindTemporaryExpr()) |
| 675 | FunctionTakesString(GetStringByValue()); |
| 676 | FunctionTakesStringByPointer(GetStringPointer()); |
| 677 | </pre></td></tr> |
| 678 | |
| 679 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 680 | <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] | 681 | <tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals. |
| 682 | |
| 683 | Example matches true |
| 684 | true |
| 685 | </pre></td></tr> |
| 686 | |
| 687 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 688 | <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] | 689 | <tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements. |
| 690 | |
| 691 | try {} catch(int i) {} |
| 692 | cxxCatchStmt() |
| 693 | matches 'catch(int i)' |
| 694 | </pre></td></tr> |
| 695 | |
| 696 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 697 | <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] | 698 | <tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression. |
| 699 | |
| 700 | Example: Matches const_cast<int*>(&r) in |
| 701 | int n = 42; |
| 702 | const int &r(n); |
| 703 | int* p = const_cast<int*>(&r); |
| 704 | </pre></td></tr> |
| 705 | |
| 706 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 707 | <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] | 708 | <tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones). |
| 709 | |
| 710 | Example matches string(ptr, n) and ptr within arguments of f |
| 711 | (matcher = cxxConstructExpr()) |
| 712 | void f(const string &a, const string &b); |
| 713 | char *ptr; |
| 714 | int n; |
| 715 | f(string(ptr, n), ptr); |
| 716 | </pre></td></tr> |
| 717 | |
| 718 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 719 | <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] | 720 | <tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site. |
| 721 | |
| 722 | Example matches the CXXDefaultArgExpr placeholder inserted for the |
| 723 | default value of the second parameter in the call expression f(42) |
| 724 | (matcher = cxxDefaultArgExpr()) |
| 725 | void f(int x, int y = 0); |
| 726 | f(42); |
| 727 | </pre></td></tr> |
| 728 | |
| 729 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 730 | <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] | 731 | <tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions. |
| 732 | |
| 733 | Given |
| 734 | delete X; |
| 735 | cxxDeleteExpr() |
| 736 | matches 'delete X'. |
| 737 | </pre></td></tr> |
| 738 | |
| 739 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 740 | <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] | 741 | <tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression. |
| 742 | |
| 743 | Example: |
| 744 | cxxDynamicCastExpr() |
| 745 | matches |
| 746 | dynamic_cast<D*>(&b); |
| 747 | in |
| 748 | struct B { virtual ~B() {} }; struct D : B {}; |
| 749 | B b; |
| 750 | D* p = dynamic_cast<D*>(&b); |
| 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('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] | 755 | <tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements. |
| 756 | |
| 757 | cxxForRangeStmt() matches 'for (auto a : i)' |
| 758 | int i[] = {1, 2, 3}; for (auto a : i); |
| 759 | for(int j = 0; j < 5; ++j); |
| 760 | </pre></td></tr> |
| 761 | |
| 762 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 763 | <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] | 764 | <tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions |
| 765 | |
| 766 | Example: Matches Foo(bar); |
| 767 | Foo f = bar; |
| 768 | Foo g = (Foo) bar; |
| 769 | Foo h = Foo(bar); |
| 770 | </pre></td></tr> |
| 771 | |
| 772 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 773 | <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] | 774 | <tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions. |
| 775 | |
| 776 | Example matches x.y() |
| 777 | X x; |
| 778 | x.y(); |
| 779 | </pre></td></tr> |
| 780 | |
| 781 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 782 | <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] | 783 | <tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions. |
| 784 | |
| 785 | Given |
| 786 | new X; |
| 787 | cxxNewExpr() |
| 788 | matches 'new X'. |
| 789 | </pre></td></tr> |
| 790 | |
| 791 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 792 | <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] | 793 | <tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal. |
| 794 | </pre></td></tr> |
| 795 | |
| 796 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 797 | <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] | 798 | <tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls. |
| 799 | |
| 800 | Note that if an operator isn't overloaded, it won't match. Instead, use |
| 801 | binaryOperator matcher. |
| 802 | Currently it does not match operators such as new delete. |
| 803 | FIXME: figure out why these do not match? |
| 804 | |
| 805 | Example matches both operator<<((o << b), c) and operator<<(o, b) |
| 806 | (matcher = cxxOperatorCallExpr()) |
| 807 | ostream &operator<< (ostream &out, int i) { }; |
| 808 | ostream &o; int b = 1, c = 1; |
| 809 | o << b << c; |
| 810 | </pre></td></tr> |
| 811 | |
| 812 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 813 | <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] | 814 | <tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. |
| 815 | |
| 816 | Either the source expression or the destination type can be matched |
| 817 | using has(), but hasDestinationType() is more specific and can be |
| 818 | more readable. |
| 819 | |
| 820 | Example matches reinterpret_cast<char*>(&p) in |
| 821 | void* p = reinterpret_cast<char*>(&p); |
| 822 | </pre></td></tr> |
| 823 | |
| 824 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 825 | <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] | 826 | <tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression. |
| 827 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 828 | See also: hasDestinationType |
| 829 | See also: reinterpretCast |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 830 | |
| 831 | Example: |
| 832 | cxxStaticCastExpr() |
| 833 | matches |
| 834 | static_cast<long>(8) |
| 835 | in |
| 836 | long eight(static_cast<long>(8)); |
| 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('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] | 841 | <tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments |
| 842 | |
| 843 | Example: Matches Foo(bar, bar) |
| 844 | Foo h = Foo(bar, bar); |
| 845 | </pre></td></tr> |
| 846 | |
| 847 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 848 | <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] | 849 | <tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions. |
| 850 | |
| 851 | Example matches the implicit this expression in "return i". |
| 852 | (matcher = cxxThisExpr()) |
| 853 | struct foo { |
| 854 | int i; |
| 855 | int f() { return i; } |
| 856 | }; |
| 857 | </pre></td></tr> |
| 858 | |
| 859 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 860 | <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] | 861 | <tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions. |
| 862 | |
| 863 | try { throw 5; } catch(int i) {} |
| 864 | cxxThrowExpr() |
| 865 | matches 'throw 5' |
| 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('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] | 870 | <tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements. |
| 871 | |
| 872 | try {} catch(int i) {} |
| 873 | cxxTryStmt() |
| 874 | matches 'try {}' |
| 875 | </pre></td></tr> |
| 876 | |
| 877 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 878 | <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] | 879 | <tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. |
| 880 | |
| 881 | Example matches T(t) in return statement of f |
| 882 | (matcher = cxxUnresolvedConstructExpr()) |
| 883 | template <typename T> |
| 884 | void f(const T& t) { return T(t); } |
| 885 | </pre></td></tr> |
| 886 | |
| 887 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 888 | <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] | 889 | <tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. |
| 890 | |
| 891 | Example matches x in if (x) |
| 892 | bool x; |
| 893 | if (x) {} |
| 894 | </pre></td></tr> |
| 895 | |
| 896 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 897 | <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] | 898 | <tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. |
| 899 | |
| 900 | Given |
| 901 | int a; |
| 902 | declStmt() |
| 903 | matches 'int a'. |
| 904 | </pre></td></tr> |
| 905 | |
| 906 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 907 | <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] | 908 | <tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. |
| 909 | |
| 910 | Given |
| 911 | switch(a) { case 42: break; default: break; } |
| 912 | defaultStmt() |
| 913 | matches 'default: break;'. |
| 914 | </pre></td></tr> |
| 915 | |
| 916 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 917 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('designatedInitExpr0')"><a name="designatedInitExpr0Anchor">designatedInitExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DesignatedInitExpr.html">DesignatedInitExpr</a>>...</td></tr> |
| 918 | <tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8]. |
| 919 | |
| 920 | Example: Matches { [2].y = 1.0, [0].x = 1.0 } |
| 921 | point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; |
| 922 | </pre></td></tr> |
| 923 | |
| 924 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 925 | <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] | 926 | <tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. |
| 927 | |
| 928 | Given |
| 929 | do {} while (true); |
| 930 | doStmt() |
| 931 | matches 'do {} while(true)' |
| 932 | </pre></td></tr> |
| 933 | |
| 934 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 935 | <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] | 936 | <tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. |
| 937 | |
| 938 | Matches any cast expression written in user code, whether it be a |
| 939 | C-style cast, a functional-style cast, or a keyword cast. |
| 940 | |
| 941 | Does not match implicit conversions. |
| 942 | |
| 943 | Note: the name "explicitCast" is chosen to match Clang's terminology, as |
| 944 | Clang uses the term "cast" to apply to implicit conversions as well as to |
| 945 | actual cast expressions. |
| 946 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 947 | See also: hasDestinationType. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 948 | |
| 949 | Example: matches all five of the casts in |
| 950 | int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) |
| 951 | but does not match the implicit conversion in |
| 952 | long ell = 42; |
| 953 | </pre></td></tr> |
| 954 | |
| 955 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 956 | <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] | 957 | <tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. |
| 958 | |
| 959 | Example matches x() |
| 960 | void f() { x(); } |
| 961 | </pre></td></tr> |
| 962 | |
| 963 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 964 | <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] | 965 | <tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end |
| 966 | of the sub-expression's evaluation. |
| 967 | |
| 968 | Example matches std::string() |
| 969 | const std::string str = std::string(); |
| 970 | </pre></td></tr> |
| 971 | |
| 972 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 973 | <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] | 974 | <tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g. |
| 975 | 1.0, 1.0f, 1.0L and 1e10. |
| 976 | |
| 977 | Does not match implicit conversions such as |
| 978 | float a = 10; |
| 979 | </pre></td></tr> |
| 980 | |
| 981 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 982 | <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] | 983 | <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. |
| 984 | |
| 985 | Example matches 'for (;;) {}' |
| 986 | for (;;) {} |
| 987 | int i[] = {1, 2, 3}; for (auto a : i); |
| 988 | </pre></td></tr> |
| 989 | |
| 990 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 991 | <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] | 992 | <tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. |
| 993 | </pre></td></tr> |
| 994 | |
| 995 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 996 | <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] | 997 | <tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. |
| 998 | |
| 999 | Given |
| 1000 | goto FOO; |
| 1001 | FOO: bar(); |
| 1002 | gotoStmt() |
| 1003 | matches 'goto FOO' |
| 1004 | </pre></td></tr> |
| 1005 | |
| 1006 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1007 | <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] | 1008 | <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. |
| 1009 | |
| 1010 | Example matches 'if (x) {}' |
| 1011 | if (x) {} |
| 1012 | </pre></td></tr> |
| 1013 | |
| 1014 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1015 | <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] | 1016 | <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. |
| 1017 | |
| 1018 | This matches many different places, including function call return value |
| 1019 | eliding, as well as any type conversions. |
| 1020 | </pre></td></tr> |
| 1021 | |
| 1022 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1023 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('implicitValueInitExpr0')"><a name="implicitValueInitExpr0Anchor">implicitValueInitExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ImplicitValueInitExpr.html">ImplicitValueInitExpr</a>>...</td></tr> |
| 1024 | <tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions. |
| 1025 | |
| 1026 | Given |
| 1027 | point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; |
| 1028 | implicitValueInitExpr() |
| 1029 | matches "[0].y" (implicitly) |
| 1030 | </pre></td></tr> |
| 1031 | |
| 1032 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1033 | <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] | 1034 | <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. |
| 1035 | |
| 1036 | Given |
| 1037 | int a[] = { 1, 2 }; |
| 1038 | struct B { int x, y; }; |
| 1039 | B b = { 5, 6 }; |
| 1040 | initListExpr() |
| 1041 | matches "{ 1, 2 }" and "{ 5, 6 }" |
| 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('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] | 1046 | <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g. |
| 1047 | 1, 1L, 0x1 and 1U. |
| 1048 | |
| 1049 | Does not match character-encoded integers such as L'a'. |
| 1050 | </pre></td></tr> |
| 1051 | |
| 1052 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1053 | <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] | 1054 | <tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. |
| 1055 | |
| 1056 | Given |
| 1057 | goto FOO; |
| 1058 | FOO: bar(); |
| 1059 | labelStmt() |
| 1060 | matches 'FOO:' |
| 1061 | </pre></td></tr> |
| 1062 | |
| 1063 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1064 | <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] | 1065 | <tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. |
| 1066 | |
| 1067 | Example matches [&](){return 5;} |
| 1068 | [&](){return 5;} |
| 1069 | </pre></td></tr> |
| 1070 | |
| 1071 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1072 | <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] | 1073 | <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. |
| 1074 | |
| 1075 | Example: Given |
| 1076 | struct T {void func()}; |
| 1077 | T f(); |
| 1078 | void g(T); |
| 1079 | materializeTemporaryExpr() matches 'f()' in these statements |
| 1080 | T u(f()); |
| 1081 | g(f()); |
| 1082 | but does not match |
| 1083 | f(); |
| 1084 | f().func(); |
| 1085 | </pre></td></tr> |
| 1086 | |
| 1087 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1088 | <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] | 1089 | <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. |
| 1090 | |
| 1091 | Given |
| 1092 | class Y { |
| 1093 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 1094 | int a; static int b; |
| 1095 | }; |
| 1096 | memberExpr() |
| 1097 | matches this->x, x, y.x, a, this->b |
| 1098 | </pre></td></tr> |
| 1099 | |
| 1100 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1101 | <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] | 1102 | <tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. |
| 1103 | |
| 1104 | foo();; |
| 1105 | nullStmt() |
| 1106 | matches the second ';' |
| 1107 | </pre></td></tr> |
| 1108 | |
| 1109 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1110 | <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] | 1111 | <tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions. |
| 1112 | |
| 1113 | The innermost message send invokes the "alloc" class method on the |
| 1114 | NSString class, while the outermost message send invokes the |
| 1115 | "initWithString" instance method on the object returned from |
| 1116 | NSString's "alloc". This matcher should match both message sends. |
| 1117 | [[NSString alloc] initWithString:@"Hello"] |
| 1118 | </pre></td></tr> |
| 1119 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1120 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1121 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('opaqueValueExpr0')"><a name="opaqueValueExpr0Anchor">opaqueValueExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html">OpaqueValueExpr</a>>...</td></tr> |
| 1122 | <tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers |
| 1123 | to reference another expressions and can be met |
| 1124 | in BinaryConditionalOperators, for example. |
| 1125 | |
| 1126 | Example matches 'a' |
| 1127 | (a ?: c) + 42; |
| 1128 | </pre></td></tr> |
| 1129 | |
| 1130 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1131 | <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] | 1132 | <tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions. |
| 1133 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1134 | Example matches (foo() + 1) |
Aaron Ballman | e8295d7 | 2016-01-20 16:17:39 +0000 | [diff] [blame] | 1135 | int foo() { return 1; } |
| 1136 | int a = (foo() + 1); |
Aaron Ballman | e8295d7 | 2016-01-20 16:17:39 +0000 | [diff] [blame] | 1137 | </pre></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1138 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1139 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1140 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('parenListExpr0')"><a name="parenListExpr0Anchor">parenListExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenListExpr.html">ParenListExpr</a>>...</td></tr> |
| 1141 | <tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions. |
| 1142 | ParenListExprs don't have a predefined type and are used for late parsing. |
| 1143 | In the final AST, they can be met in template declarations. |
| 1144 | |
| 1145 | Given |
| 1146 | template<typename T> class X { |
| 1147 | void f() { |
| 1148 | X x(*this); |
| 1149 | int a = 0, b = 1; int i = (a, b); |
| 1150 | } |
| 1151 | }; |
| 1152 | parenListExpr() matches "*this" but NOT matches (a, b) because (a, b) |
| 1153 | has a predefined type and is a ParenExpr, not a ParenListExpr. |
| 1154 | </pre></td></tr> |
| 1155 | |
| 1156 | |
| 1157 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('predefinedExpr0')"><a name="predefinedExpr0Anchor">predefinedExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PredefinedExpr.html">PredefinedExpr</a>>...</td></tr> |
| 1158 | <tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2]. |
| 1159 | |
| 1160 | Example: Matches __func__ |
| 1161 | printf("%s", __func__); |
| 1162 | </pre></td></tr> |
| 1163 | |
| 1164 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1165 | <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] | 1166 | <tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. |
| 1167 | |
| 1168 | Given |
| 1169 | return 1; |
| 1170 | returnStmt() |
| 1171 | matches 'return 1' |
| 1172 | </pre></td></tr> |
| 1173 | |
| 1174 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1175 | <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] | 1176 | <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. |
| 1177 | |
| 1178 | Given |
| 1179 | { ++a; } |
| 1180 | stmt() |
| 1181 | matches both the compound statement '{ ++a; }' and '++a'. |
| 1182 | </pre></td></tr> |
| 1183 | |
| 1184 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1185 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('stmtExpr0')"><a name="stmtExpr0Anchor">stmtExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StmtExpr.html">StmtExpr</a>>...</td></tr> |
| 1186 | <tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension). |
| 1187 | |
| 1188 | Example match: ({ int X = 4; X; }) |
| 1189 | int C = ({ int X = 4; X; }); |
| 1190 | </pre></td></tr> |
| 1191 | |
| 1192 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1193 | <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] | 1194 | <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). |
| 1195 | |
| 1196 | Example matches "abcd", L"abcd" |
| 1197 | char *s = "abcd"; wchar_t *ws = L"abcd" |
| 1198 | </pre></td></tr> |
| 1199 | |
| 1200 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1201 | <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] | 1202 | <tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. |
| 1203 | |
| 1204 | Given |
| 1205 | template <int N> |
| 1206 | struct A { static const int n = N; }; |
| 1207 | struct B : public A<42> {}; |
| 1208 | substNonTypeTemplateParmExpr() |
| 1209 | matches "N" in the right-hand side of "static const int n = N;" |
| 1210 | </pre></td></tr> |
| 1211 | |
| 1212 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1213 | <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] | 1214 | <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. |
| 1215 | |
| 1216 | Given |
| 1217 | switch(a) { case 42: break; default: break; } |
| 1218 | switchCase() |
| 1219 | matches 'case 42: break;' and 'default: break;'. |
| 1220 | </pre></td></tr> |
| 1221 | |
| 1222 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1223 | <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] | 1224 | <tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. |
| 1225 | |
| 1226 | Given |
| 1227 | switch(a) { case 42: break; default: break; } |
| 1228 | switchStmt() |
| 1229 | matches 'switch(a)'. |
| 1230 | </pre></td></tr> |
| 1231 | |
| 1232 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1233 | <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] | 1234 | <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) |
| 1235 | |
| 1236 | Given |
| 1237 | Foo x = bar; |
| 1238 | int y = sizeof(x) + alignof(x); |
| 1239 | unaryExprOrTypeTraitExpr() |
| 1240 | matches sizeof(x) and alignof(x) |
| 1241 | </pre></td></tr> |
| 1242 | |
| 1243 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1244 | <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] | 1245 | <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. |
| 1246 | |
| 1247 | Example matches !a |
| 1248 | !a || b |
| 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_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] | 1253 | <tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. |
| 1254 | |
| 1255 | Example match: "foo"_suffix |
| 1256 | </pre></td></tr> |
| 1257 | |
| 1258 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1259 | <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] | 1260 | <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. |
| 1261 | |
| 1262 | Given |
| 1263 | while (true) {} |
| 1264 | whileStmt() |
| 1265 | matches 'while (true) {}'. |
| 1266 | </pre></td></tr> |
| 1267 | |
| 1268 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1269 | <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] | 1270 | <tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. |
| 1271 | |
| 1272 | Given |
| 1273 | template <typename T> struct C {}; |
| 1274 | C<int> c; |
| 1275 | templateArgument() |
| 1276 | matches 'int' in C<int>. |
| 1277 | </pre></td></tr> |
| 1278 | |
| 1279 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1280 | <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] | 1281 | <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. |
| 1282 | </pre></td></tr> |
| 1283 | |
| 1284 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1285 | <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] | 1286 | <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. |
| 1287 | |
| 1288 | Given |
| 1289 | int a[] = { 2, 3 }; |
| 1290 | int b[4]; |
| 1291 | void f() { int c[a[0]]; } |
| 1292 | arrayType() |
| 1293 | matches "int a[]", "int b[4]" and "int c[a[0]]"; |
| 1294 | </pre></td></tr> |
| 1295 | |
| 1296 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1297 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('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] | 1298 | <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. |
| 1299 | |
| 1300 | Given |
| 1301 | _Atomic(int) i; |
| 1302 | atomicType() |
| 1303 | matches "_Atomic(int) i" |
| 1304 | </pre></td></tr> |
| 1305 | |
| 1306 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1307 | <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] | 1308 | <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. |
| 1309 | |
| 1310 | Given: |
| 1311 | auto n = 4; |
| 1312 | int v[] = { 2, 3 } |
| 1313 | for (auto i : v) { } |
| 1314 | autoType() |
| 1315 | matches "auto n" and "auto i" |
| 1316 | </pre></td></tr> |
| 1317 | |
| 1318 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1319 | <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] | 1320 | <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as |
| 1321 | "void (^)(int)". |
| 1322 | |
| 1323 | The pointee is always required to be a FunctionType. |
| 1324 | </pre></td></tr> |
| 1325 | |
| 1326 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1327 | <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] | 1328 | <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. |
| 1329 | |
| 1330 | Given |
| 1331 | struct A {}; |
| 1332 | A a; |
| 1333 | int b; |
| 1334 | float c; |
| 1335 | bool d; |
| 1336 | builtinType() |
| 1337 | matches "int b", "float c" and "bool d" |
| 1338 | </pre></td></tr> |
| 1339 | |
| 1340 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1341 | <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] | 1342 | <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. |
| 1343 | |
| 1344 | Given |
| 1345 | _Complex float f; |
| 1346 | complexType() |
| 1347 | matches "_Complex float f" |
| 1348 | </pre></td></tr> |
| 1349 | |
| 1350 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1351 | <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] | 1352 | <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. |
| 1353 | |
| 1354 | Given |
| 1355 | void() { |
| 1356 | int a[2]; |
| 1357 | int b[] = { 2, 3 }; |
| 1358 | int c[b[0]]; |
| 1359 | } |
| 1360 | constantArrayType() |
| 1361 | matches "int a[2]" |
| 1362 | </pre></td></tr> |
| 1363 | |
| 1364 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1365 | <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] | 1366 | <tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type |
| 1367 | Example matches i[] in declaration of f. |
| 1368 | (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) |
| 1369 | Example matches i[1]. |
| 1370 | (matcher = expr(hasType(decayedType(hasDecayedType(pointerType()))))) |
| 1371 | void f(int i[]) { |
| 1372 | i[1] = 0; |
| 1373 | } |
| 1374 | </pre></td></tr> |
| 1375 | |
| 1376 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1377 | <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] | 1378 | <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. |
| 1379 | |
| 1380 | Given |
| 1381 | template<typename T, int Size> |
| 1382 | class array { |
| 1383 | T data[Size]; |
| 1384 | }; |
| 1385 | dependentSizedArrayType |
| 1386 | matches "T data[Size]" |
| 1387 | </pre></td></tr> |
| 1388 | |
| 1389 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1390 | <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] | 1391 | <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a |
| 1392 | qualified name. |
| 1393 | |
| 1394 | Given |
| 1395 | namespace N { |
| 1396 | namespace M { |
| 1397 | class D {}; |
| 1398 | } |
| 1399 | } |
| 1400 | class C {}; |
| 1401 | |
| 1402 | class C c; |
| 1403 | N::M::D d; |
| 1404 | |
| 1405 | elaboratedType() matches the type of the variable declarations of both |
| 1406 | c and d. |
| 1407 | </pre></td></tr> |
| 1408 | |
| 1409 | |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 1410 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('functionProtoType0')"><a name="functionProtoType0Anchor">functionProtoType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>>...</td></tr> |
| 1411 | <tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes. |
| 1412 | |
| 1413 | Given |
| 1414 | int (*f)(int); |
| 1415 | void g(); |
| 1416 | functionProtoType() |
| 1417 | matches "int (*f)(int)" and the type of "g" in C++ mode. |
| 1418 | In C mode, "g" is not matched because it does not contain a prototype. |
| 1419 | </pre></td></tr> |
| 1420 | |
| 1421 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1422 | <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] | 1423 | <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. |
| 1424 | |
| 1425 | Given |
| 1426 | int (*f)(int); |
| 1427 | void g(); |
| 1428 | functionType() |
| 1429 | matches "int (*f)(int)" and the type of "g". |
| 1430 | </pre></td></tr> |
| 1431 | |
| 1432 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1433 | <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] | 1434 | <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. |
| 1435 | |
| 1436 | Given |
| 1437 | int a[] = { 2, 3 }; |
| 1438 | int b[42]; |
| 1439 | void f(int c[]) { int d[a[0]]; }; |
| 1440 | incompleteArrayType() |
| 1441 | matches "int a[]" and "int c[]" |
| 1442 | </pre></td></tr> |
| 1443 | |
| 1444 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1445 | <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] | 1446 | <tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types. |
| 1447 | |
| 1448 | Example matches S s, but not S<T> s. |
| 1449 | (matcher = parmVarDecl(hasType(injectedClassNameType()))) |
| 1450 | template <typename T> struct S { |
| 1451 | void f(S s); |
| 1452 | void g(S<T> s); |
| 1453 | }; |
| 1454 | </pre></td></tr> |
| 1455 | |
| 1456 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1457 | <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] | 1458 | <tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. |
| 1459 | |
| 1460 | Given: |
| 1461 | int *a; |
| 1462 | int &b = *a; |
| 1463 | int &&c = 1; |
| 1464 | auto &d = b; |
| 1465 | auto &&e = c; |
| 1466 | auto &&f = 2; |
| 1467 | int g = 5; |
| 1468 | |
| 1469 | lValueReferenceType() matches the types of b, d, and e. e is |
| 1470 | matched since the type is deduced as int& by reference collapsing rules. |
| 1471 | </pre></td></tr> |
| 1472 | |
| 1473 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1474 | <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] | 1475 | <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. |
| 1476 | Given |
| 1477 | struct A { int i; } |
| 1478 | A::* ptr = A::i; |
| 1479 | memberPointerType() |
| 1480 | matches "A::* ptr" |
| 1481 | </pre></td></tr> |
| 1482 | |
| 1483 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1484 | <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] | 1485 | <tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from |
| 1486 | a pointer type, despite being syntactically similar. |
| 1487 | |
| 1488 | Given |
| 1489 | int *a; |
| 1490 | |
| 1491 | @interface Foo |
| 1492 | @end |
| 1493 | Foo *f; |
| 1494 | pointerType() |
| 1495 | matches "Foo *f", but does not match "int *a". |
| 1496 | </pre></td></tr> |
| 1497 | |
| 1498 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1499 | <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] | 1500 | <tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. |
| 1501 | |
| 1502 | Given |
| 1503 | int (*ptr_to_array)[4]; |
| 1504 | int *array_of_ptrs[4]; |
| 1505 | |
| 1506 | varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not |
| 1507 | array_of_ptrs. |
| 1508 | </pre></td></tr> |
| 1509 | |
| 1510 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1511 | <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] | 1512 | <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer |
| 1513 | types. |
| 1514 | |
| 1515 | Given |
| 1516 | int *a; |
| 1517 | int &b = *a; |
| 1518 | int c = 5; |
| 1519 | |
| 1520 | @interface Foo |
| 1521 | @end |
| 1522 | Foo *f; |
| 1523 | pointerType() |
| 1524 | matches "int *a", but does not match "Foo *f". |
| 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('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] | 1529 | <tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. |
| 1530 | |
| 1531 | Given: |
| 1532 | int *a; |
| 1533 | int &b = *a; |
| 1534 | int &&c = 1; |
| 1535 | auto &d = b; |
| 1536 | auto &&e = c; |
| 1537 | auto &&f = 2; |
| 1538 | int g = 5; |
| 1539 | |
| 1540 | rValueReferenceType() matches the types of c and f. e is not |
| 1541 | matched as it is deduced to int& by reference collapsing rules. |
| 1542 | </pre></td></tr> |
| 1543 | |
| 1544 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1545 | <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] | 1546 | <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). |
| 1547 | |
| 1548 | Given |
| 1549 | class C {}; |
| 1550 | struct S {}; |
| 1551 | |
| 1552 | C c; |
| 1553 | S s; |
| 1554 | |
| 1555 | recordType() matches the type of the variable declarations of both c |
| 1556 | and s. |
| 1557 | </pre></td></tr> |
| 1558 | |
| 1559 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1560 | <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] | 1561 | <tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. |
| 1562 | |
| 1563 | Given |
| 1564 | int *a; |
| 1565 | int &b = *a; |
| 1566 | int &&c = 1; |
| 1567 | auto &d = b; |
| 1568 | auto &&e = c; |
| 1569 | auto &&f = 2; |
| 1570 | int g = 5; |
| 1571 | |
| 1572 | referenceType() matches the types of b, c, d, e, and f. |
| 1573 | </pre></td></tr> |
| 1574 | |
| 1575 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1576 | <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] | 1577 | <tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a |
| 1578 | template type parameter. |
| 1579 | |
| 1580 | Given |
| 1581 | template <typename T> |
| 1582 | void F(T t) { |
| 1583 | int i = 1 + t; |
| 1584 | } |
| 1585 | |
| 1586 | substTemplateTypeParmType() matches the type of 't' but not '1' |
| 1587 | </pre></td></tr> |
| 1588 | |
| 1589 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1590 | <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] | 1591 | <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. |
| 1592 | |
| 1593 | Given |
| 1594 | template <typename T> |
| 1595 | class C { }; |
| 1596 | |
| 1597 | template class C<int>; A |
| 1598 | C<char> var; B |
| 1599 | |
| 1600 | templateSpecializationType() matches the type of the explicit |
| 1601 | instantiation in A and the type of the variable declaration in B. |
| 1602 | </pre></td></tr> |
| 1603 | |
| 1604 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1605 | <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] | 1606 | <tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types. |
| 1607 | |
| 1608 | Example matches T, but not int. |
| 1609 | (matcher = templateTypeParmType()) |
| 1610 | template <typename T> void f(int i); |
| 1611 | </pre></td></tr> |
| 1612 | |
| 1613 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1614 | <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] | 1615 | <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. |
| 1616 | </pre></td></tr> |
| 1617 | |
| 1618 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1619 | <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] | 1620 | <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. |
| 1621 | |
| 1622 | Given |
| 1623 | typedef int X; |
| 1624 | typedefType() |
| 1625 | matches "typedef int X" |
| 1626 | </pre></td></tr> |
| 1627 | |
| 1628 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1629 | <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] | 1630 | <tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. |
| 1631 | |
| 1632 | Given: |
| 1633 | typedef __underlying_type(T) type; |
| 1634 | unaryTransformType() |
| 1635 | matches "__underlying_type(T)" |
| 1636 | </pre></td></tr> |
| 1637 | |
| 1638 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1639 | <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] | 1640 | <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an |
| 1641 | integer-constant-expression. |
| 1642 | |
| 1643 | Given |
| 1644 | void f() { |
| 1645 | int a[] = { 2, 3 } |
| 1646 | int b[42]; |
| 1647 | int c[a[0]]; |
| 1648 | } |
| 1649 | variableArrayType() |
| 1650 | matches "int c[a[0]]" |
| 1651 | </pre></td></tr> |
| 1652 | |
Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 1653 | <!--END_DECL_MATCHERS --> |
| 1654 | </table> |
| 1655 | |
| 1656 | <!-- ======================================================================= --> |
| 1657 | <h2 id="narrowing-matchers">Narrowing Matchers</h2> |
| 1658 | <!-- ======================================================================= --> |
| 1659 | |
| 1660 | <p>Narrowing matchers match certain attributes on the current node, thus |
| 1661 | narrowing down the set of nodes of the current type to match on.</p> |
| 1662 | |
| 1663 | <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) |
| 1664 | which allow users to create more powerful match expressions.</p> |
| 1665 | |
| 1666 | <table> |
| 1667 | <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] | 1668 | <!-- START_NARROWING_MATCHERS --> |
| 1669 | |
| 1670 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 1671 | <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. |
| 1672 | |
| 1673 | Usable as: Any Matcher |
| 1674 | </pre></td></tr> |
| 1675 | |
| 1676 | |
| 1677 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 1678 | <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. |
| 1679 | |
| 1680 | Usable as: Any Matcher |
| 1681 | </pre></td></tr> |
| 1682 | |
| 1683 | |
| 1684 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> |
| 1685 | <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. |
| 1686 | |
| 1687 | Useful when another matcher requires a child matcher, but there's no |
| 1688 | additional constraint. This will often be used with an explicit conversion |
| 1689 | to an internal::Matcher<> type such as TypeMatcher. |
| 1690 | |
| 1691 | Example: DeclarationMatcher(anything()) matches all declarations, e.g., |
| 1692 | "int* p" and "void f()" in |
| 1693 | int* p; |
| 1694 | void f(); |
| 1695 | |
| 1696 | Usable as: Any Matcher |
| 1697 | </pre></td></tr> |
| 1698 | |
| 1699 | |
| 1700 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> |
| 1701 | <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. |
| 1702 | |
| 1703 | Example matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) |
| 1704 | class X {}; |
| 1705 | class Y {}; |
| 1706 | |
| 1707 | Usable as: Any Matcher |
| 1708 | </pre></td></tr> |
| 1709 | |
| 1710 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1711 | <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] | 1712 | <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or |
| 1713 | unary). |
| 1714 | |
| 1715 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 1716 | !(a || b) |
| 1717 | </pre></td></tr> |
| 1718 | |
| 1719 | |
| 1720 | <tr><td>Matcher<CXXBoolLiteral></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr> |
| 1721 | <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value. |
| 1722 | |
| 1723 | Example matches true (matcher = cxxBoolLiteral(equals(true))) |
| 1724 | true |
| 1725 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1726 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 1727 | 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] | 1728 | </pre></td></tr> |
| 1729 | |
| 1730 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1731 | <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] | 1732 | <tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. |
| 1733 | |
| 1734 | Given |
| 1735 | try { |
| 1736 | ... |
| 1737 | } catch (int) { |
| 1738 | ... |
| 1739 | } catch (...) { |
| 1740 | ... |
| 1741 | } |
| 1742 | endcode |
| 1743 | cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). |
| 1744 | </pre></td></tr> |
| 1745 | |
| 1746 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1747 | <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] | 1748 | <tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has |
| 1749 | a specific number of arguments (including absent default arguments). |
| 1750 | |
| 1751 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 1752 | void f(int x, int y); |
| 1753 | f(0, 0); |
| 1754 | </pre></td></tr> |
| 1755 | |
| 1756 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1757 | <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] | 1758 | <tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. |
| 1759 | </pre></td></tr> |
| 1760 | |
| 1761 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1762 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('requiresZeroInitialization0')"><a name="requiresZeroInitialization0Anchor">requiresZeroInitialization</a></td><td></td></tr> |
| 1763 | <tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires |
| 1764 | zero initialization. |
| 1765 | |
| 1766 | Given |
| 1767 | void foo() { |
| 1768 | struct point { double x; double y; }; |
| 1769 | point pt[2] = { { 1.0, 2.0 } }; |
| 1770 | } |
| 1771 | initListExpr(has(cxxConstructExpr(requiresZeroInitialization())) |
| 1772 | will match the implicit array filler for pt[1]. |
| 1773 | </pre></td></tr> |
| 1774 | |
| 1775 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1776 | <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] | 1777 | <tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. |
| 1778 | |
| 1779 | Given |
| 1780 | struct S { |
| 1781 | S(); #1 |
| 1782 | S(const S &); #2 |
| 1783 | S(S &&); #3 |
| 1784 | }; |
| 1785 | cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. |
| 1786 | </pre></td></tr> |
| 1787 | |
| 1788 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1789 | <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] | 1790 | <tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. |
| 1791 | |
| 1792 | Given |
| 1793 | struct S { |
| 1794 | S(); #1 |
| 1795 | S(const S &); #2 |
| 1796 | S(S &&); #3 |
| 1797 | }; |
| 1798 | cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. |
| 1799 | </pre></td></tr> |
| 1800 | |
| 1801 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1802 | <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] | 1803 | <tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with |
| 1804 | the explicit keyword. |
| 1805 | |
| 1806 | Given |
| 1807 | struct S { |
| 1808 | S(int); #1 |
| 1809 | explicit S(double); #2 |
| 1810 | operator int(); #3 |
| 1811 | explicit operator bool(); #4 |
| 1812 | }; |
| 1813 | cxxConstructorDecl(isExplicit()) will match #2, but not #1. |
| 1814 | cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| 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_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] | 1819 | <tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. |
| 1820 | |
| 1821 | Given |
| 1822 | struct S { |
| 1823 | S(); #1 |
| 1824 | S(const S &); #2 |
| 1825 | S(S &&); #3 |
| 1826 | }; |
| 1827 | cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. |
| 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_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] | 1832 | <tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with |
| 1833 | the explicit keyword. |
| 1834 | |
| 1835 | Given |
| 1836 | struct S { |
| 1837 | S(int); #1 |
| 1838 | explicit S(double); #2 |
| 1839 | operator int(); #3 |
| 1840 | explicit operator bool(); #4 |
| 1841 | }; |
| 1842 | cxxConstructorDecl(isExplicit()) will match #2, but not #1. |
| 1843 | cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| 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_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] | 1848 | <tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as |
| 1849 | opposed to a member. |
| 1850 | |
| 1851 | Given |
| 1852 | struct B {}; |
| 1853 | struct D : B { |
| 1854 | int I; |
| 1855 | D(int i) : I(i) {} |
| 1856 | }; |
| 1857 | struct E : B { |
| 1858 | E() : B() {} |
| 1859 | }; |
| 1860 | cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) |
| 1861 | will match E(), but not match D(int). |
| 1862 | </pre></td></tr> |
| 1863 | |
| 1864 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1865 | <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] | 1866 | <tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as |
| 1867 | opposed to a base. |
| 1868 | |
| 1869 | Given |
| 1870 | struct B {}; |
| 1871 | struct D : B { |
| 1872 | int I; |
| 1873 | D(int i) : I(i) {} |
| 1874 | }; |
| 1875 | struct E : B { |
| 1876 | E() : B() {} |
| 1877 | }; |
| 1878 | cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) |
| 1879 | will match D(int), but not match E(). |
| 1880 | </pre></td></tr> |
| 1881 | |
| 1882 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1883 | <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] | 1884 | <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in |
| 1885 | code (as opposed to implicitly added by the compiler). |
| 1886 | |
| 1887 | Given |
| 1888 | struct Foo { |
| 1889 | Foo() { } |
| 1890 | Foo(int) : foo_("A") { } |
| 1891 | string foo_; |
| 1892 | }; |
| 1893 | cxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) |
| 1894 | will match Foo(int), but not Foo() |
| 1895 | </pre></td></tr> |
| 1896 | |
| 1897 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1898 | <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] | 1899 | <tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. |
| 1900 | |
| 1901 | Given |
| 1902 | struct A { |
| 1903 | void foo() const; |
| 1904 | void bar(); |
| 1905 | }; |
| 1906 | |
| 1907 | cxxMethodDecl(isConst()) matches A::foo() but not A::bar() |
| 1908 | </pre></td></tr> |
| 1909 | |
| 1910 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1911 | <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] | 1912 | <tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment |
| 1913 | operator. |
| 1914 | |
| 1915 | Given |
| 1916 | struct A { |
| 1917 | A &operator=(const A &); |
| 1918 | A &operator=(A &&); |
| 1919 | }; |
| 1920 | |
| 1921 | cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not |
| 1922 | the second one. |
| 1923 | </pre></td></tr> |
| 1924 | |
| 1925 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1926 | <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] | 1927 | <tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. |
| 1928 | |
| 1929 | Given: |
| 1930 | class A final {}; |
| 1931 | |
| 1932 | struct B { |
| 1933 | virtual void f(); |
| 1934 | }; |
| 1935 | |
| 1936 | struct C : B { |
| 1937 | void f() final; |
| 1938 | }; |
| 1939 | matches A and C::f, but not B, C, or B::f |
| 1940 | </pre></td></tr> |
| 1941 | |
| 1942 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1943 | <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] | 1944 | <tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment |
| 1945 | operator. |
| 1946 | |
| 1947 | Given |
Aaron Ballman | a681151 | 2016-01-23 17:49:18 +0000 | [diff] [blame] | 1948 | struct A { |
| 1949 | A &operator=(const A &); |
| 1950 | A &operator=(A &&); |
| 1951 | }; |
| 1952 | |
| 1953 | cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not |
| 1954 | the first one. |
Aaron Ballman | 31bde87 | 2016-01-22 22:37:09 +0000 | [diff] [blame] | 1955 | </pre></td></tr> |
| 1956 | |
| 1957 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1958 | <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] | 1959 | <tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. |
| 1960 | |
| 1961 | Given |
| 1962 | class A { |
| 1963 | public: |
| 1964 | virtual void x(); |
| 1965 | }; |
| 1966 | class B : public A { |
| 1967 | public: |
| 1968 | virtual void x(); |
| 1969 | }; |
| 1970 | matches B::x |
| 1971 | </pre></td></tr> |
| 1972 | |
| 1973 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1974 | <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] | 1975 | <tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. |
| 1976 | |
| 1977 | Given |
| 1978 | class A { |
| 1979 | public: |
| 1980 | virtual void x() = 0; |
| 1981 | }; |
| 1982 | matches A::x |
| 1983 | </pre></td></tr> |
| 1984 | |
| 1985 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1986 | <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] | 1987 | <tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. |
| 1988 | |
| 1989 | Given |
| 1990 | class A { |
| 1991 | public: |
| 1992 | virtual void x(); |
| 1993 | }; |
| 1994 | matches A::x |
| 1995 | </pre></td></tr> |
| 1996 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1997 | |
| 1998 | <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] | 1999 | <tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual". |
| 2000 | |
| 2001 | Given |
| 2002 | class A { |
| 2003 | public: |
| 2004 | virtual void x(); |
| 2005 | }; |
| 2006 | class B : public A { |
| 2007 | public: |
| 2008 | void x(); |
| 2009 | }; |
| 2010 | matches A::x but not B::x |
| 2011 | </pre></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2012 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2013 | |
| 2014 | <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] | 2015 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. |
| 2016 | |
| 2017 | Matches overloaded operator names specified in strings without the |
| 2018 | "operator" prefix: e.g. "<<". |
| 2019 | |
| 2020 | Given: |
| 2021 | class A { int operator*(); }; |
| 2022 | const A &operator<<(const A &a, const A &b); |
| 2023 | A a; |
| 2024 | a << a; <-- This matches |
| 2025 | |
| 2026 | cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the |
| 2027 | specified line and |
| 2028 | cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) |
| 2029 | matches the declaration of A. |
| 2030 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2031 | 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] | 2032 | </pre></td></tr> |
| 2033 | |
| 2034 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2035 | <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] | 2036 | <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). |
| 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_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] | 2041 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or |
| 2042 | static member variable template instantiations. |
| 2043 | |
| 2044 | Given |
| 2045 | template<typename T> void A(T t) { } |
| 2046 | template<> void A(int N) { } |
| 2047 | functionDecl(isExplicitTemplateSpecialization()) |
| 2048 | matches the specialization A<int>(). |
| 2049 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2050 | 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] | 2051 | </pre></td></tr> |
| 2052 | |
| 2053 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2054 | <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] | 2055 | <tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. |
| 2056 | |
| 2057 | Given: |
| 2058 | class A final {}; |
| 2059 | |
| 2060 | struct B { |
| 2061 | virtual void f(); |
| 2062 | }; |
| 2063 | |
| 2064 | struct C : B { |
| 2065 | void f() final; |
| 2066 | }; |
| 2067 | matches A and C::f, but not B, C, or B::f |
| 2068 | </pre></td></tr> |
| 2069 | |
| 2070 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2071 | <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] | 2072 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for |
| 2073 | isSameOrDerivedFrom(hasName(...)). |
| 2074 | </pre></td></tr> |
| 2075 | |
| 2076 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2077 | <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] | 2078 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static |
| 2079 | member variable template instantiations. |
| 2080 | |
| 2081 | Given |
| 2082 | template <typename T> class X {}; class A {}; X<A> x; |
| 2083 | or |
| 2084 | template <typename T> class X {}; class A {}; template class X<A>; |
| 2085 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 2086 | matches the template instantiation of X<A>. |
| 2087 | |
| 2088 | But given |
| 2089 | template <typename T> class X {}; class A {}; |
| 2090 | template <> class X<A> {}; X<A> x; |
| 2091 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 2092 | does not match, as X<A> is an explicit template specialization. |
| 2093 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2094 | 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] | 2095 | </pre></td></tr> |
| 2096 | |
| 2097 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2098 | <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] | 2099 | <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has |
| 2100 | a specific number of arguments (including absent default arguments). |
| 2101 | |
| 2102 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 2103 | void f(int x, int y); |
| 2104 | f(0, 0); |
| 2105 | </pre></td></tr> |
| 2106 | |
| 2107 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2108 | <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] | 2109 | <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value. |
| 2110 | |
| 2111 | Example matches true (matcher = cxxBoolLiteral(equals(true))) |
| 2112 | true |
| 2113 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2114 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 2115 | 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] | 2116 | </pre></td></tr> |
| 2117 | |
| 2118 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2119 | <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] | 2120 | <tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. |
| 2121 | |
| 2122 | Given |
| 2123 | template<typename T> struct C {}; |
| 2124 | C<int> c; |
| 2125 | classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
| 2126 | matches C<int>. |
| 2127 | </pre></td></tr> |
| 2128 | |
| 2129 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2130 | <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] | 2131 | <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of |
| 2132 | child statements. |
| 2133 | |
| 2134 | Example: Given |
| 2135 | { for (;;) {} } |
| 2136 | compoundStmt(statementCountIs(0))) |
| 2137 | matches '{}' |
| 2138 | but does not match the outer compound statement. |
| 2139 | </pre></td></tr> |
| 2140 | |
| 2141 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2142 | <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] | 2143 | <tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size. |
| 2144 | |
| 2145 | Given |
| 2146 | int a[42]; |
| 2147 | int b[2 * 21]; |
| 2148 | int c[41], d[43]; |
| 2149 | constantArrayType(hasSize(42)) |
| 2150 | matches "int a[42]" and "int b[2 * 21]" |
| 2151 | </pre></td></tr> |
| 2152 | |
| 2153 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2154 | <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] | 2155 | <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of |
| 2156 | declarations. |
| 2157 | |
| 2158 | Example: Given |
| 2159 | int a, b; |
| 2160 | int c; |
| 2161 | int d = 2, e; |
| 2162 | declCountIs(2) |
| 2163 | matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. |
| 2164 | </pre></td></tr> |
| 2165 | |
| 2166 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2167 | <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] | 2168 | <tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. |
| 2169 | |
| 2170 | Matches a node if it equals the node previously bound to ID. |
| 2171 | |
| 2172 | Given |
| 2173 | class X { int a; int b; }; |
| 2174 | cxxRecordDecl( |
| 2175 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 2176 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 2177 | matches the class X, as a and b have the same type. |
| 2178 | |
| 2179 | Note that when multiple matches are involved via forEach* matchers, |
| 2180 | equalsBoundNodes acts as a filter. |
| 2181 | For example: |
| 2182 | compoundStmt( |
| 2183 | forEachDescendant(varDecl().bind("d")), |
| 2184 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 2185 | will trigger a match for each combination of variable declaration |
| 2186 | and reference to that variable declaration within a compound statement. |
| 2187 | </pre></td></tr> |
| 2188 | |
| 2189 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2190 | <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] | 2191 | <tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. |
| 2192 | |
| 2193 | Given |
| 2194 | __attribute__((device)) void f() { ... } |
| 2195 | decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of |
| 2196 | f. If the matcher is use from clang-query, attr::Kind parameter should be |
| 2197 | passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). |
| 2198 | </pre></td></tr> |
| 2199 | |
| 2200 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2201 | <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] | 2202 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is |
| 2203 | partially matching a given regex. |
| 2204 | |
| 2205 | Example matches Y but not X |
| 2206 | (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 2207 | #include "ASTMatcher.h" |
| 2208 | class X {}; |
| 2209 | ASTMatcher.h: |
| 2210 | class Y {}; |
| 2211 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2212 | 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] | 2213 | </pre></td></tr> |
| 2214 | |
| 2215 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2216 | <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] | 2217 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. |
| 2218 | |
| 2219 | Example matches X but not Y |
| 2220 | (matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 2221 | #include <Y.h> |
| 2222 | class X {}; |
| 2223 | Y.h: |
| 2224 | class Y {}; |
| 2225 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2226 | 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] | 2227 | </pre></td></tr> |
| 2228 | |
| 2229 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2230 | <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] | 2231 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. |
| 2232 | |
| 2233 | Example matches Y but not X |
| 2234 | (matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 2235 | #include <SystemHeader.h> |
| 2236 | class X {}; |
| 2237 | SystemHeader.h: |
| 2238 | class Y {}; |
| 2239 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2240 | 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] | 2241 | </pre></td></tr> |
| 2242 | |
| 2243 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2244 | <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] | 2245 | <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added |
| 2246 | by the compiler (eg. implicit defaultcopy constructors). |
| 2247 | </pre></td></tr> |
| 2248 | |
| 2249 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2250 | <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] | 2251 | <tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. |
| 2252 | |
| 2253 | Given |
| 2254 | class C { |
| 2255 | public: int a; |
| 2256 | protected: int b; |
| 2257 | private: int c; |
| 2258 | }; |
| 2259 | fieldDecl(isPrivate()) |
| 2260 | matches 'int c;' |
| 2261 | </pre></td></tr> |
| 2262 | |
| 2263 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2264 | <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] | 2265 | <tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. |
| 2266 | |
| 2267 | Given |
| 2268 | class C { |
| 2269 | public: int a; |
| 2270 | protected: int b; |
| 2271 | private: int c; |
| 2272 | }; |
| 2273 | fieldDecl(isProtected()) |
| 2274 | matches 'int b;' |
| 2275 | </pre></td></tr> |
| 2276 | |
| 2277 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2278 | <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] | 2279 | <tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. |
| 2280 | |
| 2281 | Given |
| 2282 | class C { |
| 2283 | public: int a; |
| 2284 | protected: int b; |
| 2285 | private: int c; |
| 2286 | }; |
| 2287 | fieldDecl(isPublic()) |
| 2288 | matches 'int a;' |
| 2289 | </pre></td></tr> |
| 2290 | |
| 2291 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 2292 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DesignatedInitExpr.html">DesignatedInitExpr</a>></td><td class="name" onclick="toggle('designatorCountIs0')"><a name="designatorCountIs0Anchor">designatorCountIs</a></td><td>unsigned N</td></tr> |
| 2293 | <tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain |
| 2294 | a specific number of designators. |
| 2295 | |
| 2296 | Example: Given |
| 2297 | point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; |
| 2298 | point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }; |
| 2299 | designatorCountIs(2) |
| 2300 | matches '{ [2].y = 1.0, [0].x = 1.0 }', |
| 2301 | but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'. |
| 2302 | </pre></td></tr> |
| 2303 | |
| 2304 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2305 | <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] | 2306 | <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. |
| 2307 | |
| 2308 | Example matches true (matcher = cxxBoolLiteral(equals(true))) |
| 2309 | true |
| 2310 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2311 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 2312 | 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] | 2313 | </pre></td></tr> |
| 2314 | |
| 2315 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2316 | <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] | 2317 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. |
| 2318 | |
| 2319 | Matches overloaded operator names specified in strings without the |
| 2320 | "operator" prefix: e.g. "<<". |
| 2321 | |
| 2322 | Given: |
| 2323 | class A { int operator*(); }; |
| 2324 | const A &operator<<(const A &a, const A &b); |
| 2325 | A a; |
| 2326 | a << a; <-- This matches |
| 2327 | |
| 2328 | cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the |
| 2329 | specified line and |
| 2330 | cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) |
| 2331 | matches the declaration of A. |
| 2332 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2333 | 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] | 2334 | </pre></td></tr> |
| 2335 | |
| 2336 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2337 | <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] | 2338 | <tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations. |
| 2339 | |
| 2340 | Given: |
| 2341 | constexpr int foo = 42; |
| 2342 | constexpr int bar(); |
| 2343 | varDecl(isConstexpr()) |
| 2344 | matches the declaration of foo. |
| 2345 | functionDecl(isConstexpr()) |
| 2346 | matches the declaration of bar. |
| 2347 | </pre></td></tr> |
| 2348 | |
| 2349 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2350 | <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] | 2351 | <tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations. |
| 2352 | |
| 2353 | Given: |
| 2354 | class A { ~A(); }; |
| 2355 | class B { ~B() = default; }; |
| 2356 | functionDecl(isDefaulted()) |
| 2357 | matches the declaration of ~B, but not ~A. |
| 2358 | </pre></td></tr> |
| 2359 | |
| 2360 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2361 | <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] | 2362 | <tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. |
| 2363 | |
| 2364 | Example matches A, va, fa |
| 2365 | class A {}; |
| 2366 | class B; Doesn't match, as it has no body. |
| 2367 | int va; |
| 2368 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 2369 | void fa() {} |
| 2370 | void fb(); Doesn't match, as it has no body. |
| 2371 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2372 | 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] | 2373 | </pre></td></tr> |
| 2374 | |
| 2375 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2376 | <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] | 2377 | <tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. |
| 2378 | |
| 2379 | Given: |
| 2380 | void Func(); |
| 2381 | void DeletedFunc() = delete; |
| 2382 | functionDecl(isDeleted()) |
| 2383 | matches the declaration of DeletedFunc, but not Func. |
| 2384 | </pre></td></tr> |
| 2385 | |
| 2386 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2387 | <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] | 2388 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or |
| 2389 | static member variable template instantiations. |
| 2390 | |
| 2391 | Given |
| 2392 | template<typename T> void A(T t) { } |
| 2393 | template<> void A(int N) { } |
| 2394 | functionDecl(isExplicitTemplateSpecialization()) |
| 2395 | matches the specialization A<int>(). |
| 2396 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2397 | 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] | 2398 | </pre></td></tr> |
| 2399 | |
| 2400 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2401 | <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] | 2402 | <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. |
| 2403 | |
| 2404 | Given: |
| 2405 | extern "C" void f() {} |
| 2406 | extern "C" { void g() {} } |
| 2407 | void h() {} |
| 2408 | functionDecl(isExternC()) |
| 2409 | matches the declaration of f and g, but not the declaration h |
| 2410 | </pre></td></tr> |
| 2411 | |
| 2412 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2413 | <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] | 2414 | <tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with |
| 2415 | the inline keyword. |
| 2416 | |
| 2417 | Given |
| 2418 | inline void f(); |
| 2419 | void g(); |
| 2420 | namespace n { |
| 2421 | inline namespace m {} |
| 2422 | } |
| 2423 | functionDecl(isInline()) will match ::f(). |
| 2424 | namespaceDecl(isInline()) will match n::m. |
| 2425 | </pre></td></tr> |
| 2426 | |
| 2427 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2428 | <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] | 2429 | <tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification. |
| 2430 | |
| 2431 | Given: |
| 2432 | void f(); |
| 2433 | void g() noexcept; |
| 2434 | void h() throw(); |
| 2435 | void i() throw(int); |
| 2436 | void j() noexcept(false); |
| 2437 | functionDecl(isNoThrow()) |
| 2438 | matches the declarations of g, and h, but not f, i or j. |
| 2439 | </pre></td></tr> |
| 2440 | |
| 2441 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2442 | <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] | 2443 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static |
| 2444 | member variable template instantiations. |
| 2445 | |
| 2446 | Given |
| 2447 | template <typename T> class X {}; class A {}; X<A> x; |
| 2448 | or |
| 2449 | template <typename T> class X {}; class A {}; template class X<A>; |
| 2450 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 2451 | matches the template instantiation of X<A>. |
| 2452 | |
| 2453 | But given |
| 2454 | template <typename T> class X {}; class A {}; |
| 2455 | template <> class X<A> {}; X<A> x; |
| 2456 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 2457 | does not match, as X<A> is an explicit template specialization. |
| 2458 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2459 | 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] | 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_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] | 2464 | <tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. |
| 2465 | |
| 2466 | Example matches f, but not g or h. The function i will not match, even when |
| 2467 | compiled in C mode. |
| 2468 | void f(...); |
| 2469 | void g(int); |
| 2470 | template <typename... Ts> void h(Ts...); |
| 2471 | void i(); |
| 2472 | </pre></td></tr> |
| 2473 | |
| 2474 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2475 | <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> |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 2476 | <tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a |
| 2477 | specific parameter count. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2478 | |
| 2479 | Given |
| 2480 | void f(int i) {} |
| 2481 | void g(int i, int j) {} |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 2482 | void h(int i, int j); |
| 2483 | void j(int i); |
| 2484 | void k(int x, int y, int z, ...); |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2485 | functionDecl(parameterCountIs(2)) |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 2486 | matches void g(int i, int j) {} |
| 2487 | functionProtoType(parameterCountIs(2)) |
| 2488 | matches void h(int i, int j) |
| 2489 | functionProtoType(parameterCountIs(3)) |
| 2490 | matches void k(int x, int y, int z, ...); |
| 2491 | </pre></td></tr> |
| 2492 | |
| 2493 | |
| 2494 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>></td><td class="name" onclick="toggle('parameterCountIs1')"><a name="parameterCountIs1Anchor">parameterCountIs</a></td><td>unsigned N</td></tr> |
| 2495 | <tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a |
| 2496 | specific parameter count. |
| 2497 | |
| 2498 | Given |
| 2499 | void f(int i) {} |
| 2500 | void g(int i, int j) {} |
| 2501 | void h(int i, int j); |
| 2502 | void j(int i); |
| 2503 | void k(int x, int y, int z, ...); |
| 2504 | functionDecl(parameterCountIs(2)) |
| 2505 | matches void g(int i, int j) {} |
| 2506 | functionProtoType(parameterCountIs(2)) |
| 2507 | matches void h(int i, int j) |
| 2508 | functionProtoType(parameterCountIs(3)) |
| 2509 | matches void k(int x, int y, int z, ...); |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2510 | </pre></td></tr> |
| 2511 | |
| 2512 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2513 | <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] | 2514 | <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. |
| 2515 | |
| 2516 | Example matches true (matcher = cxxBoolLiteral(equals(true))) |
| 2517 | true |
| 2518 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2519 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, |
| 2520 | 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] | 2521 | </pre></td></tr> |
| 2522 | |
| 2523 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2524 | <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] | 2525 | <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed |
| 2526 | to '.'. |
| 2527 | |
| 2528 | Member calls on the implicit this pointer match as called with '->'. |
| 2529 | |
| 2530 | Given |
| 2531 | class Y { |
| 2532 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 2533 | int a; |
| 2534 | static int b; |
| 2535 | }; |
| 2536 | memberExpr(isArrow()) |
| 2537 | matches this->x, x, y.x, a, this->b |
| 2538 | </pre></td></tr> |
| 2539 | |
| 2540 | |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 2541 | <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] | 2542 | <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. |
| 2543 | |
| 2544 | Supports specifying enclosing namespaces or classes by prefixing the name |
| 2545 | with '<enclosing>::'. |
| 2546 | Does not match typedefs of an underlying type with the given name. |
| 2547 | |
| 2548 | Example matches X (Name == "X") |
| 2549 | class X; |
| 2550 | |
| 2551 | Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") |
| 2552 | namespace a { namespace b { class X; } } |
| 2553 | </pre></td></tr> |
| 2554 | |
| 2555 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2556 | <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] | 2557 | <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain |
| 2558 | a substring matched by the given RegExp. |
| 2559 | |
| 2560 | Supports specifying enclosing namespaces or classes by |
| 2561 | prefixing the name with '<enclosing>::'. Does not match typedefs |
| 2562 | of an underlying type with the given name. |
| 2563 | |
| 2564 | Example matches X (regexp == "::X") |
| 2565 | class X; |
| 2566 | |
| 2567 | Example matches X (regexp is one of "::X", "^foo::.*X", among others) |
| 2568 | namespace foo { namespace bar { class X; } } |
| 2569 | </pre></td></tr> |
| 2570 | |
| 2571 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2572 | <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] | 2573 | <tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. |
| 2574 | |
| 2575 | Given |
| 2576 | namespace n { |
| 2577 | namespace {} #1 |
| 2578 | } |
| 2579 | namespaceDecl(isAnonymous()) will match #1 but not ::n. |
| 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_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] | 2584 | <tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with |
| 2585 | the inline keyword. |
| 2586 | |
| 2587 | Given |
| 2588 | inline void f(); |
| 2589 | void g(); |
| 2590 | namespace n { |
| 2591 | inline namespace m {} |
| 2592 | } |
| 2593 | functionDecl(isInline()) will match ::f(). |
| 2594 | namespaceDecl(isInline()) will match n::m. |
| 2595 | </pre></td></tr> |
| 2596 | |
| 2597 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2598 | <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] | 2599 | <tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has |
| 2600 | a specific number of arguments (including absent default arguments). |
| 2601 | |
| 2602 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 2603 | void f(int x, int y); |
| 2604 | f(0, 0); |
| 2605 | </pre></td></tr> |
| 2606 | |
| 2607 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2608 | <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] | 2609 | <tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector |
| 2610 | |
| 2611 | objCMessageExpr(hasKeywordSelector()) matches the generated setFrame |
| 2612 | message expression in |
| 2613 | |
| 2614 | UIWebView *webView = ...; |
| 2615 | CGRect bodyFrame = webView.frame; |
| 2616 | bodyFrame.size.height = self.bodyContentHeight; |
| 2617 | webView.frame = bodyFrame; |
| 2618 | ^---- matches here |
| 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_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] | 2623 | <tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector |
| 2624 | |
| 2625 | Matches only when the selector of the objCMessageExpr is NULL. This may |
| 2626 | represent an error condition in the tree! |
| 2627 | </pre></td></tr> |
| 2628 | |
| 2629 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2630 | <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] | 2631 | <tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() |
| 2632 | |
| 2633 | matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); |
| 2634 | matches the outer message expr in the code below, but NOT the message |
| 2635 | invocation for self.bodyView. |
| 2636 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 2637 | </pre></td></tr> |
| 2638 | |
| 2639 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2640 | <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] | 2641 | <tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector |
| 2642 | |
| 2643 | matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); |
| 2644 | matches self.bodyView in the code below, but NOT the outer message |
| 2645 | invocation of "loadHTMLString:baseURL:". |
| 2646 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 2647 | </pre></td></tr> |
| 2648 | |
| 2649 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2650 | <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] | 2651 | <tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains |
| 2652 | a substring matched by the given RegExp. |
| 2653 | matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message |
| 2654 | invocation for self.bodyView. |
| 2655 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 2656 | </pre></td></tr> |
| 2657 | |
| 2658 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2659 | <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] | 2660 | <tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments |
| 2661 | |
| 2662 | matcher = objCMessageExpr(numSelectorArgs(0)); |
| 2663 | matches self.bodyView in the code below |
| 2664 | |
| 2665 | matcher = objCMessageExpr(numSelectorArgs(2)); |
| 2666 | matches the invocation of "loadHTMLString:baseURL:" but not that |
| 2667 | of self.bodyView |
| 2668 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 2669 | </pre></td></tr> |
| 2670 | |
| 2671 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2672 | <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] | 2673 | <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. |
| 2674 | |
| 2675 | Given |
| 2676 | class Y { public: void x(); }; |
| 2677 | void z() { Y* y; y->x(); } |
| 2678 | cxxMemberCallExpr(on(hasType(asString("class Y *")))) |
| 2679 | matches y->x() |
| 2680 | </pre></td></tr> |
| 2681 | |
| 2682 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2683 | <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] | 2684 | <tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. |
| 2685 | |
| 2686 | Matches a node if it equals the node previously bound to ID. |
| 2687 | |
| 2688 | Given |
| 2689 | class X { int a; int b; }; |
| 2690 | cxxRecordDecl( |
| 2691 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 2692 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 2693 | matches the class X, as a and b have the same type. |
| 2694 | |
| 2695 | Note that when multiple matches are involved via forEach* matchers, |
| 2696 | equalsBoundNodes acts as a filter. |
| 2697 | For example: |
| 2698 | compoundStmt( |
| 2699 | forEachDescendant(varDecl().bind("d")), |
| 2700 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 2701 | will trigger a match for each combination of variable declaration |
| 2702 | and reference to that variable declaration within a compound statement. |
| 2703 | </pre></td></tr> |
| 2704 | |
| 2705 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2706 | <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] | 2707 | <tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to |
| 2708 | the node, not hidden within a typedef. |
| 2709 | |
| 2710 | Given |
| 2711 | typedef const int const_int; |
| 2712 | const_int i; |
| 2713 | int *const j; |
| 2714 | int *volatile k; |
| 2715 | int m; |
| 2716 | varDecl(hasType(hasLocalQualifiers())) matches only j and k. |
| 2717 | i is const-qualified but the qualifier is not local. |
| 2718 | </pre></td></tr> |
| 2719 | |
| 2720 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2721 | <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] | 2722 | <tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type. |
| 2723 | |
| 2724 | Given |
| 2725 | void a(char); |
| 2726 | void b(wchar_t); |
| 2727 | void c(double); |
| 2728 | functionDecl(hasAnyParameter(hasType(isAnyCharacter()))) |
| 2729 | matches "a(char)", "b(wchar_t)", but not "c(double)". |
| 2730 | </pre></td></tr> |
| 2731 | |
| 2732 | |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 2733 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isAnyPointer0')"><a name="isAnyPointer0Anchor">isAnyPointer</a></td><td></td></tr> |
| 2734 | <tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type. |
| 2735 | |
| 2736 | Given |
| 2737 | int *i = nullptr; |
| 2738 | int j; |
| 2739 | varDecl(hasType(isAnyPointer())) |
| 2740 | matches "int *i", but not "int j". |
| 2741 | </pre></td></tr> |
| 2742 | |
| 2743 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2744 | <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] | 2745 | <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that |
| 2746 | include "top-level" const. |
| 2747 | |
| 2748 | Given |
| 2749 | void a(int); |
| 2750 | void b(int const); |
| 2751 | void c(const int); |
| 2752 | void d(const int*); |
| 2753 | void e(int const) {}; |
| 2754 | functionDecl(hasAnyParameter(hasType(isConstQualified()))) |
| 2755 | matches "void b(int const)", "void c(const int)" and |
| 2756 | "void e(int const) {}". It does not match d as there |
| 2757 | is no top-level const on the parameter type "const int *". |
| 2758 | </pre></td></tr> |
| 2759 | |
| 2760 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2761 | <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] | 2762 | <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. |
| 2763 | |
| 2764 | Given |
| 2765 | void a(int); |
| 2766 | void b(long); |
| 2767 | void c(double); |
| 2768 | functionDecl(hasAnyParameter(hasType(isInteger()))) |
| 2769 | matches "a(int)", "b(long)", but not "c(double)". |
| 2770 | </pre></td></tr> |
| 2771 | |
| 2772 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2773 | <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] | 2774 | <tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that |
| 2775 | include "top-level" volatile. |
| 2776 | |
| 2777 | Given |
| 2778 | void a(int); |
| 2779 | void b(int volatile); |
| 2780 | void c(volatile int); |
| 2781 | void d(volatile int*); |
| 2782 | void e(int volatile) {}; |
| 2783 | functionDecl(hasAnyParameter(hasType(isVolatileQualified()))) |
| 2784 | matches "void b(int volatile)", "void c(volatile int)" and |
| 2785 | "void e(int volatile) {}". It does not match d as there |
| 2786 | is no top-level volatile on the parameter type "volatile int *". |
| 2787 | </pre></td></tr> |
| 2788 | |
| 2789 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2790 | <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] | 2791 | <tr><td colspan="4" class="doc" id="isClass0"><pre>Matches RecordDecl object that are spelled with "class." |
| 2792 | |
| 2793 | Example matches C, but not S or U. |
| 2794 | struct S {}; |
| 2795 | class C {}; |
| 2796 | union U {}; |
| 2797 | </pre></td></tr> |
| 2798 | |
| 2799 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2800 | <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] | 2801 | <tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches RecordDecl object that are spelled with "struct." |
| 2802 | |
| 2803 | Example matches S, but not C or U. |
| 2804 | struct S {}; |
| 2805 | class C {}; |
| 2806 | union U {}; |
| 2807 | </pre></td></tr> |
| 2808 | |
| 2809 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2810 | <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] | 2811 | <tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches RecordDecl object that are spelled with "union." |
| 2812 | |
| 2813 | Example matches U, but not C or S. |
| 2814 | struct S {}; |
| 2815 | class C {}; |
| 2816 | union U {}; |
| 2817 | </pre></td></tr> |
| 2818 | |
| 2819 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2820 | <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] | 2821 | <tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. |
| 2822 | |
| 2823 | Matches a node if it equals the node previously bound to ID. |
| 2824 | |
| 2825 | Given |
| 2826 | class X { int a; int b; }; |
| 2827 | cxxRecordDecl( |
| 2828 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 2829 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 2830 | matches the class X, as a and b have the same type. |
| 2831 | |
| 2832 | Note that when multiple matches are involved via forEach* matchers, |
| 2833 | equalsBoundNodes acts as a filter. |
| 2834 | For example: |
| 2835 | compoundStmt( |
| 2836 | forEachDescendant(varDecl().bind("d")), |
| 2837 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 2838 | will trigger a match for each combination of variable declaration |
| 2839 | and reference to that variable declaration within a compound statement. |
| 2840 | </pre></td></tr> |
| 2841 | |
| 2842 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2843 | <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] | 2844 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is |
| 2845 | partially matching a given regex. |
| 2846 | |
| 2847 | Example matches Y but not X |
| 2848 | (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 2849 | #include "ASTMatcher.h" |
| 2850 | class X {}; |
| 2851 | ASTMatcher.h: |
| 2852 | class Y {}; |
| 2853 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2854 | 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] | 2855 | </pre></td></tr> |
| 2856 | |
| 2857 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2858 | <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] | 2859 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. |
| 2860 | |
| 2861 | Example matches X but not Y |
| 2862 | (matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 2863 | #include <Y.h> |
| 2864 | class X {}; |
| 2865 | Y.h: |
| 2866 | class Y {}; |
| 2867 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2868 | 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] | 2869 | </pre></td></tr> |
| 2870 | |
| 2871 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2872 | <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] | 2873 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. |
| 2874 | |
| 2875 | Example matches Y but not X |
| 2876 | (matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 2877 | #include <SystemHeader.h> |
| 2878 | class X {}; |
| 2879 | SystemHeader.h: |
| 2880 | class Y {}; |
| 2881 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2882 | 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] | 2883 | </pre></td></tr> |
| 2884 | |
| 2885 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2886 | <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] | 2887 | <tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. |
| 2888 | |
| 2889 | Example matches A, va, fa |
| 2890 | class A {}; |
| 2891 | class B; Doesn't match, as it has no body. |
| 2892 | int va; |
| 2893 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 2894 | void fa() {} |
| 2895 | void fb(); Doesn't match, as it has no body. |
| 2896 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2897 | 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] | 2898 | </pre></td></tr> |
| 2899 | |
| 2900 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2901 | <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] | 2902 | <tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. |
| 2903 | |
| 2904 | Note that 'Value' is a string as the template argument's value is |
| 2905 | an arbitrary precision integer. 'Value' must be euqal to the canonical |
| 2906 | representation of that integral value in base 10. |
| 2907 | |
| 2908 | Given |
| 2909 | template<int T> struct A {}; |
| 2910 | C<42> c; |
| 2911 | classTemplateSpecializationDecl( |
| 2912 | hasAnyTemplateArgument(equalsIntegralValue("42"))) |
| 2913 | matches the implicit instantiation of C in C<42>. |
| 2914 | </pre></td></tr> |
| 2915 | |
| 2916 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2917 | <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] | 2918 | <tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. |
| 2919 | |
| 2920 | Given |
| 2921 | template<int T> struct A {}; |
| 2922 | C<42> c; |
| 2923 | classTemplateSpecializationDecl( |
| 2924 | hasAnyTemplateArgument(isIntegral())) |
| 2925 | matches the implicit instantiation of C in C<42> |
| 2926 | with isIntegral() matching 42. |
| 2927 | </pre></td></tr> |
| 2928 | |
| 2929 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2930 | <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] | 2931 | <tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. |
| 2932 | |
| 2933 | Given |
| 2934 | template<typename T> struct C {}; |
| 2935 | C<int> c; |
| 2936 | classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
| 2937 | matches C<int>. |
| 2938 | </pre></td></tr> |
| 2939 | |
| 2940 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2941 | <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] | 2942 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is |
| 2943 | partially matching a given regex. |
| 2944 | |
| 2945 | Example matches Y but not X |
| 2946 | (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 2947 | #include "ASTMatcher.h" |
| 2948 | class X {}; |
| 2949 | ASTMatcher.h: |
| 2950 | class Y {}; |
| 2951 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2952 | 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] | 2953 | </pre></td></tr> |
| 2954 | |
| 2955 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2956 | <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] | 2957 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. |
| 2958 | |
| 2959 | Example matches X but not Y |
| 2960 | (matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 2961 | #include <Y.h> |
| 2962 | class X {}; |
| 2963 | Y.h: |
| 2964 | class Y {}; |
| 2965 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2966 | 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] | 2967 | </pre></td></tr> |
| 2968 | |
| 2969 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2970 | <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] | 2971 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. |
| 2972 | |
| 2973 | Example matches Y but not X |
| 2974 | (matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 2975 | #include <SystemHeader.h> |
| 2976 | class X {}; |
| 2977 | SystemHeader.h: |
| 2978 | class Y {}; |
| 2979 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2980 | 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] | 2981 | </pre></td></tr> |
| 2982 | |
| 2983 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2984 | <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] | 2985 | <tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool. |
| 2986 | |
| 2987 | Given |
| 2988 | struct S { bool func(); }; |
| 2989 | functionDecl(returns(booleanType())) |
| 2990 | matches "bool func();" |
| 2991 | </pre></td></tr> |
| 2992 | |
| 2993 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2994 | <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] | 2995 | <tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. |
| 2996 | |
| 2997 | Matches a node if it equals the node previously bound to ID. |
| 2998 | |
| 2999 | Given |
| 3000 | class X { int a; int b; }; |
| 3001 | cxxRecordDecl( |
| 3002 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 3003 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 3004 | matches the class X, as a and b have the same type. |
| 3005 | |
| 3006 | Note that when multiple matches are involved via forEach* matchers, |
| 3007 | equalsBoundNodes acts as a filter. |
| 3008 | For example: |
| 3009 | compoundStmt( |
| 3010 | forEachDescendant(varDecl().bind("d")), |
| 3011 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 3012 | will trigger a match for each combination of variable declaration |
| 3013 | and reference to that variable declaration within a compound statement. |
| 3014 | </pre></td></tr> |
| 3015 | |
| 3016 | |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 3017 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('realFloatingPointType0')"><a name="realFloatingPointType0Anchor">realFloatingPointType</a></td><td></td></tr> |
| 3018 | <tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double). |
| 3019 | |
| 3020 | Given |
| 3021 | int i; |
| 3022 | float f; |
| 3023 | realFloatingPointType() |
| 3024 | matches "float f" but not "int i" |
| 3025 | </pre></td></tr> |
| 3026 | |
| 3027 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3028 | <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] | 3029 | <tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. |
| 3030 | |
| 3031 | Given |
| 3032 | struct S { void func(); }; |
| 3033 | functionDecl(returns(voidType())) |
| 3034 | matches "void func();" |
| 3035 | </pre></td></tr> |
| 3036 | |
| 3037 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3038 | <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] | 3039 | <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. |
| 3040 | |
| 3041 | Given |
| 3042 | int x; |
| 3043 | int s = sizeof(x) + alignof(x) |
| 3044 | unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) |
| 3045 | matches sizeof(x) |
| 3046 | </pre></td></tr> |
| 3047 | |
| 3048 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3049 | <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] | 3050 | <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or |
| 3051 | unary). |
| 3052 | |
| 3053 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 3054 | !(a || b) |
| 3055 | </pre></td></tr> |
| 3056 | |
| 3057 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3058 | <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] | 3059 | <tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration. |
| 3060 | |
| 3061 | Example matches x, but not y, z, or a. |
| 3062 | (matcher = varDecl(hasAutomaticStorageDuration()) |
| 3063 | void f() { |
| 3064 | int x; |
| 3065 | static int y; |
| 3066 | thread_local int z; |
| 3067 | } |
| 3068 | int a; |
| 3069 | </pre></td></tr> |
| 3070 | |
| 3071 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3072 | <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] | 3073 | <tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. |
| 3074 | |
| 3075 | Example matches y and z (matcher = varDecl(hasGlobalStorage()) |
| 3076 | void f() { |
| 3077 | int x; |
| 3078 | static int y; |
| 3079 | } |
| 3080 | int z; |
| 3081 | </pre></td></tr> |
| 3082 | |
| 3083 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3084 | <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] | 3085 | <tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a |
| 3086 | non-static local variable. |
| 3087 | |
| 3088 | Example matches x (matcher = varDecl(hasLocalStorage()) |
| 3089 | void f() { |
| 3090 | int x; |
| 3091 | static int y; |
| 3092 | } |
| 3093 | int z; |
| 3094 | </pre></td></tr> |
| 3095 | |
| 3096 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3097 | <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] | 3098 | <tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration. |
| 3099 | |
| 3100 | Example matches y and a, but not x or z. |
| 3101 | (matcher = varDecl(hasStaticStorageDuration()) |
| 3102 | void f() { |
| 3103 | int x; |
| 3104 | static int y; |
| 3105 | thread_local int z; |
| 3106 | } |
| 3107 | int a; |
| 3108 | </pre></td></tr> |
| 3109 | |
| 3110 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3111 | <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] | 3112 | <tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration. |
| 3113 | |
| 3114 | Example matches z, but not x, z, or a. |
| 3115 | (matcher = varDecl(hasThreadStorageDuration()) |
| 3116 | void f() { |
| 3117 | int x; |
| 3118 | static int y; |
| 3119 | thread_local int z; |
| 3120 | } |
| 3121 | int a; |
| 3122 | </pre></td></tr> |
| 3123 | |
| 3124 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3125 | <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] | 3126 | <tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations. |
| 3127 | |
| 3128 | Given: |
| 3129 | constexpr int foo = 42; |
| 3130 | constexpr int bar(); |
| 3131 | varDecl(isConstexpr()) |
| 3132 | matches the declaration of foo. |
| 3133 | functionDecl(isConstexpr()) |
| 3134 | matches the declaration of bar. |
| 3135 | </pre></td></tr> |
| 3136 | |
| 3137 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3138 | <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] | 3139 | <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. |
| 3140 | |
| 3141 | Example matches A, va, fa |
| 3142 | class A {}; |
| 3143 | class B; Doesn't match, as it has no body. |
| 3144 | int va; |
| 3145 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 3146 | void fa() {} |
| 3147 | void fb(); Doesn't match, as it has no body. |
| 3148 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3149 | 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] | 3150 | </pre></td></tr> |
| 3151 | |
| 3152 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3153 | <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] | 3154 | <tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from |
| 3155 | a C++ catch block, or an Objective-C statement. |
| 3156 | |
| 3157 | Example matches x (matcher = varDecl(isExceptionVariable()) |
| 3158 | void f(int y) { |
| 3159 | try { |
| 3160 | } catch (int x) { |
| 3161 | } |
| 3162 | } |
| 3163 | </pre></td></tr> |
| 3164 | |
| 3165 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3166 | <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] | 3167 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or |
| 3168 | static member variable template instantiations. |
| 3169 | |
| 3170 | Given |
| 3171 | template<typename T> void A(T t) { } |
| 3172 | template<> void A(int N) { } |
| 3173 | functionDecl(isExplicitTemplateSpecialization()) |
| 3174 | matches the specialization A<int>(). |
| 3175 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3176 | 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] | 3177 | </pre></td></tr> |
| 3178 | |
| 3179 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3180 | <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] | 3181 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static |
| 3182 | member variable template instantiations. |
| 3183 | |
| 3184 | Given |
| 3185 | template <typename T> class X {}; class A {}; X<A> x; |
| 3186 | or |
| 3187 | template <typename T> class X {}; class A {}; template class X<A>; |
| 3188 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 3189 | matches the template instantiation of X<A>. |
| 3190 | |
| 3191 | But given |
| 3192 | template <typename T> class X {}; class A {}; |
| 3193 | template <> class X<A> {}; X<A> x; |
| 3194 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 3195 | does not match, as X<A> is an explicit template specialization. |
| 3196 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3197 | 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] | 3198 | </pre></td></tr> |
| 3199 | |
| 3200 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3201 | <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] | 3202 | <tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside |
| 3203 | template instantiations. |
| 3204 | |
| 3205 | Given |
| 3206 | template<typename T> void A(T t) { T i; } |
| 3207 | A(0); |
| 3208 | A(0U); |
| 3209 | functionDecl(isInstantiated()) |
| 3210 | matches 'A(int) {...};' and 'A(unsigned) {...}'. |
| 3211 | </pre></td></tr> |
| 3212 | |
| 3213 | |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 3214 | <tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>></td><td class="name" onclick="toggle('nullPointerConstant0')"><a name="nullPointerConstant0Anchor">nullPointerConstant</a></td><td></td></tr> |
| 3215 | <tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as |
| 3216 | GNU's __null, C++11's nullptr, or C's NULL macro. |
| 3217 | |
| 3218 | Given: |
| 3219 | void *v1 = NULL; |
| 3220 | void *v2 = nullptr; |
| 3221 | void *v3 = __null; GNU extension |
| 3222 | char *cp = (char *)0; |
| 3223 | int *ip = 0; |
| 3224 | int i = 0; |
| 3225 | expr(nullPointerConstant()) |
| 3226 | matches the initializer for v1, v2, v3, cp, and ip. Does not match the |
| 3227 | initializer for i. |
| 3228 | </pre></td></tr> |
| 3229 | |
| 3230 | |
Samuel Benzaquen | 922bef4 | 2016-02-22 21:13:02 +0000 | [diff] [blame] | 3231 | <tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>>></td><td class="name" onclick="toggle('hasAnyName0')"><a name="hasAnyName0Anchor">hasAnyName</a></td><td>StringRef, ..., StringRef</td></tr> |
| 3232 | <tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names. |
| 3233 | |
| 3234 | This matcher is only provided as a performance optimization of hasName. |
| 3235 | hasAnyName(a, b, c) |
| 3236 | is equivalent but faster than |
| 3237 | anyOf(hasName(a), hasName(b), hasName(c)) |
| 3238 | </pre></td></tr> |
| 3239 | |
| 3240 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3241 | <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] | 3242 | <tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. |
| 3243 | |
| 3244 | Given |
| 3245 | int j; |
| 3246 | template<typename T> void A(T t) { T i; j += 42;} |
| 3247 | A(0); |
| 3248 | A(0U); |
| 3249 | declStmt(isInTemplateInstantiation()) |
| 3250 | matches 'int i;' and 'unsigned i'. |
| 3251 | unless(stmt(isInTemplateInstantiation())) |
| 3252 | will NOT match j += 42; as it's shared between the template definition and |
| 3253 | instantiation. |
| 3254 | </pre></td></tr> |
| 3255 | |
Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 3256 | <!--END_NARROWING_MATCHERS --> |
| 3257 | </table> |
| 3258 | |
| 3259 | <!-- ======================================================================= --> |
| 3260 | <h2 id="traversal-matchers">AST Traversal Matchers</h2> |
| 3261 | <!-- ======================================================================= --> |
| 3262 | |
| 3263 | <p>Traversal matchers specify the relationship to other nodes that are |
| 3264 | reachable from the current node.</p> |
| 3265 | |
| 3266 | <p>Note that there are special traversal matchers (has, hasDescendant, forEach and |
| 3267 | forEachDescendant) which work on all nodes and allow users to write more generic |
| 3268 | match expressions.</p> |
| 3269 | |
| 3270 | <table> |
| 3271 | <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] | 3272 | <!-- START_TRAVERSAL_MATCHERS --> |
| 3273 | |
| 3274 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 3275 | <tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. |
| 3276 | |
| 3277 | Unlike anyOf, eachOf will generate a match result for each |
| 3278 | matching submatcher. |
| 3279 | |
| 3280 | For example, in: |
| 3281 | class A { int a; int b; }; |
| 3282 | The matcher: |
| 3283 | cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), |
| 3284 | has(fieldDecl(hasName("b")).bind("v")))) |
| 3285 | will generate two results binding "v", the first of which binds |
| 3286 | the field declaration of a, the second the field declaration of |
| 3287 | b. |
| 3288 | |
| 3289 | Usable as: Any Matcher |
| 3290 | </pre></td></tr> |
| 3291 | |
| 3292 | |
| 3293 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> |
| 3294 | <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 3295 | provided matcher. |
| 3296 | |
| 3297 | Example matches X, A, B, C |
| 3298 | (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) |
| 3299 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 3300 | class A { class X {}; }; |
| 3301 | class B { class C { class X {}; }; }; |
| 3302 | |
| 3303 | DescendantT must be an AST base type. |
| 3304 | |
| 3305 | As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for |
| 3306 | each result that matches instead of only on the first one. |
| 3307 | |
| 3308 | Note: Recursively combined ForEachDescendant can cause many matches: |
| 3309 | cxxRecordDecl(forEachDescendant(cxxRecordDecl( |
| 3310 | forEachDescendant(cxxRecordDecl()) |
| 3311 | ))) |
| 3312 | will match 10 times (plus injected class name matches) on: |
| 3313 | class A { class B { class C { class D { class E {}; }; }; }; }; |
| 3314 | |
| 3315 | Usable as: Any Matcher |
| 3316 | </pre></td></tr> |
| 3317 | |
| 3318 | |
| 3319 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> |
| 3320 | <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the |
| 3321 | provided matcher. |
| 3322 | |
| 3323 | Example matches X, Y |
| 3324 | (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) |
| 3325 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 3326 | class Y { class X {}; }; |
| 3327 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 3328 | |
| 3329 | ChildT must be an AST base type. |
| 3330 | |
| 3331 | As opposed to 'has', 'forEach' will cause a match for each result that |
| 3332 | matches instead of only on the first one. |
| 3333 | |
| 3334 | Usable as: Any Matcher |
| 3335 | </pre></td></tr> |
| 3336 | |
| 3337 | |
| 3338 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> |
| 3339 | <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided |
| 3340 | matcher. |
| 3341 | |
| 3342 | Given |
| 3343 | void f() { if (true) { int x = 42; } } |
| 3344 | void g() { for (;;) { int x = 43; } } |
| 3345 | expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. |
| 3346 | |
| 3347 | Usable as: Any Matcher |
| 3348 | </pre></td></tr> |
| 3349 | |
| 3350 | |
| 3351 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> |
| 3352 | <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 3353 | provided matcher. |
| 3354 | |
| 3355 | Example matches X, Y, Z |
| 3356 | (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) |
| 3357 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 3358 | class Y { class X {}; }; |
| 3359 | class Z { class Y { class X {}; }; }; |
| 3360 | |
| 3361 | DescendantT must be an AST base type. |
| 3362 | |
| 3363 | Usable as: Any Matcher |
| 3364 | </pre></td></tr> |
| 3365 | |
| 3366 | |
| 3367 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> |
| 3368 | <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the |
| 3369 | provided matcher. |
| 3370 | |
| 3371 | Example matches X, Y |
| 3372 | (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) |
| 3373 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 3374 | class Y { class X {}; }; |
| 3375 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 3376 | |
| 3377 | ChildT must be an AST base type. |
| 3378 | |
| 3379 | Usable as: Any Matcher |
| 3380 | </pre></td></tr> |
| 3381 | |
| 3382 | |
| 3383 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> |
| 3384 | <tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided |
| 3385 | matcher. |
| 3386 | |
| 3387 | Given |
| 3388 | void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } |
| 3389 | compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". |
| 3390 | |
| 3391 | Usable as: Any Matcher |
| 3392 | </pre></td></tr> |
| 3393 | |
| 3394 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 3395 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</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> |
| 3396 | <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, |
| 3397 | or conditional operator. |
| 3398 | |
| 3399 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 3400 | if (true) {} |
| 3401 | </pre></td></tr> |
| 3402 | |
| 3403 | |
| 3404 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</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> |
| 3405 | <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator |
| 3406 | (binary or ternary). |
| 3407 | |
| 3408 | Example matches b |
| 3409 | condition ? a : b |
| 3410 | condition ?: b |
| 3411 | </pre></td></tr> |
| 3412 | |
| 3413 | |
| 3414 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</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> |
| 3415 | <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. |
| 3416 | |
| 3417 | Example 1 (conditional ternary operator): matches a |
| 3418 | condition ? a : b |
| 3419 | |
| 3420 | Example 2 (conditional binary operator): matches opaqueValueExpr(condition) |
| 3421 | condition ?: b |
| 3422 | </pre></td></tr> |
| 3423 | |
| 3424 | |
| 3425 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</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> |
| 3426 | <tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node |
| 3427 | matches the given matcher. |
| 3428 | |
| 3429 | The associated declaration is: |
| 3430 | - for type nodes, the declaration of the underlying type |
| 3431 | - for CallExpr, the declaration of the callee |
| 3432 | - for MemberExpr, the declaration of the referenced member |
| 3433 | - for CXXConstructExpr, the declaration of the constructor |
| 3434 | |
| 3435 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3436 | function. e.g. various subtypes of clang::Type and various expressions. |
| 3437 | |
| 3438 | 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>>, |
| 3439 | 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>>, |
| 3440 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 3441 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
| 3442 | 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>>, |
| 3443 | 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>> |
| 3444 | </pre></td></tr> |
| 3445 | |
| 3446 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3447 | <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] | 3448 | <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. |
| 3449 | |
| 3450 | Given |
| 3451 | int i[5]; |
| 3452 | void f() { i[1] = 42; } |
| 3453 | arraySubscriptExpression(hasBase(implicitCastExpr( |
| 3454 | hasSourceExpression(declRefExpr())))) |
| 3455 | matches i[1] with the declRefExpr() matching i |
| 3456 | </pre></td></tr> |
| 3457 | |
| 3458 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3459 | <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] | 3460 | <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. |
| 3461 | |
| 3462 | Given |
| 3463 | int i[5]; |
| 3464 | void f() { i[1] = 42; } |
| 3465 | arraySubscriptExpression(hasIndex(integerLiteral())) |
| 3466 | matches i[1] with the integerLiteral() matching 1 |
| 3467 | </pre></td></tr> |
| 3468 | |
| 3469 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3470 | <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] | 3471 | <tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions. |
| 3472 | |
| 3473 | Example matches a (matcher = binaryOperator(hasLHS())) |
| 3474 | a || b |
| 3475 | </pre></td></tr> |
| 3476 | |
| 3477 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3478 | <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] | 3479 | <tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions. |
| 3480 | |
| 3481 | Example matches b (matcher = binaryOperator(hasRHS())) |
| 3482 | a || b |
| 3483 | </pre></td></tr> |
| 3484 | |
| 3485 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3486 | <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] | 3487 | <tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element |
| 3488 | type. |
| 3489 | |
| 3490 | Given |
| 3491 | struct A {}; |
| 3492 | A a[7]; |
| 3493 | int b[7]; |
| 3494 | arrayType(hasElementType(builtinType())) |
| 3495 | matches "int b[7]" |
| 3496 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3497 | 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] | 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_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] | 3502 | <tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element |
| 3503 | type. |
| 3504 | |
| 3505 | Given |
| 3506 | struct A {}; |
| 3507 | A a[7]; |
| 3508 | int b[7]; |
| 3509 | arrayType(hasElementType(builtinType())) |
| 3510 | matches "int b[7]" |
| 3511 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3512 | 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] | 3513 | </pre></td></tr> |
| 3514 | |
| 3515 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3516 | <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] | 3517 | <tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. |
| 3518 | |
| 3519 | Given |
| 3520 | _Atomic(int) i; |
| 3521 | _Atomic(float) f; |
| 3522 | atomicType(hasValueType(isInteger())) |
| 3523 | matches "_Atomic(int) i" |
| 3524 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3525 | 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] | 3526 | </pre></td></tr> |
| 3527 | |
| 3528 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3529 | <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] | 3530 | <tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. |
| 3531 | |
| 3532 | Given |
| 3533 | _Atomic(int) i; |
| 3534 | _Atomic(float) f; |
| 3535 | atomicType(hasValueType(isInteger())) |
| 3536 | matches "_Atomic(int) i" |
| 3537 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3538 | 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] | 3539 | </pre></td></tr> |
| 3540 | |
| 3541 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3542 | <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] | 3543 | <tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. |
| 3544 | |
| 3545 | Note: There is no TypeLoc for the deduced type and thus no |
| 3546 | getDeducedLoc() matcher. |
| 3547 | |
| 3548 | Given |
| 3549 | auto a = 1; |
| 3550 | auto b = 2.0; |
| 3551 | autoType(hasDeducedType(isInteger())) |
| 3552 | matches "auto a" |
| 3553 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3554 | 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] | 3555 | </pre></td></tr> |
| 3556 | |
| 3557 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3558 | <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] | 3559 | <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a |
| 3560 | binary operator matches. |
| 3561 | </pre></td></tr> |
| 3562 | |
| 3563 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3564 | <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] | 3565 | <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. |
| 3566 | |
| 3567 | Example matches a (matcher = binaryOperator(hasLHS())) |
| 3568 | a || b |
| 3569 | </pre></td></tr> |
| 3570 | |
| 3571 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3572 | <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] | 3573 | <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. |
| 3574 | |
| 3575 | Example matches b (matcher = binaryOperator(hasRHS())) |
| 3576 | a || b |
| 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_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] | 3581 | <tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3582 | pointee matches a given matcher. |
| 3583 | |
| 3584 | Given |
| 3585 | int *a; |
| 3586 | int const *b; |
| 3587 | float const *f; |
| 3588 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3589 | matches "int const *b" |
| 3590 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3591 | 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>>, |
| 3592 | 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] | 3593 | </pre></td></tr> |
| 3594 | |
| 3595 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3596 | <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] | 3597 | <tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the |
| 3598 | pointee matches a given matcher. |
| 3599 | |
| 3600 | Given |
| 3601 | int *a; |
| 3602 | int const *b; |
| 3603 | float const *f; |
| 3604 | pointerType(pointee(isConstQualified(), isInteger())) |
| 3605 | matches "int const *b" |
| 3606 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3607 | 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>>, |
| 3608 | 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] | 3609 | </pre></td></tr> |
| 3610 | |
| 3611 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3612 | <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] | 3613 | <tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl. |
| 3614 | |
| 3615 | Given |
| 3616 | void f(int i); |
| 3617 | int y; |
| 3618 | f(y); |
| 3619 | callExpr(declRefExpr(to(varDecl(hasName("y")))), |
| 3620 | parmVarDecl(hasType(isInteger()))) |
| 3621 | matches f(y); |
| 3622 | with declRefExpr(...) |
| 3623 | matching int y |
| 3624 | and parmVarDecl(...) |
| 3625 | matching int i |
| 3626 | </pre></td></tr> |
| 3627 | |
| 3628 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3629 | <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] | 3630 | <tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call |
| 3631 | expression. |
| 3632 | |
| 3633 | Given |
| 3634 | void x(int, int, int) { int y; x(1, y, 42); } |
| 3635 | callExpr(hasAnyArgument(declRefExpr())) |
| 3636 | matches x(1, y, 42) |
| 3637 | with hasAnyArgument(...) |
| 3638 | matching y |
| 3639 | |
| 3640 | FIXME: Currently this will ignore parentheses and implicit casts on |
| 3641 | the argument before applying the inner matcher. We'll want to remove |
| 3642 | this to allow for greater control by the user once ignoreImplicit() |
| 3643 | has been implemented. |
| 3644 | </pre></td></tr> |
| 3645 | |
| 3646 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3647 | <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] | 3648 | <tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor |
| 3649 | call expression. |
| 3650 | |
| 3651 | Example matches y in x(y) |
| 3652 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 3653 | void x(int) { int y; x(y); } |
| 3654 | </pre></td></tr> |
| 3655 | |
| 3656 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 3657 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</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> |
| 3658 | <tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3659 | matches the given matcher. |
| 3660 | |
| 3661 | The associated declaration is: |
| 3662 | - for type nodes, the declaration of the underlying type |
| 3663 | - for CallExpr, the declaration of the callee |
| 3664 | - for MemberExpr, the declaration of the referenced member |
| 3665 | - for CXXConstructExpr, the declaration of the constructor |
| 3666 | |
| 3667 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3668 | function. e.g. various subtypes of clang::Type and various expressions. |
| 3669 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3670 | 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>>, |
| 3671 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 3672 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 3673 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3674 | 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>>, |
| 3675 | 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] | 3676 | </pre></td></tr> |
| 3677 | |
| 3678 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3679 | <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] | 3680 | <tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. |
| 3681 | |
| 3682 | Given |
| 3683 | class A { A() : i(42), j(42) {} int i; int j; }; |
| 3684 | cxxConstructorDecl(forEachConstructorInitializer( |
| 3685 | forField(decl().bind("x")) |
| 3686 | )) |
| 3687 | will trigger two matches, binding for 'i' and 'j' respectively. |
| 3688 | </pre></td></tr> |
| 3689 | |
| 3690 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3691 | <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] | 3692 | <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. |
| 3693 | |
| 3694 | Given |
| 3695 | struct Foo { |
| 3696 | Foo() : foo_(1) { } |
| 3697 | int foo_; |
| 3698 | }; |
| 3699 | cxxRecordDecl(has(cxxConstructorDecl( |
| 3700 | hasAnyConstructorInitializer(anything()) |
| 3701 | ))) |
| 3702 | record matches Foo, hasAnyConstructorInitializer matches foo_(1) |
| 3703 | </pre></td></tr> |
| 3704 | |
| 3705 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3706 | <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] | 3707 | <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. |
| 3708 | |
| 3709 | Given |
| 3710 | struct Foo { |
| 3711 | Foo() : foo_(1) { } |
| 3712 | int foo_; |
| 3713 | }; |
| 3714 | cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( |
| 3715 | forField(hasName("foo_")))))) |
| 3716 | matches Foo |
| 3717 | with forField matching foo_ |
| 3718 | </pre></td></tr> |
| 3719 | |
| 3720 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3721 | <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] | 3722 | <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. |
| 3723 | |
| 3724 | Given |
| 3725 | struct Foo { |
| 3726 | Foo() : foo_(1) { } |
| 3727 | int foo_; |
| 3728 | }; |
| 3729 | cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( |
| 3730 | withInitializer(integerLiteral(equals(1))))))) |
| 3731 | matches Foo |
| 3732 | with withInitializer matching (1) |
| 3733 | </pre></td></tr> |
| 3734 | |
| 3735 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3736 | <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] | 3737 | <tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 3738 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3739 | |
| 3740 | Given |
| 3741 | for (;;) {} |
| 3742 | hasBody(compoundStmt()) |
| 3743 | matches 'for (;;) {}' |
| 3744 | with compoundStmt() |
| 3745 | matching '{}' |
| 3746 | </pre></td></tr> |
| 3747 | |
| 3748 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3749 | <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] | 3750 | <tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. |
| 3751 | |
| 3752 | Example: |
| 3753 | forStmt(hasLoopVariable(anything())) |
| 3754 | matches 'int x' in |
| 3755 | for (int x : a) { } |
| 3756 | </pre></td></tr> |
| 3757 | |
| 3758 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3759 | <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] | 3760 | <tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. |
| 3761 | |
| 3762 | Example: |
| 3763 | forStmt(hasRangeInit(anything())) |
| 3764 | matches 'a' in |
| 3765 | for (int x : a) { } |
| 3766 | </pre></td></tr> |
| 3767 | |
| 3768 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3769 | <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] | 3770 | <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> |
| 3771 | |
| 3772 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3773 | <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] | 3774 | <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. |
| 3775 | |
| 3776 | Example matches y.x() |
| 3777 | (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))) |
| 3778 | class Y { public: void x(); }; |
| 3779 | void z() { Y y; y.x(); }", |
| 3780 | |
| 3781 | FIXME: Overload to allow directly matching types? |
| 3782 | </pre></td></tr> |
| 3783 | |
| 3784 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3785 | <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] | 3786 | <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. |
| 3787 | </pre></td></tr> |
| 3788 | |
| 3789 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3790 | <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] | 3791 | <tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified |
| 3792 | matcher, or is a pointer to a type that matches the InnerMatcher. |
| 3793 | </pre></td></tr> |
| 3794 | |
| 3795 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3796 | <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] | 3797 | <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration |
| 3798 | belongs to. |
| 3799 | |
| 3800 | FIXME: Generalize this for other kinds of declarations. |
| 3801 | FIXME: What other kind of declarations would we need to generalize |
| 3802 | this to? |
| 3803 | |
| 3804 | Example matches A() in the last line |
| 3805 | (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( |
| 3806 | ofClass(hasName("A")))))) |
| 3807 | class A { |
| 3808 | public: |
| 3809 | A(); |
| 3810 | }; |
| 3811 | A a = A(); |
| 3812 | </pre></td></tr> |
| 3813 | |
| 3814 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3815 | <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] | 3816 | <tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. |
| 3817 | |
| 3818 | Given: |
| 3819 | class A { void func(); }; |
| 3820 | class B { void member(); }; |
| 3821 | |
| 3822 | cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of |
| 3823 | A but not B. |
| 3824 | </pre></td></tr> |
| 3825 | |
| 3826 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3827 | <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] | 3828 | <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from |
| 3829 | a class matching Base. |
| 3830 | |
| 3831 | Note that a class is not considered to be derived from itself. |
| 3832 | |
| 3833 | Example matches Y, Z, C (Base == hasName("X")) |
| 3834 | class X; |
| 3835 | class Y : public X {}; directly derived |
| 3836 | class Z : public Y {}; indirectly derived |
| 3837 | typedef X A; |
| 3838 | typedef A B; |
| 3839 | class C : public B {}; derived from a typedef of X |
| 3840 | |
| 3841 | In the following example, Bar matches isDerivedFrom(hasName("X")): |
| 3842 | class Foo; |
| 3843 | typedef Foo X; |
| 3844 | class Bar : public Foo {}; derived from a type that X is a typedef of |
| 3845 | </pre></td></tr> |
| 3846 | |
| 3847 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3848 | <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] | 3849 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly |
| 3850 | match Base. |
| 3851 | </pre></td></tr> |
| 3852 | |
| 3853 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3854 | <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] | 3855 | <tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the |
| 3856 | given matcher. |
| 3857 | |
| 3858 | Example matches y.x() (matcher = callExpr(callee( |
| 3859 | cxxMethodDecl(hasName("x"))))) |
| 3860 | class Y { public: void x(); }; |
| 3861 | void z() { Y y; y.x(); } |
| 3862 | </pre></td></tr> |
| 3863 | |
| 3864 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3865 | <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] | 3866 | <tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. |
| 3867 | |
| 3868 | Given |
| 3869 | class Y { void x() { this->x(); x(); Y y; y.x(); } }; |
| 3870 | void f() { f(); } |
| 3871 | callExpr(callee(expr())) |
| 3872 | matches this->x(), x(), y.x(), f() |
| 3873 | with callee(...) |
| 3874 | matching this->x, x, y.x, f respectively |
| 3875 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3876 | 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] | 3877 | because this introduces ambiguous overloads with calls to Callee taking a |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3878 | 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] | 3879 | implemented in terms of implicit casts. |
| 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_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] | 3884 | <tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl. |
| 3885 | |
| 3886 | Given |
| 3887 | void f(int i); |
| 3888 | int y; |
| 3889 | f(y); |
| 3890 | callExpr(declRefExpr(to(varDecl(hasName("y")))), |
| 3891 | parmVarDecl(hasType(isInteger()))) |
| 3892 | matches f(y); |
| 3893 | with declRefExpr(...) |
| 3894 | matching int y |
| 3895 | and parmVarDecl(...) |
| 3896 | matching int i |
| 3897 | </pre></td></tr> |
| 3898 | |
| 3899 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3900 | <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] | 3901 | <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call |
| 3902 | expression. |
| 3903 | |
| 3904 | Given |
| 3905 | void x(int, int, int) { int y; x(1, y, 42); } |
| 3906 | callExpr(hasAnyArgument(declRefExpr())) |
| 3907 | matches x(1, y, 42) |
| 3908 | with hasAnyArgument(...) |
| 3909 | matching y |
| 3910 | |
| 3911 | FIXME: Currently this will ignore parentheses and implicit casts on |
| 3912 | the argument before applying the inner matcher. We'll want to remove |
| 3913 | this to allow for greater control by the user once ignoreImplicit() |
| 3914 | has been implemented. |
| 3915 | </pre></td></tr> |
| 3916 | |
| 3917 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3918 | <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] | 3919 | <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor |
| 3920 | call expression. |
| 3921 | |
| 3922 | Example matches y in x(y) |
| 3923 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 3924 | void x(int) { int y; x(y); } |
| 3925 | </pre></td></tr> |
| 3926 | |
| 3927 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 3928 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasDeclaration14')"><a name="hasDeclaration14Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 3929 | <tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3930 | matches the given matcher. |
| 3931 | |
| 3932 | The associated declaration is: |
| 3933 | - for type nodes, the declaration of the underlying type |
| 3934 | - for CallExpr, the declaration of the callee |
| 3935 | - for MemberExpr, the declaration of the referenced member |
| 3936 | - for CXXConstructExpr, the declaration of the constructor |
| 3937 | |
| 3938 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 3939 | function. e.g. various subtypes of clang::Type and various expressions. |
| 3940 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3941 | 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>>, |
| 3942 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 3943 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 3944 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3945 | 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>>, |
| 3946 | 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] | 3947 | </pre></td></tr> |
| 3948 | |
| 3949 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3950 | <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] | 3951 | <tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range |
| 3952 | extension, matches the constant given in the statement. |
| 3953 | |
| 3954 | Given |
| 3955 | switch (1) { case 1: case 1+1: case 3 ... 4: ; } |
| 3956 | caseStmt(hasCaseConstant(integerLiteral())) |
| 3957 | matches "case 1:" |
| 3958 | </pre></td></tr> |
| 3959 | |
| 3960 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3961 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 3962 | <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre></pre></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3963 | |
| 3964 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3965 | <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] | 3966 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one |
| 3967 | TemplateArgument matching the given InnerMatcher. |
| 3968 | |
| 3969 | Given |
| 3970 | template<typename T> class A {}; |
| 3971 | template<> class A<double> {}; |
| 3972 | A<int> a; |
| 3973 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 3974 | refersToType(asString("int")))) |
| 3975 | matches the specialization A<int> |
| 3976 | </pre></td></tr> |
| 3977 | |
| 3978 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3979 | <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] | 3980 | <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument |
| 3981 | matches the given InnerMatcher. |
| 3982 | |
| 3983 | Given |
| 3984 | template<typename T, typename U> class A {}; |
| 3985 | A<bool, int> b; |
| 3986 | A<int, bool> c; |
| 3987 | classTemplateSpecializationDecl(hasTemplateArgument( |
| 3988 | 1, refersToType(asString("int")))) |
| 3989 | matches the specialization A<bool, int> |
| 3990 | </pre></td></tr> |
| 3991 | |
| 3992 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3993 | <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] | 3994 | <tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element |
| 3995 | type. |
| 3996 | |
| 3997 | Given |
| 3998 | struct A {}; |
| 3999 | A a[7]; |
| 4000 | int b[7]; |
| 4001 | arrayType(hasElementType(builtinType())) |
| 4002 | matches "int b[7]" |
| 4003 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4004 | 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] | 4005 | </pre></td></tr> |
| 4006 | |
| 4007 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4008 | <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] | 4009 | <tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element |
| 4010 | type. |
| 4011 | |
| 4012 | Given |
| 4013 | struct A {}; |
| 4014 | A a[7]; |
| 4015 | int b[7]; |
| 4016 | arrayType(hasElementType(builtinType())) |
| 4017 | matches "int b[7]" |
| 4018 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4019 | 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] | 4020 | </pre></td></tr> |
| 4021 | |
| 4022 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4023 | <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] | 4024 | <tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4025 | a given matcher. Also matches StmtExprs that have CompoundStmt as children. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4026 | |
| 4027 | Given |
| 4028 | { {}; 1+2; } |
| 4029 | hasAnySubstatement(compoundStmt()) |
| 4030 | matches '{ {}; 1+2; }' |
| 4031 | with compoundStmt() |
| 4032 | matching '{}' |
| 4033 | </pre></td></tr> |
| 4034 | |
| 4035 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4036 | <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] | 4037 | <tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whos decayed type matches InnerMatcher |
| 4038 | </pre></td></tr> |
| 4039 | |
| 4040 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4041 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</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> |
| 4042 | <tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4043 | matches the given matcher. |
| 4044 | |
| 4045 | The associated declaration is: |
| 4046 | - for type nodes, the declaration of the underlying type |
| 4047 | - for CallExpr, the declaration of the callee |
| 4048 | - for MemberExpr, the declaration of the referenced member |
| 4049 | - for CXXConstructExpr, the declaration of the constructor |
| 4050 | |
| 4051 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4052 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4053 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4054 | 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>>, |
| 4055 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4056 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 4057 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4058 | 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>>, |
| 4059 | 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] | 4060 | </pre></td></tr> |
| 4061 | |
| 4062 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4063 | <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] | 4064 | <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a |
| 4065 | specific using shadow declaration. |
| 4066 | |
| 4067 | Given |
| 4068 | namespace a { void f() {} } |
| 4069 | using a::f; |
| 4070 | void g() { |
| 4071 | f(); Matches this .. |
| 4072 | a::f(); .. but not this. |
| 4073 | } |
| 4074 | declRefExpr(throughUsingDecl(anything())) |
| 4075 | matches f() |
| 4076 | </pre></td></tr> |
| 4077 | |
| 4078 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4079 | <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] | 4080 | <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the |
| 4081 | specified matcher. |
| 4082 | |
| 4083 | Example matches x in if(x) |
| 4084 | (matcher = declRefExpr(to(varDecl(hasName("x"))))) |
| 4085 | bool x; |
| 4086 | if (x) {} |
| 4087 | </pre></td></tr> |
| 4088 | |
| 4089 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4090 | <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] | 4091 | <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. |
| 4092 | |
| 4093 | Note that this does not work for global declarations because the AST |
| 4094 | breaks up multiple-declaration DeclStmt's into multiple single-declaration |
| 4095 | DeclStmt's. |
| 4096 | Example: Given non-global declarations |
| 4097 | int a, b = 0; |
| 4098 | int c; |
| 4099 | int d = 2, e; |
| 4100 | declStmt(containsDeclaration( |
| 4101 | 0, varDecl(hasInitializer(anything())))) |
| 4102 | matches only 'int d = 2, e;', and |
| 4103 | declStmt(containsDeclaration(1, varDecl())) |
| 4104 | matches 'int a, b = 0' as well as 'int d = 2, e;' |
| 4105 | but 'int c;' is not matched. |
| 4106 | </pre></td></tr> |
| 4107 | |
| 4108 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4109 | <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] | 4110 | <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. |
| 4111 | |
| 4112 | Given |
| 4113 | int a, b; |
| 4114 | int c; |
| 4115 | declStmt(hasSingleDecl(anything())) |
| 4116 | matches 'int c;' but not 'int a, b;'. |
| 4117 | </pre></td></tr> |
| 4118 | |
| 4119 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4120 | <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] | 4121 | <tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches |
| 4122 | the inner matcher. |
| 4123 | |
| 4124 | Given |
| 4125 | int x; |
| 4126 | declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 4127 | matches int x |
| 4128 | </pre></td></tr> |
| 4129 | |
| 4130 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4131 | <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] | 4132 | <tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a |
| 4133 | Decl, matches InnerMatcher. |
| 4134 | |
| 4135 | Given |
| 4136 | namespace N { |
| 4137 | namespace M { |
| 4138 | class D {}; |
| 4139 | } |
| 4140 | } |
| 4141 | |
| 4142 | cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the |
| 4143 | declaration of class D. |
| 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_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] | 4148 | <tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 4149 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 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_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] | 4161 | <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, |
| 4162 | or conditional operator. |
| 4163 | |
| 4164 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 4165 | if (true) {} |
| 4166 | </pre></td></tr> |
| 4167 | |
| 4168 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4169 | <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] | 4170 | <tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, |
| 4171 | matches InnerMatcher if the qualifier exists. |
| 4172 | |
| 4173 | Given |
| 4174 | namespace N { |
| 4175 | namespace M { |
| 4176 | class D {}; |
| 4177 | } |
| 4178 | } |
| 4179 | N::M::D d; |
| 4180 | |
| 4181 | elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) |
| 4182 | matches the type of the variable declaration of d. |
| 4183 | </pre></td></tr> |
| 4184 | |
| 4185 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4186 | <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] | 4187 | <tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. |
| 4188 | |
| 4189 | Given |
| 4190 | namespace N { |
| 4191 | namespace M { |
| 4192 | class D {}; |
| 4193 | } |
| 4194 | } |
| 4195 | N::M::D d; |
| 4196 | |
| 4197 | elaboratedType(namesType(recordType( |
| 4198 | hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable |
| 4199 | declaration of d. |
| 4200 | </pre></td></tr> |
| 4201 | |
| 4202 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4203 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</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> |
| 4204 | <tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4205 | matches the given matcher. |
| 4206 | |
| 4207 | The associated declaration is: |
| 4208 | - for type nodes, the declaration of the underlying type |
| 4209 | - for CallExpr, the declaration of the callee |
| 4210 | - for MemberExpr, the declaration of the referenced member |
| 4211 | - for CXXConstructExpr, the declaration of the constructor |
| 4212 | |
| 4213 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4214 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4215 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4216 | 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>>, |
| 4217 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4218 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 4219 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4220 | 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>>, |
| 4221 | 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] | 4222 | </pre></td></tr> |
| 4223 | |
| 4224 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4225 | <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] | 4226 | <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. |
| 4227 | |
| 4228 | (Note: Clang's AST refers to other conversions as "casts" too, and calls |
| 4229 | actual casts "explicit" casts.) |
| 4230 | </pre></td></tr> |
| 4231 | |
| 4232 | |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 4233 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('hasType3')"><a name="hasType3Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 4234 | <tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4235 | declaration's type. |
| 4236 | |
| 4237 | In case of a value declaration (for example a variable declaration), |
| 4238 | this resolves one layer of indirection. For example, in the value |
| 4239 | declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 4240 | X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 4241 | declaration of x. |
| 4242 | |
| 4243 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 4244 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 4245 | class X {}; |
| 4246 | void y(X &x) { x; X z; } |
| 4247 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4248 | 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] | 4249 | </pre></td></tr> |
| 4250 | |
| 4251 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4252 | <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] | 4253 | <tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type |
| 4254 | matcher. |
| 4255 | |
| 4256 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 4257 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 4258 | and U (matcher = typedefDecl(hasType(asString("int"))) |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4259 | class X {}; |
| 4260 | void y(X &x) { x; X z; } |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 4261 | typedef int U; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4262 | </pre></td></tr> |
| 4263 | |
| 4264 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4265 | <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] | 4266 | <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts |
| 4267 | are stripped off. |
| 4268 | |
| 4269 | Parentheses and explicit casts are not discarded. |
| 4270 | Given |
| 4271 | int arr[5]; |
| 4272 | int a = 0; |
| 4273 | char b = 0; |
| 4274 | const int c = a; |
| 4275 | int *d = arr; |
| 4276 | long e = (long) 0l; |
| 4277 | The matchers |
| 4278 | varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) |
| 4279 | varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) |
| 4280 | would match the declarations for a, b, c, and d, but not e. |
| 4281 | While |
| 4282 | varDecl(hasInitializer(integerLiteral())) |
| 4283 | varDecl(hasInitializer(declRefExpr())) |
| 4284 | only match the declarations for b, c, and d. |
| 4285 | </pre></td></tr> |
| 4286 | |
| 4287 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4288 | <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] | 4289 | <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and |
| 4290 | casts are stripped off. |
| 4291 | |
| 4292 | Implicit and non-C Style casts are also discarded. |
| 4293 | Given |
| 4294 | int a = 0; |
| 4295 | char b = (0); |
| 4296 | void* c = reinterpret_cast<char*>(0); |
| 4297 | char d = char(0); |
| 4298 | The matcher |
| 4299 | varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) |
| 4300 | would match the declarations for a, b, c, and d. |
| 4301 | while |
| 4302 | varDecl(hasInitializer(integerLiteral())) |
| 4303 | only match the declaration for a. |
| 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_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] | 4308 | <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and |
| 4309 | parentheses are stripped off. |
| 4310 | |
| 4311 | Explicit casts are not discarded. |
| 4312 | Given |
| 4313 | int arr[5]; |
| 4314 | int a = 0; |
| 4315 | char b = (0); |
| 4316 | const int c = a; |
| 4317 | int *d = (arr); |
| 4318 | long e = ((long) 0l); |
| 4319 | The matchers |
| 4320 | varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) |
| 4321 | varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) |
| 4322 | would match the declarations for a, b, c, and d, but not e. |
| 4323 | while |
| 4324 | varDecl(hasInitializer(integerLiteral())) |
| 4325 | varDecl(hasInitializer(declRefExpr())) |
| 4326 | would only match the declaration for a. |
| 4327 | </pre></td></tr> |
| 4328 | |
| 4329 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4330 | <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] | 4331 | <tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 4332 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4333 | |
| 4334 | Given |
| 4335 | for (;;) {} |
| 4336 | hasBody(compoundStmt()) |
| 4337 | matches 'for (;;) {}' |
| 4338 | with compoundStmt() |
| 4339 | matching '{}' |
| 4340 | </pre></td></tr> |
| 4341 | |
| 4342 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4343 | <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] | 4344 | <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, |
| 4345 | or conditional operator. |
| 4346 | |
| 4347 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 4348 | if (true) {} |
| 4349 | </pre></td></tr> |
| 4350 | |
| 4351 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4352 | <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] | 4353 | <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. |
| 4354 | |
| 4355 | Example: |
| 4356 | forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) |
| 4357 | matches '++x' in |
| 4358 | for (x; x < N; ++x) { } |
| 4359 | </pre></td></tr> |
| 4360 | |
| 4361 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4362 | <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] | 4363 | <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. |
| 4364 | |
| 4365 | Example: |
| 4366 | forStmt(hasLoopInit(declStmt())) |
| 4367 | matches 'int x = 0' in |
| 4368 | for (int x = 0; x < N; ++x) { } |
| 4369 | </pre></td></tr> |
| 4370 | |
| 4371 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4372 | <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] | 4373 | <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. |
| 4374 | |
| 4375 | Does not match the 'this' parameter of a method. |
| 4376 | |
| 4377 | Given |
| 4378 | class X { void f(int x, int y, int z) {} }; |
| 4379 | cxxMethodDecl(hasAnyParameter(hasName("y"))) |
| 4380 | matches f(int x, int y, int z) {} |
| 4381 | with hasAnyParameter(...) |
| 4382 | matching int y |
| 4383 | </pre></td></tr> |
| 4384 | |
| 4385 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4386 | <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] | 4387 | <tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 4388 | definition that has a given body. |
| 4389 | |
| 4390 | Given |
| 4391 | for (;;) {} |
| 4392 | hasBody(compoundStmt()) |
| 4393 | matches 'for (;;) {}' |
| 4394 | with compoundStmt() |
| 4395 | matching '{}' |
| 4396 | </pre></td></tr> |
| 4397 | |
| 4398 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4399 | <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] | 4400 | <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. |
| 4401 | |
| 4402 | Given |
| 4403 | class X { void f(int x) {} }; |
| 4404 | cxxMethodDecl(hasParameter(0, hasType(varDecl()))) |
| 4405 | matches f(int x) {} |
| 4406 | with hasParameter(...) |
| 4407 | matching int x |
| 4408 | </pre></td></tr> |
| 4409 | |
| 4410 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4411 | <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] | 4412 | <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. |
| 4413 | |
| 4414 | Given: |
| 4415 | class X { int f() { return 1; } }; |
| 4416 | cxxMethodDecl(returns(asString("int"))) |
| 4417 | matches int f() { return 1; } |
| 4418 | </pre></td></tr> |
| 4419 | |
| 4420 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4421 | <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] | 4422 | <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, |
| 4423 | or conditional operator. |
| 4424 | |
| 4425 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 4426 | if (true) {} |
| 4427 | </pre></td></tr> |
| 4428 | |
| 4429 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4430 | <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] | 4431 | <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. |
| 4432 | |
| 4433 | Given |
| 4434 | if (A* a = GetAPointer()) {} |
| 4435 | hasConditionVariableStatement(...) |
| 4436 | matches 'A* a = GetAPointer()'. |
| 4437 | </pre></td></tr> |
| 4438 | |
| 4439 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4440 | <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] | 4441 | <tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. |
| 4442 | |
| 4443 | Examples matches the if statement |
| 4444 | (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) |
| 4445 | if (false) false; else true; |
| 4446 | </pre></td></tr> |
| 4447 | |
| 4448 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4449 | <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] | 4450 | <tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. |
| 4451 | |
| 4452 | Examples matches the if statement |
| 4453 | (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) |
| 4454 | if (false) true; else false; |
| 4455 | </pre></td></tr> |
| 4456 | |
| 4457 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4458 | <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] | 4459 | <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given |
| 4460 | matcher. |
| 4461 | |
| 4462 | FIXME: Unit test this matcher |
| 4463 | </pre></td></tr> |
| 4464 | |
| 4465 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4466 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>></td><td class="name" onclick="toggle('hasSyntacticForm0')"><a name="hasSyntacticForm0Anchor">hasSyntacticForm</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 4467 | <tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions |
| 4468 | (if expression have it). |
| 4469 | </pre></td></tr> |
| 4470 | |
| 4471 | |
| 4472 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</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> |
| 4473 | <tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node |
| 4474 | matches the given matcher. |
| 4475 | |
| 4476 | The associated declaration is: |
| 4477 | - for type nodes, the declaration of the underlying type |
| 4478 | - for CallExpr, the declaration of the callee |
| 4479 | - for MemberExpr, the declaration of the referenced member |
| 4480 | - for CXXConstructExpr, the declaration of the constructor |
| 4481 | |
| 4482 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4483 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4484 | |
| 4485 | 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>>, |
| 4486 | 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>>, |
| 4487 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 4488 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
| 4489 | 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>>, |
| 4490 | 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>> |
| 4491 | </pre></td></tr> |
| 4492 | |
| 4493 | |
| 4494 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</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] | 4495 | <tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node |
| 4496 | matches the given matcher. |
| 4497 | |
| 4498 | The associated declaration is: |
| 4499 | - for type nodes, the declaration of the underlying type |
| 4500 | - for CallExpr, the declaration of the callee |
| 4501 | - for MemberExpr, the declaration of the referenced member |
| 4502 | - for CXXConstructExpr, the declaration of the constructor |
| 4503 | |
| 4504 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4505 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4506 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4507 | 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>>, |
| 4508 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4509 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 4510 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4511 | 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>>, |
| 4512 | 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] | 4513 | </pre></td></tr> |
| 4514 | |
| 4515 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4516 | <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] | 4517 | <tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node |
| 4518 | matches the given matcher. |
| 4519 | |
| 4520 | The associated declaration is: |
| 4521 | - for type nodes, the declaration of the underlying type |
| 4522 | - for CallExpr, the declaration of the callee |
| 4523 | - for MemberExpr, the declaration of the referenced member |
| 4524 | - for CXXConstructExpr, the declaration of the constructor |
| 4525 | |
| 4526 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4527 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4528 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4529 | 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>>, |
| 4530 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4531 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 4532 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4533 | 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>>, |
| 4534 | 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] | 4535 | </pre></td></tr> |
| 4536 | |
| 4537 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4538 | <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] | 4539 | <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is |
| 4540 | matched by a given matcher. |
| 4541 | |
| 4542 | Given |
| 4543 | struct X { int m; }; |
| 4544 | void f(X x) { x.m; m; } |
| 4545 | memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))))) |
| 4546 | matches "x.m" and "m" |
| 4547 | with hasObjectExpression(...) |
| 4548 | matching "x" and the implicit object expression of "m" which has type X*. |
| 4549 | </pre></td></tr> |
| 4550 | |
| 4551 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4552 | <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] | 4553 | <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a |
| 4554 | given matcher. |
| 4555 | |
| 4556 | Given |
| 4557 | struct { int first, second; } first, second; |
| 4558 | int i(second.first); |
| 4559 | int j(first.second); |
| 4560 | memberExpr(member(hasName("first"))) |
| 4561 | matches second.first |
| 4562 | but not first.second (because the member name there is "second"). |
| 4563 | </pre></td></tr> |
| 4564 | |
| 4565 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4566 | <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] | 4567 | <tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4568 | pointee matches a given matcher. |
| 4569 | |
| 4570 | Given |
| 4571 | int *a; |
| 4572 | int const *b; |
| 4573 | float const *f; |
| 4574 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4575 | matches "int const *b" |
| 4576 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4577 | 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>>, |
| 4578 | 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] | 4579 | </pre></td></tr> |
| 4580 | |
| 4581 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4582 | <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] | 4583 | <tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4584 | pointee matches a given matcher. |
| 4585 | |
| 4586 | Given |
| 4587 | int *a; |
| 4588 | int const *b; |
| 4589 | float const *f; |
| 4590 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4591 | matches "int const *b" |
| 4592 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4593 | 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>>, |
| 4594 | 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] | 4595 | </pre></td></tr> |
| 4596 | |
| 4597 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4598 | <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] | 4599 | <tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. |
| 4600 | |
| 4601 | Given |
| 4602 | struct A { struct B { struct C {}; }; }; |
| 4603 | A::B::C c; |
| 4604 | nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) |
| 4605 | matches "A::" |
| 4606 | </pre></td></tr> |
| 4607 | |
| 4608 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4609 | <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] | 4610 | <tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the |
| 4611 | given TypeLoc. |
| 4612 | |
| 4613 | Given |
| 4614 | struct A { struct B { struct C {}; }; }; |
| 4615 | A::B::C c; |
| 4616 | nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( |
| 4617 | hasDeclaration(cxxRecordDecl(hasName("A"))))))) |
| 4618 | matches "A::" |
| 4619 | </pre></td></tr> |
| 4620 | |
| 4621 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4622 | <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] | 4623 | <tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. |
| 4624 | |
| 4625 | Given |
| 4626 | struct A { struct B { struct C {}; }; }; |
| 4627 | A::B::C c; |
| 4628 | nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and |
| 4629 | matches "A::" |
| 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_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] | 4634 | <tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the |
| 4635 | given namespace matcher. |
| 4636 | |
| 4637 | Given |
| 4638 | namespace ns { struct A {}; } |
| 4639 | ns::A a; |
| 4640 | nestedNameSpecifier(specifiesNamespace(hasName("ns"))) |
| 4641 | matches "ns::" |
| 4642 | </pre></td></tr> |
| 4643 | |
| 4644 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4645 | <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] | 4646 | <tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the |
| 4647 | given QualType matcher without qualifiers. |
| 4648 | |
| 4649 | Given |
| 4650 | struct A { struct B { struct C {}; }; }; |
| 4651 | A::B::C c; |
| 4652 | nestedNameSpecifier(specifiesType( |
| 4653 | hasDeclaration(cxxRecordDecl(hasName("A"))) |
| 4654 | )) |
| 4655 | matches "A::" |
| 4656 | </pre></td></tr> |
| 4657 | |
| 4658 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4659 | <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] | 4660 | <tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor |
| 4661 | call expression. |
| 4662 | |
| 4663 | Example matches y in x(y) |
| 4664 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 4665 | void x(int) { int y; x(y); } |
| 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_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] | 4670 | <tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. |
| 4671 | |
| 4672 | Example |
| 4673 | matcher = objCMessageExpr(hasRecieverType(asString("UIWebView *"))); |
| 4674 | matches the [webView ...] message invocation. |
| 4675 | NSString *webViewJavaScript = ... |
| 4676 | UIWebView *webView = ... |
| 4677 | [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; |
| 4678 | </pre></td></tr> |
| 4679 | |
| 4680 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4681 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html">OpaqueValueExpr</a>></td><td class="name" onclick="toggle('hasSourceExpression1')"><a name="hasSourceExpression1Anchor">hasSourceExpression</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 4682 | <tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre></pre></td></tr> |
| 4683 | |
| 4684 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4685 | <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] | 4686 | <tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. |
| 4687 | |
| 4688 | Given |
| 4689 | int (*ptr_to_array)[4]; |
| 4690 | int (*ptr_to_func)(int); |
| 4691 | |
| 4692 | varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches |
| 4693 | ptr_to_func but not ptr_to_array. |
| 4694 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4695 | 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] | 4696 | </pre></td></tr> |
| 4697 | |
| 4698 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4699 | <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] | 4700 | <tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4701 | pointee matches a given matcher. |
| 4702 | |
| 4703 | Given |
| 4704 | int *a; |
| 4705 | int const *b; |
| 4706 | float const *f; |
| 4707 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4708 | matches "int const *b" |
| 4709 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4710 | 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>>, |
| 4711 | 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] | 4712 | </pre></td></tr> |
| 4713 | |
| 4714 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4715 | <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] | 4716 | <tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4717 | pointee matches a given matcher. |
| 4718 | |
| 4719 | Given |
| 4720 | int *a; |
| 4721 | int const *b; |
| 4722 | float const *f; |
| 4723 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4724 | matches "int const *b" |
| 4725 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4726 | 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>>, |
| 4727 | 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] | 4728 | </pre></td></tr> |
| 4729 | |
| 4730 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4731 | <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] | 4732 | <tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. |
| 4733 | |
| 4734 | Given: |
| 4735 | typedef int &int_ref; |
| 4736 | int a; |
| 4737 | int_ref b = a; |
| 4738 | |
| 4739 | varDecl(hasType(qualType(referenceType()))))) will not match the |
| 4740 | declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. |
| 4741 | </pre></td></tr> |
| 4742 | |
| 4743 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4744 | <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] | 4745 | <tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node |
| 4746 | matches the given matcher. |
| 4747 | |
| 4748 | The associated declaration is: |
| 4749 | - for type nodes, the declaration of the underlying type |
| 4750 | - for CallExpr, the declaration of the callee |
| 4751 | - for MemberExpr, the declaration of the referenced member |
| 4752 | - for CXXConstructExpr, the declaration of the constructor |
| 4753 | |
| 4754 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4755 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4756 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4757 | 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>>, |
| 4758 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4759 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 4760 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4761 | 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>>, |
| 4762 | 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] | 4763 | </pre></td></tr> |
| 4764 | |
| 4765 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4766 | <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] | 4767 | <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. |
| 4768 | </pre></td></tr> |
| 4769 | |
| 4770 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4771 | <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] | 4772 | <tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type |
| 4773 | matches the specified matcher. |
| 4774 | |
| 4775 | Example matches y->x() |
| 4776 | (matcher = cxxMemberCallExpr(on(hasType(pointsTo |
| 4777 | cxxRecordDecl(hasName("Y"))))))) |
| 4778 | class Y { public: void x(); }; |
| 4779 | void z() { Y *y; y->x(); } |
| 4780 | </pre></td></tr> |
| 4781 | |
| 4782 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4783 | <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] | 4784 | <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. |
| 4785 | </pre></td></tr> |
| 4786 | |
| 4787 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4788 | <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] | 4789 | <tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced |
| 4790 | type matches the specified matcher. |
| 4791 | |
| 4792 | Example matches X &x and const X &y |
| 4793 | (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) |
| 4794 | class X { |
| 4795 | void a(X b) { |
| 4796 | X &x = b; |
| 4797 | const X &y = b; |
| 4798 | } |
| 4799 | }; |
| 4800 | </pre></td></tr> |
| 4801 | |
| 4802 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4803 | <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] | 4804 | <tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node |
| 4805 | matches the given matcher. |
| 4806 | |
| 4807 | The associated declaration is: |
| 4808 | - for type nodes, the declaration of the underlying type |
| 4809 | - for CallExpr, the declaration of the callee |
| 4810 | - for MemberExpr, the declaration of the referenced member |
| 4811 | - for CXXConstructExpr, the declaration of the constructor |
| 4812 | |
| 4813 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4814 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4815 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4816 | 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>>, |
| 4817 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4818 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 4819 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4820 | 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>>, |
| 4821 | 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] | 4822 | </pre></td></tr> |
| 4823 | |
| 4824 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4825 | <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] | 4826 | <tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4827 | pointee matches a given matcher. |
| 4828 | |
| 4829 | Given |
| 4830 | int *a; |
| 4831 | int const *b; |
| 4832 | float const *f; |
| 4833 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4834 | matches "int const *b" |
| 4835 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4836 | 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>>, |
| 4837 | 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] | 4838 | </pre></td></tr> |
| 4839 | |
| 4840 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4841 | <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] | 4842 | <tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4843 | pointee matches a given matcher. |
| 4844 | |
| 4845 | Given |
| 4846 | int *a; |
| 4847 | int const *b; |
| 4848 | float const *f; |
| 4849 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4850 | matches "int const *b" |
| 4851 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4852 | 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>>, |
| 4853 | 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] | 4854 | </pre></td></tr> |
| 4855 | |
| 4856 | |
Alexander Kornienko | 976921d | 2016-03-22 11:03:03 +0000 | [diff] [blame^] | 4857 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>></td><td class="name" onclick="toggle('hasReturnValue0')"><a name="hasReturnValue0Anchor">hasReturnValue</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 4858 | <tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement |
| 4859 | |
| 4860 | Given |
| 4861 | return a + b; |
| 4862 | hasReturnValue(binaryOperator()) |
| 4863 | matches 'return a + b' |
| 4864 | with binaryOperator() |
| 4865 | matching 'a + b' |
| 4866 | </pre></td></tr> |
| 4867 | |
| 4868 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4869 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StmtExpr.html">StmtExpr</a>></td><td class="name" onclick="toggle('hasAnySubstatement1')"><a name="hasAnySubstatement1Anchor">hasAnySubstatement</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> |
| 4870 | <tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches |
| 4871 | a given matcher. Also matches StmtExprs that have CompoundStmt as children. |
| 4872 | |
| 4873 | Given |
| 4874 | { {}; 1+2; } |
| 4875 | hasAnySubstatement(compoundStmt()) |
| 4876 | matches '{ {}; 1+2; }' |
| 4877 | with compoundStmt() |
| 4878 | matching '{}' |
| 4879 | </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_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] | 4883 | <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 4884 | alignof. |
| 4885 | </pre></td></tr> |
| 4886 | |
| 4887 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4888 | <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] | 4889 | <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 4890 | sizeof. |
| 4891 | </pre></td></tr> |
| 4892 | |
| 4893 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4894 | <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] | 4895 | <tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch |
| 4896 | statement. This matcher may produce multiple matches. |
| 4897 | |
| 4898 | Given |
| 4899 | switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } |
| 4900 | switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") |
| 4901 | matches four times, with "c" binding each of "case 1:", "case 2:", |
| 4902 | "case 3:" and "case 4:", and "s" respectively binding "switch (1)", |
| 4903 | "switch (1)", "switch (2)" and "switch (2)". |
| 4904 | </pre></td></tr> |
| 4905 | |
| 4906 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4907 | <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] | 4908 | <tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node |
| 4909 | matches the given matcher. |
| 4910 | |
| 4911 | The associated declaration is: |
| 4912 | - for type nodes, the declaration of the underlying type |
| 4913 | - for CallExpr, the declaration of the callee |
| 4914 | - for MemberExpr, the declaration of the referenced member |
| 4915 | - for CXXConstructExpr, the declaration of the constructor |
| 4916 | |
| 4917 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 4918 | function. e.g. various subtypes of clang::Type and various expressions. |
| 4919 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4920 | 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>>, |
| 4921 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4922 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 4923 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4924 | 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>>, |
| 4925 | 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] | 4926 | </pre></td></tr> |
| 4927 | |
| 4928 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4929 | <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] | 4930 | <tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. |
| 4931 | |
| 4932 | Given |
| 4933 | template<typename T> struct A {}; |
| 4934 | struct B { B* next; }; |
| 4935 | A<&B::next> a; |
| 4936 | templateSpecializationType(hasAnyTemplateArgument( |
| 4937 | isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) |
| 4938 | matches the specialization A<&B::next> with fieldDecl(...) matching |
| 4939 | B::next |
| 4940 | </pre></td></tr> |
| 4941 | |
| 4942 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4943 | <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] | 4944 | <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain |
| 4945 | declaration. |
| 4946 | |
| 4947 | Given |
| 4948 | template<typename T> struct A {}; |
| 4949 | struct B { B* next; }; |
| 4950 | A<&B::next> a; |
| 4951 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 4952 | refersToDeclaration(fieldDecl(hasName("next")))) |
| 4953 | matches the specialization A<&B::next> with fieldDecl(...) matching |
| 4954 | B::next |
| 4955 | </pre></td></tr> |
| 4956 | |
| 4957 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4958 | <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] | 4959 | <tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type. |
| 4960 | |
| 4961 | Given |
| 4962 | template<int T> struct A {}; |
| 4963 | C<42> c; |
| 4964 | classTemplateSpecializationDecl( |
| 4965 | hasAnyTemplateArgument(refersToIntegralType(asString("int")))) |
| 4966 | matches the implicit instantiation of C in C<42>. |
| 4967 | </pre></td></tr> |
| 4968 | |
| 4969 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4970 | <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] | 4971 | <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. |
| 4972 | |
| 4973 | Given |
| 4974 | struct X {}; |
| 4975 | template<typename T> struct A {}; |
| 4976 | A<X> a; |
| 4977 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 4978 | refersToType(class(hasName("X"))))) |
| 4979 | matches the specialization A<X> |
| 4980 | </pre></td></tr> |
| 4981 | |
| 4982 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4983 | <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] | 4984 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations that have at least one |
| 4985 | TemplateArgument matching the given InnerMatcher. |
| 4986 | |
| 4987 | Given |
| 4988 | template<typename T> class A {}; |
| 4989 | template<> class A<double> {}; |
| 4990 | A<int> a; |
| 4991 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 4992 | refersToType(asString("int")))) |
| 4993 | matches the specialization A<int> |
| 4994 | </pre></td></tr> |
| 4995 | |
| 4996 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4997 | <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] | 4998 | <tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node |
| 4999 | matches the given matcher. |
| 5000 | |
| 5001 | The associated declaration is: |
| 5002 | - for type nodes, the declaration of the underlying type |
| 5003 | - for CallExpr, the declaration of the callee |
| 5004 | - for MemberExpr, the declaration of the referenced member |
| 5005 | - for CXXConstructExpr, the declaration of the constructor |
| 5006 | |
| 5007 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 5008 | function. e.g. various subtypes of clang::Type and various expressions. |
| 5009 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5010 | 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>>, |
| 5011 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 5012 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 5013 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5014 | 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>>, |
| 5015 | 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] | 5016 | </pre></td></tr> |
| 5017 | |
| 5018 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5019 | <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] | 5020 | <tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument |
| 5021 | matches the given InnerMatcher. |
| 5022 | |
| 5023 | Given |
| 5024 | template<typename T, typename U> class A {}; |
| 5025 | A<bool, int> b; |
| 5026 | A<int, bool> c; |
| 5027 | classTemplateSpecializationDecl(hasTemplateArgument( |
| 5028 | 1, refersToType(asString("int")))) |
| 5029 | matches the specialization A<bool, int> |
| 5030 | </pre></td></tr> |
| 5031 | |
| 5032 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5033 | <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] | 5034 | <tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node |
| 5035 | matches the given matcher. |
| 5036 | |
| 5037 | The associated declaration is: |
| 5038 | - for type nodes, the declaration of the underlying type |
| 5039 | - for CallExpr, the declaration of the callee |
| 5040 | - for MemberExpr, the declaration of the referenced member |
| 5041 | - for CXXConstructExpr, the declaration of the constructor |
| 5042 | |
| 5043 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 5044 | function. e.g. various subtypes of clang::Type and various expressions. |
| 5045 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5046 | 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>>, |
| 5047 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 5048 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 5049 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5050 | 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>>, |
| 5051 | 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] | 5052 | </pre></td></tr> |
| 5053 | |
| 5054 | |
| 5055 | <tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<T> Matcher</td></tr> |
| 5056 | <tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. |
| 5057 | |
| 5058 | Generates results for each match. |
| 5059 | |
| 5060 | For example, in: |
| 5061 | class A { class B {}; class C {}; }; |
| 5062 | The matcher: |
| 5063 | cxxRecordDecl(hasName("::A"), |
| 5064 | findAll(cxxRecordDecl(isDefinition()).bind("m"))) |
| 5065 | will generate results for A, B and C. |
| 5066 | |
| 5067 | Usable as: Any Matcher |
| 5068 | </pre></td></tr> |
| 5069 | |
| 5070 | |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 5071 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html">TypedefDecl</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> |
| 5072 | <tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type |
| 5073 | matcher. |
| 5074 | |
| 5075 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 5076 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 5077 | and U (matcher = typedefDecl(hasType(asString("int"))) |
| 5078 | class X {}; |
| 5079 | void y(X &x) { x; X z; } |
| 5080 | typedef int U; |
| 5081 | </pre></td></tr> |
| 5082 | |
| 5083 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5084 | <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] | 5085 | <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node |
| 5086 | matches the given matcher. |
| 5087 | |
| 5088 | The associated declaration is: |
| 5089 | - for type nodes, the declaration of the underlying type |
| 5090 | - for CallExpr, the declaration of the callee |
| 5091 | - for MemberExpr, the declaration of the referenced member |
| 5092 | - for CXXConstructExpr, the declaration of the constructor |
| 5093 | |
| 5094 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 5095 | function. e.g. various subtypes of clang::Type and various expressions. |
| 5096 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5097 | 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>>, |
| 5098 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 5099 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 5100 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5101 | 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>>, |
| 5102 | 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] | 5103 | </pre></td></tr> |
| 5104 | |
| 5105 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5106 | <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] | 5107 | <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. |
| 5108 | |
| 5109 | Given |
| 5110 | int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); |
| 5111 | unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) |
| 5112 | matches sizeof(a) and alignof(c) |
| 5113 | </pre></td></tr> |
| 5114 | |
| 5115 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5116 | <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] | 5117 | <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. |
| 5118 | |
| 5119 | Example matches true (matcher = hasUnaryOperand( |
| 5120 | cxxBoolLiteral(equals(true)))) |
| 5121 | !true |
| 5122 | </pre></td></tr> |
| 5123 | |
| 5124 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5125 | <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] | 5126 | <tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node |
| 5127 | matches the given matcher. |
| 5128 | |
| 5129 | The associated declaration is: |
| 5130 | - for type nodes, the declaration of the underlying type |
| 5131 | - for CallExpr, the declaration of the callee |
| 5132 | - for MemberExpr, the declaration of the referenced member |
| 5133 | - for CXXConstructExpr, the declaration of the constructor |
| 5134 | |
| 5135 | Also usable as Matcher<T> for any T supporting the getDecl() member |
| 5136 | function. e.g. various subtypes of clang::Type and various expressions. |
| 5137 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5138 | 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>>, |
| 5139 | 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>>, |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 5140 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, |
| 5141 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5142 | 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>>, |
| 5143 | 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] | 5144 | </pre></td></tr> |
| 5145 | |
| 5146 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5147 | <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] | 5148 | <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. |
| 5149 | |
| 5150 | Given |
| 5151 | namespace X { void b(); } |
| 5152 | using X::b; |
| 5153 | usingDecl(hasAnyUsingShadowDecl(hasName("b")))) |
| 5154 | matches using X::b </pre></td></tr> |
| 5155 | |
| 5156 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5157 | <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] | 5158 | <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is |
| 5159 | matched by the given matcher. |
| 5160 | |
| 5161 | Given |
| 5162 | namespace X { int a; void b(); } |
| 5163 | using X::a; |
| 5164 | using X::b; |
| 5165 | usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) |
| 5166 | matches using X::b but not using X::a </pre></td></tr> |
| 5167 | |
| 5168 | |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 5169 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType4')"><a name="hasType4Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 5170 | <tr><td colspan="4" class="doc" id="hasType4"><pre>Overloaded to match the declaration of the expression's or value |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5171 | declaration's type. |
| 5172 | |
| 5173 | In case of a value declaration (for example a variable declaration), |
| 5174 | this resolves one layer of indirection. For example, in the value |
| 5175 | declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 5176 | X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 5177 | declaration of x. |
| 5178 | |
| 5179 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 5180 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 5181 | class X {}; |
| 5182 | void y(X &x) { x; X z; } |
| 5183 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5184 | 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] | 5185 | </pre></td></tr> |
| 5186 | |
| 5187 | |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 5188 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType2')"><a name="hasType2Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
| 5189 | <tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5190 | matcher. |
| 5191 | |
| 5192 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 5193 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 5194 | and U (matcher = typedefDecl(hasType(asString("int"))) |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5195 | class X {}; |
| 5196 | void y(X &x) { x; X z; } |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 5197 | typedef int U; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5198 | </pre></td></tr> |
| 5199 | |
| 5200 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5201 | <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] | 5202 | <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression |
| 5203 | that matches the given matcher. |
| 5204 | |
| 5205 | Example matches x (matcher = varDecl(hasInitializer(callExpr()))) |
| 5206 | bool y() { return true; } |
| 5207 | bool x = y(); |
| 5208 | </pre></td></tr> |
| 5209 | |
| 5210 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5211 | <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] | 5212 | <tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size |
| 5213 | expression. |
| 5214 | |
| 5215 | Given |
| 5216 | void f(int b) { |
| 5217 | int a[b]; |
| 5218 | } |
| 5219 | variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( |
| 5220 | varDecl(hasName("b"))))))) |
| 5221 | matches "int a[b]" |
| 5222 | </pre></td></tr> |
| 5223 | |
| 5224 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5225 | <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] | 5226 | <tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 5227 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5228 | |
| 5229 | Given |
| 5230 | for (;;) {} |
| 5231 | hasBody(compoundStmt()) |
| 5232 | matches 'for (;;) {}' |
| 5233 | with compoundStmt() |
| 5234 | matching '{}' |
| 5235 | </pre></td></tr> |
| 5236 | |
| 5237 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5238 | <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] | 5239 | <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, |
| 5240 | or conditional operator. |
| 5241 | |
| 5242 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 5243 | if (true) {} |
| 5244 | </pre></td></tr> |
| 5245 | |
| 5246 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5247 | <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] | 5248 | <tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner |
| 5249 | NestedNameSpecifier-matcher matches. |
| 5250 | </pre></td></tr> |
| 5251 | |
| 5252 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5253 | <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] | 5254 | <tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner |
| 5255 | QualType-matcher matches. |
| 5256 | </pre></td></tr> |
| 5257 | |
Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 5258 | <!--END_TRAVERSAL_MATCHERS --> |
| 5259 | </table> |
| 5260 | |
| 5261 | </div> |
| 5262 | </body> |
| 5263 | </html> |
| 5264 | |
| 5265 | |