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 | |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +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('blockDecl0')"><a name="blockDecl0Anchor">blockDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>...</td></tr> |
| 128 | <tr><td colspan="4" class="doc" id="blockDecl0"><pre>Matches block declarations. |
| 129 | |
| 130 | Example matches the declaration of the nameless block printing an input |
| 131 | integer. |
| 132 | |
| 133 | myFunc(^(int p) { |
| 134 | printf("%d", p); |
| 135 | }) |
| 136 | </pre></td></tr> |
| 137 | |
| 138 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 139 | <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] | 140 | <tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations. |
| 141 | |
| 142 | Example matches Z |
| 143 | template<class T> class Z {}; |
| 144 | </pre></td></tr> |
| 145 | |
| 146 | |
Stephen Kelly | 9b8fa52 | 2018-10-09 08:24:11 +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('classTemplatePartialSpecializationDecl0')"><a name="classTemplatePartialSpecializationDecl0Anchor">classTemplatePartialSpecializationDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplatePartialSpecializationDecl.html">ClassTemplatePartialSpecializationDecl</a>>...</td></tr> |
| 148 | <tr><td colspan="4" class="doc" id="classTemplatePartialSpecializationDecl0"><pre>Matches C++ class template partial specializations. |
| 149 | |
| 150 | Given |
| 151 | template<class T1, class T2, int I> |
| 152 | class A {}; |
| 153 | |
| 154 | template<class T, int I> |
| 155 | class A<T, T*, I> {}; |
| 156 | |
| 157 | template<> |
| 158 | class A<int, int, 1> {}; |
| 159 | classTemplatePartialSpecializationDecl() |
| 160 | matches the specialization A<T,T*,I> but not A<int,int,1> |
| 161 | </pre></td></tr> |
| 162 | |
| 163 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 164 | <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] | 165 | <tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations. |
| 166 | |
| 167 | Given |
| 168 | template<typename T> class A {}; |
| 169 | template<> class A<double> {}; |
| 170 | A<int> a; |
| 171 | classTemplateSpecializationDecl() |
| 172 | matches the specializations A<int> and A<double> |
| 173 | </pre></td></tr> |
| 174 | |
| 175 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 176 | <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] | 177 | <tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations. |
| 178 | |
| 179 | Example matches Foo::Foo() and Foo::Foo(int) |
| 180 | class Foo { |
| 181 | public: |
| 182 | Foo(); |
| 183 | Foo(int); |
| 184 | int DoSomething(); |
| 185 | }; |
| 186 | </pre></td></tr> |
| 187 | |
| 188 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 189 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('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] | 190 | <tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations. |
| 191 | |
| 192 | Example matches the operator. |
| 193 | class X { operator int() const; }; |
| 194 | </pre></td></tr> |
| 195 | |
| 196 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 197 | <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] | 198 | <tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations. |
| 199 | |
| 200 | Example matches Foo::~Foo() |
| 201 | class Foo { |
| 202 | public: |
| 203 | virtual ~Foo(); |
| 204 | }; |
| 205 | </pre></td></tr> |
| 206 | |
| 207 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 208 | <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] | 209 | <tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations. |
| 210 | |
| 211 | Example matches y |
| 212 | class X { void y(); }; |
| 213 | </pre></td></tr> |
| 214 | |
| 215 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 216 | <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] | 217 | <tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations. |
| 218 | |
| 219 | Example matches X, Z |
| 220 | class X; |
| 221 | template<class T> class Z {}; |
| 222 | </pre></td></tr> |
| 223 | |
| 224 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 225 | <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] | 226 | <tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. |
| 227 | |
| 228 | Examples matches X, C, and the friend declaration inside C; |
| 229 | void X(); |
| 230 | class C { |
| 231 | friend X; |
| 232 | }; |
| 233 | </pre></td></tr> |
| 234 | |
| 235 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 236 | <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] | 237 | <tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function |
| 238 | and non-type template parameter declarations). |
| 239 | |
| 240 | Given |
| 241 | class X { int y; }; |
| 242 | declaratorDecl() |
| 243 | matches int y. |
| 244 | </pre></td></tr> |
| 245 | |
| 246 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 247 | <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] | 248 | <tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. |
| 249 | |
| 250 | Example matches A, B, C |
| 251 | enum X { |
| 252 | A, B, C |
| 253 | }; |
| 254 | </pre></td></tr> |
| 255 | |
| 256 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 257 | <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] | 258 | <tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. |
| 259 | |
| 260 | Example matches X |
| 261 | enum X { |
| 262 | A, B, C |
| 263 | }; |
| 264 | </pre></td></tr> |
| 265 | |
| 266 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 267 | <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] | 268 | <tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. |
| 269 | |
| 270 | Given |
| 271 | class X { int m; }; |
| 272 | fieldDecl() |
| 273 | matches 'm'. |
| 274 | </pre></td></tr> |
| 275 | |
| 276 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 277 | <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] | 278 | <tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations. |
| 279 | |
| 280 | Given |
| 281 | class X { friend void foo(); }; |
| 282 | friendDecl() |
| 283 | matches 'friend void foo()'. |
| 284 | </pre></td></tr> |
| 285 | |
| 286 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 287 | <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] | 288 | <tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. |
| 289 | |
| 290 | Example matches f |
| 291 | void f(); |
| 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('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] | 296 | <tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. |
| 297 | |
| 298 | Example matches f |
| 299 | template<class T> void f(T t) {} |
| 300 | </pre></td></tr> |
| 301 | |
| 302 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 303 | <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> |
| 304 | <tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label. |
| 305 | |
| 306 | Given |
| 307 | goto FOO; |
| 308 | FOO: bar(); |
| 309 | labelDecl() |
| 310 | matches 'FOO:' |
| 311 | </pre></td></tr> |
| 312 | |
| 313 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 314 | <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] | 315 | <tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification. |
| 316 | |
| 317 | Given |
| 318 | extern "C" {} |
| 319 | linkageSpecDecl() |
| 320 | matches "extern "C" {}" |
| 321 | </pre></td></tr> |
| 322 | |
| 323 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 324 | <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] | 325 | <tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. |
| 326 | |
| 327 | Example matches X, S, the anonymous union type, i, and U; |
| 328 | typedef int X; |
| 329 | struct S { |
| 330 | union { |
| 331 | int i; |
| 332 | } U; |
| 333 | }; |
| 334 | </pre></td></tr> |
| 335 | |
| 336 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 337 | <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] | 338 | <tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias. |
| 339 | |
| 340 | Given |
| 341 | namespace test {} |
| 342 | namespace alias = ::test; |
| 343 | namespaceAliasDecl() |
| 344 | matches "namespace alias" but not "namespace test" |
| 345 | </pre></td></tr> |
| 346 | |
| 347 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 348 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('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] | 349 | <tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. |
| 350 | |
| 351 | Given |
| 352 | namespace {} |
| 353 | namespace test {} |
| 354 | namespaceDecl() |
| 355 | matches "namespace {}" and "namespace test {}" |
| 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('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] | 360 | <tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations. |
| 361 | |
| 362 | Given |
| 363 | template <typename T, int N> struct C {}; |
| 364 | nonTypeTemplateParmDecl() |
| 365 | matches 'N', but not 'T'. |
| 366 | </pre></td></tr> |
| 367 | |
| 368 | |
Aaron Ballman | 9fd6ee6 | 2017-03-15 20:14:25 +0000 | [diff] [blame] | 369 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcCategoryDecl0')"><a name="objcCategoryDecl0Anchor">objcCategoryDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryDecl.html">ObjCCategoryDecl</a>>...</td></tr> |
| 370 | <tr><td colspan="4" class="doc" id="objcCategoryDecl0"><pre>Matches Objective-C category declarations. |
| 371 | |
| 372 | Example matches Foo (Additions) |
| 373 | @interface Foo (Additions) |
| 374 | @end |
| 375 | </pre></td></tr> |
| 376 | |
| 377 | |
Dave Lee | 55540a0 | 2017-10-26 15:53:37 +0000 | [diff] [blame] | 378 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcCategoryImplDecl0')"><a name="objcCategoryImplDecl0Anchor">objcCategoryImplDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryImplDecl.html">ObjCCategoryImplDecl</a>>...</td></tr> |
| 379 | <tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions. |
| 380 | |
| 381 | Example matches Foo (Additions) |
| 382 | @implementation Foo (Additions) |
| 383 | @end |
| 384 | </pre></td></tr> |
| 385 | |
| 386 | |
Dave Lee | e6d362c | 2017-09-10 21:00:15 +0000 | [diff] [blame] | 387 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcImplementationDecl0')"><a name="objcImplementationDecl0Anchor">objcImplementationDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html">ObjCImplementationDecl</a>>...</td></tr> |
| 388 | <tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations. |
| 389 | |
| 390 | Example matches Foo |
| 391 | @implementation Foo |
| 392 | @end |
| 393 | </pre></td></tr> |
| 394 | |
| 395 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 396 | <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] | 397 | <tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations. |
| 398 | |
| 399 | Example matches Foo |
| 400 | @interface Foo |
| 401 | @end |
| 402 | </pre></td></tr> |
| 403 | |
| 404 | |
Aaron Ballman | 9fd6ee6 | 2017-03-15 20:14:25 +0000 | [diff] [blame] | 405 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcIvarDecl0')"><a name="objcIvarDecl0Anchor">objcIvarDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCIvarDecl.html">ObjCIvarDecl</a>>...</td></tr> |
| 406 | <tr><td colspan="4" class="doc" id="objcIvarDecl0"><pre>Matches Objective-C instance variable declarations. |
| 407 | |
| 408 | Example matches _enabled |
| 409 | @implementation Foo { |
| 410 | BOOL _enabled; |
| 411 | } |
| 412 | @end |
| 413 | </pre></td></tr> |
| 414 | |
| 415 | |
| 416 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcMethodDecl0')"><a name="objcMethodDecl0Anchor">objcMethodDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>>...</td></tr> |
| 417 | <tr><td colspan="4" class="doc" id="objcMethodDecl0"><pre>Matches Objective-C method declarations. |
| 418 | |
| 419 | Example matches both declaration and definition of -[Foo method] |
| 420 | @interface Foo |
| 421 | - (void)method; |
| 422 | @end |
| 423 | |
| 424 | @implementation Foo |
| 425 | - (void)method {} |
| 426 | @end |
| 427 | </pre></td></tr> |
| 428 | |
| 429 | |
| 430 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcPropertyDecl0')"><a name="objcPropertyDecl0Anchor">objcPropertyDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>...</td></tr> |
| 431 | <tr><td colspan="4" class="doc" id="objcPropertyDecl0"><pre>Matches Objective-C property declarations. |
| 432 | |
| 433 | Example matches enabled |
| 434 | @interface Foo |
| 435 | @property BOOL enabled; |
| 436 | @end |
| 437 | </pre></td></tr> |
| 438 | |
| 439 | |
| 440 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcProtocolDecl0')"><a name="objcProtocolDecl0Anchor">objcProtocolDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCProtocolDecl.html">ObjCProtocolDecl</a>>...</td></tr> |
| 441 | <tr><td colspan="4" class="doc" id="objcProtocolDecl0"><pre>Matches Objective-C protocol declarations. |
| 442 | |
| 443 | Example matches FooDelegate |
| 444 | @protocol FooDelegate |
| 445 | @end |
| 446 | </pre></td></tr> |
| 447 | |
| 448 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 449 | <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] | 450 | <tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. |
| 451 | |
| 452 | Given |
| 453 | void f(int x); |
| 454 | parmVarDecl() |
| 455 | matches int x. |
| 456 | </pre></td></tr> |
| 457 | |
| 458 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 459 | <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] | 460 | <tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations. |
| 461 | |
| 462 | Example matches X, Z, U, and S |
| 463 | class X; |
| 464 | template<class T> class Z {}; |
| 465 | struct S {}; |
| 466 | union U {}; |
| 467 | </pre></td></tr> |
| 468 | |
| 469 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 470 | <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] | 471 | <tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration. |
| 472 | |
| 473 | Example: |
| 474 | staticAssertExpr() |
| 475 | matches |
| 476 | static_assert(sizeof(S) == sizeof(int)) |
| 477 | in |
| 478 | struct S { |
| 479 | int x; |
| 480 | }; |
| 481 | static_assert(sizeof(S) == sizeof(int)); |
| 482 | </pre></td></tr> |
| 483 | |
| 484 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 485 | <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] | 486 | <tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations. |
| 487 | |
| 488 | Given |
| 489 | template <typename T, int N> struct C {}; |
| 490 | templateTypeParmDecl() |
| 491 | matches 'T', but not 'N'. |
| 492 | </pre></td></tr> |
| 493 | |
| 494 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 495 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 496 | <tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context. |
| 497 | |
| 498 | Given |
| 499 | int X; |
| 500 | namespace NS { |
| 501 | int Y; |
| 502 | } namespace NS |
| 503 | decl(hasDeclContext(translationUnitDecl())) |
| 504 | matches "int X", but not "int Y". |
| 505 | </pre></td></tr> |
| 506 | |
| 507 | |
Aaron Ballman | 66eb58a | 2016-04-14 16:05:45 +0000 | [diff] [blame] | 508 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typeAliasDecl0')"><a name="typeAliasDecl0Anchor">typeAliasDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeAliasDecl.html">TypeAliasDecl</a>>...</td></tr> |
| 509 | <tr><td colspan="4" class="doc" id="typeAliasDecl0"><pre>Matches type alias declarations. |
| 510 | |
| 511 | Given |
| 512 | typedef int X; |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 513 | using Y = int; |
Aaron Ballman | 66eb58a | 2016-04-14 16:05:45 +0000 | [diff] [blame] | 514 | typeAliasDecl() |
| 515 | matches "using Y = int", but not "typedef int X" |
| 516 | </pre></td></tr> |
| 517 | |
| 518 | |
Eric Liu | 285f804 | 2017-03-28 12:56:47 +0000 | [diff] [blame] | 519 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typeAliasTemplateDecl0')"><a name="typeAliasTemplateDecl0Anchor">typeAliasTemplateDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeAliasTemplateDecl.html">TypeAliasTemplateDecl</a>>...</td></tr> |
| 520 | <tr><td colspan="4" class="doc" id="typeAliasTemplateDecl0"><pre>Matches type alias template declarations. |
| 521 | |
| 522 | typeAliasTemplateDecl() matches |
| 523 | template <typename T> |
| 524 | using Y = X<T>; |
| 525 | </pre></td></tr> |
| 526 | |
| 527 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 528 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 529 | <tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations. |
| 530 | |
| 531 | Given |
| 532 | typedef int X; |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 533 | using Y = int; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 534 | typedefDecl() |
Aaron Ballman | 66eb58a | 2016-04-14 16:05:45 +0000 | [diff] [blame] | 535 | matches "typedef int X", but not "using Y = int" |
| 536 | </pre></td></tr> |
| 537 | |
| 538 | |
| 539 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typedefNameDecl0')"><a name="typedefNameDecl0Anchor">typedefNameDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>>...</td></tr> |
| 540 | <tr><td colspan="4" class="doc" id="typedefNameDecl0"><pre>Matches typedef name declarations. |
| 541 | |
| 542 | Given |
| 543 | typedef int X; |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 544 | using Y = int; |
Aaron Ballman | 66eb58a | 2016-04-14 16:05:45 +0000 | [diff] [blame] | 545 | typedefNameDecl() |
| 546 | matches "typedef int X" and "using Y = int" |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 547 | </pre></td></tr> |
| 548 | |
| 549 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 550 | <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] | 551 | <tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the |
| 552 | typename. |
| 553 | |
| 554 | Given |
| 555 | template <typename T> |
| 556 | struct Base { typedef T Foo; }; |
| 557 | |
| 558 | template<typename T> |
| 559 | struct S : private Base<T> { |
| 560 | using typename Base<T>::Foo; |
| 561 | }; |
| 562 | unresolvedUsingTypenameDecl() |
| 563 | matches using Base<T>::Foo </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_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] | 567 | <tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations. |
| 568 | |
| 569 | Given |
| 570 | template<typename X> |
| 571 | class C : private X { |
| 572 | using X::x; |
| 573 | }; |
| 574 | unresolvedUsingValueDecl() |
| 575 | matches using X::x </pre></td></tr> |
| 576 | |
| 577 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 578 | <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] | 579 | <tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. |
| 580 | |
| 581 | Given |
| 582 | namespace X { int x; } |
| 583 | using X::x; |
| 584 | usingDecl() |
| 585 | matches using X::x </pre></td></tr> |
| 586 | |
| 587 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 588 | <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] | 589 | <tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations. |
| 590 | |
| 591 | Given |
| 592 | namespace X { int x; } |
| 593 | using namespace X; |
| 594 | usingDirectiveDecl() |
| 595 | matches using namespace X </pre></td></tr> |
| 596 | |
| 597 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 598 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 599 | <tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration. |
| 600 | |
| 601 | Example matches A, B, C and F |
| 602 | enum X { A, B, C }; |
| 603 | void F(); |
| 604 | </pre></td></tr> |
| 605 | |
| 606 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 607 | <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] | 608 | <tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. |
| 609 | |
| 610 | Note: this does not match declarations of member variables, which are |
| 611 | "field" declarations in Clang parlance. |
| 612 | |
| 613 | Example matches a |
| 614 | int a; |
| 615 | </pre></td></tr> |
| 616 | |
| 617 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 618 | <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] | 619 | <tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. |
| 620 | </pre></td></tr> |
| 621 | |
| 622 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 623 | <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] | 624 | <tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. |
| 625 | |
| 626 | Given |
| 627 | namespace ns { |
| 628 | struct A { static void f(); }; |
| 629 | void A::f() {} |
| 630 | void g() { A::f(); } |
| 631 | } |
| 632 | ns::A a; |
| 633 | nestedNameSpecifier() |
| 634 | matches "ns::" and both "A::" |
| 635 | </pre></td></tr> |
| 636 | |
| 637 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 638 | <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] | 639 | <tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. |
| 640 | </pre></td></tr> |
| 641 | |
| 642 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 643 | <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> |
| 644 | <tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension). |
| 645 | |
| 646 | Given |
| 647 | FOO: bar(); |
| 648 | void *ptr = &&FOO; |
| 649 | goto *bar; |
| 650 | addrLabelExpr() |
| 651 | matches '&&FOO' |
| 652 | </pre></td></tr> |
| 653 | |
| 654 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 655 | <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] | 656 | <tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. |
| 657 | |
| 658 | Given |
| 659 | int i = a[1]; |
| 660 | arraySubscriptExpr() |
| 661 | matches "a[1]" |
| 662 | </pre></td></tr> |
| 663 | |
| 664 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 665 | <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] | 666 | <tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. |
| 667 | |
| 668 | int i = 100; |
| 669 | __asm("mov al, 2"); |
| 670 | asmStmt() |
| 671 | matches '__asm("mov al, 2")' |
| 672 | </pre></td></tr> |
| 673 | |
| 674 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 675 | <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> |
| 676 | <tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins. |
| 677 | Example matches __atomic_load_n(ptr, 1) |
| 678 | void foo() { int *ptr; __atomic_load_n(ptr, 1); } |
| 679 | </pre></td></tr> |
| 680 | |
| 681 | |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 682 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('autoreleasePoolStmt0')"><a name="autoreleasePoolStmt0Anchor">autoreleasePoolStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCAutoreleasePoolStmt.html">ObjCAutoreleasePoolStmt</a>>...</td></tr> |
| 683 | <tr><td colspan="4" class="doc" id="autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement. |
| 684 | |
| 685 | Given |
| 686 | @autoreleasepool { |
| 687 | int x = 0; |
| 688 | } |
| 689 | autoreleasePoolStmt(stmt()) matches the declaration of "x" |
| 690 | inside the autorelease pool. |
| 691 | </pre></td></tr> |
| 692 | |
| 693 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 694 | <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> |
| 695 | <tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension). |
| 696 | |
| 697 | Example matches a ?: b |
| 698 | (a ?: b) + 42; |
| 699 | </pre></td></tr> |
| 700 | |
| 701 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 702 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('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] | 703 | <tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. |
| 704 | |
| 705 | Example matches a || b |
| 706 | !(a || b) |
| 707 | </pre></td></tr> |
| 708 | |
| 709 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 710 | <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] | 711 | <tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. |
| 712 | |
| 713 | Given |
| 714 | while (true) { break; } |
| 715 | breakStmt() |
| 716 | matches 'break' |
| 717 | </pre></td></tr> |
| 718 | |
| 719 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 720 | <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] | 721 | <tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. |
| 722 | |
Artem Dergachev | ded92a9 | 2016-11-11 22:34:53 +0000 | [diff] [blame] | 723 | Example: Matches (int) 2.2f in |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 724 | int i = (int) 2.2f; |
| 725 | </pre></td></tr> |
| 726 | |
| 727 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 728 | <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] | 729 | <tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. |
| 730 | |
| 731 | Example matches x.y() and y() |
| 732 | X x; |
| 733 | x.y(); |
| 734 | y(); |
| 735 | </pre></td></tr> |
| 736 | |
| 737 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 738 | <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] | 739 | <tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. |
| 740 | |
| 741 | Given |
| 742 | switch(a) { case 42: break; default: break; } |
| 743 | caseStmt() |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 744 | matches 'case 42:'. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 745 | </pre></td></tr> |
| 746 | |
| 747 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 748 | <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] | 749 | <tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. |
| 750 | |
| 751 | Example: castExpr() matches each of the following: |
| 752 | (int) 3; |
| 753 | const_cast<Expr *>(SubExpr); |
| 754 | char c = 0; |
| 755 | but does not match |
| 756 | int i = (0); |
| 757 | int k = 0; |
| 758 | </pre></td></tr> |
| 759 | |
| 760 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 761 | <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] | 762 | <tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). |
| 763 | |
| 764 | Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), |
| 765 | though. |
| 766 | |
| 767 | Example matches 'a', L'a' |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 768 | char ch = 'a'; |
| 769 | wchar_t chw = L'a'; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 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('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] | 774 | <tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals |
| 775 | |
| 776 | Example match: {1}, (1, 2) |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 777 | int array[4] = {1}; |
| 778 | vector int myvec = (vector int)(1, 2); |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 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('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] | 783 | <tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. |
| 784 | |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 785 | Example matches '{}' and '{{}}' in 'for (;;) {{}}' |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 786 | for (;;) {{}} |
| 787 | </pre></td></tr> |
| 788 | |
| 789 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 790 | <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] | 791 | <tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. |
| 792 | |
| 793 | Example matches a ? b : c |
| 794 | (a ? b : c) + 42 |
| 795 | </pre></td></tr> |
| 796 | |
| 797 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 798 | <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] | 799 | <tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. |
| 800 | |
| 801 | Given |
| 802 | while (true) { continue; } |
| 803 | continueStmt() |
| 804 | matches 'continue' |
| 805 | </pre></td></tr> |
| 806 | |
| 807 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 808 | <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] | 809 | <tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression. |
| 810 | |
| 811 | Example matches, |
| 812 | kernel<<<i,j>>>(); |
| 813 | </pre></td></tr> |
| 814 | |
| 815 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 816 | <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] | 817 | <tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created. |
| 818 | |
| 819 | Example matches FunctionTakesString(GetStringByValue()) |
| 820 | (matcher = cxxBindTemporaryExpr()) |
| 821 | FunctionTakesString(GetStringByValue()); |
| 822 | FunctionTakesStringByPointer(GetStringPointer()); |
| 823 | </pre></td></tr> |
| 824 | |
| 825 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 826 | <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] | 827 | <tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals. |
| 828 | |
| 829 | Example matches true |
| 830 | true |
| 831 | </pre></td></tr> |
| 832 | |
| 833 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 834 | <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] | 835 | <tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements. |
| 836 | |
| 837 | try {} catch(int i) {} |
| 838 | cxxCatchStmt() |
| 839 | matches 'catch(int i)' |
| 840 | </pre></td></tr> |
| 841 | |
| 842 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 843 | <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] | 844 | <tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression. |
| 845 | |
| 846 | Example: Matches const_cast<int*>(&r) in |
| 847 | int n = 42; |
| 848 | const int &r(n); |
| 849 | int* p = const_cast<int*>(&r); |
| 850 | </pre></td></tr> |
| 851 | |
| 852 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 853 | <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] | 854 | <tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones). |
| 855 | |
| 856 | Example matches string(ptr, n) and ptr within arguments of f |
| 857 | (matcher = cxxConstructExpr()) |
| 858 | void f(const string &a, const string &b); |
| 859 | char *ptr; |
| 860 | int n; |
| 861 | f(string(ptr, n), ptr); |
| 862 | </pre></td></tr> |
| 863 | |
| 864 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 865 | <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] | 866 | <tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site. |
| 867 | |
| 868 | Example matches the CXXDefaultArgExpr placeholder inserted for the |
| 869 | default value of the second parameter in the call expression f(42) |
| 870 | (matcher = cxxDefaultArgExpr()) |
| 871 | void f(int x, int y = 0); |
| 872 | f(42); |
| 873 | </pre></td></tr> |
| 874 | |
| 875 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 876 | <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] | 877 | <tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions. |
| 878 | |
| 879 | Given |
| 880 | delete X; |
| 881 | cxxDeleteExpr() |
| 882 | matches 'delete X'. |
| 883 | </pre></td></tr> |
| 884 | |
| 885 | |
Shuai Wang | 72b56ed | 2018-08-12 17:34:36 +0000 | [diff] [blame] | 886 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDependentScopeMemberExpr0')"><a name="cxxDependentScopeMemberExpr0Anchor">cxxDependentScopeMemberExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>>...</td></tr> |
| 887 | <tr><td colspan="4" class="doc" id="cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be |
| 888 | resolved because the base expression or the member name was dependent. |
| 889 | |
| 890 | Given |
| 891 | template <class T> void f() { T t; t.g(); } |
| 892 | cxxDependentScopeMemberExpr() |
| 893 | matches t.g |
| 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('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] | 898 | <tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression. |
| 899 | |
| 900 | Example: |
| 901 | cxxDynamicCastExpr() |
| 902 | matches |
| 903 | dynamic_cast<D*>(&b); |
| 904 | in |
| 905 | struct B { virtual ~B() {} }; struct D : B {}; |
| 906 | B b; |
| 907 | D* p = dynamic_cast<D*>(&b); |
| 908 | </pre></td></tr> |
| 909 | |
| 910 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 911 | <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] | 912 | <tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements. |
| 913 | |
| 914 | cxxForRangeStmt() matches 'for (auto a : i)' |
| 915 | int i[] = {1, 2, 3}; for (auto a : i); |
| 916 | for(int j = 0; j < 5; ++j); |
| 917 | </pre></td></tr> |
| 918 | |
| 919 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 920 | <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] | 921 | <tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions |
| 922 | |
| 923 | Example: Matches Foo(bar); |
| 924 | Foo f = bar; |
| 925 | Foo g = (Foo) bar; |
| 926 | Foo h = Foo(bar); |
| 927 | </pre></td></tr> |
| 928 | |
| 929 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 930 | <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] | 931 | <tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions. |
| 932 | |
| 933 | Example matches x.y() |
| 934 | X x; |
| 935 | x.y(); |
| 936 | </pre></td></tr> |
| 937 | |
| 938 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 939 | <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] | 940 | <tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions. |
| 941 | |
| 942 | Given |
| 943 | new X; |
| 944 | cxxNewExpr() |
| 945 | matches 'new X'. |
| 946 | </pre></td></tr> |
| 947 | |
| 948 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 949 | <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] | 950 | <tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal. |
| 951 | </pre></td></tr> |
| 952 | |
| 953 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 954 | <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] | 955 | <tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls. |
| 956 | |
| 957 | Note that if an operator isn't overloaded, it won't match. Instead, use |
| 958 | binaryOperator matcher. |
| 959 | Currently it does not match operators such as new delete. |
| 960 | FIXME: figure out why these do not match? |
| 961 | |
| 962 | Example matches both operator<<((o << b), c) and operator<<(o, b) |
| 963 | (matcher = cxxOperatorCallExpr()) |
| 964 | ostream &operator<< (ostream &out, int i) { }; |
| 965 | ostream &o; int b = 1, c = 1; |
| 966 | o << b << c; |
| 967 | </pre></td></tr> |
| 968 | |
| 969 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 970 | <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] | 971 | <tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. |
| 972 | |
| 973 | Either the source expression or the destination type can be matched |
| 974 | using has(), but hasDestinationType() is more specific and can be |
| 975 | more readable. |
| 976 | |
| 977 | Example matches reinterpret_cast<char*>(&p) in |
| 978 | void* p = reinterpret_cast<char*>(&p); |
| 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('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] | 983 | <tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression. |
| 984 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 985 | See also: hasDestinationType |
| 986 | See also: reinterpretCast |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 987 | |
| 988 | Example: |
| 989 | cxxStaticCastExpr() |
| 990 | matches |
| 991 | static_cast<long>(8) |
| 992 | in |
| 993 | long eight(static_cast<long>(8)); |
| 994 | </pre></td></tr> |
| 995 | |
| 996 | |
Jakub Kuderski | 64b6c78 | 2017-05-05 21:01:12 +0000 | [diff] [blame] | 997 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxStdInitializerListExpr0')"><a name="cxxStdInitializerListExpr0Anchor">cxxStdInitializerListExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStdInitializerListExpr.html">CXXStdInitializerListExpr</a>>...</td></tr> |
| 998 | <tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions. |
| 999 | |
| 1000 | Given |
| 1001 | std::vector<int> a({ 1, 2, 3 }); |
| 1002 | std::vector<int> b = { 4, 5 }; |
| 1003 | int c[] = { 6, 7 }; |
| 1004 | std::pair<int, int> d = { 8, 9 }; |
| 1005 | cxxStdInitializerListExpr() |
| 1006 | matches "{ 1, 2, 3 }" and "{ 4, 5 }" |
| 1007 | </pre></td></tr> |
| 1008 | |
| 1009 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1010 | <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] | 1011 | <tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments |
| 1012 | |
| 1013 | Example: Matches Foo(bar, bar) |
| 1014 | Foo h = Foo(bar, bar); |
| 1015 | </pre></td></tr> |
| 1016 | |
| 1017 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1018 | <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] | 1019 | <tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions. |
| 1020 | |
| 1021 | Example matches the implicit this expression in "return i". |
| 1022 | (matcher = cxxThisExpr()) |
| 1023 | struct foo { |
| 1024 | int i; |
| 1025 | int f() { return i; } |
| 1026 | }; |
| 1027 | </pre></td></tr> |
| 1028 | |
| 1029 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1030 | <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] | 1031 | <tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions. |
| 1032 | |
| 1033 | try { throw 5; } catch(int i) {} |
| 1034 | cxxThrowExpr() |
| 1035 | matches 'throw 5' |
| 1036 | </pre></td></tr> |
| 1037 | |
| 1038 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1039 | <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] | 1040 | <tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements. |
| 1041 | |
| 1042 | try {} catch(int i) {} |
| 1043 | cxxTryStmt() |
| 1044 | matches 'try {}' |
| 1045 | </pre></td></tr> |
| 1046 | |
| 1047 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1048 | <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] | 1049 | <tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. |
| 1050 | |
| 1051 | Example matches T(t) in return statement of f |
| 1052 | (matcher = cxxUnresolvedConstructExpr()) |
| 1053 | template <typename T> |
| 1054 | void f(const T& t) { return T(t); } |
| 1055 | </pre></td></tr> |
| 1056 | |
| 1057 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1058 | <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] | 1059 | <tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. |
| 1060 | |
| 1061 | Example matches x in if (x) |
| 1062 | bool x; |
| 1063 | if (x) {} |
| 1064 | </pre></td></tr> |
| 1065 | |
| 1066 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1067 | <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] | 1068 | <tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. |
| 1069 | |
| 1070 | Given |
| 1071 | int a; |
| 1072 | declStmt() |
| 1073 | matches 'int a'. |
| 1074 | </pre></td></tr> |
| 1075 | |
| 1076 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1077 | <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] | 1078 | <tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. |
| 1079 | |
| 1080 | Given |
| 1081 | switch(a) { case 42: break; default: break; } |
| 1082 | defaultStmt() |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 1083 | matches 'default:'. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1084 | </pre></td></tr> |
| 1085 | |
| 1086 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1087 | <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> |
| 1088 | <tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8]. |
| 1089 | |
| 1090 | Example: Matches { [2].y = 1.0, [0].x = 1.0 } |
| 1091 | point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; |
| 1092 | </pre></td></tr> |
| 1093 | |
| 1094 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1095 | <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] | 1096 | <tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. |
| 1097 | |
| 1098 | Given |
| 1099 | do {} while (true); |
| 1100 | doStmt() |
| 1101 | matches 'do {} while(true)' |
| 1102 | </pre></td></tr> |
| 1103 | |
| 1104 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1105 | <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] | 1106 | <tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. |
| 1107 | |
| 1108 | Matches any cast expression written in user code, whether it be a |
| 1109 | C-style cast, a functional-style cast, or a keyword cast. |
| 1110 | |
| 1111 | Does not match implicit conversions. |
| 1112 | |
| 1113 | Note: the name "explicitCast" is chosen to match Clang's terminology, as |
| 1114 | Clang uses the term "cast" to apply to implicit conversions as well as to |
| 1115 | actual cast expressions. |
| 1116 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1117 | See also: hasDestinationType. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1118 | |
| 1119 | Example: matches all five of the casts in |
| 1120 | int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) |
| 1121 | but does not match the implicit conversion in |
| 1122 | long ell = 42; |
| 1123 | </pre></td></tr> |
| 1124 | |
| 1125 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1126 | <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] | 1127 | <tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. |
| 1128 | |
| 1129 | Example matches x() |
| 1130 | void f() { x(); } |
| 1131 | </pre></td></tr> |
| 1132 | |
| 1133 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1134 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('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] | 1135 | <tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end |
| 1136 | of the sub-expression's evaluation. |
| 1137 | |
| 1138 | Example matches std::string() |
| 1139 | const std::string str = std::string(); |
| 1140 | </pre></td></tr> |
| 1141 | |
| 1142 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1143 | <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] | 1144 | <tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g. |
| 1145 | 1.0, 1.0f, 1.0L and 1e10. |
| 1146 | |
| 1147 | Does not match implicit conversions such as |
| 1148 | float a = 10; |
| 1149 | </pre></td></tr> |
| 1150 | |
| 1151 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1152 | <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] | 1153 | <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. |
| 1154 | |
| 1155 | Example matches 'for (;;) {}' |
| 1156 | for (;;) {} |
| 1157 | int i[] = {1, 2, 3}; for (auto a : i); |
| 1158 | </pre></td></tr> |
| 1159 | |
| 1160 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1161 | <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] | 1162 | <tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. |
| 1163 | </pre></td></tr> |
| 1164 | |
| 1165 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1166 | <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] | 1167 | <tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. |
| 1168 | |
| 1169 | Given |
| 1170 | goto FOO; |
| 1171 | FOO: bar(); |
| 1172 | gotoStmt() |
| 1173 | matches 'goto FOO' |
| 1174 | </pre></td></tr> |
| 1175 | |
| 1176 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1177 | <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] | 1178 | <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. |
| 1179 | |
| 1180 | Example matches 'if (x) {}' |
| 1181 | if (x) {} |
| 1182 | </pre></td></tr> |
| 1183 | |
| 1184 | |
Stephen Kelly | 9b8fa52 | 2018-10-09 08:24:11 +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('imaginaryLiteral0')"><a name="imaginaryLiteral0Anchor">imaginaryLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ImaginaryLiteral.html">ImaginaryLiteral</a>>...</td></tr> |
| 1186 | <tr><td colspan="4" class="doc" id="imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating |
| 1187 | point literals e.g.: 1i, 1.0i |
| 1188 | </pre></td></tr> |
| 1189 | |
| 1190 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1191 | <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] | 1192 | <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. |
| 1193 | |
| 1194 | This matches many different places, including function call return value |
| 1195 | eliding, as well as any type conversions. |
| 1196 | </pre></td></tr> |
| 1197 | |
| 1198 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1199 | <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> |
| 1200 | <tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions. |
| 1201 | |
| 1202 | Given |
| 1203 | point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; |
| 1204 | implicitValueInitExpr() |
| 1205 | matches "[0].y" (implicitly) |
| 1206 | </pre></td></tr> |
| 1207 | |
| 1208 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1209 | <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] | 1210 | <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. |
| 1211 | |
| 1212 | Given |
| 1213 | int a[] = { 1, 2 }; |
| 1214 | struct B { int x, y; }; |
| 1215 | B b = { 5, 6 }; |
| 1216 | initListExpr() |
| 1217 | matches "{ 1, 2 }" and "{ 5, 6 }" |
| 1218 | </pre></td></tr> |
| 1219 | |
| 1220 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1221 | <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] | 1222 | <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g. |
| 1223 | 1, 1L, 0x1 and 1U. |
| 1224 | |
| 1225 | Does not match character-encoded integers such as L'a'. |
| 1226 | </pre></td></tr> |
| 1227 | |
| 1228 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1229 | <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] | 1230 | <tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. |
| 1231 | |
| 1232 | Given |
| 1233 | goto FOO; |
| 1234 | FOO: bar(); |
| 1235 | labelStmt() |
| 1236 | matches 'FOO:' |
| 1237 | </pre></td></tr> |
| 1238 | |
| 1239 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1240 | <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] | 1241 | <tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. |
| 1242 | |
| 1243 | Example matches [&](){return 5;} |
| 1244 | [&](){return 5;} |
| 1245 | </pre></td></tr> |
| 1246 | |
| 1247 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1248 | <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] | 1249 | <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. |
| 1250 | |
| 1251 | Example: Given |
Jakub Kuderski | 64b6c78 | 2017-05-05 21:01:12 +0000 | [diff] [blame] | 1252 | struct T {void func();}; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1253 | T f(); |
| 1254 | void g(T); |
| 1255 | materializeTemporaryExpr() matches 'f()' in these statements |
| 1256 | T u(f()); |
| 1257 | g(f()); |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 1258 | f().func(); |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1259 | but does not match |
| 1260 | f(); |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1261 | </pre></td></tr> |
| 1262 | |
| 1263 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1264 | <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] | 1265 | <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. |
| 1266 | |
| 1267 | Given |
| 1268 | class Y { |
| 1269 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 1270 | int a; static int b; |
| 1271 | }; |
| 1272 | memberExpr() |
| 1273 | matches this->x, x, y.x, a, this->b |
| 1274 | </pre></td></tr> |
| 1275 | |
| 1276 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1277 | <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] | 1278 | <tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. |
| 1279 | |
| 1280 | foo();; |
| 1281 | nullStmt() |
| 1282 | matches the second ';' |
| 1283 | </pre></td></tr> |
| 1284 | |
| 1285 | |
Dave Lee | 0934fdc | 2017-11-11 22:46:15 +0000 | [diff] [blame] | 1286 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcCatchStmt0')"><a name="objcCatchStmt0Anchor">objcCatchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCAtCatchStmt.html">ObjCAtCatchStmt</a>>...</td></tr> |
| 1287 | <tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements. |
| 1288 | |
| 1289 | Example matches @catch |
| 1290 | @try {} |
| 1291 | @catch (...) {} |
| 1292 | </pre></td></tr> |
| 1293 | |
| 1294 | |
| 1295 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcFinallyStmt0')"><a name="objcFinallyStmt0Anchor">objcFinallyStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCAtFinallyStmt.html">ObjCAtFinallyStmt</a>>...</td></tr> |
| 1296 | <tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements. |
| 1297 | |
| 1298 | Example matches @finally |
| 1299 | @try {} |
| 1300 | @finally {} |
| 1301 | </pre></td></tr> |
| 1302 | |
| 1303 | |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 1304 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcIvarRefExpr0')"><a name="objcIvarRefExpr0Anchor">objcIvarRefExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCIvarRefExpr.html">ObjCIvarRefExpr</a>>...</td></tr> |
| 1305 | <tr><td colspan="4" class="doc" id="objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar. |
| 1306 | |
| 1307 | Example: matches "a" in "init" method: |
| 1308 | @implementation A { |
| 1309 | NSString *a; |
| 1310 | } |
| 1311 | - (void) init { |
| 1312 | a = @"hello"; |
| 1313 | } |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 1314 | </pre></td></tr> |
| 1315 | |
| 1316 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1317 | <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] | 1318 | <tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions. |
| 1319 | |
| 1320 | The innermost message send invokes the "alloc" class method on the |
| 1321 | NSString class, while the outermost message send invokes the |
| 1322 | "initWithString" instance method on the object returned from |
| 1323 | NSString's "alloc". This matcher should match both message sends. |
| 1324 | [[NSString alloc] initWithString:@"Hello"] |
| 1325 | </pre></td></tr> |
| 1326 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1327 | |
Dave Lee | 0934fdc | 2017-11-11 22:46:15 +0000 | [diff] [blame] | 1328 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcThrowStmt0')"><a name="objcThrowStmt0Anchor">objcThrowStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCAtThrowStmt.html">ObjCAtThrowStmt</a>>...</td></tr> |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 1329 | <tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements. |
Dave Lee | 0934fdc | 2017-11-11 22:46:15 +0000 | [diff] [blame] | 1330 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 1331 | Example matches @throw obj; |
Dave Lee | 0934fdc | 2017-11-11 22:46:15 +0000 | [diff] [blame] | 1332 | </pre></td></tr> |
| 1333 | |
| 1334 | |
| 1335 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcTryStmt0')"><a name="objcTryStmt0Anchor">objcTryStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCAtTryStmt.html">ObjCAtTryStmt</a>>...</td></tr> |
| 1336 | <tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements. |
| 1337 | |
| 1338 | Example matches @try |
| 1339 | @try {} |
| 1340 | @catch (...) {} |
| 1341 | </pre></td></tr> |
| 1342 | |
| 1343 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1344 | <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> |
| 1345 | <tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers |
| 1346 | to reference another expressions and can be met |
| 1347 | in BinaryConditionalOperators, for example. |
| 1348 | |
| 1349 | Example matches 'a' |
| 1350 | (a ?: c) + 42; |
| 1351 | </pre></td></tr> |
| 1352 | |
| 1353 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1354 | <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] | 1355 | <tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions. |
| 1356 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1357 | Example matches (foo() + 1) |
Aaron Ballman | e8295d7 | 2016-01-20 16:17:39 +0000 | [diff] [blame] | 1358 | int foo() { return 1; } |
| 1359 | int a = (foo() + 1); |
Aaron Ballman | e8295d7 | 2016-01-20 16:17:39 +0000 | [diff] [blame] | 1360 | </pre></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1361 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1362 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1363 | <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> |
| 1364 | <tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions. |
| 1365 | ParenListExprs don't have a predefined type and are used for late parsing. |
| 1366 | In the final AST, they can be met in template declarations. |
| 1367 | |
| 1368 | Given |
| 1369 | template<typename T> class X { |
| 1370 | void f() { |
| 1371 | X x(*this); |
| 1372 | int a = 0, b = 1; int i = (a, b); |
| 1373 | } |
| 1374 | }; |
| 1375 | parenListExpr() matches "*this" but NOT matches (a, b) because (a, b) |
| 1376 | has a predefined type and is a ParenExpr, not a ParenListExpr. |
| 1377 | </pre></td></tr> |
| 1378 | |
| 1379 | |
| 1380 | <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> |
| 1381 | <tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2]. |
| 1382 | |
| 1383 | Example: Matches __func__ |
| 1384 | printf("%s", __func__); |
| 1385 | </pre></td></tr> |
| 1386 | |
| 1387 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1388 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 1389 | <tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. |
| 1390 | |
| 1391 | Given |
| 1392 | return 1; |
| 1393 | returnStmt() |
| 1394 | matches 'return 1' |
| 1395 | </pre></td></tr> |
| 1396 | |
| 1397 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1398 | <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] | 1399 | <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. |
| 1400 | |
| 1401 | Given |
| 1402 | { ++a; } |
| 1403 | stmt() |
| 1404 | matches both the compound statement '{ ++a; }' and '++a'. |
| 1405 | </pre></td></tr> |
| 1406 | |
| 1407 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1408 | <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> |
| 1409 | <tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension). |
| 1410 | |
| 1411 | Example match: ({ int X = 4; X; }) |
| 1412 | int C = ({ int X = 4; X; }); |
| 1413 | </pre></td></tr> |
| 1414 | |
| 1415 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1416 | <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] | 1417 | <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). |
| 1418 | |
| 1419 | Example matches "abcd", L"abcd" |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 1420 | char *s = "abcd"; |
| 1421 | wchar_t *ws = L"abcd"; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1422 | </pre></td></tr> |
| 1423 | |
| 1424 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1425 | <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] | 1426 | <tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. |
| 1427 | |
| 1428 | Given |
| 1429 | template <int N> |
| 1430 | struct A { static const int n = N; }; |
| 1431 | struct B : public A<42> {}; |
| 1432 | substNonTypeTemplateParmExpr() |
| 1433 | matches "N" in the right-hand side of "static const int n = N;" |
| 1434 | </pre></td></tr> |
| 1435 | |
| 1436 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1437 | <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] | 1438 | <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. |
| 1439 | |
| 1440 | Given |
| 1441 | switch(a) { case 42: break; default: break; } |
| 1442 | switchCase() |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 1443 | matches 'case 42:' and 'default:'. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1444 | </pre></td></tr> |
| 1445 | |
| 1446 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1447 | <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] | 1448 | <tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. |
| 1449 | |
| 1450 | Given |
| 1451 | switch(a) { case 42: break; default: break; } |
| 1452 | switchStmt() |
| 1453 | matches 'switch(a)'. |
| 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_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] | 1458 | <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) |
| 1459 | |
| 1460 | Given |
| 1461 | Foo x = bar; |
| 1462 | int y = sizeof(x) + alignof(x); |
| 1463 | unaryExprOrTypeTraitExpr() |
| 1464 | matches sizeof(x) and alignof(x) |
| 1465 | </pre></td></tr> |
| 1466 | |
| 1467 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1468 | <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] | 1469 | <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. |
| 1470 | |
| 1471 | Example matches !a |
| 1472 | !a || b |
| 1473 | </pre></td></tr> |
| 1474 | |
| 1475 | |
Haojian Wu | 7751c92 | 2016-05-18 12:53:59 +0000 | [diff] [blame] | 1476 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unresolvedLookupExpr0')"><a name="unresolvedLookupExpr0Anchor">unresolvedLookupExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedLookupExpr.html">UnresolvedLookupExpr</a>>...</td></tr> |
| 1477 | <tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing |
| 1478 | but could not be resolved to a specific declaration. |
| 1479 | |
| 1480 | Given |
| 1481 | template<typename T> |
| 1482 | T foo() { T a; return a; } |
| 1483 | template<typename T> |
| 1484 | void bar() { |
| 1485 | foo<T>(); |
| 1486 | } |
| 1487 | unresolvedLookupExpr() |
| 1488 | matches foo<T>() </pre></td></tr> |
| 1489 | |
| 1490 | |
Shuai Wang | 72b56ed | 2018-08-12 17:34:36 +0000 | [diff] [blame] | 1491 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unresolvedMemberExpr0')"><a name="unresolvedMemberExpr0Anchor">unresolvedMemberExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html">UnresolvedMemberExpr</a>>...</td></tr> |
| 1492 | <tr><td colspan="4" class="doc" id="unresolvedMemberExpr0"><pre>Matches unresolved member expressions. |
| 1493 | |
| 1494 | Given |
| 1495 | struct X { |
| 1496 | template <class T> void f(); |
| 1497 | void g(); |
| 1498 | }; |
| 1499 | template <class T> void h() { X x; x.f<T>(); x.g(); } |
| 1500 | unresolvedMemberExpr() |
| 1501 | matches x.f<T> |
| 1502 | </pre></td></tr> |
| 1503 | |
| 1504 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1505 | <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] | 1506 | <tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. |
| 1507 | |
| 1508 | Example match: "foo"_suffix |
| 1509 | </pre></td></tr> |
| 1510 | |
| 1511 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1512 | <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] | 1513 | <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. |
| 1514 | |
| 1515 | Given |
| 1516 | while (true) {} |
| 1517 | whileStmt() |
| 1518 | matches 'while (true) {}'. |
| 1519 | </pre></td></tr> |
| 1520 | |
| 1521 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1522 | <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] | 1523 | <tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. |
| 1524 | |
| 1525 | Given |
| 1526 | template <typename T> struct C {}; |
| 1527 | C<int> c; |
| 1528 | templateArgument() |
| 1529 | matches 'int' in C<int>. |
| 1530 | </pre></td></tr> |
| 1531 | |
| 1532 | |
Haojian Wu | b33b02e | 2016-07-29 15:45:11 +0000 | [diff] [blame] | 1533 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>></td><td class="name" onclick="toggle('templateName0')"><a name="templateName0Anchor">templateName</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>>...</td></tr> |
| 1534 | <tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name. |
| 1535 | |
| 1536 | Given |
| 1537 | template <typename T> class X { }; |
| 1538 | X<int> xi; |
| 1539 | templateName() |
| 1540 | matches 'X' in X<int>. |
| 1541 | </pre></td></tr> |
| 1542 | |
| 1543 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1544 | <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] | 1545 | <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. |
| 1546 | </pre></td></tr> |
| 1547 | |
| 1548 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1549 | <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] | 1550 | <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. |
| 1551 | |
| 1552 | Given |
| 1553 | int a[] = { 2, 3 }; |
| 1554 | int b[4]; |
| 1555 | void f() { int c[a[0]]; } |
| 1556 | arrayType() |
| 1557 | matches "int a[]", "int b[4]" and "int c[a[0]]"; |
| 1558 | </pre></td></tr> |
| 1559 | |
| 1560 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1561 | <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] | 1562 | <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. |
| 1563 | |
| 1564 | Given |
| 1565 | _Atomic(int) i; |
| 1566 | atomicType() |
| 1567 | matches "_Atomic(int) i" |
| 1568 | </pre></td></tr> |
| 1569 | |
| 1570 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1571 | <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] | 1572 | <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. |
| 1573 | |
| 1574 | Given: |
| 1575 | auto n = 4; |
| 1576 | int v[] = { 2, 3 } |
| 1577 | for (auto i : v) { } |
| 1578 | autoType() |
| 1579 | matches "auto n" and "auto i" |
| 1580 | </pre></td></tr> |
| 1581 | |
| 1582 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1583 | <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] | 1584 | <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as |
| 1585 | "void (^)(int)". |
| 1586 | |
| 1587 | The pointee is always required to be a FunctionType. |
| 1588 | </pre></td></tr> |
| 1589 | |
| 1590 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1591 | <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] | 1592 | <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. |
| 1593 | |
| 1594 | Given |
| 1595 | struct A {}; |
| 1596 | A a; |
| 1597 | int b; |
| 1598 | float c; |
| 1599 | bool d; |
| 1600 | builtinType() |
| 1601 | matches "int b", "float c" and "bool d" |
| 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('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] | 1606 | <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. |
| 1607 | |
| 1608 | Given |
| 1609 | _Complex float f; |
| 1610 | complexType() |
| 1611 | matches "_Complex float f" |
| 1612 | </pre></td></tr> |
| 1613 | |
| 1614 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1615 | <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] | 1616 | <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. |
| 1617 | |
| 1618 | Given |
| 1619 | void() { |
| 1620 | int a[2]; |
| 1621 | int b[] = { 2, 3 }; |
| 1622 | int c[b[0]]; |
| 1623 | } |
| 1624 | constantArrayType() |
| 1625 | matches "int a[2]" |
| 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('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] | 1630 | <tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type |
| 1631 | Example matches i[] in declaration of f. |
| 1632 | (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) |
| 1633 | Example matches i[1]. |
| 1634 | (matcher = expr(hasType(decayedType(hasDecayedType(pointerType()))))) |
| 1635 | void f(int i[]) { |
| 1636 | i[1] = 0; |
| 1637 | } |
| 1638 | </pre></td></tr> |
| 1639 | |
| 1640 | |
Jonas Toth | acf8367 | 2018-07-26 13:02:05 +0000 | [diff] [blame] | 1641 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('decltypeType0')"><a name="decltypeType0Anchor">decltypeType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>>...</td></tr> |
| 1642 | <tr><td colspan="4" class="doc" id="decltypeType0"><pre>Matches types nodes representing C++11 decltype(<expr>) types. |
| 1643 | |
| 1644 | Given: |
| 1645 | short i = 1; |
| 1646 | int j = 42; |
| 1647 | decltype(i + j) result = i + j; |
Shuai Wang | 72b56ed | 2018-08-12 17:34:36 +0000 | [diff] [blame] | 1648 | decltypeType() |
Jonas Toth | acf8367 | 2018-07-26 13:02:05 +0000 | [diff] [blame] | 1649 | matches "decltype(i + j)" |
| 1650 | </pre></td></tr> |
| 1651 | |
| 1652 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1653 | <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] | 1654 | <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. |
| 1655 | |
| 1656 | Given |
| 1657 | template<typename T, int Size> |
| 1658 | class array { |
| 1659 | T data[Size]; |
| 1660 | }; |
| 1661 | dependentSizedArrayType |
| 1662 | matches "T data[Size]" |
| 1663 | </pre></td></tr> |
| 1664 | |
| 1665 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1666 | <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] | 1667 | <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a |
| 1668 | qualified name. |
| 1669 | |
| 1670 | Given |
| 1671 | namespace N { |
| 1672 | namespace M { |
| 1673 | class D {}; |
| 1674 | } |
| 1675 | } |
| 1676 | class C {}; |
| 1677 | |
| 1678 | class C c; |
| 1679 | N::M::D d; |
| 1680 | |
| 1681 | elaboratedType() matches the type of the variable declarations of both |
| 1682 | c and d. |
| 1683 | </pre></td></tr> |
| 1684 | |
| 1685 | |
Haojian Wu | e775de8 | 2016-06-30 07:50:01 +0000 | [diff] [blame] | 1686 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('enumType0')"><a name="enumType0Anchor">enumType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>...</td></tr> |
| 1687 | <tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types. |
| 1688 | |
| 1689 | Given |
| 1690 | enum C { Green }; |
Aaron Ballman | 5c57434 | 2016-07-06 18:25:16 +0000 | [diff] [blame] | 1691 | enum class S { Red }; |
Haojian Wu | e775de8 | 2016-06-30 07:50:01 +0000 | [diff] [blame] | 1692 | |
| 1693 | C c; |
| 1694 | S s; |
| 1695 | |
| 1696 | enumType() matches the type of the variable declarations of both c and |
| 1697 | s. |
| 1698 | </pre></td></tr> |
| 1699 | |
| 1700 | |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 1701 | <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> |
| 1702 | <tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes. |
| 1703 | |
| 1704 | Given |
| 1705 | int (*f)(int); |
| 1706 | void g(); |
| 1707 | functionProtoType() |
| 1708 | matches "int (*f)(int)" and the type of "g" in C++ mode. |
| 1709 | In C mode, "g" is not matched because it does not contain a prototype. |
| 1710 | </pre></td></tr> |
| 1711 | |
| 1712 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1713 | <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] | 1714 | <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. |
| 1715 | |
| 1716 | Given |
| 1717 | int (*f)(int); |
| 1718 | void g(); |
| 1719 | functionType() |
| 1720 | matches "int (*f)(int)" and the type of "g". |
| 1721 | </pre></td></tr> |
| 1722 | |
| 1723 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1724 | <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] | 1725 | <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. |
| 1726 | |
| 1727 | Given |
| 1728 | int a[] = { 2, 3 }; |
| 1729 | int b[42]; |
| 1730 | void f(int c[]) { int d[a[0]]; }; |
| 1731 | incompleteArrayType() |
| 1732 | matches "int a[]" and "int c[]" |
| 1733 | </pre></td></tr> |
| 1734 | |
| 1735 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1736 | <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] | 1737 | <tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types. |
| 1738 | |
| 1739 | Example matches S s, but not S<T> s. |
| 1740 | (matcher = parmVarDecl(hasType(injectedClassNameType()))) |
| 1741 | template <typename T> struct S { |
| 1742 | void f(S s); |
| 1743 | void g(S<T> s); |
| 1744 | }; |
| 1745 | </pre></td></tr> |
| 1746 | |
| 1747 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1748 | <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] | 1749 | <tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. |
| 1750 | |
| 1751 | Given: |
| 1752 | int *a; |
| 1753 | int &b = *a; |
| 1754 | int &&c = 1; |
| 1755 | auto &d = b; |
| 1756 | auto &&e = c; |
| 1757 | auto &&f = 2; |
| 1758 | int g = 5; |
| 1759 | |
| 1760 | lValueReferenceType() matches the types of b, d, and e. e is |
| 1761 | matched since the type is deduced as int& by reference collapsing rules. |
| 1762 | </pre></td></tr> |
| 1763 | |
| 1764 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1765 | <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] | 1766 | <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. |
| 1767 | Given |
| 1768 | struct A { int i; } |
| 1769 | A::* ptr = A::i; |
| 1770 | memberPointerType() |
| 1771 | matches "A::* ptr" |
| 1772 | </pre></td></tr> |
| 1773 | |
| 1774 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1775 | <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] | 1776 | <tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from |
| 1777 | a pointer type, despite being syntactically similar. |
| 1778 | |
| 1779 | Given |
| 1780 | int *a; |
| 1781 | |
| 1782 | @interface Foo |
| 1783 | @end |
| 1784 | Foo *f; |
| 1785 | pointerType() |
| 1786 | matches "Foo *f", but does not match "int *a". |
| 1787 | </pre></td></tr> |
| 1788 | |
| 1789 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1790 | <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] | 1791 | <tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. |
| 1792 | |
| 1793 | Given |
| 1794 | int (*ptr_to_array)[4]; |
| 1795 | int *array_of_ptrs[4]; |
| 1796 | |
| 1797 | varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not |
| 1798 | array_of_ptrs. |
| 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_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] | 1803 | <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer |
| 1804 | types. |
| 1805 | |
| 1806 | Given |
| 1807 | int *a; |
| 1808 | int &b = *a; |
| 1809 | int c = 5; |
| 1810 | |
| 1811 | @interface Foo |
| 1812 | @end |
| 1813 | Foo *f; |
| 1814 | pointerType() |
| 1815 | matches "int *a", but does not match "Foo *f". |
| 1816 | </pre></td></tr> |
| 1817 | |
| 1818 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1819 | <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] | 1820 | <tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. |
| 1821 | |
| 1822 | Given: |
| 1823 | int *a; |
| 1824 | int &b = *a; |
| 1825 | int &&c = 1; |
| 1826 | auto &d = b; |
| 1827 | auto &&e = c; |
| 1828 | auto &&f = 2; |
| 1829 | int g = 5; |
| 1830 | |
| 1831 | rValueReferenceType() matches the types of c and f. e is not |
| 1832 | matched as it is deduced to int& by reference collapsing rules. |
| 1833 | </pre></td></tr> |
| 1834 | |
| 1835 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1836 | <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] | 1837 | <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). |
| 1838 | |
| 1839 | Given |
| 1840 | class C {}; |
| 1841 | struct S {}; |
| 1842 | |
| 1843 | C c; |
| 1844 | S s; |
| 1845 | |
| 1846 | recordType() matches the type of the variable declarations of both c |
| 1847 | and s. |
| 1848 | </pre></td></tr> |
| 1849 | |
| 1850 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1851 | <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] | 1852 | <tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. |
| 1853 | |
| 1854 | Given |
| 1855 | int *a; |
| 1856 | int &b = *a; |
| 1857 | int &&c = 1; |
| 1858 | auto &d = b; |
| 1859 | auto &&e = c; |
| 1860 | auto &&f = 2; |
| 1861 | int g = 5; |
| 1862 | |
| 1863 | referenceType() matches the types of b, c, d, e, and f. |
| 1864 | </pre></td></tr> |
| 1865 | |
| 1866 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1867 | <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] | 1868 | <tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a |
| 1869 | template type parameter. |
| 1870 | |
| 1871 | Given |
| 1872 | template <typename T> |
| 1873 | void F(T t) { |
| 1874 | int i = 1 + t; |
| 1875 | } |
| 1876 | |
| 1877 | substTemplateTypeParmType() matches the type of 't' but not '1' |
| 1878 | </pre></td></tr> |
| 1879 | |
| 1880 | |
Manuel Klimek | 696e505 | 2017-08-02 13:04:44 +0000 | [diff] [blame] | 1881 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('tagType0')"><a name="tagType0Anchor">tagType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>...</td></tr> |
| 1882 | <tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types). |
| 1883 | |
| 1884 | Given |
| 1885 | enum E {}; |
| 1886 | class C {}; |
| 1887 | |
| 1888 | E e; |
| 1889 | C c; |
| 1890 | |
| 1891 | tagType() matches the type of the variable declarations of both e |
| 1892 | and c. |
| 1893 | </pre></td></tr> |
| 1894 | |
| 1895 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1896 | <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] | 1897 | <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. |
| 1898 | |
| 1899 | Given |
| 1900 | template <typename T> |
| 1901 | class C { }; |
| 1902 | |
| 1903 | template class C<int>; A |
| 1904 | C<char> var; B |
| 1905 | |
| 1906 | templateSpecializationType() matches the type of the explicit |
| 1907 | instantiation in A and the type of the variable declaration in B. |
| 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_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] | 1912 | <tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types. |
| 1913 | |
| 1914 | Example matches T, but not int. |
| 1915 | (matcher = templateTypeParmType()) |
| 1916 | template <typename T> void f(int i); |
| 1917 | </pre></td></tr> |
| 1918 | |
| 1919 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1920 | <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] | 1921 | <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. |
| 1922 | </pre></td></tr> |
| 1923 | |
| 1924 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1925 | <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] | 1926 | <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. |
| 1927 | |
| 1928 | Given |
| 1929 | typedef int X; |
| 1930 | typedefType() |
| 1931 | matches "typedef int X" |
| 1932 | </pre></td></tr> |
| 1933 | |
| 1934 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1935 | <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] | 1936 | <tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. |
| 1937 | |
| 1938 | Given: |
| 1939 | typedef __underlying_type(T) type; |
| 1940 | unaryTransformType() |
| 1941 | matches "__underlying_type(T)" |
| 1942 | </pre></td></tr> |
| 1943 | |
| 1944 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 1945 | <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] | 1946 | <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an |
| 1947 | integer-constant-expression. |
| 1948 | |
| 1949 | Given |
| 1950 | void f() { |
| 1951 | int a[] = { 2, 3 } |
| 1952 | int b[42]; |
| 1953 | int c[a[0]]; |
| 1954 | } |
| 1955 | variableArrayType() |
| 1956 | matches "int c[a[0]]" |
| 1957 | </pre></td></tr> |
| 1958 | |
Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 1959 | <!--END_DECL_MATCHERS --> |
| 1960 | </table> |
| 1961 | |
| 1962 | <!-- ======================================================================= --> |
| 1963 | <h2 id="narrowing-matchers">Narrowing Matchers</h2> |
| 1964 | <!-- ======================================================================= --> |
| 1965 | |
| 1966 | <p>Narrowing matchers match certain attributes on the current node, thus |
| 1967 | narrowing down the set of nodes of the current type to match on.</p> |
| 1968 | |
| 1969 | <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) |
| 1970 | which allow users to create more powerful match expressions.</p> |
| 1971 | |
| 1972 | <table> |
| 1973 | <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] | 1974 | <!-- START_NARROWING_MATCHERS --> |
| 1975 | |
| 1976 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 1977 | <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. |
| 1978 | |
| 1979 | Usable as: Any Matcher |
| 1980 | </pre></td></tr> |
| 1981 | |
| 1982 | |
| 1983 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 1984 | <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. |
| 1985 | |
| 1986 | Usable as: Any Matcher |
| 1987 | </pre></td></tr> |
| 1988 | |
| 1989 | |
| 1990 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> |
| 1991 | <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. |
| 1992 | |
| 1993 | Useful when another matcher requires a child matcher, but there's no |
| 1994 | additional constraint. This will often be used with an explicit conversion |
| 1995 | to an internal::Matcher<> type such as TypeMatcher. |
| 1996 | |
| 1997 | Example: DeclarationMatcher(anything()) matches all declarations, e.g., |
| 1998 | "int* p" and "void f()" in |
| 1999 | int* p; |
| 2000 | void f(); |
| 2001 | |
| 2002 | Usable as: Any Matcher |
| 2003 | </pre></td></tr> |
| 2004 | |
| 2005 | |
| 2006 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> |
| 2007 | <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. |
| 2008 | |
| 2009 | Example matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) |
| 2010 | class X {}; |
| 2011 | class Y {}; |
| 2012 | |
| 2013 | Usable as: Any Matcher |
| 2014 | </pre></td></tr> |
| 2015 | |
| 2016 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2017 | <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] | 2018 | <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or |
| 2019 | unary). |
| 2020 | |
| 2021 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 2022 | !(a || b) |
| 2023 | </pre></td></tr> |
| 2024 | |
| 2025 | |
Alexander Kornienko | 395ab2e | 2018-04-30 18:12:15 +0000 | [diff] [blame] | 2026 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('isAssignmentOperator0')"><a name="isAssignmentOperator0Anchor">isAssignmentOperator</a></td><td></td></tr> |
Peter Szecsi | fff11db | 2018-03-27 12:11:46 +0000 | [diff] [blame] | 2027 | <tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators. |
| 2028 | |
| 2029 | Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) |
| 2030 | if (a == b) |
| 2031 | a += b; |
| 2032 | |
Alexander Kornienko | 395ab2e | 2018-04-30 18:12:15 +0000 | [diff] [blame] | 2033 | Example 2: matches s1 = s2 |
| 2034 | (matcher = cxxOperatorCallExpr(isAssignmentOperator())) |
| 2035 | struct S { S& operator=(const S&); }; |
Peter Szecsi | fff11db | 2018-03-27 12:11:46 +0000 | [diff] [blame] | 2036 | void x() { S s1, s2; s1 = s2; }) |
| 2037 | </pre></td></tr> |
| 2038 | |
| 2039 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 2040 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals5')"><a name="equals5Anchor">equals</a></td><td>bool Value</td></tr> |
| 2041 | <tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr> |
| 2042 | |
| 2043 | |
| 2044 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>const ValueT Value</td></tr> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2045 | <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2046 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2047 | Given |
| 2048 | f('false, 3.14, 42); |
| 2049 | characterLiteral(equals(0)) |
| 2050 | matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| 2051 | match false |
| 2052 | floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| 2053 | match 3.14 |
| 2054 | integerLiteral(equals(42)) |
| 2055 | matches 42 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2056 | |
Clement Courbet | 43bdba4 | 2017-07-11 15:45:22 +0000 | [diff] [blame] | 2057 | Note that you cannot directly match a negative numeric literal because the |
| 2058 | minus sign is not part of the literal: It is a unary operator whose operand |
| 2059 | is the positive numeric literal. Instead, you must use a unaryOperator() |
| 2060 | matcher to match the minus sign: |
| 2061 | |
| 2062 | unaryOperator(hasOperatorName("-"), |
| 2063 | hasUnaryOperand(integerLiteral(equals(13)))) |
| 2064 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2065 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2066 | 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] | 2067 | </pre></td></tr> |
| 2068 | |
| 2069 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2070 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals11')"><a name="equals11Anchor">equals</a></td><td>double Value</td></tr> |
| 2071 | <tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr> |
| 2072 | |
| 2073 | |
| 2074 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals8')"><a name="equals8Anchor">equals</a></td><td>unsigned Value</td></tr> |
| 2075 | <tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr> |
| 2076 | |
| 2077 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2078 | <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] | 2079 | <tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. |
| 2080 | |
| 2081 | Given |
| 2082 | try { |
| 2083 | ... |
| 2084 | } catch (int) { |
| 2085 | ... |
| 2086 | } catch (...) { |
| 2087 | ... |
| 2088 | } |
| 2089 | endcode |
| 2090 | cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). |
| 2091 | </pre></td></tr> |
| 2092 | |
| 2093 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2094 | <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] | 2095 | <tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has |
| 2096 | a specific number of arguments (including absent default arguments). |
| 2097 | |
| 2098 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 2099 | void f(int x, int y); |
| 2100 | f(0, 0); |
| 2101 | </pre></td></tr> |
| 2102 | |
| 2103 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2104 | <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] | 2105 | <tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. |
| 2106 | </pre></td></tr> |
| 2107 | |
| 2108 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 2109 | <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> |
| 2110 | <tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires |
| 2111 | zero initialization. |
| 2112 | |
| 2113 | Given |
| 2114 | void foo() { |
| 2115 | struct point { double x; double y; }; |
| 2116 | point pt[2] = { { 1.0, 2.0 } }; |
| 2117 | } |
| 2118 | initListExpr(has(cxxConstructExpr(requiresZeroInitialization())) |
| 2119 | will match the implicit array filler for pt[1]. |
| 2120 | </pre></td></tr> |
| 2121 | |
| 2122 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2123 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 2124 | <tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. |
| 2125 | |
| 2126 | Given |
| 2127 | struct S { |
| 2128 | S(); #1 |
| 2129 | S(const S &); #2 |
| 2130 | S(S &&); #3 |
| 2131 | }; |
| 2132 | cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. |
| 2133 | </pre></td></tr> |
| 2134 | |
| 2135 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2136 | <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] | 2137 | <tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. |
| 2138 | |
| 2139 | Given |
| 2140 | struct S { |
| 2141 | S(); #1 |
| 2142 | S(const S &); #2 |
| 2143 | S(S &&); #3 |
| 2144 | }; |
| 2145 | cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. |
| 2146 | </pre></td></tr> |
| 2147 | |
| 2148 | |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 2149 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isDelegatingConstructor0')"><a name="isDelegatingConstructor0Anchor">isDelegatingConstructor</a></td><td></td></tr> |
| 2150 | <tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor. |
| 2151 | |
| 2152 | Given |
| 2153 | struct S { |
| 2154 | S(); #1 |
| 2155 | S(int) {} #2 |
| 2156 | S(S &&) : S() {} #3 |
| 2157 | }; |
| 2158 | S::S() : S(0) {} #4 |
| 2159 | cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not |
| 2160 | #1 or #2. |
| 2161 | </pre></td></tr> |
| 2162 | |
| 2163 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2164 | <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] | 2165 | <tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with |
| 2166 | the explicit keyword. |
| 2167 | |
| 2168 | Given |
| 2169 | struct S { |
| 2170 | S(int); #1 |
| 2171 | explicit S(double); #2 |
| 2172 | operator int(); #3 |
| 2173 | explicit operator bool(); #4 |
| 2174 | }; |
| 2175 | cxxConstructorDecl(isExplicit()) will match #2, but not #1. |
| 2176 | cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| 2177 | </pre></td></tr> |
| 2178 | |
| 2179 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2180 | <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] | 2181 | <tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. |
| 2182 | |
| 2183 | Given |
| 2184 | struct S { |
| 2185 | S(); #1 |
| 2186 | S(const S &); #2 |
| 2187 | S(S &&); #3 |
| 2188 | }; |
| 2189 | cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. |
| 2190 | </pre></td></tr> |
| 2191 | |
| 2192 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2193 | <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] | 2194 | <tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with |
| 2195 | the explicit keyword. |
| 2196 | |
| 2197 | Given |
| 2198 | struct S { |
| 2199 | S(int); #1 |
| 2200 | explicit S(double); #2 |
| 2201 | operator int(); #3 |
| 2202 | explicit operator bool(); #4 |
| 2203 | }; |
| 2204 | cxxConstructorDecl(isExplicit()) will match #2, but not #1. |
| 2205 | cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| 2206 | </pre></td></tr> |
| 2207 | |
| 2208 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2209 | <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] | 2210 | <tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as |
| 2211 | opposed to a member. |
| 2212 | |
| 2213 | Given |
| 2214 | struct B {}; |
| 2215 | struct D : B { |
| 2216 | int I; |
| 2217 | D(int i) : I(i) {} |
| 2218 | }; |
| 2219 | struct E : B { |
| 2220 | E() : B() {} |
| 2221 | }; |
| 2222 | cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) |
| 2223 | will match E(), but not match D(int). |
| 2224 | </pre></td></tr> |
| 2225 | |
| 2226 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2227 | <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] | 2228 | <tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as |
| 2229 | opposed to a base. |
| 2230 | |
| 2231 | Given |
| 2232 | struct B {}; |
| 2233 | struct D : B { |
| 2234 | int I; |
| 2235 | D(int i) : I(i) {} |
| 2236 | }; |
| 2237 | struct E : B { |
| 2238 | E() : B() {} |
| 2239 | }; |
| 2240 | cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) |
| 2241 | will match D(int), but not match E(). |
| 2242 | </pre></td></tr> |
| 2243 | |
| 2244 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2245 | <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] | 2246 | <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in |
| 2247 | code (as opposed to implicitly added by the compiler). |
| 2248 | |
| 2249 | Given |
| 2250 | struct Foo { |
| 2251 | Foo() { } |
| 2252 | Foo(int) : foo_("A") { } |
| 2253 | string foo_; |
| 2254 | }; |
| 2255 | cxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) |
| 2256 | will match Foo(int), but not Foo() |
| 2257 | </pre></td></tr> |
| 2258 | |
| 2259 | |
Shuai Wang | e0248ae | 2018-09-17 18:48:43 +0000 | [diff] [blame] | 2260 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>></td><td class="name" onclick="toggle('isArrow2')"><a name="isArrow2Anchor">isArrow</a></td><td></td></tr> |
| 2261 | <tr><td colspan="4" class="doc" id="isArrow2"><pre>Matches member expressions that are called with '->' as opposed |
| 2262 | to '.'. |
| 2263 | |
| 2264 | Member calls on the implicit this pointer match as called with '->'. |
| 2265 | |
| 2266 | Given |
| 2267 | class Y { |
| 2268 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 2269 | template <class T> void f() { this->f<T>(); f<T>(); } |
| 2270 | int a; |
| 2271 | static int b; |
| 2272 | }; |
| 2273 | template <class T> |
| 2274 | class Z { |
| 2275 | void x() { this->m; } |
| 2276 | }; |
| 2277 | memberExpr(isArrow()) |
| 2278 | matches this->x, x, y.x, a, this->b |
| 2279 | cxxDependentScopeMemberExpr(isArrow()) |
| 2280 | matches this->m |
| 2281 | unresolvedMemberExpr(isArrow()) |
| 2282 | matches this->f<T>, f<T> |
| 2283 | </pre></td></tr> |
| 2284 | |
| 2285 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2286 | <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] | 2287 | <tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. |
| 2288 | |
| 2289 | Given |
| 2290 | struct A { |
| 2291 | void foo() const; |
| 2292 | void bar(); |
| 2293 | }; |
| 2294 | |
| 2295 | cxxMethodDecl(isConst()) matches A::foo() but not A::bar() |
| 2296 | </pre></td></tr> |
| 2297 | |
| 2298 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2299 | <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] | 2300 | <tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment |
| 2301 | operator. |
| 2302 | |
| 2303 | Given |
| 2304 | struct A { |
| 2305 | A &operator=(const A &); |
| 2306 | A &operator=(A &&); |
| 2307 | }; |
| 2308 | |
| 2309 | cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not |
| 2310 | the second one. |
| 2311 | </pre></td></tr> |
| 2312 | |
| 2313 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2314 | <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] | 2315 | <tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. |
| 2316 | |
| 2317 | Given: |
| 2318 | class A final {}; |
| 2319 | |
| 2320 | struct B { |
| 2321 | virtual void f(); |
| 2322 | }; |
| 2323 | |
| 2324 | struct C : B { |
| 2325 | void f() final; |
| 2326 | }; |
| 2327 | matches A and C::f, but not B, C, or B::f |
| 2328 | </pre></td></tr> |
| 2329 | |
| 2330 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2331 | <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] | 2332 | <tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment |
| 2333 | operator. |
| 2334 | |
| 2335 | Given |
Aaron Ballman | a681151 | 2016-01-23 17:49:18 +0000 | [diff] [blame] | 2336 | struct A { |
| 2337 | A &operator=(const A &); |
| 2338 | A &operator=(A &&); |
| 2339 | }; |
| 2340 | |
| 2341 | cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not |
| 2342 | the first one. |
Aaron Ballman | 31bde87 | 2016-01-22 22:37:09 +0000 | [diff] [blame] | 2343 | </pre></td></tr> |
| 2344 | |
| 2345 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2346 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 2347 | <tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. |
| 2348 | |
| 2349 | Given |
| 2350 | class A { |
| 2351 | public: |
| 2352 | virtual void x(); |
| 2353 | }; |
| 2354 | class B : public A { |
| 2355 | public: |
| 2356 | virtual void x(); |
| 2357 | }; |
| 2358 | matches B::x |
| 2359 | </pre></td></tr> |
| 2360 | |
| 2361 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2362 | <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] | 2363 | <tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. |
| 2364 | |
| 2365 | Given |
| 2366 | class A { |
| 2367 | public: |
| 2368 | virtual void x() = 0; |
| 2369 | }; |
| 2370 | matches A::x |
| 2371 | </pre></td></tr> |
| 2372 | |
| 2373 | |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 2374 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isUserProvided0')"><a name="isUserProvided0Anchor">isUserProvided</a></td><td></td></tr> |
| 2375 | <tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided. |
| 2376 | |
| 2377 | Given |
| 2378 | struct S { |
| 2379 | S(); #1 |
| 2380 | S(const S &) = default; #2 |
| 2381 | S(S &&) = delete; #3 |
| 2382 | }; |
| 2383 | cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3. |
| 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_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] | 2388 | <tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. |
| 2389 | |
| 2390 | Given |
| 2391 | class A { |
| 2392 | public: |
| 2393 | virtual void x(); |
| 2394 | }; |
| 2395 | matches A::x |
| 2396 | </pre></td></tr> |
| 2397 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2398 | |
| 2399 | <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] | 2400 | <tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual". |
| 2401 | |
| 2402 | Given |
| 2403 | class A { |
| 2404 | public: |
| 2405 | virtual void x(); |
| 2406 | }; |
| 2407 | class B : public A { |
| 2408 | public: |
| 2409 | void x(); |
| 2410 | }; |
| 2411 | matches A::x but not B::x |
| 2412 | </pre></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2413 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2414 | |
Adam Balogh | da488a6 | 2017-11-23 12:43:20 +0000 | [diff] [blame] | 2415 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('isArray0')"><a name="isArray0Anchor">isArray</a></td><td></td></tr> |
| 2416 | <tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions. |
| 2417 | |
| 2418 | Given: |
| 2419 | MyClass *p1 = new MyClass[10]; |
| 2420 | cxxNewExpr(isArray()) |
| 2421 | matches the expression 'new MyClass[10]'. |
| 2422 | </pre></td></tr> |
| 2423 | |
| 2424 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2425 | <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] | 2426 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. |
| 2427 | |
| 2428 | Matches overloaded operator names specified in strings without the |
| 2429 | "operator" prefix: e.g. "<<". |
| 2430 | |
| 2431 | Given: |
| 2432 | class A { int operator*(); }; |
| 2433 | const A &operator<<(const A &a, const A &b); |
| 2434 | A a; |
| 2435 | a << a; <-- This matches |
| 2436 | |
| 2437 | cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the |
| 2438 | specified line and |
| 2439 | cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) |
| 2440 | matches the declaration of A. |
| 2441 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2442 | 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] | 2443 | </pre></td></tr> |
| 2444 | |
| 2445 | |
Alexander Kornienko | 395ab2e | 2018-04-30 18:12:15 +0000 | [diff] [blame] | 2446 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('isAssignmentOperator1')"><a name="isAssignmentOperator1Anchor">isAssignmentOperator</a></td><td></td></tr> |
Peter Szecsi | fff11db | 2018-03-27 12:11:46 +0000 | [diff] [blame] | 2447 | <tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators. |
| 2448 | |
| 2449 | Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) |
| 2450 | if (a == b) |
| 2451 | a += b; |
| 2452 | |
Alexander Kornienko | 395ab2e | 2018-04-30 18:12:15 +0000 | [diff] [blame] | 2453 | Example 2: matches s1 = s2 |
| 2454 | (matcher = cxxOperatorCallExpr(isAssignmentOperator())) |
| 2455 | struct S { S& operator=(const S&); }; |
Peter Szecsi | fff11db | 2018-03-27 12:11:46 +0000 | [diff] [blame] | 2456 | void x() { S s1, s2; s1 = s2; }) |
| 2457 | </pre></td></tr> |
| 2458 | |
| 2459 | |
Aaron Ballman | 813e36c | 2017-11-29 21:21:51 +0000 | [diff] [blame] | 2460 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('hasDefinition0')"><a name="hasDefinition0Anchor">hasDefinition</a></td><td></td></tr> |
| 2461 | <tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined. |
| 2462 | |
| 2463 | Example matches x (matcher = cxxRecordDecl(hasDefinition())) |
| 2464 | class x {}; |
| 2465 | class y; |
| 2466 | </pre></td></tr> |
| 2467 | |
| 2468 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2469 | <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] | 2470 | <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). |
| 2471 | </pre></td></tr> |
| 2472 | |
| 2473 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2474 | <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] | 2475 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or |
| 2476 | static member variable template instantiations. |
| 2477 | |
| 2478 | Given |
| 2479 | template<typename T> void A(T t) { } |
| 2480 | template<> void A(int N) { } |
| 2481 | functionDecl(isExplicitTemplateSpecialization()) |
| 2482 | matches the specialization A<int>(). |
| 2483 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2484 | 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] | 2485 | </pre></td></tr> |
| 2486 | |
| 2487 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2488 | <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] | 2489 | <tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. |
| 2490 | |
| 2491 | Given: |
| 2492 | class A final {}; |
| 2493 | |
| 2494 | struct B { |
| 2495 | virtual void f(); |
| 2496 | }; |
| 2497 | |
| 2498 | struct C : B { |
| 2499 | void f() final; |
| 2500 | }; |
| 2501 | matches A and C::f, but not B, C, or B::f |
| 2502 | </pre></td></tr> |
| 2503 | |
| 2504 | |
Samuel Benzaquen | 49385c7 | 2016-06-28 14:08:56 +0000 | [diff] [blame] | 2505 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isLambda0')"><a name="isLambda0Anchor">isLambda</a></td><td></td></tr> |
| 2506 | <tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions. |
| 2507 | |
| 2508 | Given: |
| 2509 | auto x = []{}; |
| 2510 | |
| 2511 | cxxRecordDecl(isLambda()) matches the implicit class declaration of |
| 2512 | decltype(x) |
| 2513 | </pre></td></tr> |
| 2514 | |
| 2515 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2516 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 2517 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for |
| 2518 | isSameOrDerivedFrom(hasName(...)). |
| 2519 | </pre></td></tr> |
| 2520 | |
| 2521 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2522 | <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] | 2523 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static |
| 2524 | member variable template instantiations. |
| 2525 | |
| 2526 | Given |
| 2527 | template <typename T> class X {}; class A {}; X<A> x; |
| 2528 | or |
| 2529 | template <typename T> class X {}; class A {}; template class X<A>; |
Eric Liu | 09ee48e | 2018-02-21 14:22:42 +0000 | [diff] [blame] | 2530 | or |
| 2531 | template <typename T> class X {}; class A {}; extern template class X<A>; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2532 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 2533 | matches the template instantiation of X<A>. |
| 2534 | |
| 2535 | But given |
| 2536 | template <typename T> class X {}; class A {}; |
| 2537 | template <> class X<A> {}; X<A> x; |
| 2538 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 2539 | does not match, as X<A> is an explicit template specialization. |
| 2540 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2541 | 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] | 2542 | </pre></td></tr> |
| 2543 | |
| 2544 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2545 | <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] | 2546 | <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has |
| 2547 | a specific number of arguments (including absent default arguments). |
| 2548 | |
| 2549 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 2550 | void f(int x, int y); |
| 2551 | f(0, 0); |
| 2552 | </pre></td></tr> |
| 2553 | |
| 2554 | |
Etienne Bergeron | 75e5272 | 2016-05-13 19:36:55 +0000 | [diff] [blame] | 2555 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>></td><td class="name" onclick="toggle('hasCastKind0')"><a name="hasCastKind0Anchor">hasCastKind</a></td><td>CastKind Kind</td></tr> |
| 2556 | <tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind. |
| 2557 | |
| 2558 | Example: matches the implicit cast around 0 |
| 2559 | (matcher = castExpr(hasCastKind(CK_NullToPointer))) |
| 2560 | int *p = 0; |
| 2561 | </pre></td></tr> |
| 2562 | |
| 2563 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 2564 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals4')"><a name="equals4Anchor">equals</a></td><td>bool Value</td></tr> |
| 2565 | <tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr> |
| 2566 | |
| 2567 | |
| 2568 | <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>const ValueT Value</td></tr> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2569 | <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2570 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2571 | Given |
| 2572 | f('false, 3.14, 42); |
| 2573 | characterLiteral(equals(0)) |
| 2574 | matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| 2575 | match false |
| 2576 | floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| 2577 | match 3.14 |
| 2578 | integerLiteral(equals(42)) |
| 2579 | matches 42 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2580 | |
Clement Courbet | 43bdba4 | 2017-07-11 15:45:22 +0000 | [diff] [blame] | 2581 | Note that you cannot directly match a negative numeric literal because the |
| 2582 | minus sign is not part of the literal: It is a unary operator whose operand |
| 2583 | is the positive numeric literal. Instead, you must use a unaryOperator() |
| 2584 | matcher to match the minus sign: |
| 2585 | |
| 2586 | unaryOperator(hasOperatorName("-"), |
| 2587 | hasUnaryOperand(integerLiteral(equals(13)))) |
| 2588 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2589 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2590 | 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] | 2591 | </pre></td></tr> |
| 2592 | |
| 2593 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2594 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals10')"><a name="equals10Anchor">equals</a></td><td>double Value</td></tr> |
| 2595 | <tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr> |
| 2596 | |
| 2597 | |
| 2598 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals7')"><a name="equals7Anchor">equals</a></td><td>unsigned Value</td></tr> |
| 2599 | <tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr> |
| 2600 | |
| 2601 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2602 | <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] | 2603 | <tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. |
| 2604 | |
| 2605 | Given |
| 2606 | template<typename T> struct C {}; |
| 2607 | C<int> c; |
| 2608 | classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
| 2609 | matches C<int>. |
| 2610 | </pre></td></tr> |
| 2611 | |
| 2612 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2613 | <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] | 2614 | <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of |
| 2615 | child statements. |
| 2616 | |
| 2617 | Example: Given |
| 2618 | { for (;;) {} } |
| 2619 | compoundStmt(statementCountIs(0))) |
| 2620 | matches '{}' |
| 2621 | but does not match the outer compound statement. |
| 2622 | </pre></td></tr> |
| 2623 | |
| 2624 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2625 | <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> |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 2626 | <tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2627 | |
| 2628 | Given |
| 2629 | int a[42]; |
| 2630 | int b[2 * 21]; |
| 2631 | int c[41], d[43]; |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 2632 | char *s = "abcd"; |
| 2633 | wchar_t *ws = L"abcd"; |
| 2634 | char *w = "a"; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2635 | constantArrayType(hasSize(42)) |
| 2636 | matches "int a[42]" and "int b[2 * 21]" |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 2637 | stringLiteral(hasSize(4)) |
| 2638 | matches "abcd", L"abcd" |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2639 | </pre></td></tr> |
| 2640 | |
| 2641 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2642 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 2643 | <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of |
| 2644 | declarations. |
| 2645 | |
| 2646 | Example: Given |
| 2647 | int a, b; |
| 2648 | int c; |
| 2649 | int d = 2, e; |
| 2650 | declCountIs(2) |
| 2651 | matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. |
| 2652 | </pre></td></tr> |
| 2653 | |
| 2654 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2655 | <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] | 2656 | <tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. |
| 2657 | |
| 2658 | Matches a node if it equals the node previously bound to ID. |
| 2659 | |
| 2660 | Given |
| 2661 | class X { int a; int b; }; |
| 2662 | cxxRecordDecl( |
| 2663 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 2664 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 2665 | matches the class X, as a and b have the same type. |
| 2666 | |
| 2667 | Note that when multiple matches are involved via forEach* matchers, |
| 2668 | equalsBoundNodes acts as a filter. |
| 2669 | For example: |
| 2670 | compoundStmt( |
| 2671 | forEachDescendant(varDecl().bind("d")), |
| 2672 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 2673 | will trigger a match for each combination of variable declaration |
| 2674 | and reference to that variable declaration within a compound statement. |
| 2675 | </pre></td></tr> |
| 2676 | |
| 2677 | |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 2678 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('equalsNode0')"><a name="equalsNode0Anchor">equalsNode</a></td><td>const Decl* Other</td></tr> |
| 2679 | <tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node. |
| 2680 | |
| 2681 | Decl has pointer identity in the AST. |
| 2682 | </pre></td></tr> |
| 2683 | |
| 2684 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2685 | <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] | 2686 | <tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. |
| 2687 | |
| 2688 | Given |
| 2689 | __attribute__((device)) void f() { ... } |
| 2690 | decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of |
| 2691 | f. If the matcher is use from clang-query, attr::Kind parameter should be |
| 2692 | passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). |
| 2693 | </pre></td></tr> |
| 2694 | |
| 2695 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2696 | <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] | 2697 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is |
| 2698 | partially matching a given regex. |
| 2699 | |
| 2700 | Example matches Y but not X |
| 2701 | (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 2702 | #include "ASTMatcher.h" |
| 2703 | class X {}; |
| 2704 | ASTMatcher.h: |
| 2705 | class Y {}; |
| 2706 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2707 | 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] | 2708 | </pre></td></tr> |
| 2709 | |
| 2710 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2711 | <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] | 2712 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. |
| 2713 | |
| 2714 | Example matches X but not Y |
| 2715 | (matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 2716 | #include <Y.h> |
| 2717 | class X {}; |
| 2718 | Y.h: |
| 2719 | class Y {}; |
| 2720 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2721 | 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] | 2722 | </pre></td></tr> |
| 2723 | |
| 2724 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2725 | <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] | 2726 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. |
| 2727 | |
| 2728 | Example matches Y but not X |
| 2729 | (matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 2730 | #include <SystemHeader.h> |
| 2731 | class X {}; |
| 2732 | SystemHeader.h: |
| 2733 | class Y {}; |
| 2734 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2735 | 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] | 2736 | </pre></td></tr> |
| 2737 | |
| 2738 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2739 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 2740 | <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added |
| 2741 | by the compiler (eg. implicit defaultcopy constructors). |
| 2742 | </pre></td></tr> |
| 2743 | |
| 2744 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2745 | <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] | 2746 | <tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. |
| 2747 | |
| 2748 | Given |
| 2749 | class C { |
| 2750 | public: int a; |
| 2751 | protected: int b; |
| 2752 | private: int c; |
| 2753 | }; |
| 2754 | fieldDecl(isPrivate()) |
Cong Liu | 8a02efb | 2016-06-24 09:38:03 +0000 | [diff] [blame] | 2755 | matches 'int c;' |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2756 | </pre></td></tr> |
| 2757 | |
| 2758 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2759 | <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] | 2760 | <tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. |
| 2761 | |
| 2762 | Given |
| 2763 | class C { |
| 2764 | public: int a; |
| 2765 | protected: int b; |
| 2766 | private: int c; |
| 2767 | }; |
| 2768 | fieldDecl(isProtected()) |
Cong Liu | 8a02efb | 2016-06-24 09:38:03 +0000 | [diff] [blame] | 2769 | matches 'int b;' |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 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_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] | 2774 | <tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. |
| 2775 | |
| 2776 | Given |
| 2777 | class C { |
| 2778 | public: int a; |
| 2779 | protected: int b; |
| 2780 | private: int c; |
| 2781 | }; |
| 2782 | fieldDecl(isPublic()) |
Cong Liu | 8a02efb | 2016-06-24 09:38:03 +0000 | [diff] [blame] | 2783 | matches 'int a;' |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2784 | </pre></td></tr> |
| 2785 | |
| 2786 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 2787 | <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> |
| 2788 | <tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain |
| 2789 | a specific number of designators. |
| 2790 | |
| 2791 | Example: Given |
| 2792 | point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; |
| 2793 | point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }; |
| 2794 | designatorCountIs(2) |
| 2795 | matches '{ [2].y = 1.0, [0].x = 1.0 }', |
| 2796 | but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'. |
| 2797 | </pre></td></tr> |
| 2798 | |
| 2799 | |
Haojian Wu | 9c3be3a | 2018-01-18 09:47:57 +0000 | [diff] [blame] | 2800 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>></td><td class="name" onclick="toggle('isScoped0')"><a name="isScoped0Anchor">isScoped</a></td><td></td></tr> |
| 2801 | <tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration. |
| 2802 | |
| 2803 | Example matches Y (matcher = enumDecl(isScoped())) |
| 2804 | enum X {}; |
| 2805 | enum class Y {}; |
| 2806 | </pre></td></tr> |
| 2807 | |
| 2808 | |
Jonas Toth | 2253878 | 2018-09-11 16:09:19 +0000 | [diff] [blame] | 2809 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('isInstantiationDependent0')"><a name="isInstantiationDependent0Anchor">isInstantiationDependent</a></td><td></td></tr> |
| 2810 | <tr><td colspan="4" class="doc" id="isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is |
| 2811 | neither type- nor value-dependent. |
| 2812 | |
| 2813 | In the following example, the expression sizeof(sizeof(T() + T())) |
| 2814 | is instantiation-dependent (since it involves a template parameter T), |
| 2815 | but is neither type- nor value-dependent, since the type of the inner |
| 2816 | sizeof is known (std::size_t) and therefore the size of the outer |
| 2817 | sizeof is known. |
| 2818 | template<typename T> |
| 2819 | void f(T x, T y) { sizeof(sizeof(T() + T()); } |
| 2820 | expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T()) |
| 2821 | </pre></td></tr> |
| 2822 | |
| 2823 | |
| 2824 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('isTypeDependent0')"><a name="isTypeDependent0Anchor">isTypeDependent</a></td><td></td></tr> |
| 2825 | <tr><td colspan="4" class="doc" id="isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type |
| 2826 | is not yet instantiated. |
| 2827 | |
| 2828 | For example, the expressions "x" and "x + y" are type-dependent in |
| 2829 | the following code, but "y" is not type-dependent: |
| 2830 | template<typename T> |
| 2831 | void add(T x, int y) { |
| 2832 | x + y; |
| 2833 | } |
| 2834 | expr(isTypeDependent()) matches x + y |
| 2835 | </pre></td></tr> |
| 2836 | |
| 2837 | |
| 2838 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('isValueDependent0')"><a name="isValueDependent0Anchor">isValueDependent</a></td><td></td></tr> |
| 2839 | <tr><td colspan="4" class="doc" id="isValueDependent0"><pre>Matches expression that are value-dependent because they contain a |
| 2840 | non-type template parameter. |
| 2841 | |
| 2842 | For example, the array bound of "Chars" in the following example is |
| 2843 | value-dependent. |
| 2844 | template<int Size> int f() { return Size; } |
| 2845 | expr(isValueDependent()) matches return Size |
| 2846 | </pre></td></tr> |
| 2847 | |
| 2848 | |
Aaron Ballman | 5c57434 | 2016-07-06 18:25:16 +0000 | [diff] [blame] | 2849 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>></td><td class="name" onclick="toggle('hasBitWidth0')"><a name="hasBitWidth0Anchor">hasBitWidth</a></td><td>unsigned Width</td></tr> |
Malcolm Parsons | 81e48b2 | 2016-12-24 13:22:26 +0000 | [diff] [blame] | 2850 | <tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified |
| 2851 | bit width. |
Aaron Ballman | 5c57434 | 2016-07-06 18:25:16 +0000 | [diff] [blame] | 2852 | |
| 2853 | Given |
| 2854 | class C { |
| 2855 | int a : 2; |
| 2856 | int b : 4; |
| 2857 | int c : 2; |
| 2858 | }; |
Malcolm Parsons | 81e48b2 | 2016-12-24 13:22:26 +0000 | [diff] [blame] | 2859 | fieldDecl(hasBitWidth(2)) |
Aaron Ballman | 5c57434 | 2016-07-06 18:25:16 +0000 | [diff] [blame] | 2860 | matches 'int a;' and 'int c;' but not 'int b;'. |
| 2861 | </pre></td></tr> |
| 2862 | |
| 2863 | |
| 2864 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>></td><td class="name" onclick="toggle('isBitField0')"><a name="isBitField0Anchor">isBitField</a></td><td></td></tr> |
| 2865 | <tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields. |
| 2866 | |
| 2867 | Given |
| 2868 | class C { |
| 2869 | int a : 2; |
| 2870 | int b; |
| 2871 | }; |
| 2872 | fieldDecl(isBitField()) |
| 2873 | matches 'int a;' but not 'int b;'. |
| 2874 | </pre></td></tr> |
| 2875 | |
| 2876 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 2877 | <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>const ValueT Value</td></tr> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2878 | <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2879 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2880 | Given |
| 2881 | f('false, 3.14, 42); |
| 2882 | characterLiteral(equals(0)) |
| 2883 | matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| 2884 | match false |
| 2885 | floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| 2886 | match 3.14 |
| 2887 | integerLiteral(equals(42)) |
| 2888 | matches 42 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2889 | |
Clement Courbet | 43bdba4 | 2017-07-11 15:45:22 +0000 | [diff] [blame] | 2890 | Note that you cannot directly match a negative numeric literal because the |
| 2891 | minus sign is not part of the literal: It is a unary operator whose operand |
| 2892 | is the positive numeric literal. Instead, you must use a unaryOperator() |
| 2893 | matcher to match the minus sign: |
| 2894 | |
| 2895 | unaryOperator(hasOperatorName("-"), |
| 2896 | hasUnaryOperand(integerLiteral(equals(13)))) |
| 2897 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2898 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2899 | 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] | 2900 | </pre></td></tr> |
| 2901 | |
| 2902 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2903 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>></td><td class="name" onclick="toggle('equals12')"><a name="equals12Anchor">equals</a></td><td>double Value</td></tr> |
| 2904 | <tr><td colspan="4" class="doc" id="equals12"><pre></pre></td></tr> |
| 2905 | |
| 2906 | |
Aaron Ballman | abdbbbc | 2016-05-16 16:49:01 +0000 | [diff] [blame] | 2907 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasDynamicExceptionSpec0')"><a name="hasDynamicExceptionSpec0Anchor">hasDynamicExceptionSpec</a></td><td></td></tr> |
| 2908 | <tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification. |
| 2909 | |
| 2910 | Given: |
| 2911 | void f(); |
| 2912 | void g() noexcept; |
| 2913 | void h() noexcept(true); |
| 2914 | void i() noexcept(false); |
| 2915 | void j() throw(); |
| 2916 | void k() throw(int); |
| 2917 | void l() throw(...); |
Aaron Ballman | 230ad97 | 2016-06-07 17:34:45 +0000 | [diff] [blame] | 2918 | functionDecl(hasDynamicExceptionSpec()) and |
| 2919 | functionProtoType(hasDynamicExceptionSpec()) |
| 2920 | match the declarations of j, k, and l, but not f, g, h, or i. |
Aaron Ballman | abdbbbc | 2016-05-16 16:49:01 +0000 | [diff] [blame] | 2921 | </pre></td></tr> |
| 2922 | |
| 2923 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2924 | <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] | 2925 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. |
| 2926 | |
| 2927 | Matches overloaded operator names specified in strings without the |
| 2928 | "operator" prefix: e.g. "<<". |
| 2929 | |
| 2930 | Given: |
| 2931 | class A { int operator*(); }; |
| 2932 | const A &operator<<(const A &a, const A &b); |
| 2933 | A a; |
| 2934 | a << a; <-- This matches |
| 2935 | |
| 2936 | cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the |
| 2937 | specified line and |
| 2938 | cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) |
| 2939 | matches the declaration of A. |
| 2940 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2941 | 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] | 2942 | </pre></td></tr> |
| 2943 | |
| 2944 | |
Julie Hockett | 239d25a | 2018-01-22 22:45:23 +0000 | [diff] [blame] | 2945 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasTrailingReturn0')"><a name="hasTrailingReturn0Anchor">hasTrailingReturn</a></td><td></td></tr> |
| 2946 | <tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type. |
| 2947 | |
| 2948 | Example matches Y (matcher = functionDecl(hasTrailingReturn())) |
| 2949 | int X() {} |
| 2950 | auto Y() -> int {} |
| 2951 | </pre></td></tr> |
| 2952 | |
| 2953 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2954 | <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> |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 2955 | <tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations, |
| 2956 | and if constexpr. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2957 | |
| 2958 | Given: |
| 2959 | constexpr int foo = 42; |
| 2960 | constexpr int bar(); |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 2961 | void baz() { if constexpr(1 > 0) {} } |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2962 | varDecl(isConstexpr()) |
| 2963 | matches the declaration of foo. |
| 2964 | functionDecl(isConstexpr()) |
| 2965 | matches the declaration of bar. |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 2966 | ifStmt(isConstexpr()) |
| 2967 | matches the if statement in baz. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2968 | </pre></td></tr> |
| 2969 | |
| 2970 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2971 | <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] | 2972 | <tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations. |
| 2973 | |
| 2974 | Given: |
| 2975 | class A { ~A(); }; |
| 2976 | class B { ~B() = default; }; |
| 2977 | functionDecl(isDefaulted()) |
| 2978 | matches the declaration of ~B, but not ~A. |
| 2979 | </pre></td></tr> |
| 2980 | |
| 2981 | |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 2982 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDefinition3')"><a name="isDefinition3Anchor">isDefinition</a></td><td></td></tr> |
| 2983 | <tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2984 | |
| 2985 | Example matches A, va, fa |
| 2986 | class A {}; |
| 2987 | class B; Doesn't match, as it has no body. |
| 2988 | int va; |
| 2989 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 2990 | void fa() {} |
| 2991 | void fb(); Doesn't match, as it has no body. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 2992 | @interface X |
| 2993 | - (void)ma; Doesn't match, interface is declaration. |
| 2994 | @end |
| 2995 | @implementation X |
| 2996 | - (void)ma {} |
| 2997 | @end |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2998 | |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 2999 | 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>>, |
| 3000 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3001 | </pre></td></tr> |
| 3002 | |
| 3003 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3004 | <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] | 3005 | <tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. |
| 3006 | |
| 3007 | Given: |
| 3008 | void Func(); |
| 3009 | void DeletedFunc() = delete; |
| 3010 | functionDecl(isDeleted()) |
| 3011 | matches the declaration of DeletedFunc, but not Func. |
| 3012 | </pre></td></tr> |
| 3013 | |
| 3014 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3015 | <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] | 3016 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or |
| 3017 | static member variable template instantiations. |
| 3018 | |
| 3019 | Given |
| 3020 | template<typename T> void A(T t) { } |
| 3021 | template<> void A(int N) { } |
| 3022 | functionDecl(isExplicitTemplateSpecialization()) |
| 3023 | matches the specialization A<int>(). |
| 3024 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3025 | 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] | 3026 | </pre></td></tr> |
| 3027 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 3028 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3029 | <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> |
Alexander Shaposhnikov | f681c4e | 2017-09-22 19:29:38 +0000 | [diff] [blame] | 3030 | <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3031 | |
| 3032 | Given: |
| 3033 | extern "C" void f() {} |
| 3034 | extern "C" { void g() {} } |
| 3035 | void h() {} |
Alexander Shaposhnikov | f681c4e | 2017-09-22 19:29:38 +0000 | [diff] [blame] | 3036 | extern "C" int x = 1; |
| 3037 | extern "C" int y = 2; |
| 3038 | int z = 3; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3039 | functionDecl(isExternC()) |
Alexander Shaposhnikov | f681c4e | 2017-09-22 19:29:38 +0000 | [diff] [blame] | 3040 | matches the declaration of f and g, but not the declaration of h. |
| 3041 | varDecl(isExternC()) |
| 3042 | matches the declaration of x and y, but not the declaration of z. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3043 | </pre></td></tr> |
| 3044 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 3045 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3046 | <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] | 3047 | <tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with |
| 3048 | the inline keyword. |
| 3049 | |
| 3050 | Given |
| 3051 | inline void f(); |
| 3052 | void g(); |
| 3053 | namespace n { |
| 3054 | inline namespace m {} |
| 3055 | } |
| 3056 | functionDecl(isInline()) will match ::f(). |
| 3057 | namespaceDecl(isInline()) will match n::m. |
| 3058 | </pre></td></tr> |
| 3059 | |
| 3060 | |
George Karpenkov | fc3d72e | 2018-07-23 22:29:35 +0000 | [diff] [blame] | 3061 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isMain0')"><a name="isMain0Anchor">isMain</a></td><td></td></tr> |
| 3062 | <tr><td colspan="4" class="doc" id="isMain0"><pre>Determines whether the function is "main", which is the entry point |
| 3063 | into an executable program. |
| 3064 | </pre></td></tr> |
| 3065 | |
| 3066 | |
Roman Lebedev | 6c3871b | 2018-01-17 19:40:55 +0000 | [diff] [blame] | 3067 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isNoReturn0')"><a name="isNoReturn0Anchor">isNoReturn</a></td><td></td></tr> |
| 3068 | <tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute. |
| 3069 | |
| 3070 | Given |
| 3071 | void nope(); |
| 3072 | [[noreturn]] void a(); |
| 3073 | __attribute__((noreturn)) void b(); |
| 3074 | struct c { [[noreturn]] c(); }; |
| 3075 | functionDecl(isNoReturn()) |
| 3076 | matches all of those except |
| 3077 | void nope(); |
| 3078 | </pre></td></tr> |
| 3079 | |
| 3080 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3081 | <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] | 3082 | <tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification. |
| 3083 | |
| 3084 | Given: |
| 3085 | void f(); |
| 3086 | void g() noexcept; |
| 3087 | void h() throw(); |
| 3088 | void i() throw(int); |
| 3089 | void j() noexcept(false); |
Aaron Ballman | 230ad97 | 2016-06-07 17:34:45 +0000 | [diff] [blame] | 3090 | functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) |
| 3091 | match the declarations of g, and h, but not f, i or j. |
Aaron Ballman | a60bcda | 2015-12-02 15:23:59 +0000 | [diff] [blame] | 3092 | </pre></td></tr> |
| 3093 | |
| 3094 | |
Haojian Wu | b3d2546 | 2016-09-26 16:01:52 +0000 | [diff] [blame] | 3095 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isStaticStorageClass0')"><a name="isStaticStorageClass0Anchor">isStaticStorageClass</a></td><td></td></tr> |
Haojian Wu | 398a8ea | 2016-09-27 07:53:20 +0000 | [diff] [blame] | 3096 | <tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variablefunction declarations that have "static" storage |
| 3097 | class specifier ("static" keyword) written in the source. |
Haojian Wu | b3d2546 | 2016-09-26 16:01:52 +0000 | [diff] [blame] | 3098 | |
| 3099 | Given: |
| 3100 | static void f() {} |
| 3101 | static int i = 0; |
Haojian Wu | 398a8ea | 2016-09-27 07:53:20 +0000 | [diff] [blame] | 3102 | extern int j; |
| 3103 | int k; |
Haojian Wu | b3d2546 | 2016-09-26 16:01:52 +0000 | [diff] [blame] | 3104 | functionDecl(isStaticStorageClass()) |
| 3105 | matches the function declaration f. |
| 3106 | varDecl(isStaticStorageClass()) |
| 3107 | matches the variable declaration i. |
| 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_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] | 3112 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static |
| 3113 | member variable template instantiations. |
| 3114 | |
| 3115 | Given |
| 3116 | template <typename T> class X {}; class A {}; X<A> x; |
| 3117 | or |
| 3118 | template <typename T> class X {}; class A {}; template class X<A>; |
Eric Liu | 09ee48e | 2018-02-21 14:22:42 +0000 | [diff] [blame] | 3119 | or |
| 3120 | template <typename T> class X {}; class A {}; extern template class X<A>; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3121 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 3122 | matches the template instantiation of X<A>. |
| 3123 | |
| 3124 | But given |
| 3125 | template <typename T> class X {}; class A {}; |
| 3126 | template <> class X<A> {}; X<A> x; |
| 3127 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 3128 | does not match, as X<A> is an explicit template specialization. |
| 3129 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3130 | 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] | 3131 | </pre></td></tr> |
| 3132 | |
| 3133 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3134 | <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] | 3135 | <tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. |
| 3136 | |
| 3137 | Example matches f, but not g or h. The function i will not match, even when |
| 3138 | compiled in C mode. |
| 3139 | void f(...); |
| 3140 | void g(int); |
| 3141 | template <typename... Ts> void h(Ts...); |
| 3142 | void i(); |
| 3143 | </pre></td></tr> |
| 3144 | |
| 3145 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3146 | <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] | 3147 | <tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a |
| 3148 | specific parameter count. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3149 | |
| 3150 | Given |
| 3151 | void f(int i) {} |
| 3152 | void g(int i, int j) {} |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3153 | void h(int i, int j); |
| 3154 | void j(int i); |
| 3155 | void k(int x, int y, int z, ...); |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3156 | functionDecl(parameterCountIs(2)) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3157 | matches g and h |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3158 | functionProtoType(parameterCountIs(2)) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3159 | matches g and h |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3160 | functionProtoType(parameterCountIs(3)) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3161 | matches k |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3162 | </pre></td></tr> |
| 3163 | |
| 3164 | |
Aaron Ballman | 230ad97 | 2016-06-07 17:34:45 +0000 | [diff] [blame] | 3165 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>></td><td class="name" onclick="toggle('hasDynamicExceptionSpec1')"><a name="hasDynamicExceptionSpec1Anchor">hasDynamicExceptionSpec</a></td><td></td></tr> |
| 3166 | <tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification. |
| 3167 | |
| 3168 | Given: |
| 3169 | void f(); |
| 3170 | void g() noexcept; |
| 3171 | void h() noexcept(true); |
| 3172 | void i() noexcept(false); |
| 3173 | void j() throw(); |
| 3174 | void k() throw(int); |
| 3175 | void l() throw(...); |
| 3176 | functionDecl(hasDynamicExceptionSpec()) and |
| 3177 | functionProtoType(hasDynamicExceptionSpec()) |
| 3178 | match the declarations of j, k, and l, but not f, g, h, or i. |
| 3179 | </pre></td></tr> |
| 3180 | |
| 3181 | |
| 3182 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>></td><td class="name" onclick="toggle('isNoThrow1')"><a name="isNoThrow1Anchor">isNoThrow</a></td><td></td></tr> |
| 3183 | <tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification. |
| 3184 | |
| 3185 | Given: |
| 3186 | void f(); |
| 3187 | void g() noexcept; |
| 3188 | void h() throw(); |
| 3189 | void i() throw(int); |
| 3190 | void j() noexcept(false); |
| 3191 | functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) |
| 3192 | match the declarations of g, and h, but not f, i or j. |
| 3193 | </pre></td></tr> |
| 3194 | |
| 3195 | |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3196 | <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> |
| 3197 | <tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a |
| 3198 | specific parameter count. |
| 3199 | |
| 3200 | Given |
| 3201 | void f(int i) {} |
| 3202 | void g(int i, int j) {} |
| 3203 | void h(int i, int j); |
| 3204 | void j(int i); |
| 3205 | void k(int x, int y, int z, ...); |
| 3206 | functionDecl(parameterCountIs(2)) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3207 | matches g and h |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3208 | functionProtoType(parameterCountIs(2)) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3209 | matches g and h |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3210 | functionProtoType(parameterCountIs(3)) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3211 | matches k |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3212 | </pre></td></tr> |
| 3213 | |
| 3214 | |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 3215 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('isConstexpr2')"><a name="isConstexpr2Anchor">isConstexpr</a></td><td></td></tr> |
| 3216 | <tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations, |
| 3217 | and if constexpr. |
| 3218 | |
| 3219 | Given: |
| 3220 | constexpr int foo = 42; |
| 3221 | constexpr int bar(); |
| 3222 | void baz() { if constexpr(1 > 0) {} } |
| 3223 | varDecl(isConstexpr()) |
| 3224 | matches the declaration of foo. |
| 3225 | functionDecl(isConstexpr()) |
| 3226 | matches the declaration of bar. |
| 3227 | ifStmt(isConstexpr()) |
| 3228 | matches the if statement in baz. |
| 3229 | </pre></td></tr> |
| 3230 | |
| 3231 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 3232 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals6')"><a name="equals6Anchor">equals</a></td><td>bool Value</td></tr> |
| 3233 | <tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr> |
| 3234 | |
| 3235 | |
| 3236 | <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>const ValueT Value</td></tr> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 3237 | <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3238 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 3239 | Given |
| 3240 | f('false, 3.14, 42); |
| 3241 | characterLiteral(equals(0)) |
| 3242 | matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| 3243 | match false |
| 3244 | floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| 3245 | match 3.14 |
| 3246 | integerLiteral(equals(42)) |
| 3247 | matches 42 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3248 | |
Clement Courbet | 43bdba4 | 2017-07-11 15:45:22 +0000 | [diff] [blame] | 3249 | Note that you cannot directly match a negative numeric literal because the |
| 3250 | minus sign is not part of the literal: It is a unary operator whose operand |
| 3251 | is the positive numeric literal. Instead, you must use a unaryOperator() |
| 3252 | matcher to match the minus sign: |
| 3253 | |
| 3254 | unaryOperator(hasOperatorName("-"), |
| 3255 | hasUnaryOperand(integerLiteral(equals(13)))) |
| 3256 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 3257 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3258 | 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] | 3259 | </pre></td></tr> |
| 3260 | |
| 3261 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 3262 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals13')"><a name="equals13Anchor">equals</a></td><td>double Value</td></tr> |
| 3263 | <tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr> |
| 3264 | |
| 3265 | |
| 3266 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals9')"><a name="equals9Anchor">equals</a></td><td>unsigned Value</td></tr> |
| 3267 | <tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr> |
| 3268 | |
| 3269 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3270 | <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] | 3271 | <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed |
| 3272 | to '.'. |
| 3273 | |
| 3274 | Member calls on the implicit this pointer match as called with '->'. |
| 3275 | |
| 3276 | Given |
| 3277 | class Y { |
| 3278 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
Shuai Wang | e0248ae | 2018-09-17 18:48:43 +0000 | [diff] [blame] | 3279 | template <class T> void f() { this->f<T>(); f<T>(); } |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3280 | int a; |
| 3281 | static int b; |
| 3282 | }; |
Shuai Wang | e0248ae | 2018-09-17 18:48:43 +0000 | [diff] [blame] | 3283 | template <class T> |
| 3284 | class Z { |
| 3285 | void x() { this->m; } |
| 3286 | }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3287 | memberExpr(isArrow()) |
| 3288 | matches this->x, x, y.x, a, this->b |
Shuai Wang | e0248ae | 2018-09-17 18:48:43 +0000 | [diff] [blame] | 3289 | cxxDependentScopeMemberExpr(isArrow()) |
| 3290 | matches this->m |
| 3291 | unresolvedMemberExpr(isArrow()) |
| 3292 | matches this->f<T>, f<T> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3293 | </pre></td></tr> |
| 3294 | |
| 3295 | |
Aaron Ballman | a086b9f | 2016-08-17 13:10:42 +0000 | [diff] [blame] | 3296 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('hasExternalFormalLinkage0')"><a name="hasExternalFormalLinkage0Anchor">hasExternalFormalLinkage</a></td><td></td></tr> |
| 3297 | <tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage. |
| 3298 | |
| 3299 | Example matches only z (matcher = varDecl(hasExternalFormalLinkage())) |
| 3300 | void f() { |
| 3301 | int x; |
| 3302 | static int y; |
| 3303 | } |
| 3304 | int z; |
| 3305 | |
| 3306 | Example matches f() because it has external formal linkage despite being |
| 3307 | unique to the translation unit as though it has internal likage |
| 3308 | (matcher = functionDecl(hasExternalFormalLinkage())) |
| 3309 | |
| 3310 | namespace { |
| 3311 | void f() {} |
| 3312 | } |
| 3313 | </pre></td></tr> |
| 3314 | |
| 3315 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 3316 | <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>const std::string Name</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3317 | <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. |
| 3318 | |
| 3319 | Supports specifying enclosing namespaces or classes by prefixing the name |
| 3320 | with '<enclosing>::'. |
| 3321 | Does not match typedefs of an underlying type with the given name. |
| 3322 | |
| 3323 | Example matches X (Name == "X") |
| 3324 | class X; |
| 3325 | |
| 3326 | Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") |
| 3327 | namespace a { namespace b { class X; } } |
| 3328 | </pre></td></tr> |
| 3329 | |
| 3330 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3331 | <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] | 3332 | <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain |
| 3333 | a substring matched by the given RegExp. |
| 3334 | |
| 3335 | Supports specifying enclosing namespaces or classes by |
| 3336 | prefixing the name with '<enclosing>::'. Does not match typedefs |
| 3337 | of an underlying type with the given name. |
| 3338 | |
| 3339 | Example matches X (regexp == "::X") |
| 3340 | class X; |
| 3341 | |
| 3342 | Example matches X (regexp is one of "::X", "^foo::.*X", among others) |
| 3343 | namespace foo { namespace bar { class X; } } |
| 3344 | </pre></td></tr> |
| 3345 | |
| 3346 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3347 | <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] | 3348 | <tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. |
| 3349 | |
| 3350 | Given |
| 3351 | namespace n { |
| 3352 | namespace {} #1 |
| 3353 | } |
| 3354 | namespaceDecl(isAnonymous()) will match #1 but not ::n. |
| 3355 | </pre></td></tr> |
| 3356 | |
| 3357 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3358 | <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] | 3359 | <tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with |
| 3360 | the inline keyword. |
| 3361 | |
| 3362 | Given |
| 3363 | inline void f(); |
| 3364 | void g(); |
| 3365 | namespace n { |
| 3366 | inline namespace m {} |
| 3367 | } |
| 3368 | functionDecl(isInline()) will match ::f(). |
| 3369 | namespaceDecl(isInline()) will match n::m. |
| 3370 | </pre></td></tr> |
| 3371 | |
| 3372 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3373 | <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] | 3374 | <tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has |
| 3375 | a specific number of arguments (including absent default arguments). |
| 3376 | |
| 3377 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 3378 | void f(int x, int y); |
| 3379 | f(0, 0); |
| 3380 | </pre></td></tr> |
| 3381 | |
| 3382 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3383 | <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] | 3384 | <tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector |
| 3385 | |
| 3386 | objCMessageExpr(hasKeywordSelector()) matches the generated setFrame |
| 3387 | message expression in |
| 3388 | |
| 3389 | UIWebView *webView = ...; |
| 3390 | CGRect bodyFrame = webView.frame; |
| 3391 | bodyFrame.size.height = self.bodyContentHeight; |
| 3392 | webView.frame = bodyFrame; |
| 3393 | ^---- matches here |
| 3394 | </pre></td></tr> |
| 3395 | |
| 3396 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3397 | <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] | 3398 | <tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector |
| 3399 | |
| 3400 | Matches only when the selector of the objCMessageExpr is NULL. This may |
| 3401 | represent an error condition in the tree! |
| 3402 | </pre></td></tr> |
| 3403 | |
| 3404 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3405 | <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] | 3406 | <tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() |
| 3407 | |
| 3408 | matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); |
| 3409 | matches the outer message expr in the code below, but NOT the message |
| 3410 | invocation for self.bodyView. |
| 3411 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 3412 | </pre></td></tr> |
| 3413 | |
| 3414 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3415 | <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] | 3416 | <tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector |
| 3417 | |
| 3418 | matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); |
| 3419 | matches self.bodyView in the code below, but NOT the outer message |
| 3420 | invocation of "loadHTMLString:baseURL:". |
| 3421 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 3422 | </pre></td></tr> |
| 3423 | |
| 3424 | |
George Karpenkov | b5ea4df | 2018-07-16 20:22:12 +0000 | [diff] [blame] | 3425 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('isInstanceMessage0')"><a name="isInstanceMessage0Anchor">isInstanceMessage</a></td><td></td></tr> |
| 3426 | <tr><td colspan="4" class="doc" id="isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance. |
| 3427 | |
| 3428 | Example |
| 3429 | matcher = objcMessagaeExpr(isInstanceMessage()) |
| 3430 | matches |
| 3431 | NSString *x = @"hello"; |
George Karpenkov | daac52c | 2018-07-23 22:29:10 +0000 | [diff] [blame] | 3432 | [x containsString:@"h"]; |
George Karpenkov | b5ea4df | 2018-07-16 20:22:12 +0000 | [diff] [blame] | 3433 | but not |
George Karpenkov | daac52c | 2018-07-23 22:29:10 +0000 | [diff] [blame] | 3434 | [NSString stringWithFormat:@"format"]; |
George Karpenkov | b5ea4df | 2018-07-16 20:22:12 +0000 | [diff] [blame] | 3435 | </pre></td></tr> |
| 3436 | |
| 3437 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3438 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 3439 | <tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains |
| 3440 | a substring matched by the given RegExp. |
| 3441 | matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message |
| 3442 | invocation for self.bodyView. |
| 3443 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 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_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] | 3448 | <tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments |
| 3449 | |
| 3450 | matcher = objCMessageExpr(numSelectorArgs(0)); |
| 3451 | matches self.bodyView in the code below |
| 3452 | |
| 3453 | matcher = objCMessageExpr(numSelectorArgs(2)); |
| 3454 | matches the invocation of "loadHTMLString:baseURL:" but not that |
| 3455 | of self.bodyView |
| 3456 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 3457 | </pre></td></tr> |
| 3458 | |
| 3459 | |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3460 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>></td><td class="name" onclick="toggle('isDefinition2')"><a name="isDefinition2Anchor">isDefinition</a></td><td></td></tr> |
| 3461 | <tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. |
| 3462 | |
| 3463 | Example matches A, va, fa |
| 3464 | class A {}; |
| 3465 | class B; Doesn't match, as it has no body. |
| 3466 | int va; |
| 3467 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 3468 | void fa() {} |
| 3469 | void fb(); Doesn't match, as it has no body. |
| 3470 | @interface X |
| 3471 | - (void)ma; Doesn't match, interface is declaration. |
| 3472 | @end |
| 3473 | @implementation X |
| 3474 | - (void)ma {} |
| 3475 | @end |
| 3476 | |
| 3477 | 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>>, |
| 3478 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> |
| 3479 | </pre></td></tr> |
| 3480 | |
| 3481 | |
Aaron Ballman | 5f8980a | 2017-11-21 19:22:34 +0000 | [diff] [blame] | 3482 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>></td><td class="name" onclick="toggle('hasDefaultArgument0')"><a name="hasDefaultArgument0Anchor">hasDefaultArgument</a></td><td></td></tr> |
| 3483 | <tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments. |
| 3484 | |
| 3485 | Example matches y (matcher = parmVarDecl(hasDefaultArgument())) |
| 3486 | void x(int val) {} |
| 3487 | void y(int val = 0) {} |
| 3488 | </pre></td></tr> |
| 3489 | |
| 3490 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3491 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 3492 | <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. |
| 3493 | |
| 3494 | Given |
| 3495 | class Y { public: void x(); }; |
| 3496 | void z() { Y* y; y->x(); } |
| 3497 | cxxMemberCallExpr(on(hasType(asString("class Y *")))) |
| 3498 | matches y->x() |
| 3499 | </pre></td></tr> |
| 3500 | |
| 3501 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3502 | <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] | 3503 | <tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. |
| 3504 | |
| 3505 | Matches a node if it equals the node previously bound to ID. |
| 3506 | |
| 3507 | Given |
| 3508 | class X { int a; int b; }; |
| 3509 | cxxRecordDecl( |
| 3510 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 3511 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 3512 | matches the class X, as a and b have the same type. |
| 3513 | |
| 3514 | Note that when multiple matches are involved via forEach* matchers, |
| 3515 | equalsBoundNodes acts as a filter. |
| 3516 | For example: |
| 3517 | compoundStmt( |
| 3518 | forEachDescendant(varDecl().bind("d")), |
| 3519 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 3520 | will trigger a match for each combination of variable declaration |
| 3521 | and reference to that variable declaration within a compound statement. |
| 3522 | </pre></td></tr> |
| 3523 | |
| 3524 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3525 | <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] | 3526 | <tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to |
| 3527 | the node, not hidden within a typedef. |
| 3528 | |
| 3529 | Given |
| 3530 | typedef const int const_int; |
| 3531 | const_int i; |
| 3532 | int *const j; |
| 3533 | int *volatile k; |
| 3534 | int m; |
| 3535 | varDecl(hasType(hasLocalQualifiers())) matches only j and k. |
| 3536 | i is const-qualified but the qualifier is not local. |
| 3537 | </pre></td></tr> |
| 3538 | |
| 3539 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3540 | <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] | 3541 | <tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type. |
| 3542 | |
| 3543 | Given |
| 3544 | void a(char); |
| 3545 | void b(wchar_t); |
| 3546 | void c(double); |
| 3547 | functionDecl(hasAnyParameter(hasType(isAnyCharacter()))) |
| 3548 | matches "a(char)", "b(wchar_t)", but not "c(double)". |
| 3549 | </pre></td></tr> |
| 3550 | |
| 3551 | |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 3552 | <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> |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 3553 | <tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes |
| 3554 | the Objective-C object pointer type, which is different despite being |
| 3555 | syntactically similar. |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 3556 | |
| 3557 | Given |
| 3558 | int *i = nullptr; |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 3559 | |
| 3560 | @interface Foo |
| 3561 | @end |
| 3562 | Foo *f; |
| 3563 | |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 3564 | int j; |
| 3565 | varDecl(hasType(isAnyPointer())) |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 3566 | matches "int *i" and "Foo *f", but not "int j". |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 3567 | </pre></td></tr> |
| 3568 | |
| 3569 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3570 | <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] | 3571 | <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that |
| 3572 | include "top-level" const. |
| 3573 | |
| 3574 | Given |
| 3575 | void a(int); |
| 3576 | void b(int const); |
| 3577 | void c(const int); |
| 3578 | void d(const int*); |
| 3579 | void e(int const) {}; |
| 3580 | functionDecl(hasAnyParameter(hasType(isConstQualified()))) |
| 3581 | matches "void b(int const)", "void c(const int)" and |
| 3582 | "void e(int const) {}". It does not match d as there |
| 3583 | is no top-level const on the parameter type "const int *". |
| 3584 | </pre></td></tr> |
| 3585 | |
| 3586 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3587 | <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] | 3588 | <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. |
| 3589 | |
| 3590 | Given |
| 3591 | void a(int); |
| 3592 | void b(long); |
| 3593 | void c(double); |
| 3594 | functionDecl(hasAnyParameter(hasType(isInteger()))) |
| 3595 | matches "a(int)", "b(long)", but not "c(double)". |
| 3596 | </pre></td></tr> |
| 3597 | |
| 3598 | |
Clement Courbet | 4251759 | 2016-07-12 06:36:00 +0000 | [diff] [blame] | 3599 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isSignedInteger0')"><a name="isSignedInteger0Anchor">isSignedInteger</a></td><td></td></tr> |
| 3600 | <tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type. |
| 3601 | |
| 3602 | Given |
| 3603 | void a(int); |
| 3604 | void b(unsigned long); |
| 3605 | void c(double); |
Aaron Ballman | 75de707 | 2016-08-18 12:26:17 +0000 | [diff] [blame] | 3606 | functionDecl(hasAnyParameter(hasType(isSignedInteger()))) |
Clement Courbet | 4251759 | 2016-07-12 06:36:00 +0000 | [diff] [blame] | 3607 | matches "a(int)", but not "b(unsigned long)" and "c(double)". |
| 3608 | </pre></td></tr> |
| 3609 | |
| 3610 | |
| 3611 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isUnsignedInteger0')"><a name="isUnsignedInteger0Anchor">isUnsignedInteger</a></td><td></td></tr> |
| 3612 | <tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type. |
| 3613 | |
| 3614 | Given |
| 3615 | void a(int); |
| 3616 | void b(unsigned long); |
| 3617 | void c(double); |
Aaron Ballman | 75de707 | 2016-08-18 12:26:17 +0000 | [diff] [blame] | 3618 | functionDecl(hasAnyParameter(hasType(isUnsignedInteger()))) |
Clement Courbet | 4251759 | 2016-07-12 06:36:00 +0000 | [diff] [blame] | 3619 | matches "b(unsigned long)", but not "a(int)" and "c(double)". |
| 3620 | </pre></td></tr> |
| 3621 | |
| 3622 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3623 | <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] | 3624 | <tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that |
| 3625 | include "top-level" volatile. |
| 3626 | |
| 3627 | Given |
| 3628 | void a(int); |
| 3629 | void b(int volatile); |
| 3630 | void c(volatile int); |
| 3631 | void d(volatile int*); |
| 3632 | void e(int volatile) {}; |
| 3633 | functionDecl(hasAnyParameter(hasType(isVolatileQualified()))) |
| 3634 | matches "void b(int volatile)", "void c(volatile int)" and |
| 3635 | "void e(int volatile) {}". It does not match d as there |
| 3636 | is no top-level volatile on the parameter type "volatile int *". |
| 3637 | </pre></td></tr> |
| 3638 | |
| 3639 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3640 | <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] | 3641 | <tr><td colspan="4" class="doc" id="isClass0"><pre>Matches RecordDecl object that are spelled with "class." |
| 3642 | |
| 3643 | Example matches C, but not S or U. |
| 3644 | struct S {}; |
| 3645 | class C {}; |
| 3646 | union U {}; |
| 3647 | </pre></td></tr> |
| 3648 | |
| 3649 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3650 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 3651 | <tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches RecordDecl object that are spelled with "struct." |
| 3652 | |
| 3653 | Example matches S, but not C or U. |
| 3654 | struct S {}; |
| 3655 | class C {}; |
| 3656 | union U {}; |
| 3657 | </pre></td></tr> |
| 3658 | |
| 3659 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3660 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 3661 | <tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches RecordDecl object that are spelled with "union." |
| 3662 | |
| 3663 | Example matches U, but not C or S. |
| 3664 | struct S {}; |
| 3665 | class C {}; |
| 3666 | union U {}; |
| 3667 | </pre></td></tr> |
| 3668 | |
| 3669 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3670 | <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] | 3671 | <tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. |
| 3672 | |
| 3673 | Matches a node if it equals the node previously bound to ID. |
| 3674 | |
| 3675 | Given |
| 3676 | class X { int a; int b; }; |
| 3677 | cxxRecordDecl( |
| 3678 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 3679 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 3680 | matches the class X, as a and b have the same type. |
| 3681 | |
| 3682 | Note that when multiple matches are involved via forEach* matchers, |
| 3683 | equalsBoundNodes acts as a filter. |
| 3684 | For example: |
| 3685 | compoundStmt( |
| 3686 | forEachDescendant(varDecl().bind("d")), |
| 3687 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 3688 | will trigger a match for each combination of variable declaration |
| 3689 | and reference to that variable declaration within a compound statement. |
| 3690 | </pre></td></tr> |
| 3691 | |
| 3692 | |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 3693 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('equalsNode1')"><a name="equalsNode1Anchor">equalsNode</a></td><td>const Stmt* Other</td></tr> |
| 3694 | <tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. |
| 3695 | |
| 3696 | Stmt has pointer identity in the AST. |
| 3697 | </pre></td></tr> |
| 3698 | |
| 3699 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3700 | <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] | 3701 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is |
| 3702 | partially matching a given regex. |
| 3703 | |
| 3704 | Example matches Y but not X |
| 3705 | (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 3706 | #include "ASTMatcher.h" |
| 3707 | class X {}; |
| 3708 | ASTMatcher.h: |
| 3709 | class Y {}; |
| 3710 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3711 | 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] | 3712 | </pre></td></tr> |
| 3713 | |
| 3714 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3715 | <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] | 3716 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. |
| 3717 | |
| 3718 | Example matches X but not Y |
| 3719 | (matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 3720 | #include <Y.h> |
| 3721 | class X {}; |
| 3722 | Y.h: |
| 3723 | class Y {}; |
| 3724 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3725 | 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] | 3726 | </pre></td></tr> |
| 3727 | |
| 3728 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3729 | <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] | 3730 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. |
| 3731 | |
| 3732 | Example matches Y but not X |
| 3733 | (matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 3734 | #include <SystemHeader.h> |
| 3735 | class X {}; |
| 3736 | SystemHeader.h: |
| 3737 | class Y {}; |
| 3738 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3739 | 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] | 3740 | </pre></td></tr> |
| 3741 | |
| 3742 | |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 3743 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>></td><td class="name" onclick="toggle('hasSize1')"><a name="hasSize1Anchor">hasSize</a></td><td>unsigned N</td></tr> |
| 3744 | <tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size. |
| 3745 | |
| 3746 | Given |
| 3747 | int a[42]; |
| 3748 | int b[2 * 21]; |
| 3749 | int c[41], d[43]; |
| 3750 | char *s = "abcd"; |
| 3751 | wchar_t *ws = L"abcd"; |
| 3752 | char *w = "a"; |
| 3753 | constantArrayType(hasSize(42)) |
| 3754 | matches "int a[42]" and "int b[2 * 21]" |
| 3755 | stringLiteral(hasSize(4)) |
| 3756 | matches "abcd", L"abcd" |
| 3757 | </pre></td></tr> |
| 3758 | |
| 3759 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3760 | <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] | 3761 | <tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. |
| 3762 | |
| 3763 | Example matches A, va, fa |
| 3764 | class A {}; |
| 3765 | class B; Doesn't match, as it has no body. |
| 3766 | int va; |
| 3767 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 3768 | void fa() {} |
| 3769 | void fb(); Doesn't match, as it has no body. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3770 | @interface X |
| 3771 | - (void)ma; Doesn't match, interface is declaration. |
| 3772 | @end |
| 3773 | @implementation X |
| 3774 | - (void)ma {} |
| 3775 | @end |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3776 | |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3777 | 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>>, |
| 3778 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3779 | </pre></td></tr> |
| 3780 | |
| 3781 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3782 | <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] | 3783 | <tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. |
| 3784 | |
| 3785 | Note that 'Value' is a string as the template argument's value is |
| 3786 | an arbitrary precision integer. 'Value' must be euqal to the canonical |
| 3787 | representation of that integral value in base 10. |
| 3788 | |
| 3789 | Given |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3790 | template<int T> struct C {}; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3791 | C<42> c; |
| 3792 | classTemplateSpecializationDecl( |
| 3793 | hasAnyTemplateArgument(equalsIntegralValue("42"))) |
| 3794 | matches the implicit instantiation of C in C<42>. |
| 3795 | </pre></td></tr> |
| 3796 | |
| 3797 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3798 | <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] | 3799 | <tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. |
| 3800 | |
| 3801 | Given |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3802 | template<int T> struct C {}; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3803 | C<42> c; |
| 3804 | classTemplateSpecializationDecl( |
| 3805 | hasAnyTemplateArgument(isIntegral())) |
| 3806 | matches the implicit instantiation of C in C<42> |
| 3807 | with isIntegral() matching 42. |
| 3808 | </pre></td></tr> |
| 3809 | |
| 3810 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3811 | <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] | 3812 | <tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. |
| 3813 | |
| 3814 | Given |
| 3815 | template<typename T> struct C {}; |
| 3816 | C<int> c; |
| 3817 | classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
| 3818 | matches C<int>. |
| 3819 | </pre></td></tr> |
| 3820 | |
| 3821 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3822 | <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] | 3823 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is |
| 3824 | partially matching a given regex. |
| 3825 | |
| 3826 | Example matches Y but not X |
| 3827 | (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 3828 | #include "ASTMatcher.h" |
| 3829 | class X {}; |
| 3830 | ASTMatcher.h: |
| 3831 | class Y {}; |
| 3832 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3833 | 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] | 3834 | </pre></td></tr> |
| 3835 | |
| 3836 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3837 | <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] | 3838 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. |
| 3839 | |
| 3840 | Example matches X but not Y |
| 3841 | (matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 3842 | #include <Y.h> |
| 3843 | class X {}; |
| 3844 | Y.h: |
| 3845 | class Y {}; |
| 3846 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3847 | 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] | 3848 | </pre></td></tr> |
| 3849 | |
| 3850 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3851 | <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] | 3852 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. |
| 3853 | |
| 3854 | Example matches Y but not X |
| 3855 | (matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 3856 | #include <SystemHeader.h> |
| 3857 | class X {}; |
| 3858 | SystemHeader.h: |
| 3859 | class Y {}; |
| 3860 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3861 | 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] | 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_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] | 3866 | <tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool. |
| 3867 | |
| 3868 | Given |
| 3869 | struct S { bool func(); }; |
| 3870 | functionDecl(returns(booleanType())) |
| 3871 | matches "bool func();" |
| 3872 | </pre></td></tr> |
| 3873 | |
| 3874 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3875 | <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] | 3876 | <tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. |
| 3877 | |
| 3878 | Matches a node if it equals the node previously bound to ID. |
| 3879 | |
| 3880 | Given |
| 3881 | class X { int a; int b; }; |
| 3882 | cxxRecordDecl( |
| 3883 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 3884 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 3885 | matches the class X, as a and b have the same type. |
| 3886 | |
| 3887 | Note that when multiple matches are involved via forEach* matchers, |
| 3888 | equalsBoundNodes acts as a filter. |
| 3889 | For example: |
| 3890 | compoundStmt( |
| 3891 | forEachDescendant(varDecl().bind("d")), |
| 3892 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 3893 | will trigger a match for each combination of variable declaration |
| 3894 | and reference to that variable declaration within a compound statement. |
| 3895 | </pre></td></tr> |
| 3896 | |
| 3897 | |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 3898 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('equalsNode2')"><a name="equalsNode2Anchor">equalsNode</a></td><td>const Type* Other</td></tr> |
| 3899 | <tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node. |
| 3900 | |
| 3901 | Type has pointer identity in the AST. |
| 3902 | </pre></td></tr> |
| 3903 | |
| 3904 | |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 3905 | <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> |
| 3906 | <tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double). |
| 3907 | |
| 3908 | Given |
| 3909 | int i; |
| 3910 | float f; |
| 3911 | realFloatingPointType() |
| 3912 | matches "float f" but not "int i" |
| 3913 | </pre></td></tr> |
| 3914 | |
| 3915 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3916 | <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] | 3917 | <tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. |
| 3918 | |
| 3919 | Given |
| 3920 | struct S { void func(); }; |
| 3921 | functionDecl(returns(voidType())) |
| 3922 | matches "void func();" |
| 3923 | </pre></td></tr> |
| 3924 | |
| 3925 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3926 | <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] | 3927 | <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. |
| 3928 | |
| 3929 | Given |
| 3930 | int x; |
| 3931 | int s = sizeof(x) + alignof(x) |
| 3932 | unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) |
| 3933 | matches sizeof(x) |
| 3934 | </pre></td></tr> |
| 3935 | |
| 3936 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3937 | <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] | 3938 | <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or |
| 3939 | unary). |
| 3940 | |
| 3941 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 3942 | !(a || b) |
| 3943 | </pre></td></tr> |
| 3944 | |
| 3945 | |
Shuai Wang | e0248ae | 2018-09-17 18:48:43 +0000 | [diff] [blame] | 3946 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html">UnresolvedMemberExpr</a>></td><td class="name" onclick="toggle('isArrow1')"><a name="isArrow1Anchor">isArrow</a></td><td></td></tr> |
| 3947 | <tr><td colspan="4" class="doc" id="isArrow1"><pre>Matches member expressions that are called with '->' as opposed |
| 3948 | to '.'. |
| 3949 | |
| 3950 | Member calls on the implicit this pointer match as called with '->'. |
| 3951 | |
| 3952 | Given |
| 3953 | class Y { |
| 3954 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 3955 | template <class T> void f() { this->f<T>(); f<T>(); } |
| 3956 | int a; |
| 3957 | static int b; |
| 3958 | }; |
| 3959 | template <class T> |
| 3960 | class Z { |
| 3961 | void x() { this->m; } |
| 3962 | }; |
| 3963 | memberExpr(isArrow()) |
| 3964 | matches this->x, x, y.x, a, this->b |
| 3965 | cxxDependentScopeMemberExpr(isArrow()) |
| 3966 | matches this->m |
| 3967 | unresolvedMemberExpr(isArrow()) |
| 3968 | matches this->f<T>, f<T> |
| 3969 | </pre></td></tr> |
| 3970 | |
| 3971 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3972 | <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] | 3973 | <tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration. |
| 3974 | |
| 3975 | Example matches x, but not y, z, or a. |
| 3976 | (matcher = varDecl(hasAutomaticStorageDuration()) |
| 3977 | void f() { |
| 3978 | int x; |
| 3979 | static int y; |
| 3980 | thread_local int z; |
| 3981 | } |
| 3982 | int a; |
| 3983 | </pre></td></tr> |
| 3984 | |
| 3985 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3986 | <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] | 3987 | <tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. |
| 3988 | |
| 3989 | Example matches y and z (matcher = varDecl(hasGlobalStorage()) |
| 3990 | void f() { |
| 3991 | int x; |
| 3992 | static int y; |
| 3993 | } |
| 3994 | int z; |
| 3995 | </pre></td></tr> |
| 3996 | |
| 3997 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 3998 | <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] | 3999 | <tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a |
| 4000 | non-static local variable. |
| 4001 | |
| 4002 | Example matches x (matcher = varDecl(hasLocalStorage()) |
| 4003 | void f() { |
| 4004 | int x; |
| 4005 | static int y; |
| 4006 | } |
| 4007 | int z; |
| 4008 | </pre></td></tr> |
| 4009 | |
| 4010 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4011 | <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] | 4012 | <tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration. |
Haojian Wu | 398a8ea | 2016-09-27 07:53:20 +0000 | [diff] [blame] | 4013 | It includes the variable declared at namespace scope and those declared |
| 4014 | with "static" and "extern" storage class specifiers. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4015 | |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4016 | void f() { |
| 4017 | int x; |
| 4018 | static int y; |
| 4019 | thread_local int z; |
| 4020 | } |
| 4021 | int a; |
Haojian Wu | 398a8ea | 2016-09-27 07:53:20 +0000 | [diff] [blame] | 4022 | static int b; |
| 4023 | extern int c; |
| 4024 | varDecl(hasStaticStorageDuration()) |
| 4025 | matches the function declaration y, a, b and c. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4026 | </pre></td></tr> |
| 4027 | |
| 4028 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4029 | <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] | 4030 | <tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration. |
| 4031 | |
| 4032 | Example matches z, but not x, z, or a. |
| 4033 | (matcher = varDecl(hasThreadStorageDuration()) |
| 4034 | void f() { |
| 4035 | int x; |
| 4036 | static int y; |
| 4037 | thread_local int z; |
| 4038 | } |
| 4039 | int a; |
| 4040 | </pre></td></tr> |
| 4041 | |
| 4042 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4043 | <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> |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 4044 | <tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations, |
| 4045 | and if constexpr. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4046 | |
| 4047 | Given: |
| 4048 | constexpr int foo = 42; |
| 4049 | constexpr int bar(); |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 4050 | void baz() { if constexpr(1 > 0) {} } |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4051 | varDecl(isConstexpr()) |
| 4052 | matches the declaration of foo. |
| 4053 | functionDecl(isConstexpr()) |
| 4054 | matches the declaration of bar. |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 4055 | ifStmt(isConstexpr()) |
| 4056 | matches the if statement in baz. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4057 | </pre></td></tr> |
| 4058 | |
| 4059 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4060 | <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] | 4061 | <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. |
| 4062 | |
| 4063 | Example matches A, va, fa |
| 4064 | class A {}; |
| 4065 | class B; Doesn't match, as it has no body. |
| 4066 | int va; |
| 4067 | extern int vb; Doesn't match, as it doesn't define the variable. |
| 4068 | void fa() {} |
| 4069 | void fb(); Doesn't match, as it has no body. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 4070 | @interface X |
| 4071 | - (void)ma; Doesn't match, interface is declaration. |
| 4072 | @end |
| 4073 | @implementation X |
| 4074 | - (void)ma {} |
| 4075 | @end |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4076 | |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 4077 | 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>>, |
| 4078 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4079 | </pre></td></tr> |
| 4080 | |
| 4081 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4082 | <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] | 4083 | <tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from |
| 4084 | a C++ catch block, or an Objective-C statement. |
| 4085 | |
| 4086 | Example matches x (matcher = varDecl(isExceptionVariable()) |
| 4087 | void f(int y) { |
| 4088 | try { |
| 4089 | } catch (int x) { |
| 4090 | } |
| 4091 | } |
| 4092 | </pre></td></tr> |
| 4093 | |
| 4094 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4095 | <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] | 4096 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or |
| 4097 | static member variable template instantiations. |
| 4098 | |
| 4099 | Given |
| 4100 | template<typename T> void A(T t) { } |
| 4101 | template<> void A(int N) { } |
| 4102 | functionDecl(isExplicitTemplateSpecialization()) |
| 4103 | matches the specialization A<int>(). |
| 4104 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4105 | 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] | 4106 | </pre></td></tr> |
| 4107 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4108 | |
Benjamin Kramer | 87e6d99 | 2016-08-04 10:02:03 +0000 | [diff] [blame] | 4109 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isExternC1')"><a name="isExternC1Anchor">isExternC</a></td><td></td></tr> |
Alexander Shaposhnikov | f681c4e | 2017-09-22 19:29:38 +0000 | [diff] [blame] | 4110 | <tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations. |
Benjamin Kramer | 87e6d99 | 2016-08-04 10:02:03 +0000 | [diff] [blame] | 4111 | |
| 4112 | Given: |
| 4113 | extern "C" void f() {} |
| 4114 | extern "C" { void g() {} } |
| 4115 | void h() {} |
Alexander Shaposhnikov | f681c4e | 2017-09-22 19:29:38 +0000 | [diff] [blame] | 4116 | extern "C" int x = 1; |
| 4117 | extern "C" int y = 2; |
| 4118 | int z = 3; |
Benjamin Kramer | 87e6d99 | 2016-08-04 10:02:03 +0000 | [diff] [blame] | 4119 | functionDecl(isExternC()) |
Alexander Shaposhnikov | f681c4e | 2017-09-22 19:29:38 +0000 | [diff] [blame] | 4120 | matches the declaration of f and g, but not the declaration of h. |
| 4121 | varDecl(isExternC()) |
| 4122 | matches the declaration of x and y, but not the declaration of z. |
Benjamin Kramer | 87e6d99 | 2016-08-04 10:02:03 +0000 | [diff] [blame] | 4123 | </pre></td></tr> |
| 4124 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4125 | |
Haojian Wu | b3d2546 | 2016-09-26 16:01:52 +0000 | [diff] [blame] | 4126 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isStaticStorageClass1')"><a name="isStaticStorageClass1Anchor">isStaticStorageClass</a></td><td></td></tr> |
Haojian Wu | 398a8ea | 2016-09-27 07:53:20 +0000 | [diff] [blame] | 4127 | <tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variablefunction declarations that have "static" storage |
| 4128 | class specifier ("static" keyword) written in the source. |
Haojian Wu | b3d2546 | 2016-09-26 16:01:52 +0000 | [diff] [blame] | 4129 | |
| 4130 | Given: |
| 4131 | static void f() {} |
| 4132 | static int i = 0; |
Haojian Wu | 398a8ea | 2016-09-27 07:53:20 +0000 | [diff] [blame] | 4133 | extern int j; |
| 4134 | int k; |
Haojian Wu | b3d2546 | 2016-09-26 16:01:52 +0000 | [diff] [blame] | 4135 | functionDecl(isStaticStorageClass()) |
| 4136 | matches the function declaration f. |
| 4137 | varDecl(isStaticStorageClass()) |
| 4138 | matches the variable declaration i. |
| 4139 | </pre></td></tr> |
| 4140 | |
| 4141 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4142 | <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] | 4143 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static |
| 4144 | member variable template instantiations. |
| 4145 | |
| 4146 | Given |
| 4147 | template <typename T> class X {}; class A {}; X<A> x; |
| 4148 | or |
| 4149 | template <typename T> class X {}; class A {}; template class X<A>; |
Eric Liu | 09ee48e | 2018-02-21 14:22:42 +0000 | [diff] [blame] | 4150 | or |
| 4151 | template <typename T> class X {}; class A {}; extern template class X<A>; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4152 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 4153 | matches the template instantiation of X<A>. |
| 4154 | |
| 4155 | But given |
| 4156 | template <typename T> class X {}; class A {}; |
| 4157 | template <> class X<A> {}; X<A> x; |
| 4158 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 4159 | does not match, as X<A> is an explicit template specialization. |
| 4160 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4161 | 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] | 4162 | </pre></td></tr> |
| 4163 | |
| 4164 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4165 | <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] | 4166 | <tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside |
| 4167 | template instantiations. |
| 4168 | |
| 4169 | Given |
| 4170 | template<typename T> void A(T t) { T i; } |
| 4171 | A(0); |
| 4172 | A(0U); |
| 4173 | functionDecl(isInstantiated()) |
| 4174 | matches 'A(int) {...};' and 'A(unsigned) {...}'. |
| 4175 | </pre></td></tr> |
| 4176 | |
| 4177 | |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 4178 | <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> |
| 4179 | <tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as |
| 4180 | GNU's __null, C++11's nullptr, or C's NULL macro. |
| 4181 | |
| 4182 | Given: |
| 4183 | void *v1 = NULL; |
| 4184 | void *v2 = nullptr; |
| 4185 | void *v3 = __null; GNU extension |
| 4186 | char *cp = (char *)0; |
| 4187 | int *ip = 0; |
| 4188 | int i = 0; |
| 4189 | expr(nullPointerConstant()) |
| 4190 | matches the initializer for v1, v2, v3, cp, and ip. Does not match the |
| 4191 | initializer for i. |
| 4192 | </pre></td></tr> |
| 4193 | |
| 4194 | |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 4195 | <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> |
| 4196 | <tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names. |
| 4197 | |
| 4198 | This matcher is only provided as a performance optimization of hasName. |
| 4199 | hasAnyName(a, b, c) |
| 4200 | is equivalent to, but faster than |
| 4201 | anyOf(hasName(a), hasName(b), hasName(c)) |
| 4202 | </pre></td></tr> |
| 4203 | |
| 4204 | |
George Karpenkov | 88a16a0 | 2018-03-29 00:51:12 +0000 | [diff] [blame] | 4205 | <tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>>></td><td class="name" onclick="toggle('hasAnySelector0')"><a name="hasAnySelector0Anchor">hasAnySelector</a></td><td>StringRef, ..., StringRef</td></tr> |
| 4206 | <tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the |
| 4207 | Selector.getAsString() |
| 4208 | |
| 4209 | matcher = objCMessageExpr(hasSelector("methodA:", "methodB:")); |
| 4210 | matches both of the expressions below: |
| 4211 | [myObj methodA:argA]; |
| 4212 | [myObj methodB:argB]; |
| 4213 | </pre></td></tr> |
| 4214 | |
| 4215 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4216 | <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] | 4217 | <tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. |
| 4218 | |
| 4219 | Given |
| 4220 | int j; |
| 4221 | template<typename T> void A(T t) { T i; j += 42;} |
| 4222 | A(0); |
| 4223 | A(0U); |
| 4224 | declStmt(isInTemplateInstantiation()) |
| 4225 | matches 'int i;' and 'unsigned i'. |
| 4226 | unless(stmt(isInTemplateInstantiation())) |
| 4227 | will NOT match j += 42; as it's shared between the template definition and |
| 4228 | instantiation. |
| 4229 | </pre></td></tr> |
| 4230 | |
Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 4231 | <!--END_NARROWING_MATCHERS --> |
| 4232 | </table> |
| 4233 | |
| 4234 | <!-- ======================================================================= --> |
| 4235 | <h2 id="traversal-matchers">AST Traversal Matchers</h2> |
| 4236 | <!-- ======================================================================= --> |
| 4237 | |
| 4238 | <p>Traversal matchers specify the relationship to other nodes that are |
| 4239 | reachable from the current node.</p> |
| 4240 | |
| 4241 | <p>Note that there are special traversal matchers (has, hasDescendant, forEach and |
| 4242 | forEachDescendant) which work on all nodes and allow users to write more generic |
| 4243 | match expressions.</p> |
| 4244 | |
| 4245 | <table> |
| 4246 | <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] | 4247 | <!-- START_TRAVERSAL_MATCHERS --> |
| 4248 | |
| 4249 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 4250 | <tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. |
| 4251 | |
| 4252 | Unlike anyOf, eachOf will generate a match result for each |
| 4253 | matching submatcher. |
| 4254 | |
| 4255 | For example, in: |
| 4256 | class A { int a; int b; }; |
| 4257 | The matcher: |
| 4258 | cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), |
| 4259 | has(fieldDecl(hasName("b")).bind("v")))) |
| 4260 | will generate two results binding "v", the first of which binds |
| 4261 | the field declaration of a, the second the field declaration of |
| 4262 | b. |
| 4263 | |
| 4264 | Usable as: Any Matcher |
| 4265 | </pre></td></tr> |
| 4266 | |
| 4267 | |
| 4268 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> |
| 4269 | <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 4270 | provided matcher. |
| 4271 | |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 4272 | Example matches X, A, A::X, B, B::C, B::C::X |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4273 | (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 4274 | class X {}; |
| 4275 | class A { class X {}; }; Matches A, because A::X is a class of name |
| 4276 | X inside A. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4277 | class B { class C { class X {}; }; }; |
| 4278 | |
| 4279 | DescendantT must be an AST base type. |
| 4280 | |
| 4281 | As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for |
| 4282 | each result that matches instead of only on the first one. |
| 4283 | |
| 4284 | Note: Recursively combined ForEachDescendant can cause many matches: |
| 4285 | cxxRecordDecl(forEachDescendant(cxxRecordDecl( |
| 4286 | forEachDescendant(cxxRecordDecl()) |
| 4287 | ))) |
| 4288 | will match 10 times (plus injected class name matches) on: |
| 4289 | class A { class B { class C { class D { class E {}; }; }; }; }; |
| 4290 | |
| 4291 | Usable as: Any Matcher |
| 4292 | </pre></td></tr> |
| 4293 | |
| 4294 | |
| 4295 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> |
| 4296 | <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the |
| 4297 | provided matcher. |
| 4298 | |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 4299 | Example matches X, Y, Y::X, Z::Y, Z::Y::X |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4300 | (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 4301 | class X {}; |
| 4302 | class Y { class X {}; }; Matches Y, because Y::X is a class of name X |
| 4303 | inside Y. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4304 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 4305 | |
| 4306 | ChildT must be an AST base type. |
| 4307 | |
| 4308 | As opposed to 'has', 'forEach' will cause a match for each result that |
| 4309 | matches instead of only on the first one. |
| 4310 | |
| 4311 | Usable as: Any Matcher |
| 4312 | </pre></td></tr> |
| 4313 | |
| 4314 | |
| 4315 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> |
| 4316 | <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided |
| 4317 | matcher. |
| 4318 | |
| 4319 | Given |
| 4320 | void f() { if (true) { int x = 42; } } |
| 4321 | void g() { for (;;) { int x = 43; } } |
| 4322 | expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. |
| 4323 | |
| 4324 | Usable as: Any Matcher |
| 4325 | </pre></td></tr> |
| 4326 | |
| 4327 | |
| 4328 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> |
| 4329 | <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 4330 | provided matcher. |
| 4331 | |
| 4332 | Example matches X, Y, Z |
| 4333 | (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) |
| 4334 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 4335 | class Y { class X {}; }; |
| 4336 | class Z { class Y { class X {}; }; }; |
| 4337 | |
| 4338 | DescendantT must be an AST base type. |
| 4339 | |
| 4340 | Usable as: Any Matcher |
| 4341 | </pre></td></tr> |
| 4342 | |
| 4343 | |
| 4344 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> |
| 4345 | <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the |
| 4346 | provided matcher. |
| 4347 | |
| 4348 | Example matches X, Y |
| 4349 | (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) |
| 4350 | class X {}; Matches X, because X::X is a class of name X inside X. |
| 4351 | class Y { class X {}; }; |
| 4352 | class Z { class Y { class X {}; }; }; Does not match Z. |
| 4353 | |
| 4354 | ChildT must be an AST base type. |
| 4355 | |
| 4356 | Usable as: Any Matcher |
Aaron Ballman | ba8dbbe | 2016-06-06 18:52:17 +0000 | [diff] [blame] | 4357 | Note that has is direct matcher, so it also matches things like implicit |
| 4358 | casts and paren casts. If you are matching with expr then you should |
| 4359 | probably consider using ignoringParenImpCasts like: |
| 4360 | has(ignoringParenImpCasts(expr())). |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4361 | </pre></td></tr> |
| 4362 | |
| 4363 | |
| 4364 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> |
| 4365 | <tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided |
| 4366 | matcher. |
| 4367 | |
| 4368 | Given |
| 4369 | void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } |
| 4370 | compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". |
| 4371 | |
| 4372 | Usable as: Any Matcher |
| 4373 | </pre></td></tr> |
| 4374 | |
| 4375 | |
Etienne Bergeron | 5500f95 | 2016-05-30 15:25:25 +0000 | [diff] [blame] | 4376 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</a>></td><td class="name" onclick="toggle('hasCondition5')"><a name="hasCondition5Anchor">hasCondition</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 4377 | <tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop, |
| 4378 | switch statement or conditional operator. |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4379 | |
| 4380 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 4381 | if (true) {} |
| 4382 | </pre></td></tr> |
| 4383 | |
| 4384 | |
| 4385 | <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> |
| 4386 | <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator |
| 4387 | (binary or ternary). |
| 4388 | |
| 4389 | Example matches b |
| 4390 | condition ? a : b |
| 4391 | condition ?: b |
| 4392 | </pre></td></tr> |
| 4393 | |
| 4394 | |
| 4395 | <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> |
| 4396 | <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. |
| 4397 | |
| 4398 | Example 1 (conditional ternary operator): matches a |
| 4399 | condition ? a : b |
| 4400 | |
| 4401 | Example 2 (conditional binary operator): matches opaqueValueExpr(condition) |
| 4402 | condition ?: b |
| 4403 | </pre></td></tr> |
| 4404 | |
| 4405 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4406 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>></td><td class="name" onclick="toggle('hasDeclaration15')"><a name="hasDeclaration15Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 4407 | <tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4408 | matches the given matcher. |
| 4409 | |
| 4410 | The associated declaration is: |
| 4411 | - for type nodes, the declaration of the underlying type |
| 4412 | - for CallExpr, the declaration of the callee |
| 4413 | - for MemberExpr, the declaration of the referenced member |
| 4414 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 4415 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 4416 | - for ObjCIvarExpr, the declaration of the ivar |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4417 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4418 | For type nodes, hasDeclaration will generally match the declaration of the |
| 4419 | sugared type. Given |
| 4420 | class X {}; |
| 4421 | typedef X Y; |
| 4422 | Y y; |
| 4423 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 4424 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 4425 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 4426 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 4427 | recordType(hasDeclaration(decl()))))) |
| 4428 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4429 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 4430 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 4431 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 4432 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 4433 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 4434 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 4435 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 4436 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 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_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] | 4441 | <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. |
| 4442 | |
| 4443 | Given |
| 4444 | int i[5]; |
| 4445 | void f() { i[1] = 42; } |
| 4446 | arraySubscriptExpression(hasBase(implicitCastExpr( |
| 4447 | hasSourceExpression(declRefExpr())))) |
| 4448 | matches i[1] with the declRefExpr() matching i |
| 4449 | </pre></td></tr> |
| 4450 | |
| 4451 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4452 | <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] | 4453 | <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. |
| 4454 | |
| 4455 | Given |
| 4456 | int i[5]; |
| 4457 | void f() { i[1] = 42; } |
| 4458 | arraySubscriptExpression(hasIndex(integerLiteral())) |
| 4459 | matches i[1] with the integerLiteral() matching 1 |
| 4460 | </pre></td></tr> |
| 4461 | |
| 4462 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4463 | <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] | 4464 | <tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions. |
| 4465 | |
| 4466 | Example matches a (matcher = binaryOperator(hasLHS())) |
| 4467 | a || b |
| 4468 | </pre></td></tr> |
| 4469 | |
| 4470 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4471 | <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] | 4472 | <tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions. |
| 4473 | |
| 4474 | Example matches b (matcher = binaryOperator(hasRHS())) |
| 4475 | a || b |
| 4476 | </pre></td></tr> |
| 4477 | |
| 4478 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4479 | <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] | 4480 | <tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element |
| 4481 | type. |
| 4482 | |
| 4483 | Given |
| 4484 | struct A {}; |
| 4485 | A a[7]; |
| 4486 | int b[7]; |
| 4487 | arrayType(hasElementType(builtinType())) |
| 4488 | matches "int b[7]" |
| 4489 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4490 | 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] | 4491 | </pre></td></tr> |
| 4492 | |
| 4493 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4494 | <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] | 4495 | <tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. |
| 4496 | |
| 4497 | Given |
| 4498 | _Atomic(int) i; |
| 4499 | _Atomic(float) f; |
| 4500 | atomicType(hasValueType(isInteger())) |
| 4501 | matches "_Atomic(int) i" |
| 4502 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4503 | 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] | 4504 | </pre></td></tr> |
| 4505 | |
| 4506 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4507 | <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] | 4508 | <tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. |
| 4509 | |
| 4510 | Note: There is no TypeLoc for the deduced type and thus no |
| 4511 | getDeducedLoc() matcher. |
| 4512 | |
| 4513 | Given |
| 4514 | auto a = 1; |
| 4515 | auto b = 2.0; |
| 4516 | autoType(hasDeducedType(isInteger())) |
| 4517 | matches "auto a" |
| 4518 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4519 | 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] | 4520 | </pre></td></tr> |
| 4521 | |
| 4522 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4523 | <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>const 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] | 4524 | <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a |
| 4525 | binary operator matches. |
| 4526 | </pre></td></tr> |
| 4527 | |
| 4528 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4529 | <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] | 4530 | <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. |
| 4531 | |
| 4532 | Example matches a (matcher = binaryOperator(hasLHS())) |
| 4533 | a || b |
| 4534 | </pre></td></tr> |
| 4535 | |
| 4536 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4537 | <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] | 4538 | <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. |
| 4539 | |
| 4540 | Example matches b (matcher = binaryOperator(hasRHS())) |
| 4541 | a || b |
| 4542 | </pre></td></tr> |
| 4543 | |
| 4544 | |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 4545 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>></td><td class="name" onclick="toggle('hasAnyParameter2')"><a name="hasAnyParameter2Anchor">hasAnyParameter</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> |
| 4546 | <tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a |
| 4547 | block. |
| 4548 | |
| 4549 | Does not match the 'this' parameter of a method. |
| 4550 | |
| 4551 | Given |
| 4552 | class X { void f(int x, int y, int z) {} }; |
| 4553 | cxxMethodDecl(hasAnyParameter(hasName("y"))) |
| 4554 | matches f(int x, int y, int z) {} |
| 4555 | with hasAnyParameter(...) |
| 4556 | matching int y |
| 4557 | |
| 4558 | For ObjectiveC, given |
| 4559 | @interface I - (void) f:(int) y; @end |
| 4560 | |
| 4561 | the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) |
| 4562 | matches the declaration of method f with hasParameter |
| 4563 | matching y. |
| 4564 | |
| 4565 | For blocks, given |
| 4566 | b = ^(int y) { printf("%d", y) }; |
| 4567 | |
| 4568 | the matcher blockDecl(hasAnyParameter(hasName("y"))) |
| 4569 | matches the declaration of the block b with hasParameter |
| 4570 | matching y. |
| 4571 | </pre></td></tr> |
| 4572 | |
| 4573 | |
| 4574 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>></td><td class="name" onclick="toggle('hasParameter2')"><a name="hasParameter2Anchor">hasParameter</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> |
| 4575 | <tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method |
| 4576 | declaration or a block. |
| 4577 | |
| 4578 | Given |
| 4579 | class X { void f(int x) {} }; |
| 4580 | cxxMethodDecl(hasParameter(0, hasType(varDecl()))) |
| 4581 | matches f(int x) {} |
| 4582 | with hasParameter(...) |
| 4583 | matching int x |
| 4584 | |
| 4585 | For ObjectiveC, given |
| 4586 | @interface I - (void) f:(int) y; @end |
| 4587 | |
| 4588 | the matcher objcMethodDecl(hasParameter(0, hasName("y"))) |
| 4589 | matches the declaration of method f with hasParameter |
| 4590 | matching y. |
| 4591 | </pre></td></tr> |
| 4592 | |
| 4593 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4594 | <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] | 4595 | <tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4596 | pointee matches a given matcher. |
| 4597 | |
| 4598 | Given |
| 4599 | int *a; |
| 4600 | int const *b; |
| 4601 | float const *f; |
| 4602 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4603 | matches "int const *b" |
| 4604 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4605 | 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>>, |
| 4606 | 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] | 4607 | </pre></td></tr> |
| 4608 | |
| 4609 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4610 | <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] | 4611 | <tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl. |
| 4612 | |
| 4613 | Given |
| 4614 | void f(int i); |
| 4615 | int y; |
| 4616 | f(y); |
Clement Courbet | 4251759 | 2016-07-12 06:36:00 +0000 | [diff] [blame] | 4617 | callExpr( |
| 4618 | forEachArgumentWithParam( |
| 4619 | declRefExpr(to(varDecl(hasName("y")))), |
| 4620 | parmVarDecl(hasType(isInteger())) |
| 4621 | )) |
Aaron Ballman | d7b18b9 | 2016-01-18 20:28:57 +0000 | [diff] [blame] | 4622 | matches f(y); |
| 4623 | with declRefExpr(...) |
| 4624 | matching int y |
| 4625 | and parmVarDecl(...) |
| 4626 | matching int i |
| 4627 | </pre></td></tr> |
| 4628 | |
| 4629 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4630 | <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] | 4631 | <tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 4632 | expression, or an ObjC-message-send expression. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4633 | |
| 4634 | Given |
| 4635 | void x(int, int, int) { int y; x(1, y, 42); } |
| 4636 | callExpr(hasAnyArgument(declRefExpr())) |
| 4637 | matches x(1, y, 42) |
| 4638 | with hasAnyArgument(...) |
| 4639 | matching y |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 4640 | |
| 4641 | For ObjectiveC, given |
| 4642 | @interface I - (void) f:(int) y; @end |
Clement Courbet | 2513aa0 | 2018-03-21 10:48:00 +0000 | [diff] [blame] | 4643 | void foo(I *i) { [i f:12]; } |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 4644 | objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) |
| 4645 | matches [i f:12] |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4646 | </pre></td></tr> |
| 4647 | |
| 4648 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4649 | <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] | 4650 | <tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor |
| 4651 | call expression. |
| 4652 | |
| 4653 | Example matches y in x(y) |
| 4654 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 4655 | void x(int) { int y; x(y); } |
| 4656 | </pre></td></tr> |
| 4657 | |
| 4658 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4659 | <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>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4660 | <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] | 4661 | matches the given matcher. |
| 4662 | |
| 4663 | The associated declaration is: |
| 4664 | - for type nodes, the declaration of the underlying type |
| 4665 | - for CallExpr, the declaration of the callee |
| 4666 | - for MemberExpr, the declaration of the referenced member |
| 4667 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 4668 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 4669 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4670 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4671 | For type nodes, hasDeclaration will generally match the declaration of the |
| 4672 | sugared type. Given |
| 4673 | class X {}; |
| 4674 | typedef X Y; |
| 4675 | Y y; |
| 4676 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 4677 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 4678 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 4679 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 4680 | recordType(hasDeclaration(decl()))))) |
| 4681 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4682 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 4683 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 4684 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 4685 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 4686 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 4687 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 4688 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 4689 | 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] | 4690 | </pre></td></tr> |
| 4691 | |
| 4692 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4693 | <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] | 4694 | <tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. |
| 4695 | |
| 4696 | Given |
| 4697 | class A { A() : i(42), j(42) {} int i; int j; }; |
| 4698 | cxxConstructorDecl(forEachConstructorInitializer( |
| 4699 | forField(decl().bind("x")) |
| 4700 | )) |
| 4701 | will trigger two matches, binding for 'i' and 'j' respectively. |
| 4702 | </pre></td></tr> |
| 4703 | |
| 4704 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4705 | <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] | 4706 | <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. |
| 4707 | |
| 4708 | Given |
| 4709 | struct Foo { |
| 4710 | Foo() : foo_(1) { } |
| 4711 | int foo_; |
| 4712 | }; |
| 4713 | cxxRecordDecl(has(cxxConstructorDecl( |
| 4714 | hasAnyConstructorInitializer(anything()) |
| 4715 | ))) |
| 4716 | record matches Foo, hasAnyConstructorInitializer matches foo_(1) |
| 4717 | </pre></td></tr> |
| 4718 | |
| 4719 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4720 | <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] | 4721 | <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. |
| 4722 | |
| 4723 | Given |
| 4724 | struct Foo { |
| 4725 | Foo() : foo_(1) { } |
| 4726 | int foo_; |
| 4727 | }; |
| 4728 | cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( |
| 4729 | forField(hasName("foo_")))))) |
| 4730 | matches Foo |
| 4731 | with forField matching foo_ |
| 4732 | </pre></td></tr> |
| 4733 | |
| 4734 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4735 | <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] | 4736 | <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. |
| 4737 | |
| 4738 | Given |
| 4739 | struct Foo { |
| 4740 | Foo() : foo_(1) { } |
| 4741 | int foo_; |
| 4742 | }; |
| 4743 | cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( |
| 4744 | withInitializer(integerLiteral(equals(1))))))) |
| 4745 | matches Foo |
| 4746 | with withInitializer matching (1) |
| 4747 | </pre></td></tr> |
| 4748 | |
| 4749 | |
Shuai Wang | 92f9d1b | 2018-08-23 17:16:06 +0000 | [diff] [blame] | 4750 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>></td><td class="name" onclick="toggle('hasObjectExpression2')"><a name="hasObjectExpression2Anchor">hasObjectExpression</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 4751 | <tr><td colspan="4" class="doc" id="hasObjectExpression2"><pre>Matches a member expression where the object expression is |
| 4752 | matched by a given matcher. |
| 4753 | |
| 4754 | Given |
| 4755 | struct X { int m; }; |
| 4756 | void f(X x) { x.m; m; } |
| 4757 | memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))))) |
| 4758 | matches "x.m" and "m" |
| 4759 | with hasObjectExpression(...) |
| 4760 | matching "x" and the implicit object expression of "m" which has type X*. |
| 4761 | </pre></td></tr> |
| 4762 | |
| 4763 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4764 | <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] | 4765 | <tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 4766 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4767 | |
| 4768 | Given |
| 4769 | for (;;) {} |
| 4770 | hasBody(compoundStmt()) |
| 4771 | matches 'for (;;) {}' |
| 4772 | with compoundStmt() |
| 4773 | matching '{}' |
| 4774 | </pre></td></tr> |
| 4775 | |
| 4776 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4777 | <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] | 4778 | <tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. |
| 4779 | |
| 4780 | Example: |
| 4781 | forStmt(hasLoopVariable(anything())) |
| 4782 | matches 'int x' in |
| 4783 | for (int x : a) { } |
| 4784 | </pre></td></tr> |
| 4785 | |
| 4786 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4787 | <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] | 4788 | <tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. |
| 4789 | |
| 4790 | Example: |
| 4791 | forStmt(hasRangeInit(anything())) |
| 4792 | matches 'a' in |
| 4793 | for (int x : a) { } |
| 4794 | </pre></td></tr> |
| 4795 | |
| 4796 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4797 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_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] | 4798 | <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> |
| 4799 | |
| 4800 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4801 | <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] | 4802 | <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. |
| 4803 | |
| 4804 | Example matches y.x() |
| 4805 | (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))) |
| 4806 | class Y { public: void x(); }; |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 4807 | void z() { Y y; y.x(); } |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4808 | |
| 4809 | FIXME: Overload to allow directly matching types? |
| 4810 | </pre></td></tr> |
| 4811 | |
| 4812 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4813 | <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] | 4814 | <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. |
| 4815 | </pre></td></tr> |
| 4816 | |
| 4817 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4818 | <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] | 4819 | <tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified |
| 4820 | matcher, or is a pointer to a type that matches the InnerMatcher. |
| 4821 | </pre></td></tr> |
| 4822 | |
| 4823 | |
Clement Courbet | 6ecaec8 | 2016-07-05 07:49:31 +0000 | [diff] [blame] | 4824 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('forEachOverridden0')"><a name="forEachOverridden0Anchor">forEachOverridden</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> InnerMatcher</td></tr> |
Alexander Kornienko | 2a8c18d | 2018-04-06 15:14:32 +0000 | [diff] [blame] | 4825 | <tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may |
Clement Courbet | 6ecaec8 | 2016-07-05 07:49:31 +0000 | [diff] [blame] | 4826 | produce multiple matches. |
| 4827 | |
| 4828 | Given |
| 4829 | class A { virtual void f(); }; |
| 4830 | class B : public A { void f(); }; |
| 4831 | class C : public B { void f(); }; |
| 4832 | cxxMethodDecl(ofClass(hasName("C")), |
| 4833 | forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") |
| 4834 | matches once, with "b" binding "A::f" and "d" binding "C::f" (Note |
| 4835 | that B::f is not overridden by C::f). |
| 4836 | |
| 4837 | The check can produce multiple matches in case of multiple inheritance, e.g. |
| 4838 | class A1 { virtual void f(); }; |
| 4839 | class A2 { virtual void f(); }; |
| 4840 | class C : public A1, public A2 { void f(); }; |
| 4841 | cxxMethodDecl(ofClass(hasName("C")), |
| 4842 | forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") |
| 4843 | matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and |
| 4844 | once with "b" binding "A2::f" and "d" binding "C::f". |
| 4845 | </pre></td></tr> |
| 4846 | |
| 4847 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4848 | <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] | 4849 | <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration |
| 4850 | belongs to. |
| 4851 | |
| 4852 | FIXME: Generalize this for other kinds of declarations. |
| 4853 | FIXME: What other kind of declarations would we need to generalize |
| 4854 | this to? |
| 4855 | |
| 4856 | Example matches A() in the last line |
| 4857 | (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( |
| 4858 | ofClass(hasName("A")))))) |
| 4859 | class A { |
| 4860 | public: |
| 4861 | A(); |
| 4862 | }; |
| 4863 | A a = A(); |
| 4864 | </pre></td></tr> |
| 4865 | |
| 4866 | |
Adam Balogh | da488a6 | 2017-11-23 12:43:20 +0000 | [diff] [blame] | 4867 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('hasArraySize0')"><a name="hasArraySize0Anchor">hasArraySize</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 4868 | <tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size. |
| 4869 | |
| 4870 | Given: |
| 4871 | MyClass *p1 = new MyClass[10]; |
| 4872 | cxxNewExpr(hasArraySize(intgerLiteral(equals(10)))) |
| 4873 | matches the expression 'new MyClass[10]'. |
| 4874 | </pre></td></tr> |
| 4875 | |
| 4876 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4877 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('hasDeclaration12')"><a name="hasDeclaration12Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 4878 | <tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 4879 | matches the given matcher. |
| 4880 | |
| 4881 | The associated declaration is: |
| 4882 | - for type nodes, the declaration of the underlying type |
| 4883 | - for CallExpr, the declaration of the callee |
| 4884 | - for MemberExpr, the declaration of the referenced member |
| 4885 | - for CXXConstructExpr, the declaration of the constructor |
| 4886 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 4887 | - for ObjCIvarExpr, the declaration of the ivar |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 4888 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4889 | For type nodes, hasDeclaration will generally match the declaration of the |
| 4890 | sugared type. Given |
| 4891 | class X {}; |
| 4892 | typedef X Y; |
| 4893 | Y y; |
| 4894 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 4895 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 4896 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 4897 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 4898 | recordType(hasDeclaration(decl()))))) |
| 4899 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 4900 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 4901 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 4902 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 4903 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 4904 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 4905 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 4906 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 4907 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 4908 | </pre></td></tr> |
| 4909 | |
| 4910 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4911 | <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] | 4912 | <tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. |
| 4913 | |
| 4914 | Given: |
| 4915 | class A { void func(); }; |
| 4916 | class B { void member(); }; |
| 4917 | |
| 4918 | cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of |
| 4919 | A but not B. |
| 4920 | </pre></td></tr> |
| 4921 | |
| 4922 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4923 | <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] | 4924 | <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from |
| 4925 | a class matching Base. |
| 4926 | |
| 4927 | Note that a class is not considered to be derived from itself. |
| 4928 | |
| 4929 | Example matches Y, Z, C (Base == hasName("X")) |
| 4930 | class X; |
| 4931 | class Y : public X {}; directly derived |
| 4932 | class Z : public Y {}; indirectly derived |
| 4933 | typedef X A; |
| 4934 | typedef A B; |
| 4935 | class C : public B {}; derived from a typedef of X |
| 4936 | |
| 4937 | In the following example, Bar matches isDerivedFrom(hasName("X")): |
| 4938 | class Foo; |
| 4939 | typedef Foo X; |
| 4940 | class Bar : public Foo {}; derived from a type that X is a typedef of |
| 4941 | </pre></td></tr> |
| 4942 | |
| 4943 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4944 | <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] | 4945 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly |
| 4946 | match Base. |
| 4947 | </pre></td></tr> |
| 4948 | |
| 4949 | |
Shuai Wang | 3b2a17b | 2018-08-12 23:30:05 +0000 | [diff] [blame] | 4950 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>></td><td class="name" onclick="toggle('hasAnyArgument2')"><a name="hasAnyArgument2Anchor">hasAnyArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 4951 | <tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call |
| 4952 | expression, or an ObjC-message-send expression. |
| 4953 | |
| 4954 | Given |
| 4955 | void x(int, int, int) { int y; x(1, y, 42); } |
| 4956 | callExpr(hasAnyArgument(declRefExpr())) |
| 4957 | matches x(1, y, 42) |
| 4958 | with hasAnyArgument(...) |
| 4959 | matching y |
| 4960 | |
| 4961 | For ObjectiveC, given |
| 4962 | @interface I - (void) f:(int) y; @end |
| 4963 | void foo(I *i) { [i f:12]; } |
| 4964 | objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) |
| 4965 | matches [i f:12] |
| 4966 | </pre></td></tr> |
| 4967 | |
| 4968 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4969 | <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] | 4970 | <tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the |
| 4971 | given matcher. |
| 4972 | |
| 4973 | Example matches y.x() (matcher = callExpr(callee( |
| 4974 | cxxMethodDecl(hasName("x"))))) |
| 4975 | class Y { public: void x(); }; |
| 4976 | void z() { Y y; y.x(); } |
| 4977 | </pre></td></tr> |
| 4978 | |
| 4979 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4980 | <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] | 4981 | <tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. |
| 4982 | |
| 4983 | Given |
| 4984 | class Y { void x() { this->x(); x(); Y y; y.x(); } }; |
| 4985 | void f() { f(); } |
| 4986 | callExpr(callee(expr())) |
| 4987 | matches this->x(), x(), y.x(), f() |
| 4988 | with callee(...) |
| 4989 | matching this->x, x, y.x, f respectively |
| 4990 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4991 | 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] | 4992 | because this introduces ambiguous overloads with calls to Callee taking a |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4993 | 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] | 4994 | implemented in terms of implicit casts. |
| 4995 | </pre></td></tr> |
| 4996 | |
| 4997 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 4998 | <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] | 4999 | <tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl. |
| 5000 | |
| 5001 | Given |
| 5002 | void f(int i); |
| 5003 | int y; |
| 5004 | f(y); |
Clement Courbet | 4251759 | 2016-07-12 06:36:00 +0000 | [diff] [blame] | 5005 | callExpr( |
| 5006 | forEachArgumentWithParam( |
| 5007 | declRefExpr(to(varDecl(hasName("y")))), |
| 5008 | parmVarDecl(hasType(isInteger())) |
| 5009 | )) |
Aaron Ballman | d7b18b9 | 2016-01-18 20:28:57 +0000 | [diff] [blame] | 5010 | matches f(y); |
| 5011 | with declRefExpr(...) |
| 5012 | matching int y |
| 5013 | and parmVarDecl(...) |
| 5014 | matching int i |
| 5015 | </pre></td></tr> |
| 5016 | |
| 5017 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5018 | <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] | 5019 | <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 5020 | expression, or an ObjC-message-send expression. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5021 | |
| 5022 | Given |
| 5023 | void x(int, int, int) { int y; x(1, y, 42); } |
| 5024 | callExpr(hasAnyArgument(declRefExpr())) |
| 5025 | matches x(1, y, 42) |
| 5026 | with hasAnyArgument(...) |
| 5027 | matching y |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 5028 | |
| 5029 | For ObjectiveC, given |
| 5030 | @interface I - (void) f:(int) y; @end |
Clement Courbet | 2513aa0 | 2018-03-21 10:48:00 +0000 | [diff] [blame] | 5031 | void foo(I *i) { [i f:12]; } |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 5032 | objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) |
| 5033 | matches [i f:12] |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5034 | </pre></td></tr> |
| 5035 | |
| 5036 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5037 | <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] | 5038 | <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor |
| 5039 | call expression. |
| 5040 | |
| 5041 | Example matches y in x(y) |
| 5042 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 5043 | void x(int) { int y; x(y); } |
| 5044 | </pre></td></tr> |
| 5045 | |
| 5046 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5047 | <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>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 5048 | <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] | 5049 | matches the given matcher. |
| 5050 | |
| 5051 | The associated declaration is: |
| 5052 | - for type nodes, the declaration of the underlying type |
| 5053 | - for CallExpr, the declaration of the callee |
| 5054 | - for MemberExpr, the declaration of the referenced member |
| 5055 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 5056 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 5057 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5058 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5059 | For type nodes, hasDeclaration will generally match the declaration of the |
| 5060 | sugared type. Given |
| 5061 | class X {}; |
| 5062 | typedef X Y; |
| 5063 | Y y; |
| 5064 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 5065 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 5066 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 5067 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 5068 | recordType(hasDeclaration(decl()))))) |
| 5069 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5070 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5071 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 5072 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 5073 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 5074 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 5075 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 5076 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 5077 | 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] | 5078 | </pre></td></tr> |
| 5079 | |
| 5080 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5081 | <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] | 5082 | <tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range |
| 5083 | extension, matches the constant given in the statement. |
| 5084 | |
| 5085 | Given |
| 5086 | switch (1) { case 1: case 1+1: case 3 ... 4: ; } |
| 5087 | caseStmt(hasCaseConstant(integerLiteral())) |
| 5088 | matches "case 1:" |
| 5089 | </pre></td></tr> |
| 5090 | |
| 5091 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5092 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>></td><td class="name" onclick="toggle('hasSourceExpression0')"><a name="hasSourceExpression0Anchor">hasSourceExpression</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5093 | <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression |
| 5094 | or opaque value's source expression matches the given matcher. |
| 5095 | |
| 5096 | Example 1: matches "a string" |
| 5097 | (matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) |
| 5098 | class URL { URL(string); }; |
| 5099 | URL url = "a string"; |
| 5100 | |
| 5101 | Example 2: matches 'b' (matcher = |
| 5102 | opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) |
| 5103 | int a = b ?: 1; |
| 5104 | </pre></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5105 | |
| 5106 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5107 | <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> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5108 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and |
| 5109 | functionDecl that have at least one TemplateArgument matching the given |
| 5110 | InnerMatcher. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5111 | |
| 5112 | Given |
| 5113 | template<typename T> class A {}; |
| 5114 | template<> class A<double> {}; |
| 5115 | A<int> a; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5116 | |
Haojian Wu | 99e39a7 | 2016-07-29 17:30:13 +0000 | [diff] [blame] | 5117 | template<typename T> f() {}; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5118 | void func() { f<int>(); }; |
| 5119 | |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5120 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 5121 | refersToType(asString("int")))) |
| 5122 | matches the specialization A<int> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5123 | |
| 5124 | functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) |
| 5125 | matches the specialization f<int> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5126 | </pre></td></tr> |
| 5127 | |
| 5128 | |
Manuel Klimek | 696e505 | 2017-08-02 13:04:44 +0000 | [diff] [blame] | 5129 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('hasSpecializedTemplate0')"><a name="hasSpecializedTemplate0Anchor">hasSpecializedTemplate</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>> InnerMatcher</td></tr> |
| 5130 | <tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration. |
| 5131 | |
| 5132 | Given |
Stephen Kelly | 9b8fa52 | 2018-10-09 08:24:11 +0000 | [diff] [blame] | 5133 | template<typename T> class A {}; #1 |
| 5134 | template<> class A<int> {}; #2 |
Manuel Klimek | 696e505 | 2017-08-02 13:04:44 +0000 | [diff] [blame] | 5135 | classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl())) |
Stephen Kelly | 9b8fa52 | 2018-10-09 08:24:11 +0000 | [diff] [blame] | 5136 | matches '#2' with classTemplateDecl() matching the class template |
| 5137 | declaration of 'A' at #1. |
Manuel Klimek | 696e505 | 2017-08-02 13:04:44 +0000 | [diff] [blame] | 5138 | </pre></td></tr> |
| 5139 | |
| 5140 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5141 | <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> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5142 | <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and |
| 5143 | functionDecl where the n'th TemplateArgument matches the given InnerMatcher. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5144 | |
| 5145 | Given |
| 5146 | template<typename T, typename U> class A {}; |
| 5147 | A<bool, int> b; |
| 5148 | A<int, bool> c; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5149 | |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 5150 | template<typename T> void f() {} |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5151 | void func() { f<int>(); }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5152 | classTemplateSpecializationDecl(hasTemplateArgument( |
| 5153 | 1, refersToType(asString("int")))) |
| 5154 | matches the specialization A<bool, int> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5155 | |
| 5156 | functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) |
| 5157 | matches the specialization f<int> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5158 | </pre></td></tr> |
| 5159 | |
| 5160 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5161 | <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] | 5162 | <tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element |
| 5163 | type. |
| 5164 | |
| 5165 | Given |
| 5166 | struct A {}; |
| 5167 | A a[7]; |
| 5168 | int b[7]; |
| 5169 | arrayType(hasElementType(builtinType())) |
| 5170 | matches "int b[7]" |
| 5171 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5172 | 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] | 5173 | </pre></td></tr> |
| 5174 | |
| 5175 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5176 | <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] | 5177 | <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] | 5178 | a given matcher. Also matches StmtExprs that have CompoundStmt as children. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5179 | |
| 5180 | Given |
| 5181 | { {}; 1+2; } |
| 5182 | hasAnySubstatement(compoundStmt()) |
| 5183 | matches '{ {}; 1+2; }' |
| 5184 | with compoundStmt() |
| 5185 | matching '{}' |
| 5186 | </pre></td></tr> |
| 5187 | |
| 5188 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5189 | <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] | 5190 | <tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whos decayed type matches InnerMatcher |
| 5191 | </pre></td></tr> |
| 5192 | |
| 5193 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5194 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('hasDeclaration11')"><a name="hasDeclaration11Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5195 | <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] | 5196 | matches the given matcher. |
| 5197 | |
| 5198 | The associated declaration is: |
| 5199 | - for type nodes, the declaration of the underlying type |
| 5200 | - for CallExpr, the declaration of the callee |
| 5201 | - for MemberExpr, the declaration of the referenced member |
| 5202 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 5203 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 5204 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5205 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5206 | For type nodes, hasDeclaration will generally match the declaration of the |
| 5207 | sugared type. Given |
| 5208 | class X {}; |
| 5209 | typedef X Y; |
| 5210 | Y y; |
| 5211 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 5212 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 5213 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 5214 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 5215 | recordType(hasDeclaration(decl()))))) |
| 5216 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5217 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5218 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 5219 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 5220 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 5221 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 5222 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 5223 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 5224 | 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] | 5225 | </pre></td></tr> |
| 5226 | |
| 5227 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5228 | <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] | 5229 | <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a |
| 5230 | specific using shadow declaration. |
| 5231 | |
| 5232 | Given |
| 5233 | namespace a { void f() {} } |
| 5234 | using a::f; |
| 5235 | void g() { |
| 5236 | f(); Matches this .. |
| 5237 | a::f(); .. but not this. |
| 5238 | } |
| 5239 | declRefExpr(throughUsingDecl(anything())) |
| 5240 | matches f() |
| 5241 | </pre></td></tr> |
| 5242 | |
| 5243 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5244 | <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] | 5245 | <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the |
| 5246 | specified matcher. |
| 5247 | |
| 5248 | Example matches x in if(x) |
| 5249 | (matcher = declRefExpr(to(varDecl(hasName("x"))))) |
| 5250 | bool x; |
| 5251 | if (x) {} |
| 5252 | </pre></td></tr> |
| 5253 | |
| 5254 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5255 | <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] | 5256 | <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. |
| 5257 | |
| 5258 | Note that this does not work for global declarations because the AST |
| 5259 | breaks up multiple-declaration DeclStmt's into multiple single-declaration |
| 5260 | DeclStmt's. |
| 5261 | Example: Given non-global declarations |
| 5262 | int a, b = 0; |
| 5263 | int c; |
| 5264 | int d = 2, e; |
| 5265 | declStmt(containsDeclaration( |
| 5266 | 0, varDecl(hasInitializer(anything())))) |
| 5267 | matches only 'int d = 2, e;', and |
| 5268 | declStmt(containsDeclaration(1, varDecl())) |
| 5269 | matches 'int a, b = 0' as well as 'int d = 2, e;' |
| 5270 | but 'int c;' is not matched. |
| 5271 | </pre></td></tr> |
| 5272 | |
| 5273 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5274 | <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] | 5275 | <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. |
| 5276 | |
| 5277 | Given |
| 5278 | int a, b; |
| 5279 | int c; |
| 5280 | declStmt(hasSingleDecl(anything())) |
| 5281 | matches 'int c;' but not 'int a, b;'. |
| 5282 | </pre></td></tr> |
| 5283 | |
| 5284 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5285 | <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] | 5286 | <tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches |
| 5287 | the inner matcher. |
| 5288 | |
| 5289 | Given |
| 5290 | int x; |
| 5291 | declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 5292 | matches int x |
| 5293 | </pre></td></tr> |
| 5294 | |
| 5295 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5296 | <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] | 5297 | <tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a |
| 5298 | Decl, matches InnerMatcher. |
| 5299 | |
| 5300 | Given |
| 5301 | namespace N { |
| 5302 | namespace M { |
| 5303 | class D {}; |
| 5304 | } |
| 5305 | } |
| 5306 | |
| 5307 | cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the |
| 5308 | declaration of class D. |
| 5309 | </pre></td></tr> |
| 5310 | |
| 5311 | |
Jonas Toth | acf8367 | 2018-07-26 13:02:05 +0000 | [diff] [blame] | 5312 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>></td><td class="name" onclick="toggle('hasUnderlyingType0')"><a name="hasUnderlyingType0Anchor">hasUnderlyingType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> |
| 5313 | <tr><td colspan="4" class="doc" id="hasUnderlyingType0"><pre>Matches DecltypeType nodes to find out the underlying type. |
| 5314 | |
| 5315 | Given |
| 5316 | decltype(1) a = 1; |
| 5317 | decltype(2.0) b = 2.0; |
| 5318 | decltypeType(hasUnderlyingType(isInteger())) |
Stephen Kelly | 9b8fa52 | 2018-10-09 08:24:11 +0000 | [diff] [blame] | 5319 | matches the type of "a" |
Jonas Toth | acf8367 | 2018-07-26 13:02:05 +0000 | [diff] [blame] | 5320 | |
| 5321 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>> |
| 5322 | </pre></td></tr> |
| 5323 | |
| 5324 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5325 | <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] | 5326 | <tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 5327 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5328 | |
| 5329 | Given |
| 5330 | for (;;) {} |
| 5331 | hasBody(compoundStmt()) |
| 5332 | matches 'for (;;) {}' |
| 5333 | with compoundStmt() |
| 5334 | matching '{}' |
| 5335 | </pre></td></tr> |
| 5336 | |
| 5337 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5338 | <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] | 5339 | <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, |
Etienne Bergeron | 5500f95 | 2016-05-30 15:25:25 +0000 | [diff] [blame] | 5340 | switch statement or conditional operator. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5341 | |
| 5342 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 5343 | if (true) {} |
| 5344 | </pre></td></tr> |
| 5345 | |
| 5346 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5347 | <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] | 5348 | <tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, |
| 5349 | matches InnerMatcher if the qualifier exists. |
| 5350 | |
| 5351 | Given |
| 5352 | namespace N { |
| 5353 | namespace M { |
| 5354 | class D {}; |
| 5355 | } |
| 5356 | } |
| 5357 | N::M::D d; |
| 5358 | |
| 5359 | elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) |
| 5360 | matches the type of the variable declaration of d. |
| 5361 | </pre></td></tr> |
| 5362 | |
| 5363 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5364 | <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] | 5365 | <tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. |
| 5366 | |
| 5367 | Given |
| 5368 | namespace N { |
| 5369 | namespace M { |
| 5370 | class D {}; |
| 5371 | } |
| 5372 | } |
| 5373 | N::M::D d; |
| 5374 | |
| 5375 | elaboratedType(namesType(recordType( |
| 5376 | hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable |
| 5377 | declaration of d. |
| 5378 | </pre></td></tr> |
| 5379 | |
| 5380 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5381 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>></td><td class="name" onclick="toggle('hasDeclaration10')"><a name="hasDeclaration10Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5382 | <tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5383 | matches the given matcher. |
| 5384 | |
| 5385 | The associated declaration is: |
| 5386 | - for type nodes, the declaration of the underlying type |
| 5387 | - for CallExpr, the declaration of the callee |
| 5388 | - for MemberExpr, the declaration of the referenced member |
| 5389 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 5390 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 5391 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5392 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5393 | For type nodes, hasDeclaration will generally match the declaration of the |
| 5394 | sugared type. Given |
| 5395 | class X {}; |
| 5396 | typedef X Y; |
| 5397 | Y y; |
| 5398 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 5399 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 5400 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 5401 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 5402 | recordType(hasDeclaration(decl()))))) |
| 5403 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5404 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5405 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 5406 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 5407 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 5408 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 5409 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 5410 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 5411 | 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] | 5412 | </pre></td></tr> |
| 5413 | |
| 5414 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5415 | <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] | 5416 | <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. |
| 5417 | |
| 5418 | (Note: Clang's AST refers to other conversions as "casts" too, and calls |
| 5419 | actual casts "explicit" casts.) |
| 5420 | </pre></td></tr> |
| 5421 | |
| 5422 | |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5423 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> |
| 5424 | <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] | 5425 | declaration's type. |
| 5426 | |
| 5427 | In case of a value declaration (for example a variable declaration), |
| 5428 | this resolves one layer of indirection. For example, in the value |
| 5429 | declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 5430 | X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 5431 | declaration of x. |
| 5432 | |
| 5433 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 5434 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5435 | and friend class X (matcher = friendDecl(hasType("X")) |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5436 | class X {}; |
| 5437 | void y(X &x) { x; X z; } |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5438 | class Y { friend class X; }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5439 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5440 | 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] | 5441 | </pre></td></tr> |
| 5442 | |
| 5443 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5444 | <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] | 5445 | <tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type |
| 5446 | matcher. |
| 5447 | |
| 5448 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 5449 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 5450 | and U (matcher = typedefDecl(hasType(asString("int"))) |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5451 | and friend class X (matcher = friendDecl(hasType("X")) |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5452 | class X {}; |
| 5453 | void y(X &x) { x; X z; } |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 5454 | typedef int U; |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5455 | class Y { friend class X; }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5456 | </pre></td></tr> |
| 5457 | |
| 5458 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5459 | <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] | 5460 | <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts |
| 5461 | are stripped off. |
| 5462 | |
| 5463 | Parentheses and explicit casts are not discarded. |
| 5464 | Given |
| 5465 | int arr[5]; |
| 5466 | int a = 0; |
| 5467 | char b = 0; |
| 5468 | const int c = a; |
| 5469 | int *d = arr; |
| 5470 | long e = (long) 0l; |
| 5471 | The matchers |
| 5472 | varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) |
| 5473 | varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) |
| 5474 | would match the declarations for a, b, c, and d, but not e. |
| 5475 | While |
| 5476 | varDecl(hasInitializer(integerLiteral())) |
| 5477 | varDecl(hasInitializer(declRefExpr())) |
| 5478 | only match the declarations for b, c, and d. |
| 5479 | </pre></td></tr> |
| 5480 | |
| 5481 | |
Clement Courbet | 369e975 | 2018-03-21 10:54:29 +0000 | [diff] [blame] | 5482 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('ignoringImplicit0')"><a name="ignoringImplicit0Anchor">ignoringImplicit</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
Cong Liu | 8a02efb | 2016-06-24 09:38:03 +0000 | [diff] [blame] | 5483 | <tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST |
| 5484 | nodes are stripped off. |
| 5485 | |
| 5486 | Parentheses and explicit casts are not discarded. |
| 5487 | Given |
| 5488 | class C {}; |
| 5489 | C a = C(); |
| 5490 | C b; |
| 5491 | C c = b; |
| 5492 | The matchers |
| 5493 | varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr()))) |
| 5494 | would match the declarations for a, b, and c. |
| 5495 | While |
| 5496 | varDecl(hasInitializer(cxxConstructExpr())) |
| 5497 | only match the declarations for b and c. |
| 5498 | </pre></td></tr> |
| 5499 | |
| 5500 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5501 | <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] | 5502 | <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and |
| 5503 | casts are stripped off. |
| 5504 | |
| 5505 | Implicit and non-C Style casts are also discarded. |
| 5506 | Given |
| 5507 | int a = 0; |
| 5508 | char b = (0); |
| 5509 | void* c = reinterpret_cast<char*>(0); |
| 5510 | char d = char(0); |
| 5511 | The matcher |
| 5512 | varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) |
| 5513 | would match the declarations for a, b, c, and d. |
| 5514 | while |
| 5515 | varDecl(hasInitializer(integerLiteral())) |
| 5516 | only match the declaration for a. |
| 5517 | </pre></td></tr> |
| 5518 | |
| 5519 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5520 | <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] | 5521 | <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and |
| 5522 | parentheses are stripped off. |
| 5523 | |
| 5524 | Explicit casts are not discarded. |
| 5525 | Given |
| 5526 | int arr[5]; |
| 5527 | int a = 0; |
| 5528 | char b = (0); |
| 5529 | const int c = a; |
| 5530 | int *d = (arr); |
| 5531 | long e = ((long) 0l); |
| 5532 | The matchers |
| 5533 | varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) |
| 5534 | varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) |
| 5535 | would match the declarations for a, b, c, and d, but not e. |
| 5536 | while |
| 5537 | varDecl(hasInitializer(integerLiteral())) |
| 5538 | varDecl(hasInitializer(declRefExpr())) |
| 5539 | would only match the declaration for a. |
| 5540 | </pre></td></tr> |
| 5541 | |
| 5542 | |
Malcolm Parsons | 4ca3d18 | 2016-12-24 13:35:14 +0000 | [diff] [blame] | 5543 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>></td><td class="name" onclick="toggle('hasInClassInitializer0')"><a name="hasInClassInitializer0Anchor">hasInClassInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 5544 | <tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer. |
| 5545 | |
| 5546 | Given |
| 5547 | class C { |
| 5548 | int a = 2; |
| 5549 | int b = 3; |
| 5550 | int c; |
| 5551 | }; |
| 5552 | fieldDecl(hasInClassInitializer(integerLiteral(equals(2)))) |
| 5553 | matches 'int a;' but not 'int b;'. |
| 5554 | fieldDecl(hasInClassInitializer(anything())) |
| 5555 | matches 'int a;' and 'int b;' but not 'int c;'. |
| 5556 | </pre></td></tr> |
| 5557 | |
| 5558 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5559 | <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] | 5560 | <tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 5561 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5562 | |
| 5563 | Given |
| 5564 | for (;;) {} |
| 5565 | hasBody(compoundStmt()) |
| 5566 | matches 'for (;;) {}' |
| 5567 | with compoundStmt() |
| 5568 | matching '{}' |
| 5569 | </pre></td></tr> |
| 5570 | |
| 5571 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5572 | <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] | 5573 | <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, |
Etienne Bergeron | 5500f95 | 2016-05-30 15:25:25 +0000 | [diff] [blame] | 5574 | switch statement or conditional operator. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5575 | |
| 5576 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 5577 | if (true) {} |
| 5578 | </pre></td></tr> |
| 5579 | |
| 5580 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5581 | <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] | 5582 | <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. |
| 5583 | |
| 5584 | Example: |
| 5585 | forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) |
| 5586 | matches '++x' in |
| 5587 | for (x; x < N; ++x) { } |
| 5588 | </pre></td></tr> |
| 5589 | |
| 5590 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5591 | <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] | 5592 | <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. |
| 5593 | |
| 5594 | Example: |
| 5595 | forStmt(hasLoopInit(declStmt())) |
| 5596 | matches 'int x = 0' in |
| 5597 | for (int x = 0; x < N; ++x) { } |
| 5598 | </pre></td></tr> |
| 5599 | |
| 5600 | |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5601 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>></td><td class="name" onclick="toggle('hasType5')"><a name="hasType5Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 5602 | <tr><td colspan="4" class="doc" id="hasType5"><pre>Overloaded to match the declaration of the expression's or value |
| 5603 | declaration's type. |
| 5604 | |
| 5605 | In case of a value declaration (for example a variable declaration), |
| 5606 | this resolves one layer of indirection. For example, in the value |
| 5607 | declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 5608 | X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 5609 | declaration of x. |
| 5610 | |
| 5611 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 5612 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 5613 | and friend class X (matcher = friendDecl(hasType("X")) |
| 5614 | class X {}; |
| 5615 | void y(X &x) { x; X z; } |
| 5616 | class Y { friend class X; }; |
| 5617 | |
| 5618 | 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>> |
| 5619 | </pre></td></tr> |
| 5620 | |
| 5621 | |
| 5622 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</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> |
| 5623 | <tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type |
| 5624 | matcher. |
| 5625 | |
| 5626 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 5627 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 5628 | and U (matcher = typedefDecl(hasType(asString("int"))) |
| 5629 | and friend class X (matcher = friendDecl(hasType("X")) |
| 5630 | class X {}; |
| 5631 | void y(X &x) { x; X z; } |
| 5632 | typedef int U; |
| 5633 | class Y { friend class X; }; |
| 5634 | </pre></td></tr> |
| 5635 | |
| 5636 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5637 | <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> |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 5638 | <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a |
| 5639 | block. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5640 | |
| 5641 | Does not match the 'this' parameter of a method. |
| 5642 | |
| 5643 | Given |
| 5644 | class X { void f(int x, int y, int z) {} }; |
| 5645 | cxxMethodDecl(hasAnyParameter(hasName("y"))) |
| 5646 | matches f(int x, int y, int z) {} |
| 5647 | with hasAnyParameter(...) |
| 5648 | matching int y |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 5649 | |
| 5650 | For ObjectiveC, given |
| 5651 | @interface I - (void) f:(int) y; @end |
| 5652 | |
| 5653 | the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) |
| 5654 | matches the declaration of method f with hasParameter |
| 5655 | matching y. |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 5656 | |
| 5657 | For blocks, given |
| 5658 | b = ^(int y) { printf("%d", y) }; |
| 5659 | |
| 5660 | the matcher blockDecl(hasAnyParameter(hasName("y"))) |
| 5661 | matches the declaration of the block b with hasParameter |
| 5662 | matching y. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5663 | </pre></td></tr> |
| 5664 | |
| 5665 | |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5666 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgument2')"><a name="hasAnyTemplateArgument2Anchor">hasAnyTemplateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> |
| 5667 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and |
| 5668 | functionDecl that have at least one TemplateArgument matching the given |
| 5669 | InnerMatcher. |
| 5670 | |
| 5671 | Given |
| 5672 | template<typename T> class A {}; |
| 5673 | template<> class A<double> {}; |
| 5674 | A<int> a; |
| 5675 | |
Haojian Wu | 99e39a7 | 2016-07-29 17:30:13 +0000 | [diff] [blame] | 5676 | template<typename T> f() {}; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5677 | void func() { f<int>(); }; |
| 5678 | |
| 5679 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 5680 | refersToType(asString("int")))) |
| 5681 | matches the specialization A<int> |
| 5682 | |
| 5683 | functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) |
| 5684 | matches the specialization f<int> |
| 5685 | </pre></td></tr> |
| 5686 | |
| 5687 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5688 | <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] | 5689 | <tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 5690 | definition that has a given body. |
| 5691 | |
| 5692 | Given |
| 5693 | for (;;) {} |
| 5694 | hasBody(compoundStmt()) |
| 5695 | matches 'for (;;) {}' |
| 5696 | with compoundStmt() |
| 5697 | matching '{}' |
| 5698 | </pre></td></tr> |
| 5699 | |
| 5700 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5701 | <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> |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 5702 | <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 5703 | declaration or a block. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5704 | |
| 5705 | Given |
| 5706 | class X { void f(int x) {} }; |
| 5707 | cxxMethodDecl(hasParameter(0, hasType(varDecl()))) |
| 5708 | matches f(int x) {} |
| 5709 | with hasParameter(...) |
| 5710 | matching int x |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 5711 | |
| 5712 | For ObjectiveC, given |
| 5713 | @interface I - (void) f:(int) y; @end |
| 5714 | |
| 5715 | the matcher objcMethodDecl(hasParameter(0, hasName("y"))) |
| 5716 | matches the declaration of method f with hasParameter |
| 5717 | matching y. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5718 | </pre></td></tr> |
| 5719 | |
| 5720 | |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5721 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasTemplateArgument2')"><a name="hasTemplateArgument2Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> |
| 5722 | <tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and |
| 5723 | functionDecl where the n'th TemplateArgument matches the given InnerMatcher. |
| 5724 | |
| 5725 | Given |
| 5726 | template<typename T, typename U> class A {}; |
| 5727 | A<bool, int> b; |
| 5728 | A<int, bool> c; |
| 5729 | |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 5730 | template<typename T> void f() {} |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5731 | void func() { f<int>(); }; |
| 5732 | classTemplateSpecializationDecl(hasTemplateArgument( |
| 5733 | 1, refersToType(asString("int")))) |
| 5734 | matches the specialization A<bool, int> |
| 5735 | |
| 5736 | functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) |
| 5737 | matches the specialization f<int> |
| 5738 | </pre></td></tr> |
| 5739 | |
| 5740 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5741 | <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] | 5742 | <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. |
| 5743 | |
| 5744 | Given: |
| 5745 | class X { int f() { return 1; } }; |
| 5746 | cxxMethodDecl(returns(asString("int"))) |
| 5747 | matches int f() { return 1; } |
| 5748 | </pre></td></tr> |
| 5749 | |
| 5750 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5751 | <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] | 5752 | <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, |
Etienne Bergeron | 5500f95 | 2016-05-30 15:25:25 +0000 | [diff] [blame] | 5753 | switch statement or conditional operator. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5754 | |
| 5755 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 5756 | if (true) {} |
| 5757 | </pre></td></tr> |
| 5758 | |
| 5759 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5760 | <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] | 5761 | <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. |
| 5762 | |
| 5763 | Given |
| 5764 | if (A* a = GetAPointer()) {} |
| 5765 | hasConditionVariableStatement(...) |
| 5766 | matches 'A* a = GetAPointer()'. |
| 5767 | </pre></td></tr> |
| 5768 | |
| 5769 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5770 | <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] | 5771 | <tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. |
| 5772 | |
| 5773 | Examples matches the if statement |
| 5774 | (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) |
| 5775 | if (false) false; else true; |
| 5776 | </pre></td></tr> |
| 5777 | |
| 5778 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5779 | <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] | 5780 | <tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. |
| 5781 | |
| 5782 | Examples matches the if statement |
| 5783 | (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) |
| 5784 | if (false) true; else false; |
| 5785 | </pre></td></tr> |
| 5786 | |
| 5787 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5788 | <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] | 5789 | <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given |
| 5790 | matcher. |
| 5791 | |
| 5792 | FIXME: Unit test this matcher |
| 5793 | </pre></td></tr> |
| 5794 | |
| 5795 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 5796 | <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> |
| 5797 | <tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions |
| 5798 | (if expression have it). |
| 5799 | </pre></td></tr> |
| 5800 | |
| 5801 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5802 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>></td><td class="name" onclick="toggle('hasDeclaration9')"><a name="hasDeclaration9Anchor">hasDeclaration</a></td><td>const 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] | 5803 | <tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node |
| 5804 | matches the given matcher. |
| 5805 | |
| 5806 | The associated declaration is: |
| 5807 | - for type nodes, the declaration of the underlying type |
| 5808 | - for CallExpr, the declaration of the callee |
| 5809 | - for MemberExpr, the declaration of the referenced member |
| 5810 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 5811 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 5812 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5813 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5814 | For type nodes, hasDeclaration will generally match the declaration of the |
| 5815 | sugared type. Given |
| 5816 | class X {}; |
| 5817 | typedef X Y; |
| 5818 | Y y; |
| 5819 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 5820 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 5821 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 5822 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 5823 | recordType(hasDeclaration(decl()))))) |
| 5824 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5825 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5826 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 5827 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 5828 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 5829 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 5830 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 5831 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 5832 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
| 5833 | </pre></td></tr> |
| 5834 | |
| 5835 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5836 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>></td><td class="name" onclick="toggle('hasDeclaration8')"><a name="hasDeclaration8Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5837 | <tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node |
| 5838 | matches the given matcher. |
| 5839 | |
| 5840 | The associated declaration is: |
| 5841 | - for type nodes, the declaration of the underlying type |
| 5842 | - for CallExpr, the declaration of the callee |
| 5843 | - for MemberExpr, the declaration of the referenced member |
| 5844 | - for CXXConstructExpr, the declaration of the constructor |
| 5845 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 5846 | - for ObjCIvarExpr, the declaration of the ivar |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5847 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5848 | For type nodes, hasDeclaration will generally match the declaration of the |
| 5849 | sugared type. Given |
| 5850 | class X {}; |
| 5851 | typedef X Y; |
| 5852 | Y y; |
| 5853 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 5854 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 5855 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 5856 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 5857 | recordType(hasDeclaration(decl()))))) |
| 5858 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5859 | |
| 5860 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 5861 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 5862 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 5863 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 5864 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 5865 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 5866 | 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] | 5867 | </pre></td></tr> |
| 5868 | |
| 5869 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5870 | <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>const 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] | 5871 | <tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node |
| 5872 | matches the given matcher. |
| 5873 | |
| 5874 | The associated declaration is: |
| 5875 | - for type nodes, the declaration of the underlying type |
| 5876 | - for CallExpr, the declaration of the callee |
| 5877 | - for MemberExpr, the declaration of the referenced member |
| 5878 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 5879 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 5880 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5881 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5882 | For type nodes, hasDeclaration will generally match the declaration of the |
| 5883 | sugared type. Given |
| 5884 | class X {}; |
| 5885 | typedef X Y; |
| 5886 | Y y; |
| 5887 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 5888 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 5889 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 5890 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 5891 | recordType(hasDeclaration(decl()))))) |
| 5892 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5893 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5894 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 5895 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 5896 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 5897 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 5898 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 5899 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 5900 | 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] | 5901 | </pre></td></tr> |
| 5902 | |
| 5903 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5904 | <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] | 5905 | <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is |
| 5906 | matched by a given matcher. |
| 5907 | |
| 5908 | Given |
| 5909 | struct X { int m; }; |
| 5910 | void f(X x) { x.m; m; } |
| 5911 | memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))))) |
| 5912 | matches "x.m" and "m" |
| 5913 | with hasObjectExpression(...) |
| 5914 | matching "x" and the implicit object expression of "m" which has type X*. |
| 5915 | </pre></td></tr> |
| 5916 | |
| 5917 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5918 | <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] | 5919 | <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a |
| 5920 | given matcher. |
| 5921 | |
| 5922 | Given |
| 5923 | struct { int first, second; } first, second; |
| 5924 | int i(second.first); |
| 5925 | int j(first.second); |
| 5926 | memberExpr(member(hasName("first"))) |
| 5927 | matches second.first |
| 5928 | but not first.second (because the member name there is "second"). |
| 5929 | </pre></td></tr> |
| 5930 | |
| 5931 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5932 | <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] | 5933 | <tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the |
| 5934 | pointee matches a given matcher. |
| 5935 | |
| 5936 | Given |
| 5937 | int *a; |
| 5938 | int const *b; |
| 5939 | float const *f; |
| 5940 | pointerType(pointee(isConstQualified(), isInteger())) |
| 5941 | matches "int const *b" |
| 5942 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5943 | 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>>, |
| 5944 | 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] | 5945 | </pre></td></tr> |
| 5946 | |
| 5947 | |
Martin Bohme | 8cef2c2 | 2016-08-09 15:07:52 +0000 | [diff] [blame] | 5948 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('hasUnderlyingDecl0')"><a name="hasUnderlyingDecl0Anchor">hasUnderlyingDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> InnerMatcher</td></tr> |
| 5949 | <tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given |
| 5950 | matcher. |
| 5951 | |
| 5952 | Given |
| 5953 | namespace N { template<class T> void f(T t); } |
| 5954 | template <class T> void g() { using N::f; f(T()); } |
| 5955 | unresolvedLookupExpr(hasAnyDeclaration( |
| 5956 | namedDecl(hasUnderlyingDecl(hasName("::N::f"))))) |
| 5957 | matches the use of f in g() . |
| 5958 | </pre></td></tr> |
| 5959 | |
| 5960 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5961 | <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] | 5962 | <tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. |
| 5963 | |
| 5964 | Given |
| 5965 | struct A { struct B { struct C {}; }; }; |
| 5966 | A::B::C c; |
| 5967 | nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) |
| 5968 | matches "A::" |
| 5969 | </pre></td></tr> |
| 5970 | |
| 5971 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5972 | <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] | 5973 | <tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the |
| 5974 | given TypeLoc. |
| 5975 | |
| 5976 | Given |
| 5977 | struct A { struct B { struct C {}; }; }; |
| 5978 | A::B::C c; |
| 5979 | nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( |
| 5980 | hasDeclaration(cxxRecordDecl(hasName("A"))))))) |
| 5981 | matches "A::" |
| 5982 | </pre></td></tr> |
| 5983 | |
| 5984 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5985 | <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] | 5986 | <tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. |
| 5987 | |
| 5988 | Given |
| 5989 | struct A { struct B { struct C {}; }; }; |
| 5990 | A::B::C c; |
| 5991 | nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and |
| 5992 | matches "A::" |
| 5993 | </pre></td></tr> |
| 5994 | |
| 5995 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 5996 | <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] | 5997 | <tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the |
| 5998 | given namespace matcher. |
| 5999 | |
| 6000 | Given |
| 6001 | namespace ns { struct A {}; } |
| 6002 | ns::A a; |
| 6003 | nestedNameSpecifier(specifiesNamespace(hasName("ns"))) |
| 6004 | matches "ns::" |
| 6005 | </pre></td></tr> |
| 6006 | |
| 6007 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6008 | <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] | 6009 | <tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the |
| 6010 | given QualType matcher without qualifiers. |
| 6011 | |
| 6012 | Given |
| 6013 | struct A { struct B { struct C {}; }; }; |
| 6014 | A::B::C c; |
| 6015 | nestedNameSpecifier(specifiesType( |
| 6016 | hasDeclaration(cxxRecordDecl(hasName("A"))) |
| 6017 | )) |
| 6018 | matches "A::" |
| 6019 | </pre></td></tr> |
| 6020 | |
| 6021 | |
Shuai Wang | 3b2a17b | 2018-08-12 23:30:05 +0000 | [diff] [blame] | 6022 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasAnyArgument3')"><a name="hasAnyArgument3Anchor">hasAnyArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 6023 | <tr><td colspan="4" class="doc" id="hasAnyArgument3"><pre>Matches any argument of a call expression or a constructor call |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 6024 | expression, or an ObjC-message-send expression. |
| 6025 | |
| 6026 | Given |
| 6027 | void x(int, int, int) { int y; x(1, y, 42); } |
| 6028 | callExpr(hasAnyArgument(declRefExpr())) |
| 6029 | matches x(1, y, 42) |
| 6030 | with hasAnyArgument(...) |
| 6031 | matching y |
| 6032 | |
| 6033 | For ObjectiveC, given |
| 6034 | @interface I - (void) f:(int) y; @end |
Clement Courbet | 2513aa0 | 2018-03-21 10:48:00 +0000 | [diff] [blame] | 6035 | void foo(I *i) { [i f:12]; } |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 6036 | objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) |
| 6037 | matches [i f:12] |
| 6038 | </pre></td></tr> |
| 6039 | |
| 6040 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6041 | <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] | 6042 | <tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor |
| 6043 | call expression. |
| 6044 | |
| 6045 | Example matches y in x(y) |
| 6046 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 6047 | void x(int) { int y; x(y); } |
| 6048 | </pre></td></tr> |
| 6049 | |
| 6050 | |
George Karpenkov | b5ea4df | 2018-07-16 20:22:12 +0000 | [diff] [blame] | 6051 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasReceiver0')"><a name="hasReceiver0Anchor">hasReceiver</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 6052 | <tr><td colspan="4" class="doc" id="hasReceiver0"><pre>Matches if the Objective-C message is sent to an instance, |
| 6053 | and the inner matcher matches on that instance. |
| 6054 | |
| 6055 | For example the method call in |
| 6056 | NSString *x = @"hello"; |
George Karpenkov | daac52c | 2018-07-23 22:29:10 +0000 | [diff] [blame] | 6057 | [x containsString:@"h"]; |
George Karpenkov | b5ea4df | 2018-07-16 20:22:12 +0000 | [diff] [blame] | 6058 | is matched by |
| 6059 | objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x")))))) |
| 6060 | </pre></td></tr> |
| 6061 | |
| 6062 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6063 | <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] | 6064 | <tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. |
| 6065 | |
| 6066 | Example |
Jakub Kuderski | 64b6c78 | 2017-05-05 21:01:12 +0000 | [diff] [blame] | 6067 | matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *"))); |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6068 | matches the [webView ...] message invocation. |
| 6069 | NSString *webViewJavaScript = ... |
| 6070 | UIWebView *webView = ... |
| 6071 | [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; |
| 6072 | </pre></td></tr> |
| 6073 | |
| 6074 | |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 6075 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>></td><td class="name" onclick="toggle('hasAnyParameter1')"><a name="hasAnyParameter1Anchor">hasAnyParameter</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 6076 | <tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a |
| 6077 | block. |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 6078 | |
| 6079 | Does not match the 'this' parameter of a method. |
| 6080 | |
| 6081 | Given |
| 6082 | class X { void f(int x, int y, int z) {} }; |
| 6083 | cxxMethodDecl(hasAnyParameter(hasName("y"))) |
| 6084 | matches f(int x, int y, int z) {} |
| 6085 | with hasAnyParameter(...) |
| 6086 | matching int y |
| 6087 | |
| 6088 | For ObjectiveC, given |
| 6089 | @interface I - (void) f:(int) y; @end |
| 6090 | |
| 6091 | the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) |
| 6092 | matches the declaration of method f with hasParameter |
| 6093 | matching y. |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 6094 | |
| 6095 | For blocks, given |
| 6096 | b = ^(int y) { printf("%d", y) }; |
| 6097 | |
| 6098 | the matcher blockDecl(hasAnyParameter(hasName("y"))) |
| 6099 | matches the declaration of the block b with hasParameter |
| 6100 | matching y. |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 6101 | </pre></td></tr> |
| 6102 | |
| 6103 | |
| 6104 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>></td><td class="name" onclick="toggle('hasParameter1')"><a name="hasParameter1Anchor">hasParameter</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> |
| 6105 | <tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 6106 | declaration or a block. |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 6107 | |
| 6108 | Given |
| 6109 | class X { void f(int x) {} }; |
| 6110 | cxxMethodDecl(hasParameter(0, hasType(varDecl()))) |
| 6111 | matches f(int x) {} |
| 6112 | with hasParameter(...) |
| 6113 | matching int x |
| 6114 | |
| 6115 | For ObjectiveC, given |
| 6116 | @interface I - (void) f:(int) y; @end |
| 6117 | |
| 6118 | the matcher objcMethodDecl(hasParameter(0, hasName("y"))) |
| 6119 | matches the declaration of method f with hasParameter |
| 6120 | matching y. |
| 6121 | </pre></td></tr> |
| 6122 | |
| 6123 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 6124 | <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> |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6125 | <tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression |
| 6126 | or opaque value's source expression matches the given matcher. |
| 6127 | |
| 6128 | Example 1: matches "a string" |
| 6129 | (matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) |
| 6130 | class URL { URL(string); }; |
| 6131 | URL url = "a string"; |
| 6132 | |
| 6133 | Example 2: matches 'b' (matcher = |
| 6134 | opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) |
| 6135 | int a = b ?: 1; |
| 6136 | </pre></td></tr> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 6137 | |
| 6138 | |
Martin Bohme | 8cef2c2 | 2016-08-09 15:07:52 +0000 | [diff] [blame] | 6139 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1OverloadExpr.html">OverloadExpr</a>></td><td class="name" onclick="toggle('hasAnyDeclaration0')"><a name="hasAnyDeclaration0Anchor">hasAnyDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 6140 | <tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of |
| 6141 | overloads matches the given matcher. |
| 6142 | |
| 6143 | Given |
| 6144 | template <typename T> void foo(T); |
| 6145 | template <typename T> void bar(T); |
| 6146 | template <typename T> void baz(T t) { |
| 6147 | foo(t); |
| 6148 | bar(t); |
| 6149 | } |
| 6150 | unresolvedLookupExpr(hasAnyDeclaration( |
| 6151 | functionTemplateDecl(hasName("foo")))) |
| 6152 | matches foo in foo(t); but not bar in bar(t); |
| 6153 | </pre></td></tr> |
| 6154 | |
| 6155 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6156 | <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] | 6157 | <tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. |
| 6158 | |
| 6159 | Given |
| 6160 | int (*ptr_to_array)[4]; |
| 6161 | int (*ptr_to_func)(int); |
| 6162 | |
| 6163 | varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches |
| 6164 | ptr_to_func but not ptr_to_array. |
| 6165 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6166 | 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] | 6167 | </pre></td></tr> |
| 6168 | |
| 6169 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6170 | <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] | 6171 | <tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the |
| 6172 | pointee matches a given matcher. |
| 6173 | |
| 6174 | Given |
| 6175 | int *a; |
| 6176 | int const *b; |
| 6177 | float const *f; |
| 6178 | pointerType(pointee(isConstQualified(), isInteger())) |
| 6179 | matches "int const *b" |
| 6180 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6181 | 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>>, |
| 6182 | 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] | 6183 | </pre></td></tr> |
| 6184 | |
| 6185 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6186 | <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] | 6187 | <tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. |
| 6188 | |
| 6189 | Given: |
| 6190 | typedef int &int_ref; |
| 6191 | int a; |
| 6192 | int_ref b = a; |
| 6193 | |
| 6194 | varDecl(hasType(qualType(referenceType()))))) will not match the |
| 6195 | declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. |
| 6196 | </pre></td></tr> |
| 6197 | |
| 6198 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6199 | <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>const 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] | 6200 | <tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node |
| 6201 | matches the given matcher. |
| 6202 | |
| 6203 | The associated declaration is: |
| 6204 | - for type nodes, the declaration of the underlying type |
| 6205 | - for CallExpr, the declaration of the callee |
| 6206 | - for MemberExpr, the declaration of the referenced member |
| 6207 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6208 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6209 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6210 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6211 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6212 | sugared type. Given |
| 6213 | class X {}; |
| 6214 | typedef X Y; |
| 6215 | Y y; |
| 6216 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6217 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6218 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6219 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6220 | recordType(hasDeclaration(decl()))))) |
| 6221 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6222 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 6223 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 6224 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 6225 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 6226 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 6227 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 6228 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 6229 | 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] | 6230 | </pre></td></tr> |
| 6231 | |
| 6232 | |
Aaron Ballman | ba8dbbe | 2016-06-06 18:52:17 +0000 | [diff] [blame] | 6233 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('ignoringParens0')"><a name="ignoringParens0Anchor">ignoringParens</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
| 6234 | <tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped. |
| 6235 | |
| 6236 | Given |
| 6237 | void (*fp)(void); |
| 6238 | The matcher |
| 6239 | varDecl(hasType(pointerType(pointee(ignoringParens(functionType()))))) |
| 6240 | would match the declaration for fp. |
| 6241 | </pre></td></tr> |
| 6242 | |
| 6243 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6244 | <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] | 6245 | <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. |
| 6246 | </pre></td></tr> |
| 6247 | |
| 6248 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6249 | <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] | 6250 | <tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type |
| 6251 | matches the specified matcher. |
| 6252 | |
| 6253 | Example matches y->x() |
| 6254 | (matcher = cxxMemberCallExpr(on(hasType(pointsTo |
| 6255 | cxxRecordDecl(hasName("Y"))))))) |
| 6256 | class Y { public: void x(); }; |
| 6257 | void z() { Y *y; y->x(); } |
| 6258 | </pre></td></tr> |
| 6259 | |
| 6260 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6261 | <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] | 6262 | <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. |
| 6263 | </pre></td></tr> |
| 6264 | |
| 6265 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6266 | <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] | 6267 | <tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced |
| 6268 | type matches the specified matcher. |
| 6269 | |
| 6270 | Example matches X &x and const X &y |
| 6271 | (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) |
| 6272 | class X { |
| 6273 | void a(X b) { |
| 6274 | X &x = b; |
| 6275 | const X &y = b; |
| 6276 | } |
| 6277 | }; |
| 6278 | </pre></td></tr> |
| 6279 | |
| 6280 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6281 | <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>const 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] | 6282 | <tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node |
| 6283 | matches the given matcher. |
| 6284 | |
| 6285 | The associated declaration is: |
| 6286 | - for type nodes, the declaration of the underlying type |
| 6287 | - for CallExpr, the declaration of the callee |
| 6288 | - for MemberExpr, the declaration of the referenced member |
| 6289 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6290 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6291 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6292 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6293 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6294 | sugared type. Given |
| 6295 | class X {}; |
| 6296 | typedef X Y; |
| 6297 | Y y; |
| 6298 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6299 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6300 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6301 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6302 | recordType(hasDeclaration(decl()))))) |
| 6303 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6304 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 6305 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 6306 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 6307 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 6308 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 6309 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 6310 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 6311 | 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] | 6312 | </pre></td></tr> |
| 6313 | |
| 6314 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6315 | <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] | 6316 | <tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the |
| 6317 | pointee matches a given matcher. |
| 6318 | |
| 6319 | Given |
| 6320 | int *a; |
| 6321 | int const *b; |
| 6322 | float const *f; |
| 6323 | pointerType(pointee(isConstQualified(), isInteger())) |
| 6324 | matches "int const *b" |
| 6325 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6326 | 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>>, |
| 6327 | 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] | 6328 | </pre></td></tr> |
| 6329 | |
| 6330 | |
Alexander Kornienko | 976921d | 2016-03-22 11:03:03 +0000 | [diff] [blame] | 6331 | <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> |
| 6332 | <tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement |
| 6333 | |
| 6334 | Given |
| 6335 | return a + b; |
| 6336 | hasReturnValue(binaryOperator()) |
| 6337 | matches 'return a + b' |
| 6338 | with binaryOperator() |
| 6339 | matching 'a + b' |
| 6340 | </pre></td></tr> |
| 6341 | |
| 6342 | |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 6343 | <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> |
| 6344 | <tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches |
| 6345 | a given matcher. Also matches StmtExprs that have CompoundStmt as children. |
| 6346 | |
| 6347 | Given |
| 6348 | { {}; 1+2; } |
| 6349 | hasAnySubstatement(compoundStmt()) |
| 6350 | matches '{ {}; 1+2; }' |
| 6351 | with compoundStmt() |
| 6352 | matching '{}' |
| 6353 | </pre></td></tr> |
| 6354 | |
| 6355 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6356 | <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>const 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] | 6357 | <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 6358 | alignof. |
| 6359 | </pre></td></tr> |
| 6360 | |
| 6361 | |
Gabor Horvath | 1b3f8db | 2016-05-04 11:59:39 +0000 | [diff] [blame] | 6362 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('forFunction0')"><a name="forFunction0Anchor">forFunction</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> InnerMatcher</td></tr> |
Malcolm Parsons | def8f90 | 2017-01-20 09:54:26 +0000 | [diff] [blame] | 6363 | <tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to |
Gabor Horvath | 1b3f8db | 2016-05-04 11:59:39 +0000 | [diff] [blame] | 6364 | |
| 6365 | Given: |
| 6366 | F& operator=(const F& o) { |
| 6367 | std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); |
| 6368 | return *this; |
| 6369 | } |
| 6370 | returnStmt(forFunction(hasName("operator="))) |
| 6371 | matches 'return *this' |
| 6372 | but does match 'return > 0' |
| 6373 | </pre></td></tr> |
| 6374 | |
| 6375 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6376 | <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>const 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] | 6377 | <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 6378 | sizeof. |
| 6379 | </pre></td></tr> |
| 6380 | |
| 6381 | |
Malcolm Parsons | 77f039b | 2016-12-08 11:46:22 +0000 | [diff] [blame] | 6382 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html">SubstTemplateTypeParmType</a>></td><td class="name" onclick="toggle('hasReplacementType0')"><a name="hasReplacementType0Anchor">hasReplacementType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> |
| 6383 | <tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement |
| 6384 | type that matches the provided matcher. |
| 6385 | |
| 6386 | Given |
| 6387 | template <typename T> |
| 6388 | double F(T t); |
| 6389 | int i; |
| 6390 | double j = F(i); |
| 6391 | |
| 6392 | substTemplateTypeParmType(hasReplacementType(type())) matches int |
| 6393 | </pre></td></tr> |
| 6394 | |
| 6395 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6396 | <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] | 6397 | <tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch |
| 6398 | statement. This matcher may produce multiple matches. |
| 6399 | |
| 6400 | Given |
| 6401 | switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } |
| 6402 | switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") |
| 6403 | matches four times, with "c" binding each of "case 1:", "case 2:", |
| 6404 | "case 3:" and "case 4:", and "s" respectively binding "switch (1)", |
| 6405 | "switch (1)", "switch (2)" and "switch (2)". |
| 6406 | </pre></td></tr> |
| 6407 | |
| 6408 | |
Etienne Bergeron | 5500f95 | 2016-05-30 15:25:25 +0000 | [diff] [blame] | 6409 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</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> |
| 6410 | <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, |
| 6411 | switch statement or conditional operator. |
| 6412 | |
| 6413 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 6414 | if (true) {} |
| 6415 | </pre></td></tr> |
| 6416 | |
| 6417 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6418 | <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>const 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] | 6419 | <tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node |
| 6420 | matches the given matcher. |
| 6421 | |
| 6422 | The associated declaration is: |
| 6423 | - for type nodes, the declaration of the underlying type |
| 6424 | - for CallExpr, the declaration of the callee |
| 6425 | - for MemberExpr, the declaration of the referenced member |
| 6426 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6427 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6428 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6429 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6430 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6431 | sugared type. Given |
| 6432 | class X {}; |
| 6433 | typedef X Y; |
| 6434 | Y y; |
| 6435 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6436 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6437 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6438 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6439 | recordType(hasDeclaration(decl()))))) |
| 6440 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6441 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 6442 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 6443 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 6444 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 6445 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 6446 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 6447 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 6448 | 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] | 6449 | </pre></td></tr> |
| 6450 | |
| 6451 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6452 | <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] | 6453 | <tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. |
| 6454 | |
| 6455 | Given |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 6456 | struct B { int next; }; |
| 6457 | template<int(B::*next_ptr)> struct A {}; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6458 | A<&B::next> a; |
| 6459 | templateSpecializationType(hasAnyTemplateArgument( |
| 6460 | isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) |
| 6461 | matches the specialization A<&B::next> with fieldDecl(...) matching |
| 6462 | B::next |
| 6463 | </pre></td></tr> |
| 6464 | |
| 6465 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6466 | <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] | 6467 | <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain |
| 6468 | declaration. |
| 6469 | |
| 6470 | Given |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 6471 | struct B { int next; }; |
| 6472 | template<int(B::*next_ptr)> struct A {}; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6473 | A<&B::next> a; |
| 6474 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 6475 | refersToDeclaration(fieldDecl(hasName("next"))))) |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6476 | matches the specialization A<&B::next> with fieldDecl(...) matching |
| 6477 | B::next |
| 6478 | </pre></td></tr> |
| 6479 | |
| 6480 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6481 | <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] | 6482 | <tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type. |
| 6483 | |
| 6484 | Given |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 6485 | template<int T> struct C {}; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6486 | C<42> c; |
| 6487 | classTemplateSpecializationDecl( |
| 6488 | hasAnyTemplateArgument(refersToIntegralType(asString("int")))) |
| 6489 | matches the implicit instantiation of C in C<42>. |
| 6490 | </pre></td></tr> |
| 6491 | |
| 6492 | |
Haojian Wu | b33b02e | 2016-07-29 15:45:11 +0000 | [diff] [blame] | 6493 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('refersToTemplate0')"><a name="refersToTemplate0Anchor">refersToTemplate</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>> InnerMatcher</td></tr> |
| 6494 | <tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template. |
| 6495 | |
| 6496 | Given |
| 6497 | template<template <typename> class S> class X {}; |
Stephen Kelly | 9b8fa52 | 2018-10-09 08:24:11 +0000 | [diff] [blame] | 6498 | template<typename T> class Y {}; |
Haojian Wu | b33b02e | 2016-07-29 15:45:11 +0000 | [diff] [blame] | 6499 | X<Y> xi; |
| 6500 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 6501 | refersToTemplate(templateName()))) |
| 6502 | matches the specialization X<Y> |
| 6503 | </pre></td></tr> |
| 6504 | |
| 6505 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6506 | <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] | 6507 | <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. |
| 6508 | |
| 6509 | Given |
| 6510 | struct X {}; |
| 6511 | template<typename T> struct A {}; |
| 6512 | A<X> a; |
| 6513 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 6514 | refersToType(class(hasName("X"))))) |
| 6515 | matches the specialization A<X> |
| 6516 | </pre></td></tr> |
| 6517 | |
| 6518 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6519 | <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> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6520 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and |
| 6521 | functionDecl that have at least one TemplateArgument matching the given |
| 6522 | InnerMatcher. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6523 | |
| 6524 | Given |
| 6525 | template<typename T> class A {}; |
| 6526 | template<> class A<double> {}; |
| 6527 | A<int> a; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6528 | |
Haojian Wu | 99e39a7 | 2016-07-29 17:30:13 +0000 | [diff] [blame] | 6529 | template<typename T> f() {}; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6530 | void func() { f<int>(); }; |
| 6531 | |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6532 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 6533 | refersToType(asString("int")))) |
| 6534 | matches the specialization A<int> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6535 | |
| 6536 | functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) |
| 6537 | matches the specialization f<int> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6538 | </pre></td></tr> |
| 6539 | |
| 6540 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6541 | <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>const 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] | 6542 | <tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node |
| 6543 | matches the given matcher. |
| 6544 | |
| 6545 | The associated declaration is: |
| 6546 | - for type nodes, the declaration of the underlying type |
| 6547 | - for CallExpr, the declaration of the callee |
| 6548 | - for MemberExpr, the declaration of the referenced member |
| 6549 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6550 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6551 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6552 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6553 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6554 | sugared type. Given |
| 6555 | class X {}; |
| 6556 | typedef X Y; |
| 6557 | Y y; |
| 6558 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6559 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6560 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6561 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6562 | recordType(hasDeclaration(decl()))))) |
| 6563 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6564 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 6565 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 6566 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 6567 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 6568 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 6569 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 6570 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 6571 | 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] | 6572 | </pre></td></tr> |
| 6573 | |
| 6574 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6575 | <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> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6576 | <tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and |
| 6577 | functionDecl where the n'th TemplateArgument matches the given InnerMatcher. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6578 | |
| 6579 | Given |
| 6580 | template<typename T, typename U> class A {}; |
| 6581 | A<bool, int> b; |
| 6582 | A<int, bool> c; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6583 | |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 6584 | template<typename T> void f() {} |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6585 | void func() { f<int>(); }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6586 | classTemplateSpecializationDecl(hasTemplateArgument( |
| 6587 | 1, refersToType(asString("int")))) |
| 6588 | matches the specialization A<bool, int> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6589 | |
| 6590 | functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) |
| 6591 | matches the specialization f<int> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6592 | </pre></td></tr> |
| 6593 | |
| 6594 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6595 | <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>const 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] | 6596 | <tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node |
| 6597 | matches the given matcher. |
| 6598 | |
| 6599 | The associated declaration is: |
| 6600 | - for type nodes, the declaration of the underlying type |
| 6601 | - for CallExpr, the declaration of the callee |
| 6602 | - for MemberExpr, the declaration of the referenced member |
| 6603 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6604 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6605 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6606 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6607 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6608 | sugared type. Given |
| 6609 | class X {}; |
| 6610 | typedef X Y; |
| 6611 | Y y; |
| 6612 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6613 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6614 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6615 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6616 | recordType(hasDeclaration(decl()))))) |
| 6617 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6618 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 6619 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 6620 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 6621 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 6622 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 6623 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 6624 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 6625 | 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] | 6626 | </pre></td></tr> |
| 6627 | |
| 6628 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6629 | <tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>const Matcher<T> Matcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6630 | <tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. |
| 6631 | |
| 6632 | Generates results for each match. |
| 6633 | |
| 6634 | For example, in: |
| 6635 | class A { class B {}; class C {}; }; |
| 6636 | The matcher: |
| 6637 | cxxRecordDecl(hasName("::A"), |
| 6638 | findAll(cxxRecordDecl(isDefinition()).bind("m"))) |
| 6639 | will generate results for A, B and C. |
| 6640 | |
| 6641 | Usable as: Any Matcher |
| 6642 | </pre></td></tr> |
| 6643 | |
| 6644 | |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6645 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</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> |
| 6646 | <tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 6647 | matcher. |
| 6648 | |
| 6649 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 6650 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 6651 | and U (matcher = typedefDecl(hasType(asString("int"))) |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6652 | and friend class X (matcher = friendDecl(hasType("X")) |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 6653 | class X {}; |
| 6654 | void y(X &x) { x; X z; } |
| 6655 | typedef int U; |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6656 | class Y { friend class X; }; |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 6657 | </pre></td></tr> |
| 6658 | |
| 6659 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6660 | <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>const 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] | 6661 | <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node |
| 6662 | matches the given matcher. |
| 6663 | |
| 6664 | The associated declaration is: |
| 6665 | - for type nodes, the declaration of the underlying type |
| 6666 | - for CallExpr, the declaration of the callee |
| 6667 | - for MemberExpr, the declaration of the referenced member |
| 6668 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6669 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6670 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6671 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6672 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6673 | sugared type. Given |
| 6674 | class X {}; |
| 6675 | typedef X Y; |
| 6676 | Y y; |
| 6677 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6678 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6679 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6680 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6681 | recordType(hasDeclaration(decl()))))) |
| 6682 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6683 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 6684 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 6685 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 6686 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 6687 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 6688 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 6689 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 6690 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
| 6691 | </pre></td></tr> |
| 6692 | |
| 6693 | |
| 6694 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('hasUnqualifiedDesugaredType0')"><a name="hasUnqualifiedDesugaredType0Anchor">hasUnqualifiedDesugaredType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>> InnerMatcher</td></tr> |
| 6695 | <tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared |
| 6696 | type of the matched node. |
| 6697 | |
| 6698 | For example, in: |
| 6699 | class A {}; |
| 6700 | using B = A; |
George Karpenkov | daac52c | 2018-07-23 22:29:10 +0000 | [diff] [blame] | 6701 | The matcher type(hasUnqualifiedDesugaredType(recordType())) matches |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 6702 | both B and A. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6703 | </pre></td></tr> |
| 6704 | |
| 6705 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6706 | <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] | 6707 | <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. |
| 6708 | |
| 6709 | Given |
| 6710 | int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); |
| 6711 | unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) |
| 6712 | matches sizeof(a) and alignof(c) |
| 6713 | </pre></td></tr> |
| 6714 | |
| 6715 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6716 | <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] | 6717 | <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. |
| 6718 | |
| 6719 | Example matches true (matcher = hasUnaryOperand( |
| 6720 | cxxBoolLiteral(equals(true)))) |
| 6721 | !true |
| 6722 | </pre></td></tr> |
| 6723 | |
| 6724 | |
Shuai Wang | 92f9d1b | 2018-08-23 17:16:06 +0000 | [diff] [blame] | 6725 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html">UnresolvedMemberExpr</a>></td><td class="name" onclick="toggle('hasObjectExpression1')"><a name="hasObjectExpression1Anchor">hasObjectExpression</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
| 6726 | <tr><td colspan="4" class="doc" id="hasObjectExpression1"><pre>Matches a member expression where the object expression is |
| 6727 | matched by a given matcher. |
| 6728 | |
| 6729 | Given |
| 6730 | struct X { int m; }; |
| 6731 | void f(X x) { x.m; m; } |
| 6732 | memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))))) |
| 6733 | matches "x.m" and "m" |
| 6734 | with hasObjectExpression(...) |
| 6735 | matching "x" and the implicit object expression of "m" which has type X*. |
| 6736 | </pre></td></tr> |
| 6737 | |
| 6738 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6739 | <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>const 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] | 6740 | <tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node |
| 6741 | matches the given matcher. |
| 6742 | |
| 6743 | The associated declaration is: |
| 6744 | - for type nodes, the declaration of the underlying type |
| 6745 | - for CallExpr, the declaration of the callee |
| 6746 | - for MemberExpr, the declaration of the referenced member |
| 6747 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6748 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6749 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6750 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6751 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6752 | sugared type. Given |
| 6753 | class X {}; |
| 6754 | typedef X Y; |
| 6755 | Y y; |
| 6756 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6757 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6758 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6759 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6760 | recordType(hasDeclaration(decl()))))) |
| 6761 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6762 | |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 6763 | Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, |
| 6764 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, |
| 6765 | 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>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, |
| 6766 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, |
| 6767 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, |
| 6768 | Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, |
| 6769 | 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] | 6770 | </pre></td></tr> |
| 6771 | |
| 6772 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6773 | <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] | 6774 | <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. |
| 6775 | |
| 6776 | Given |
| 6777 | namespace X { void b(); } |
| 6778 | using X::b; |
| 6779 | usingDecl(hasAnyUsingShadowDecl(hasName("b")))) |
| 6780 | matches using X::b </pre></td></tr> |
| 6781 | |
| 6782 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6783 | <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] | 6784 | <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is |
| 6785 | matched by the given matcher. |
| 6786 | |
| 6787 | Given |
| 6788 | namespace X { int a; void b(); } |
| 6789 | using X::a; |
| 6790 | using X::b; |
| 6791 | usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) |
| 6792 | matches using X::b but not using X::a </pre></td></tr> |
| 6793 | |
| 6794 | |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6795 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType6')"><a name="hasType6Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
| 6796 | <tr><td colspan="4" class="doc" id="hasType6"><pre>Overloaded to match the declaration of the expression's or value |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6797 | declaration's type. |
| 6798 | |
| 6799 | In case of a value declaration (for example a variable declaration), |
| 6800 | this resolves one layer of indirection. For example, in the value |
| 6801 | declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 6802 | X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 6803 | declaration of x. |
| 6804 | |
| 6805 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 6806 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6807 | and friend class X (matcher = friendDecl(hasType("X")) |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6808 | class X {}; |
| 6809 | void y(X &x) { x; X z; } |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6810 | class Y { friend class X; }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6811 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6812 | 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] | 6813 | </pre></td></tr> |
| 6814 | |
| 6815 | |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6816 | <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType3')"><a name="hasType3Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> |
| 6817 | <tr><td colspan="4" class="doc" id="hasType3"><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] | 6818 | matcher. |
| 6819 | |
| 6820 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 6821 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 6822 | and U (matcher = typedefDecl(hasType(asString("int"))) |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6823 | and friend class X (matcher = friendDecl(hasType("X")) |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6824 | class X {}; |
| 6825 | void y(X &x) { x; X z; } |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 6826 | typedef int U; |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6827 | class Y { friend class X; }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6828 | </pre></td></tr> |
| 6829 | |
| 6830 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6831 | <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] | 6832 | <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression |
| 6833 | that matches the given matcher. |
| 6834 | |
| 6835 | Example matches x (matcher = varDecl(hasInitializer(callExpr()))) |
| 6836 | bool y() { return true; } |
| 6837 | bool x = y(); |
| 6838 | </pre></td></tr> |
| 6839 | |
| 6840 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6841 | <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] | 6842 | <tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size |
| 6843 | expression. |
| 6844 | |
| 6845 | Given |
| 6846 | void f(int b) { |
| 6847 | int a[b]; |
| 6848 | } |
| 6849 | variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( |
| 6850 | varDecl(hasName("b"))))))) |
| 6851 | matches "int a[b]" |
| 6852 | </pre></td></tr> |
| 6853 | |
| 6854 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6855 | <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] | 6856 | <tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 6857 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6858 | |
| 6859 | Given |
| 6860 | for (;;) {} |
| 6861 | hasBody(compoundStmt()) |
| 6862 | matches 'for (;;) {}' |
| 6863 | with compoundStmt() |
| 6864 | matching '{}' |
| 6865 | </pre></td></tr> |
| 6866 | |
| 6867 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6868 | <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] | 6869 | <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, |
Etienne Bergeron | 5500f95 | 2016-05-30 15:25:25 +0000 | [diff] [blame] | 6870 | switch statement or conditional operator. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6871 | |
| 6872 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 6873 | if (true) {} |
| 6874 | </pre></td></tr> |
| 6875 | |
| 6876 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6877 | <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] | 6878 | <tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner |
| 6879 | NestedNameSpecifier-matcher matches. |
| 6880 | </pre></td></tr> |
| 6881 | |
| 6882 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 6883 | <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] | 6884 | <tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner |
| 6885 | QualType-matcher matches. |
| 6886 | </pre></td></tr> |
| 6887 | |
Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 6888 | <!--END_TRAVERSAL_MATCHERS --> |
| 6889 | </table> |
| 6890 | |
| 6891 | </div> |
| 6892 | </body> |
| 6893 | </html> |
| 6894 | |
| 6895 | |