| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| "http://www.w3.org/TR/html4/strict.dtd"> |
| <html> |
| <head> |
| <title>AST Matcher Reference</title> |
| <link type="text/css" rel="stylesheet" href="../menu.css" /> |
| <link type="text/css" rel="stylesheet" href="../content.css" /> |
| <style type="text/css"> |
| td { |
| padding: .33em; |
| } |
| td.doc { |
| display: none; |
| border-bottom: 1px solid black; |
| } |
| td.name:hover { |
| color: blue; |
| cursor: pointer; |
| } |
| span.mono { font-family: monospace; } |
| |
| .traverse_compare, .traverse_compare td, .traverse_compare th { |
| border: 1px solid black; |
| border-collapse: collapse; |
| } |
| </style> |
| <script type="text/javascript"> |
| function toggle(id) { |
| if (!id) return; |
| row = document.getElementById(id); |
| if (row.style.display != 'table-cell') |
| row.style.display = 'table-cell'; |
| else |
| row.style.display = 'none'; |
| } |
| </script> |
| </head> |
| <body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))"> |
| |
| <!--#include virtual="../menu.html.incl"--> |
| |
| <div id="content"> |
| |
| <h1>AST Matcher Reference</h1> |
| |
| <p>This document shows all currently implemented matchers. The matchers are grouped |
| by category and node type they match. You can click on matcher names to show the |
| matcher's source documentation.</p> |
| |
| <p>There are three different basic categories of matchers: |
| <ul> |
| <li><a href="#decl-matchers">Node Matchers:</a> Matchers that match a specific type of AST node.</li> |
| <li><a href="#narrowing-matchers">Narrowing Matchers:</a> Matchers that match attributes on AST nodes.</li> |
| <li><a href="#traversal-matchers">Traversal Matchers:</a> Matchers that allow traversal between AST nodes.</li> |
| </ul> |
| </p> |
| |
| <p>Within each category the matchers are ordered by node type they match on. |
| Note that if a matcher can match multiple node types, it will appear |
| multiple times. This means that by searching for Matcher<Stmt> you can |
| find all matchers that can be used to match on Stmt nodes.</p> |
| |
| <p>The exception to that rule are matchers that can match on any node. Those |
| are marked with a * and are listed in the beginning of each category.</p> |
| |
| <p>Note that the categorization of matchers is a great help when you combine |
| them into matcher expressions. You will usually want to form matcher expressions |
| that read like english sentences by alternating between node matchers and |
| narrowing or traversal matchers, like this: |
| <pre> |
| recordDecl(hasDescendant( |
| ifStmt(hasTrueExpression( |
| expr(hasDescendant( |
| ifStmt())))))) |
| </pre> |
| </p> |
| |
| <!-- ======================================================================= --> |
| <h2 id="traverse-mode">Traverse Mode</h2> |
| <!-- ======================================================================= --> |
| |
| <p>The default mode of operation of AST Matchers visits all nodes in the AST, |
| even if they are not spelled in the source. This is |
| <span class="mono">AsIs</span> mode. This mode requires writing AST matchers |
| that explicitly traverse or ignore implicit nodes, such as parentheses |
| surrounding an expression or expressions with cleanups. These implicit |
| nodes are not always obvious from the syntax of the source code, and so this |
| mode requires careful consideration and testing to get the desired behavior |
| from an AST matcher. |
| </p> |
| |
| <p>In addition, because template instantiations are matched in the default mode, |
| transformations can be accidentally made to template declarations. Finally, |
| because implicit nodes are matched by default, transformations can be made on |
| entirely incorrect places in the code.</p> |
| |
| <p>For these reasons, it is possible to ignore AST nodes which are not spelled |
| in the source using the <span class="mono">IgnoreUnlessSpelledInSource</span> |
| mode. This is likely to be far less error-prone for users who are not already |
| very familiar with where implicit nodes appear in the AST. It is also likely |
| to be less error-prone for experienced AST users, as difficult cases do not |
| need to be encountered and matcher expressions adjusted for these cases.</p> |
| |
| <p>In clang-query, the mode can be changed with |
| <pre> |
| set traversal IgnoreUnlessSpelledInSource |
| </pre> |
| </p> |
| This affects both matchers and AST dump output in results. |
| |
| <p>When using the C++ API such as in clang-tidy checks, the |
| <span class="mono">traverse()</span> matcher is used to set the mode: |
| <pre> |
| Finder->addMatcher(traverse(TK_IgnoreUnlessSpelledInSource, |
| returnStmt(hasReturnArgument(integerLiteral(equals(0)))) |
| ), this); |
| </pre> |
| </p> |
| <p>The following table compares the <span class="mono">AsIs</span> mode with |
| the <span class="mono">IgnoreUnlessSpelledInSource</span> mode:</p> |
| |
| <table class="traverse_compare"> |
| <tr> |
| <th></th> |
| <th><span class="mono">AsIs</span></th> |
| <th><span class="mono">IgnoreUnlessSpelledInSource</span></th> |
| </tr> |
| <tr> |
| <td>AST dump of <span class="mono">func1</span>: |
| <pre> |
| struct B { |
| B(int); |
| }; |
| |
| B func1() { return 42; } |
| </pre> |
| |
| </td> |
| <td> |
| C++98 dialect: |
| <pre> |
| FunctionDecl |
| `-CompoundStmt |
| `-ReturnStmt |
| `-ExprWithCleanups |
| `-CXXConstructExpr |
| `-MaterializeTemporaryExpr |
| `-ImplicitCastExpr |
| `-ImplicitCastExpr |
| `-CXXConstructExpr |
| `-IntegerLiteral 'int' 42 |
| </pre> |
| C++11, C++14 dialect: |
| <pre> |
| FunctionDecl |
| `-CompoundStmt |
| `-ReturnStmt |
| `-ExprWithCleanups |
| `-CXXConstructExpr |
| `-MaterializeTemporaryExpr |
| `-ImplicitCastExpr |
| `-CXXConstructExpr |
| `-IntegerLiteral 'int' 42 |
| </pre> |
| C++17, C++20 dialect: |
| <pre> |
| FunctionDecl |
| `-CompoundStmt |
| `-ReturnStmt |
| `-ImplicitCastExpr |
| `-CXXConstructExpr |
| `-IntegerLiteral 'int' 42 |
| </pre> |
| </td> |
| <td> |
| All dialects: |
| <pre> |
| FunctionDecl |
| `-CompoundStmt |
| `-ReturnStmt |
| `-IntegerLiteral 'int' 42 |
| </pre></td> |
| </tr> |
| |
| <tr> |
| <td>Matcher for returned <span class="mono">42</span>: |
| <pre> |
| struct B { |
| B(int); |
| }; |
| |
| B func1() { return 42; } |
| </pre> |
| |
| </td> |
| <td> |
| All dialects: |
| <pre> |
| returnStmt(hasReturnValue( |
| ignoringImplicit( |
| ignoringElidableConstructorCall( |
| ignoringImplicit( |
| cxxConstructExpr(hasArgument(0, |
| ignoringImplicit( |
| integerLiteral().bind("returnVal") |
| ) |
| )) |
| ) |
| ) |
| ) |
| )) |
| </pre></td> |
| <td> |
| All dialects: |
| <pre> |
| returnStmt(hasReturnValue( |
| integerLiteral().bind("returnVal") |
| )) |
| </pre></td> |
| </tr> |
| <tr> |
| <td>Match result for |
| <pre>implicitCastExpr()</pre> |
| given: |
| <pre> |
| struct B { |
| B(int); |
| }; |
| |
| B func1() { return 42; } |
| </pre> |
| |
| </td> |
| <td> |
| Match found.</td> |
| <td> |
| No match.</td> |
| </tr> |
| <tr> |
| <td>Match result for: |
| <pre> |
| cxxConstructorDecl( |
| isCopyConstructor() |
| ).bind("prepend_explicit") |
| </pre> |
| given: |
| <pre> |
| struct Other {}; |
| struct Copyable { |
| Other m_o; |
| Copyable(); |
| }; |
| </pre> |
| </td> |
| <td> |
| Match found. Insertion produces incorrect output: |
| <pre> |
| struct Other {}; |
| struct explicit Copyable { |
| Other m_o; |
| Copyable(); |
| }; |
| </pre> |
| </td> |
| <td> |
| No match found. Incorrect replacement not possible. |
| </td> |
| </tr> |
| <tr> |
| <td>Replacement of <span class="mono">begin()</span> |
| with <span class="mono">cbegin()</span>: |
| <pre> |
| cxxMemberCallExpr( |
| on(ConstContainerExpr), |
| callee(cxxMethodDecl(hasName("begin"))) |
| ).bind("replace_with_cbegin") |
| </pre> |
| given: |
| <pre> |
| void foo() { |
| const Container c; |
| c.begin(); |
| |
| for (auto i : c) { |
| } |
| } |
| </pre> |
| </td> |
| <td> |
| 2 matches found. Replacement produces incorrect output: |
| <pre> |
| void foo() { |
| const Container c; |
| c.cbegin(); |
| |
| for (auto i :.cbegin() c) { |
| } |
| } |
| </pre> |
| </td> |
| <td> |
| 1 match found. Replacement produces correct output: |
| <pre> |
| void foo() { |
| const Container c; |
| c.cbegin(); |
| |
| for (auto i : c) { |
| } |
| } |
| </pre> |
| </td> |
| </tr> |
| <tr> |
| <td>Replacement of <span class="mono">int</span> member |
| with <span class="mono">safe_int</span>: |
| <pre> |
| fieldDecl( |
| hasType(asString("int")) |
| ).bind("use_safe_int") |
| </pre> |
| given: |
| <pre> |
| struct S { |
| int m_i; |
| }; |
| |
| template <typename T> struct TemplStruct { |
| TemplStruct() {} |
| ~TemplStruct() {} |
| |
| private: |
| T m_t; |
| }; |
| |
| void instantiate() { TemplStruct<int> ti; } |
| </pre> |
| </td> |
| <td> |
| 2 matches found. Replacement produces incorrect output: |
| <pre> |
| struct S { |
| safe_int m_i; |
| }; |
| |
| template <typename T> struct TemplStruct { |
| TemplStruct() {} |
| ~TemplStruct() {} |
| |
| private: |
| safe_int m_t; |
| }; |
| |
| void instantiate() { TemplStruct<int> ti; } |
| </pre> |
| </td> |
| <td> |
| 1 match found. Replacement produces correct output: |
| <pre> |
| struct S { |
| safe_int m_i; |
| }; |
| |
| template <typename T> struct TemplStruct { |
| TemplStruct() {} |
| ~TemplStruct() {} |
| |
| private: |
| T m_t; |
| }; |
| |
| void instantiate() { TemplStruct<int> ti; } |
| </pre> |
| </td> |
| </tr> |
| <tr> |
| <td>Add prefix to member initializer |
| <pre> |
| cxxCtorInitializer( |
| forField(fieldDecl()) |
| ).bind("add_prefix") |
| </pre> |
| given: |
| <pre> |
| struct Simple {}; |
| |
| struct Record { |
| Record() : i(42) {} |
| private: |
| int i; |
| Simple s; |
| }; |
| </pre> |
| </td> |
| <td> |
| 2 matches found. Replacement produces incorrect output: |
| <pre> |
| struct Simple {}; |
| |
| struct Record { |
| m_Record() : m_i(42) {} |
| private: |
| int i; |
| Simple s; |
| }; |
| </pre> |
| </td> |
| <td> |
| 1 match found. Replacement produces correct output: |
| <pre> |
| struct Simple {}; |
| |
| struct Record { |
| Record() : m_i(42) {} |
| private: |
| int i; |
| Simple s; |
| }; |
| </pre> |
| </td> |
| </tr> |
| <tr> |
| <td>Ignored default arguments |
| <pre> |
| callExpr( |
| callee(functionDecl( |
| hasName("hasDefaultArg") |
| )), |
| argumentCountIs(1) |
| ).bind("add_prefix") |
| </pre> |
| given: |
| <pre> |
| void hasDefaultArg(int i, int j = 0) {} |
| void callDefaultArg() { hasDefaultArg(42); } |
| </pre> |
| </td> |
| <td> |
| No match. |
| </td> |
| <td> |
| 1 match found. |
| </td> |
| </tr> |
| <tr> |
| <td>Lambda fields |
| <pre> |
| fieldDecl( |
| hasType(asString("int")) |
| ).bind("make_safe") |
| </pre> |
| given: |
| <pre> |
| struct S { |
| int m_i; |
| }; |
| |
| void func() { |
| int a = 0; |
| int c = 0; |
| |
| auto l = [a, b = c](int d) { int e = d; }; |
| l(43); |
| } |
| </pre> |
| </td> |
| <td> |
| 2 matches found. Replacement produces incorrect output: |
| <pre> |
| struct S { |
| safe_int m_i; |
| }; |
| |
| void func() { |
| int a = 0; |
| int c = 0; |
| |
| auto l = [safe_a, safe_b = c](int d) { int e = d; }; |
| l(43); |
| } |
| </pre> |
| </td> |
| <td> |
| 1 match found. Replacement produces correct output: |
| <pre> |
| struct S { |
| safe_int m_i; |
| }; |
| |
| void func() { |
| int a = 0; |
| int c = 0; |
| |
| auto l = [a, b = c](int d) { int e = d; }; |
| l(43); |
| } |
| </pre> |
| </td> |
| |
| </tr> |
| |
| |
| |
| |
| |
| <tr> |
| <td>Rewritten binary operators |
| <pre> |
| binaryOperator( |
| hasOperatorName("<"), |
| hasRHS(hasDescendant(integerLiteral(equals(0)))) |
| ) |
| </pre> |
| given: |
| <pre> |
| #include <compare> |
| |
| class HasSpaceship { |
| public: |
| int x; |
| bool operator==(const HasSpaceship&) const = default; |
| std::strong_ordering operator<=>(const HasSpaceship&) const = default; |
| }; |
| |
| bool isLess(const HasSpaceship& a, const HasSpaceship& b) { |
| return a < b; |
| } |
| </pre> |
| </td> |
| <td> |
| 1 match found. |
| |
| <pre> |
| return a < b; |
| ^~~~~ |
| </pre> |
| |
| </td> |
| <td> |
| No match found. |
| </td> |
| </tr> |
| </table> |
| |
| <!-- ======================================================================= --> |
| <h2 id="decl-matchers">Node Matchers</h2> |
| <!-- ======================================================================= --> |
| |
| <p>Node matchers are at the core of matcher expressions - they specify the type |
| of node that is expected. Every match expression starts with a node matcher, |
| which can then be further refined with a narrowing or traversal matcher. All |
| traversal matchers take node matchers as their arguments.</p> |
| |
| <p>For convenience, all node matchers take an arbitrary number of arguments |
| and implicitly act as allOf matchers.</p> |
| |
| <p>Node matchers are the only matchers that support the bind("id") call to |
| bind the matched node to the given string, to be later retrieved from the |
| match callback.</p> |
| |
| <p>It is important to remember that the arguments to node matchers are |
| predicates on the same node, just with additional information about the type. |
| This is often useful to make matcher expression more readable by inlining bind |
| calls into redundant node matchers inside another node matcher: |
| <pre> |
| // This binds the CXXRecordDecl to "id", as the decl() matcher will stay on |
| // the same node. |
| recordDecl(decl().bind("id"), hasName("::MyClass")) |
| </pre> |
| </p> |
| |
| <table> |
| <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| <!-- START_DECL_MATCHERS --> |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>></td><td class="name" onclick="toggle('attr0')"><a name="attr0Anchor">attr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="attr0"><pre>Matches attributes. |
| Attributes may be attached with a variety of different syntaxes (including |
| keywords, C++11 attributes, GNU ``__attribute``` and MSVC `__declspec``, |
| and ``#pragma``s). They may also be implicit. |
| |
| Given |
| struct [[nodiscard]] Foo{}; |
| void bar(int * __attribute__((nonnull)) ); |
| __declspec(noinline) void baz(); |
| |
| #pragma omp declare simd |
| int min(); |
| attr() |
| matches "nodiscard", "nonnull", "noinline", and the whole "#pragma" line. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>></td><td class="name" onclick="toggle('cxxBaseSpecifier0')"><a name="cxxBaseSpecifier0Anchor">cxxBaseSpecifier</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxBaseSpecifier0"><pre>Matches class bases. |
| |
| Examples matches public virtual B. |
| class B {}; |
| class C : public virtual B {}; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers. |
| |
| Examples matches i(42). |
| class C { |
| C() : i(42) {} |
| int i; |
| }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AccessSpecDecl.html">AccessSpecDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations. |
| |
| Given |
| class C { |
| public: |
| int a; |
| }; |
| accessSpecDecl() |
| matches 'public:' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('bindingDecl0')"><a name="bindingDecl0Anchor">bindingDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html">BindingDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="bindingDecl0"><pre>Matches binding declarations |
| Example matches foo and bar |
| (matcher = bindingDecl() |
| |
| auto [foo, bar] = std::make_pair{42, 42}; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="blockDecl0"><pre>Matches block declarations. |
| |
| Example matches the declaration of the nameless block printing an input |
| integer. |
| |
| myFunc(^(int p) { |
| printf("%d", p); |
| }) |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations. |
| |
| Example matches Z |
| template<class T> class Z {}; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplatePartialSpecializationDecl.html">ClassTemplatePartialSpecializationDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="classTemplatePartialSpecializationDecl0"><pre>Matches C++ class template partial specializations. |
| |
| Given |
| template<class T1, class T2, int I> |
| class A {}; |
| |
| template<class T, int I> |
| class A<T, T*, I> {}; |
| |
| template<> |
| class A<int, int, 1> {}; |
| classTemplatePartialSpecializationDecl() |
| matches the specialization A<T,T*,I> but not A<int,int,1> |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations. |
| |
| Given |
| template<typename T> class A {}; |
| template<> class A<double> {}; |
| A<int> a; |
| classTemplateSpecializationDecl() |
| matches the specializations A<int> and A<double> |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations. |
| |
| Example matches Foo::Foo() and Foo::Foo(int) |
| class Foo { |
| public: |
| Foo(); |
| Foo(int); |
| int DoSomething(); |
| }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations. |
| |
| Example matches the operator. |
| class X { operator int() const; }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxDeductionGuideDecl0')"><a name="cxxDeductionGuideDecl0Anchor">cxxDeductionGuideDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDeductionGuideDecl.html">CXXDeductionGuideDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxDeductionGuideDecl0"><pre>Matches user-defined and implicitly generated deduction guide. |
| |
| Example matches the deduction guide. |
| template<typename T> |
| class X { X(int) }; |
| X(int) -> X<int>; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations. |
| |
| Example matches Foo::~Foo() |
| class Foo { |
| public: |
| virtual ~Foo(); |
| }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations. |
| |
| Example matches y |
| class X { void y(); }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations. |
| |
| Example matches X, Z |
| class X; |
| template<class T> class Z {}; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. |
| |
| Examples matches X, C, and the friend declaration inside C; |
| void X(); |
| class C { |
| friend X; |
| }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function |
| and non-type template parameter declarations). |
| |
| Given |
| class X { int y; }; |
| declaratorDecl() |
| matches int y. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('decompositionDecl0')"><a name="decompositionDecl0Anchor">decompositionDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html">DecompositionDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="decompositionDecl0"><pre>Matches decomposition-declarations. |
| |
| Examples matches the declaration node with foo and bar, but not |
| number. |
| (matcher = declStmt(has(decompositionDecl()))) |
| |
| int number = 42; |
| auto [foo, bar] = std::make_pair{42, 42}; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html">EnumConstantDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. |
| |
| Example matches A, B, C |
| enum X { |
| A, B, C |
| }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. |
| |
| Example matches X |
| enum X { |
| A, B, C |
| }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. |
| |
| Given |
| class X { int m; }; |
| fieldDecl() |
| matches 'm'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations. |
| |
| Given |
| class X { friend void foo(); }; |
| friendDecl() |
| matches 'friend void foo()'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. |
| |
| Example matches f |
| void f(); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FunctionTemplateDecl.html">FunctionTemplateDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. |
| |
| Example matches f |
| template<class T> void f(T t) {} |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('indirectFieldDecl0')"><a name="indirectFieldDecl0Anchor">indirectFieldDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IndirectFieldDecl.html">IndirectFieldDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="indirectFieldDecl0"><pre>Matches indirect field declarations. |
| |
| Given |
| struct X { struct { int a; }; }; |
| indirectFieldDecl() |
| matches 'a'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1LabelDecl.html">LabelDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label. |
| |
| Given |
| goto FOO; |
| FOO: bar(); |
| labelDecl() |
| matches 'FOO:' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1LinkageSpecDecl.html">LinkageSpecDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification. |
| |
| Given |
| extern "C" {} |
| linkageSpecDecl() |
| matches "extern "C" {}" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. |
| |
| Example matches X, S, the anonymous union type, i, and U; |
| typedef int X; |
| struct S { |
| union { |
| int i; |
| } U; |
| }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamespaceAliasDecl.html">NamespaceAliasDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias. |
| |
| Given |
| namespace test {} |
| namespace alias = ::test; |
| namespaceAliasDecl() |
| matches "namespace alias" but not "namespace test" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. |
| |
| Given |
| namespace {} |
| namespace test {} |
| namespaceDecl() |
| matches "namespace {}" and "namespace test {}" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NonTypeTemplateParmDecl.html">NonTypeTemplateParmDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations. |
| |
| Given |
| template <typename T, int N> struct C {}; |
| nonTypeTemplateParmDecl() |
| matches 'N', but not 'T'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryDecl.html">ObjCCategoryDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcCategoryDecl0"><pre>Matches Objective-C category declarations. |
| |
| Example matches Foo (Additions) |
| @interface Foo (Additions) |
| @end |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryImplDecl.html">ObjCCategoryImplDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions. |
| |
| Example matches Foo (Additions) |
| @implementation Foo (Additions) |
| @end |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html">ObjCImplementationDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations. |
| |
| Example matches Foo |
| @implementation Foo |
| @end |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations. |
| |
| Example matches Foo |
| @interface Foo |
| @end |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCIvarDecl.html">ObjCIvarDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcIvarDecl0"><pre>Matches Objective-C instance variable declarations. |
| |
| Example matches _enabled |
| @implementation Foo { |
| BOOL _enabled; |
| } |
| @end |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcMethodDecl0"><pre>Matches Objective-C method declarations. |
| |
| Example matches both declaration and definition of -[Foo method] |
| @interface Foo |
| - (void)method; |
| @end |
| |
| @implementation Foo |
| - (void)method {} |
| @end |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcPropertyDecl0"><pre>Matches Objective-C property declarations. |
| |
| Example matches enabled |
| @interface Foo |
| @property BOOL enabled; |
| @end |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCProtocolDecl.html">ObjCProtocolDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcProtocolDecl0"><pre>Matches Objective-C protocol declarations. |
| |
| Example matches FooDelegate |
| @protocol FooDelegate |
| @end |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. |
| |
| Given |
| void f(int x); |
| parmVarDecl() |
| matches int x. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations. |
| |
| Example matches X, Z, U, and S |
| class X; |
| template<class T> class Z {}; |
| struct S {}; |
| union U {}; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1StaticAssertDecl.html">StaticAssertDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration. |
| |
| Example: |
| staticAssertExpr() |
| matches |
| static_assert(sizeof(S) == sizeof(int)) |
| in |
| struct S { |
| int x; |
| }; |
| static_assert(sizeof(S) == sizeof(int)); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('tagDecl0')"><a name="tagDecl0Anchor">tagDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="tagDecl0"><pre>Matches tag declarations. |
| |
| Example matches X, Z, U, S, E |
| class X; |
| template<class T> class Z {}; |
| struct S {}; |
| union U {}; |
| enum E { |
| A, B, C |
| }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('templateTemplateParmDecl0')"><a name="templateTemplateParmDecl0Anchor">templateTemplateParmDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTemplateParmDecl.html">TemplateTemplateParmDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="templateTemplateParmDecl0"><pre>Matches template template parameter declarations. |
| |
| Given |
| template <template <typename> class Z, int N> struct C {}; |
| templateTypeParmDecl() |
| matches 'Z', but not 'N'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmDecl.html">TemplateTypeParmDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations. |
| |
| Given |
| template <typename T, int N> struct C {}; |
| templateTypeParmDecl() |
| matches 'T', but not 'N'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TranslationUnitDecl.html">TranslationUnitDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context. |
| |
| Given |
| int X; |
| namespace NS { |
| int Y; |
| } // namespace NS |
| decl(hasDeclContext(translationUnitDecl())) |
| matches "int X", but not "int Y". |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypeAliasDecl.html">TypeAliasDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="typeAliasDecl0"><pre>Matches type alias declarations. |
| |
| Given |
| typedef int X; |
| using Y = int; |
| typeAliasDecl() |
| matches "using Y = int", but not "typedef int X" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypeAliasTemplateDecl.html">TypeAliasTemplateDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="typeAliasTemplateDecl0"><pre>Matches type alias template declarations. |
| |
| typeAliasTemplateDecl() matches |
| template <typename T> |
| using Y = X<T>; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html">TypedefDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations. |
| |
| Given |
| typedef int X; |
| using Y = int; |
| typedefDecl() |
| matches "typedef int X", but not "using Y = int" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="typedefNameDecl0"><pre>Matches typedef name declarations. |
| |
| Given |
| typedef int X; |
| using Y = int; |
| typedefNameDecl() |
| matches "typedef int X" and "using Y = int" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingTypenameDecl.html">UnresolvedUsingTypenameDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the |
| typename. |
| |
| Given |
| template <typename T> |
| struct Base { typedef T Foo; }; |
| |
| template<typename T> |
| struct S : private Base<T> { |
| using typename Base<T>::Foo; |
| }; |
| unresolvedUsingTypenameDecl() |
| matches using Base<T>::Foo </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingValueDecl.html">UnresolvedUsingValueDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations. |
| |
| Given |
| template<typename X> |
| class C : private X { |
| using X::x; |
| }; |
| unresolvedUsingValueDecl() |
| matches using X::x </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. |
| |
| Given |
| namespace X { int x; } |
| using X::x; |
| usingDecl() |
| matches using X::x </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UsingDirectiveDecl.html">UsingDirectiveDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations. |
| |
| Given |
| namespace X { int x; } |
| using namespace X; |
| usingDirectiveDecl() |
| matches using namespace X </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('usingEnumDecl0')"><a name="usingEnumDecl0Anchor">usingEnumDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingEnumDecl.html">UsingEnumDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="usingEnumDecl0"><pre>Matches using-enum declarations. |
| |
| Given |
| namespace X { enum x {...}; } |
| using enum X::x; |
| usingEnumDecl() |
| matches using enum X::x </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration. |
| |
| Example matches A, B, C and F |
| enum X { A, B, C }; |
| void F(); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. |
| |
| Note: this does not match declarations of member variables, which are |
| "field" declarations in Clang parlance. |
| |
| Example matches a |
| int a; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>></td><td class="name" onclick="toggle('lambdaCapture0')"><a name="lambdaCapture0Anchor">lambdaCapture</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="lambdaCapture0"><pre>Matches lambda captures. |
| |
| Given |
| int main() { |
| int x; |
| auto f = [x](){}; |
| auto g = [x = 1](){}; |
| } |
| In the matcher `lambdaExpr(hasAnyCapture(lambdaCapture()))`, |
| `lambdaCapture()` matches `x` and `x=1`. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. |
| |
| Given |
| namespace ns { |
| struct A { static void f(); }; |
| void A::f() {} |
| void g() { A::f(); } |
| } |
| ns::A a; |
| nestedNameSpecifier() |
| matches "ns::" and both "A::" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPClause.html">OMPClause</a>></td><td class="name" onclick="toggle('ompDefaultClause0')"><a name="ompDefaultClause0Anchor">ompDefaultClause</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="ompDefaultClause0"><pre>Matches OpenMP ``default`` clause. |
| |
| Given |
| |
| #pragma omp parallel default(none) |
| #pragma omp parallel default(shared) |
| #pragma omp parallel default(firstprivate) |
| #pragma omp parallel |
| |
| ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, and |
| ``default(firstprivate)`` |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension). |
| |
| Given |
| FOO: bar(); |
| void *ptr = &&FOO; |
| goto *bar; |
| addrLabelExpr() |
| matches '&&FOO' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. |
| |
| Given |
| int i = a[1]; |
| arraySubscriptExpr() |
| matches "a[1]" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AsmStmt.html">AsmStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. |
| |
| int i = 100; |
| __asm("mov al, 2"); |
| asmStmt() |
| matches '__asm("mov al, 2")' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AtomicExpr.html">AtomicExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins. |
| Example matches __atomic_load_n(ptr, 1) |
| void foo() { int *ptr; __atomic_load_n(ptr, 1); } |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCAutoreleasePoolStmt.html">ObjCAutoreleasePoolStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement. |
| |
| Given |
| @autoreleasepool { |
| int x = 0; |
| } |
| autoreleasePoolStmt(stmt()) matches the declaration of "x" |
| inside the autorelease pool. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BinaryConditionalOperator.html">BinaryConditionalOperator</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension). |
| |
| Example matches a ?: b |
| (a ?: b) + 42; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. |
| |
| Example matches a || b |
| !(a || b) |
| See also the binaryOperation() matcher for more-general matching. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('blockExpr0')"><a name="blockExpr0Anchor">blockExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockExpr.html">BlockExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="blockExpr0"><pre>Matches a reference to a block. |
| |
| Example: matches "^{}": |
| void f() { ^{}(); } |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BreakStmt.html">BreakStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. |
| |
| Given |
| while (true) { break; } |
| breakStmt() |
| matches 'break' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CStyleCastExpr.html">CStyleCastExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. |
| |
| Example: Matches (int) 2.2f in |
| int i = (int) 2.2f; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. |
| |
| Example matches x.y() and y() |
| X x; |
| x.y(); |
| y(); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. |
| |
| Given |
| switch(a) { case 42: break; default: break; } |
| caseStmt() |
| matches 'case 42:'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. |
| |
| Example: castExpr() matches each of the following: |
| (int) 3; |
| const_cast<Expr *>(SubExpr); |
| char c = 0; |
| but does not match |
| int i = (0); |
| int k = 0; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). |
| |
| Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), |
| though. |
| |
| Example matches 'a', L'a' |
| char ch = 'a'; |
| wchar_t chw = L'a'; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('chooseExpr0')"><a name="chooseExpr0Anchor">chooseExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ChooseExpr.html">ChooseExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="chooseExpr0"><pre>Matches GNU __builtin_choose_expr. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('coawaitExpr0')"><a name="coawaitExpr0Anchor">coawaitExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CoawaitExpr.html">CoawaitExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="coawaitExpr0"><pre>Matches co_await expressions. |
| |
| Given |
| co_await 1; |
| coawaitExpr() |
| matches 'co_await 1' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals |
| |
| Example match: {1}, (1, 2) |
| int array[4] = {1}; |
| vector int myvec = (vector int)(1, 2); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. |
| |
| Example matches '{}' and '{{}}' in 'for (;;) {{}}' |
| for (;;) {{}} |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. |
| |
| Example matches a ? b : c |
| (a ? b : c) + 42 |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('constantExpr0')"><a name="constantExpr0Anchor">constantExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ConstantExpr.html">ConstantExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="constantExpr0"><pre>Matches a constant expression wrapper. |
| |
| Example matches the constant in the case statement: |
| (matcher = constantExpr()) |
| switch (a) { |
| case 37: break; |
| } |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ContinueStmt.html">ContinueStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. |
| |
| Given |
| while (true) { continue; } |
| continueStmt() |
| matches 'continue' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('coreturnStmt0')"><a name="coreturnStmt0Anchor">coreturnStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CoreturnStmt.html">CoreturnStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="coreturnStmt0"><pre>Matches co_return statements. |
| |
| Given |
| while (true) { co_return; } |
| coreturnStmt() |
| matches 'co_return' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('coyieldExpr0')"><a name="coyieldExpr0Anchor">coyieldExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CoyieldExpr.html">CoyieldExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="coyieldExpr0"><pre>Matches co_yield expressions. |
| |
| Given |
| co_yield 1; |
| coyieldExpr() |
| matches 'co_yield 1' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression. |
| |
| Example matches, |
| kernel<<<i,j>>>(); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created. |
| |
| Example matches FunctionTakesString(GetStringByValue()) |
| (matcher = cxxBindTemporaryExpr()) |
| FunctionTakesString(GetStringByValue()); |
| FunctionTakesStringByPointer(GetStringPointer()); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals. |
| |
| Example matches true |
| true |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements. |
| |
| try {} catch(int i) {} |
| cxxCatchStmt() |
| matches 'catch(int i)' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression. |
| |
| Example: Matches const_cast<int*>(&r) in |
| int n = 42; |
| const int &r(n); |
| int* p = const_cast<int*>(&r); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones). |
| |
| Example matches string(ptr, n) and ptr within arguments of f |
| (matcher = cxxConstructExpr()) |
| void f(const string &a, const string &b); |
| char *ptr; |
| int n; |
| f(string(ptr, n), ptr); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site. |
| |
| Example matches the CXXDefaultArgExpr placeholder inserted for the |
| default value of the second parameter in the call expression f(42) |
| (matcher = cxxDefaultArgExpr()) |
| void f(int x, int y = 0); |
| f(42); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions. |
| |
| Given |
| delete X; |
| cxxDeleteExpr() |
| matches 'delete X'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be |
| resolved because the base expression or the member name was dependent. |
| |
| Given |
| template <class T> void f() { T t; t.g(); } |
| cxxDependentScopeMemberExpr() |
| matches t.g |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression. |
| |
| Example: |
| cxxDynamicCastExpr() |
| matches |
| dynamic_cast<D*>(&b); |
| in |
| struct B { virtual ~B() {} }; struct D : B {}; |
| B b; |
| D* p = dynamic_cast<D*>(&b); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements. |
| |
| cxxForRangeStmt() matches 'for (auto a : i)' |
| int i[] = {1, 2, 3}; for (auto a : i); |
| for(int j = 0; j < 5; ++j); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions |
| |
| Example: Matches Foo(bar); |
| Foo f = bar; |
| Foo g = (Foo) bar; |
| Foo h = Foo(bar); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions. |
| |
| Example matches x.y() |
| X x; |
| x.y(); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions. |
| |
| Given |
| new X; |
| cxxNewExpr() |
| matches 'new X'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxNoexceptExpr0')"><a name="cxxNoexceptExpr0Anchor">cxxNoexceptExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNoexceptExpr.html">CXXNoexceptExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxNoexceptExpr0"><pre>Matches noexcept expressions. |
| |
| Given |
| bool a() noexcept; |
| bool b() noexcept(true); |
| bool c() noexcept(false); |
| bool d() noexcept(noexcept(a())); |
| bool e = noexcept(b()) || noexcept(c()); |
| cxxNoexceptExpr() |
| matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`. |
| doesn't match the noexcept specifier in the declarations a, b, c or d. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls. |
| |
| Note that if an operator isn't overloaded, it won't match. Instead, use |
| binaryOperator matcher. |
| Currently it does not match operators such as new delete. |
| FIXME: figure out why these do not match? |
| |
| Example matches both operator<<((o << b), c) and operator<<(o, b) |
| (matcher = cxxOperatorCallExpr()) |
| ostream &operator<< (ostream &out, int i) { }; |
| ostream &o; int b = 1, c = 1; |
| o << b << c; |
| See also the binaryOperation() matcher for more-general matching of binary |
| uses of this AST node. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. |
| |
| Either the source expression or the destination type can be matched |
| using has(), but hasDestinationType() is more specific and can be |
| more readable. |
| |
| Example matches reinterpret_cast<char*>(&p) in |
| void* p = reinterpret_cast<char*>(&p); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxRewrittenBinaryOperator0')"><a name="cxxRewrittenBinaryOperator0Anchor">cxxRewrittenBinaryOperator</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxRewrittenBinaryOperator0"><pre>Matches rewritten binary operators |
| |
| Example matches use of "<": |
| #include <compare> |
| struct HasSpaceshipMem { |
| int a; |
| constexpr auto operator<=>(const HasSpaceshipMem&) const = default; |
| }; |
| void compare() { |
| HasSpaceshipMem hs1, hs2; |
| if (hs1 < hs2) |
| return; |
| } |
| See also the binaryOperation() matcher for more-general matching |
| of this AST node. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression. |
| |
| See also: hasDestinationType |
| See also: reinterpretCast |
| |
| Example: |
| cxxStaticCastExpr() |
| matches |
| static_cast<long>(8) |
| in |
| long eight(static_cast<long>(8)); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXStdInitializerListExpr.html">CXXStdInitializerListExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions. |
| |
| Given |
| std::vector<int> a({ 1, 2, 3 }); |
| std::vector<int> b = { 4, 5 }; |
| int c[] = { 6, 7 }; |
| std::pair<int, int> d = { 8, 9 }; |
| cxxStdInitializerListExpr() |
| matches "{ 1, 2, 3 }" and "{ 4, 5 }" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments |
| |
| Example: Matches Foo(bar, bar) |
| Foo h = Foo(bar, bar); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions. |
| |
| Example matches the implicit this expression in "return i". |
| (matcher = cxxThisExpr()) |
| struct foo { |
| int i; |
| int f() { return i; } |
| }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions. |
| |
| try { throw 5; } catch(int i) {} |
| cxxThrowExpr() |
| matches 'throw 5' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements. |
| |
| try {} catch(int i) {} |
| cxxTryStmt() |
| matches 'try {}' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. |
| |
| Example matches T(t) in return statement of f |
| (matcher = cxxUnresolvedConstructExpr()) |
| template <typename T> |
| void f(const T& t) { return T(t); } |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. |
| |
| Example matches x in if (x) |
| bool x; |
| if (x) {} |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. |
| |
| Given |
| int a; |
| declStmt() |
| matches 'int a'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DefaultStmt.html">DefaultStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. |
| |
| Given |
| switch(a) { case 42: break; default: break; } |
| defaultStmt() |
| matches 'default:'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('dependentCoawaitExpr0')"><a name="dependentCoawaitExpr0Anchor">dependentCoawaitExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentCoawaitExpr.html">DependentCoawaitExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="dependentCoawaitExpr0"><pre>Matches co_await expressions where the type of the promise is dependent |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DesignatedInitExpr.html">DesignatedInitExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8]. |
| |
| Example: Matches { [2].y = 1.0, [0].x = 1.0 } |
| point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. |
| |
| Given |
| do {} while (true); |
| doStmt() |
| matches 'do {} while(true)' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. |
| |
| Matches any cast expression written in user code, whether it be a |
| C-style cast, a functional-style cast, or a keyword cast. |
| |
| Does not match implicit conversions. |
| |
| Note: the name "explicitCast" is chosen to match Clang's terminology, as |
| Clang uses the term "cast" to apply to implicit conversions as well as to |
| actual cast expressions. |
| |
| See also: hasDestinationType. |
| |
| Example: matches all five of the casts in |
| int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) |
| but does not match the implicit conversion in |
| long ell = 42; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. |
| |
| Example matches x() |
| void f() { x(); } |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ExprWithCleanups.html">ExprWithCleanups</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end |
| of the sub-expression's evaluation. |
| |
| Example matches std::string() |
| const std::string str = std::string(); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('fixedPointLiteral0')"><a name="fixedPointLiteral0Anchor">fixedPointLiteral</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FixedPointLiteral.html">FixedPointLiteral</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="fixedPointLiteral0"><pre>Matches fixed point literals |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g. |
| 1.0, 1.0f, 1.0L and 1e10. |
| |
| Does not match implicit conversions such as |
| float a = 10; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. |
| |
| Example matches 'for (;;) {}' |
| for (;;) {} |
| int i[] = {1, 2, 3}; for (auto a : i); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('genericSelectionExpr0')"><a name="genericSelectionExpr0Anchor">genericSelectionExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1GenericSelectionExpr.html">GenericSelectionExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="genericSelectionExpr0"><pre>Matches C11 _Generic expression. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1GNUNullExpr.html">GNUNullExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1GotoStmt.html">GotoStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. |
| |
| Given |
| goto FOO; |
| FOO: bar(); |
| gotoStmt() |
| matches 'goto FOO' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. |
| |
| Example matches 'if (x) {}' |
| if (x) {} |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ImaginaryLiteral.html">ImaginaryLiteral</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating |
| point literals e.g.: 1i, 1.0i |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. |
| |
| This matches many different places, including function call return value |
| eliding, as well as any type conversions. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ImplicitValueInitExpr.html">ImplicitValueInitExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions. |
| |
| Given |
| point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; |
| implicitValueInitExpr() |
| matches "[0].y" (implicitly) |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. |
| |
| Given |
| int a[] = { 1, 2 }; |
| struct B { int x, y; }; |
| B b = { 5, 6 }; |
| initListExpr() |
| matches "{ 1, 2 }" and "{ 5, 6 }" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g. |
| 1, 1L, 0x1 and 1U. |
| |
| Does not match character-encoded integers such as L'a'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. |
| |
| Given |
| goto FOO; |
| FOO: bar(); |
| labelStmt() |
| matches 'FOO:' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. |
| |
| Example matches [&](){return 5;} |
| [&](){return 5;} |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1MaterializeTemporaryExpr.html">MaterializeTemporaryExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. |
| |
| Example: Given |
| struct T {void func();}; |
| T f(); |
| void g(T); |
| materializeTemporaryExpr() matches 'f()' in these statements |
| T u(f()); |
| g(f()); |
| f().func(); |
| but does not match |
| f(); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. |
| |
| Given |
| class Y { |
| void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| int a; static int b; |
| }; |
| memberExpr() |
| matches this->x, x, y.x, a, this->b |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NullStmt.html">NullStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. |
| |
| foo();; |
| nullStmt() |
| matches the second ';' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtCatchStmt.html">ObjCAtCatchStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements. |
| |
| Example matches @catch |
| @try {} |
| @catch (...) {} |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtFinallyStmt.html">ObjCAtFinallyStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements. |
| |
| Example matches @finally |
| @try {} |
| @finally {} |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCIvarRefExpr.html">ObjCIvarRefExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar. |
| |
| Example: matches "a" in "init" method: |
| @implementation A { |
| NSString *a; |
| } |
| - (void) init { |
| a = @"hello"; |
| } |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions. |
| |
| The innermost message send invokes the "alloc" class method on the |
| NSString class, while the outermost message send invokes the |
| "initWithString" instance method on the object returned from |
| NSString's "alloc". This matcher should match both message sends. |
| [[NSString alloc] initWithString:@"Hello"] |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtThrowStmt.html">ObjCAtThrowStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements. |
| |
| Example matches @throw obj; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtTryStmt.html">ObjCAtTryStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements. |
| |
| Example matches @try |
| @try {} |
| @catch (...) {} |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('ompExecutableDirective0')"><a name="ompExecutableDirective0Anchor">ompExecutableDirective</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="ompExecutableDirective0"><pre>Matches any ``#pragma omp`` executable directive. |
| |
| Given |
| |
| #pragma omp parallel |
| #pragma omp parallel default(none) |
| #pragma omp taskyield |
| |
| ``ompExecutableDirective()`` matches ``omp parallel``, |
| ``omp parallel default(none)`` and ``omp taskyield``. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html">OpaqueValueExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers |
| to reference another expressions and can be met |
| in BinaryConditionalOperators, for example. |
| |
| Example matches 'a' |
| (a ?: c) + 42; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ParenExpr.html">ParenExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions. |
| |
| Example matches (foo() + 1) |
| int foo() { return 1; } |
| int a = (foo() + 1); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ParenListExpr.html">ParenListExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions. |
| ParenListExprs don't have a predefined type and are used for late parsing. |
| In the final AST, they can be met in template declarations. |
| |
| Given |
| template<typename T> class X { |
| void f() { |
| X x(*this); |
| int a = 0, b = 1; int i = (a, b); |
| } |
| }; |
| parenListExpr() matches "*this" but NOT matches (a, b) because (a, b) |
| has a predefined type and is a ParenExpr, not a ParenListExpr. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1PredefinedExpr.html">PredefinedExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2]. |
| |
| Example: Matches __func__ |
| printf("%s", __func__); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. |
| |
| Given |
| return 1; |
| returnStmt() |
| matches 'return 1' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. |
| |
| Given |
| { ++a; } |
| stmt() |
| matches both the compound statement '{ ++a; }' and '++a'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1StmtExpr.html">StmtExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension). |
| |
| Example match: ({ int X = 4; X; }) |
| int C = ({ int X = 4; X; }); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). |
| |
| Example matches "abcd", L"abcd" |
| char *s = "abcd"; |
| wchar_t *ws = L"abcd"; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1SubstNonTypeTemplateParmExpr.html">SubstNonTypeTemplateParmExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. |
| |
| Given |
| template <int N> |
| struct A { static const int n = N; }; |
| struct B : public A<42> {}; |
| substNonTypeTemplateParmExpr() |
| matches "N" in the right-hand side of "static const int n = N;" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. |
| |
| Given |
| switch(a) { case 42: break; default: break; } |
| switchCase() |
| matches 'case 42:' and 'default:'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. |
| |
| Given |
| switch(a) { case 42: break; default: break; } |
| switchStmt() |
| matches 'switch(a)'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) |
| |
| Given |
| Foo x = bar; |
| int y = sizeof(x) + alignof(x); |
| unaryExprOrTypeTraitExpr() |
| matches sizeof(x) and alignof(x) |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. |
| |
| Example matches !a |
| !a || b |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedLookupExpr.html">UnresolvedLookupExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing |
| but could not be resolved to a specific declaration. |
| |
| Given |
| template<typename T> |
| T foo() { T a; return a; } |
| template<typename T> |
| void bar() { |
| foo<T>(); |
| } |
| unresolvedLookupExpr() |
| matches foo<T>() </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html">UnresolvedMemberExpr</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="unresolvedMemberExpr0"><pre>Matches unresolved member expressions. |
| |
| Given |
| struct X { |
| template <class T> void f(); |
| void g(); |
| }; |
| template <class T> void h() { X x; x.f<T>(); x.g(); } |
| unresolvedMemberExpr() |
| matches x.f<T> |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UserDefinedLiteral.html">UserDefinedLiteral</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. |
| |
| Example match: "foo"_suffix |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. |
| |
| Given |
| while (true) {} |
| whileStmt() |
| matches 'while (true) {}'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>></td><td class="name" onclick="toggle('templateArgumentLoc0')"><a name="templateArgumentLoc0Anchor">templateArgumentLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="templateArgumentLoc0"><pre>Matches template arguments (with location info). |
| |
| Given |
| template <typename T> struct C {}; |
| C<int> c; |
| templateArgumentLoc() |
| matches 'int' in C<int>. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. |
| |
| Given |
| template <typename T> struct C {}; |
| C<int> c; |
| templateArgument() |
| matches 'int' in C<int>. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name. |
| |
| Given |
| template <typename T> class X { }; |
| X<int> xi; |
| templateName() |
| matches 'X' in X<int>. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('elaboratedTypeLoc0')"><a name="elaboratedTypeLoc0Anchor">elaboratedTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedTypeLoc.html">ElaboratedTypeLoc</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="elaboratedTypeLoc0"><pre>Matches C or C++ elaborated `TypeLoc`s. |
| |
| Given |
| struct s {}; |
| struct s ss; |
| elaboratedTypeLoc() |
| matches the `TypeLoc` of the variable declaration of `ss`. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('pointerTypeLoc0')"><a name="pointerTypeLoc0Anchor">pointerTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer `TypeLoc`s. |
| |
| Given |
| int* x; |
| pointerTypeLoc() |
| matches `int*`. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('qualifiedTypeLoc0')"><a name="qualifiedTypeLoc0Anchor">qualifiedTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualifiedTypeLoc.html">QualifiedTypeLoc</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="qualifiedTypeLoc0"><pre>Matches `QualifiedTypeLoc`s in the clang AST. |
| |
| Given |
| const int x = 0; |
| qualifiedTypeLoc() |
| matches `const int`. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('referenceTypeLoc0')"><a name="referenceTypeLoc0Anchor">referenceTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="referenceTypeLoc0"><pre>Matches reference `TypeLoc`s. |
| |
| Given |
| int x = 3; |
| int& l = x; |
| int&& r = 3; |
| referenceTypeLoc() |
| matches `int&` and `int&&`. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('templateSpecializationTypeLoc0')"><a name="templateSpecializationTypeLoc0Anchor">templateSpecializationTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="templateSpecializationTypeLoc0"><pre>Matches template specialization `TypeLoc`s. |
| |
| Given |
| template <typename T> class C {}; |
| C<char> var; |
| varDecl(hasTypeLoc(templateSpecializationTypeLoc(typeLoc()))) |
| matches `C<char> var`. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. |
| |
| Given |
| int a[] = { 2, 3 }; |
| int b[4]; |
| void f() { int c[a[0]]; } |
| arrayType() |
| matches "int a[]", "int b[4]" and "int c[a[0]]"; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. |
| |
| Given |
| _Atomic(int) i; |
| atomicType() |
| matches "_Atomic(int) i" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. |
| |
| Given: |
| auto n = 4; |
| int v[] = { 2, 3 } |
| for (auto i : v) { } |
| autoType() |
| matches "auto n" and "auto i" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as |
| "void (^)(int)". |
| |
| The pointee is always required to be a FunctionType. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BuiltinType.html">BuiltinType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. |
| |
| Given |
| struct A {}; |
| A a; |
| int b; |
| float c; |
| bool d; |
| builtinType() |
| matches "int b", "float c" and "bool d" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. |
| |
| Given |
| _Complex float f; |
| complexType() |
| matches "_Complex float f" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. |
| |
| Given |
| void() { |
| int a[2]; |
| int b[] = { 2, 3 }; |
| int c[b[0]]; |
| } |
| constantArrayType() |
| matches "int a[2]" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type |
| Example matches i[] in declaration of f. |
| (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) |
| Example matches i[1]. |
| (matcher = expr(hasType(decayedType(hasDecayedType(pointerType()))))) |
| void f(int i[]) { |
| i[1] = 0; |
| } |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="decltypeType0"><pre>Matches types nodes representing C++11 decltype(<expr>) types. |
| |
| Given: |
| short i = 1; |
| int j = 42; |
| decltype(i + j) result = i + j; |
| decltypeType() |
| matches "decltype(i + j)" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('deducedTemplateSpecializationType0')"><a name="deducedTemplateSpecializationType0Anchor">deducedTemplateSpecializationType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeducedTemplateSpecializationType.html">DeducedTemplateSpecializationType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="deducedTemplateSpecializationType0"><pre>Matches C++17 deduced template specialization types, e.g. deduced class |
| template types. |
| |
| Given |
| template <typename T> |
| class C { public: C(T); }; |
| |
| C c(123); |
| deducedTemplateSpecializationType() matches the type in the declaration |
| of the variable c. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html">DependentSizedArrayType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. |
| |
| Given |
| template<typename T, int Size> |
| class array { |
| T data[Size]; |
| }; |
| dependentSizedArrayType |
| matches "T data[Size]" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a |
| qualified name. |
| |
| Given |
| namespace N { |
| namespace M { |
| class D {}; |
| } |
| } |
| class C {}; |
| |
| class C c; |
| N::M::D d; |
| |
| elaboratedType() matches the type of the variable declarations of both |
| c and d. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types. |
| |
| Given |
| enum C { Green }; |
| enum class S { Red }; |
| |
| C c; |
| S s; |
| |
| enumType() matches the type of the variable declarations of both c and |
| s. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes. |
| |
| Given |
| int (*f)(int); |
| void g(); |
| functionProtoType() |
| matches "int (*f)(int)" and the type of "g" in C++ mode. |
| In C mode, "g" is not matched because it does not contain a prototype. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FunctionType.html">FunctionType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. |
| |
| Given |
| int (*f)(int); |
| void g(); |
| functionType() |
| matches "int (*f)(int)" and the type of "g". |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1IncompleteArrayType.html">IncompleteArrayType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. |
| |
| Given |
| int a[] = { 2, 3 }; |
| int b[42]; |
| void f(int c[]) { int d[a[0]]; }; |
| incompleteArrayType() |
| matches "int a[]" and "int c[]" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types. |
| |
| Example matches S s, but not S<T> s. |
| (matcher = parmVarDecl(hasType(injectedClassNameType()))) |
| template <typename T> struct S { |
| void f(S s); |
| void g(S<T> s); |
| }; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. |
| |
| Given: |
| int *a; |
| int &b = *a; |
| int &&c = 1; |
| auto &d = b; |
| auto &&e = c; |
| auto &&f = 2; |
| int g = 5; |
| |
| lValueReferenceType() matches the types of b, d, and e. e is |
| matched since the type is deduced as int& by reference collapsing rules. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. |
| Given |
| struct A { int i; } |
| A::* ptr = A::i; |
| memberPointerType() |
| matches "A::* ptr" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from |
| a pointer type, despite being syntactically similar. |
| |
| Given |
| int *a; |
| |
| @interface Foo |
| @end |
| Foo *f; |
| pointerType() |
| matches "Foo *f", but does not match "int *a". |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. |
| |
| Given |
| int (*ptr_to_array)[4]; |
| int *array_of_ptrs[4]; |
| |
| varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not |
| array_of_ptrs. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer |
| types. |
| |
| Given |
| int *a; |
| int &b = *a; |
| int c = 5; |
| |
| @interface Foo |
| @end |
| Foo *f; |
| pointerType() |
| matches "int *a", but does not match "Foo *f". |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. |
| |
| Given: |
| int *a; |
| int &b = *a; |
| int &&c = 1; |
| auto &d = b; |
| auto &&e = c; |
| auto &&f = 2; |
| int g = 5; |
| |
| rValueReferenceType() matches the types of c and f. e is not |
| matched as it is deduced to int& by reference collapsing rules. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). |
| |
| Given |
| class C {}; |
| struct S {}; |
| |
| C c; |
| S s; |
| |
| recordType() matches the type of the variable declarations of both c |
| and s. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. |
| |
| Given |
| int *a; |
| int &b = *a; |
| int &&c = 1; |
| auto &d = b; |
| auto &&e = c; |
| auto &&f = 2; |
| int g = 5; |
| |
| referenceType() matches the types of b, c, d, e, and f. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html">SubstTemplateTypeParmType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a |
| template type parameter. |
| |
| Given |
| template <typename T> |
| void F(T t) { |
| int i = 1 + t; |
| } |
| |
| substTemplateTypeParmType() matches the type of 't' but not '1' |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types). |
| |
| Given |
| enum E {}; |
| class C {}; |
| |
| E e; |
| C c; |
| |
| tagType() matches the type of the variable declarations of both e |
| and c. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. |
| |
| Given |
| template <typename T> |
| class C { }; |
| |
| template class C<int>; // A |
| C<char> var; // B |
| |
| templateSpecializationType() matches the type of the explicit |
| instantiation in A and the type of the variable declaration in B. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types. |
| |
| Example matches T, but not int. |
| (matcher = templateTypeParmType()) |
| template <typename T> void f(int i); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. |
| |
| Given |
| typedef int X; |
| typedefType() |
| matches "typedef int X" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnaryTransformType.html">UnaryTransformType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. |
| |
| Given: |
| typedef __underlying_type(T) type; |
| unaryTransformType() |
| matches "__underlying_type(T)" |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html">VariableArrayType</a>>...</td></tr> |
| <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an |
| integer-constant-expression. |
| |
| Given |
| void f() { |
| int a[] = { 2, 3 } |
| int b[42]; |
| int c[a[0]]; |
| } |
| variableArrayType() |
| matches "int c[a[0]]" |
|