| <!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; |
| } |
| </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 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="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_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('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('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('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('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_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 |
| |
| ``ompDefaultClause()`` matches ``default(none)`` and ``default(shared)``. |
| </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) |
| </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('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('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('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; |
| </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('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('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('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('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_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('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('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]]" |
| </pre></td></tr> |
| |
| <!--END_DECL_MATCHERS --> |
| </table> |
| |
| <!-- ======================================================================= --> |
| <h2 id="narrowing-matchers">Narrowing Matchers</h2> |
| <!-- ======================================================================= --> |
| |
| <p>Narrowing matchers match certain attributes on the current node, thus |
| narrowing down the set of nodes of the current type to match on.</p> |
| |
| <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) |
| which allow users to create more powerful match expressions.</p> |
| |
| <table> |
| <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
| <!-- START_NARROWING_MATCHERS --> |
| |
| <tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. |
| |
| Usable as: Any Matcher |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. |
| |
| Usable as: Any Matcher |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. |
| |
| Useful when another matcher requires a child matcher, but there's no |
| additional constraint. This will often be used with an explicit conversion |
| to an internal::Matcher<> type such as TypeMatcher. |
| |
| Example: DeclarationMatcher(anything()) matches all declarations, e.g., |
| "int* p" and "void f()" in |
| int* p; |
| void f(); |
| |
| Usable as: Any Matcher |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> |
| <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. |
| |
| Example matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) |
| class X {}; |
| class Y {}; |
| |
| Usable as: Any Matcher |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('hasOperatorName0')"><a name="hasOperatorName0Anchor">hasOperatorName</a></td><td>std::string Name</td></tr> |
| <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or |
| unary). |
| |
| Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| !(a || b) |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('isAssignmentOperator0')"><a name="isAssignmentOperator0Anchor">isAssignmentOperator</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators. |
| |
| Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) |
| if (a == b) |
| a += b; |
| |
| Example 2: matches s1 = s2 |
| (matcher = cxxOperatorCallExpr(isAssignmentOperator())) |
| struct S { S& operator=(const S&); }; |
| void x() { S s1, s2; s1 = s2; }) |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals5')"><a name="equals5Anchor">equals</a></td><td>bool Value</td></tr> |
| <tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>const ValueT Value</td></tr> |
| <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT. |
| |
| Given |
| f('false, 3.14, 42); |
| characterLiteral(equals(0)) |
| matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| match false |
| floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| match 3.14 |
| integerLiteral(equals(42)) |
| matches 42 |
| |
| Note that you cannot directly match a negative numeric literal because the |
| minus sign is not part of the literal: It is a unary operator whose operand |
| is the positive numeric literal. Instead, you must use a unaryOperator() |
| matcher to match the minus sign: |
| |
| unaryOperator(hasOperatorName("-"), |
| hasUnaryOperand(integerLiteral(equals(13)))) |
| |
| Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, |
| Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals11')"><a name="equals11Anchor">equals</a></td><td>double Value</td></tr> |
| <tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals8')"><a name="equals8Anchor">equals</a></td><td>unsigned Value</td></tr> |
| <tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>></td><td class="name" onclick="toggle('isCatchAll0')"><a name="isCatchAll0Anchor">isCatchAll</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. |
| |
| Given |
| try { |
| // ... |
| } catch (int) { |
| // ... |
| } catch (...) { |
| // ... |
| } |
| cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('argumentCountIs1')"><a name="argumentCountIs1Anchor">argumentCountIs</a></td><td>unsigned N</td></tr> |
| <tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has |
| a specific number of arguments (including absent default arguments). |
| |
| Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| void f(int x, int y); |
| f(0, 0); |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('isListInitialization0')"><a name="isListInitialization0Anchor">isListInitialization</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('requiresZeroInitialization0')"><a name="requiresZeroInitialization0Anchor">requiresZeroInitialization</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires |
| zero initialization. |
| |
| Given |
| void foo() { |
| struct point { double x; double y; }; |
| point pt[2] = { { 1.0, 2.0 } }; |
| } |
| initListExpr(has(cxxConstructExpr(requiresZeroInitialization())) |
| will match the implicit array filler for pt[1]. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isCopyConstructor0')"><a name="isCopyConstructor0Anchor">isCopyConstructor</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. |
| |
| Given |
| struct S { |
| S(); // #1 |
| S(const S &); // #2 |
| S(S &&); // #3 |
| }; |
| cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isDefaultConstructor0')"><a name="isDefaultConstructor0Anchor">isDefaultConstructor</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. |
| |
| Given |
| struct S { |
| S(); // #1 |
| S(const S &); // #2 |
| S(S &&); // #3 |
| }; |
| cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isDelegatingConstructor0')"><a name="isDelegatingConstructor0Anchor">isDelegatingConstructor</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor. |
| |
| Given |
| struct S { |
| S(); // #1 |
| S(int) {} // #2 |
| S(S &&) : S() {} // #3 |
| }; |
| S::S() : S(0) {} // #4 |
| cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not |
| #1 or #2. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isExplicit0')"><a name="isExplicit0Anchor">isExplicit</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor, conversion function, and deduction guide declarations |
| that have an explicit specifier if this explicit specifier is resolved to |
| true. |
| |
| Given |
| template<bool b> |
| struct S { |
| S(int); // #1 |
| explicit S(double); // #2 |
| operator int(); // #3 |
| explicit operator bool(); // #4 |
| explicit(false) S(bool) // # 7 |
| explicit(true) S(char) // # 8 |
| explicit(b) S(S) // # 9 |
| }; |
| S(int) -> S<true> // #5 |
| explicit S(double) -> S<false> // #6 |
| cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. |
| cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isMoveConstructor0')"><a name="isMoveConstructor0Anchor">isMoveConstructor</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. |
| |
| Given |
| struct S { |
| S(); // #1 |
| S(const S &); // #2 |
| S(S &&); // #3 |
| }; |
| cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>></td><td class="name" onclick="toggle('isExplicit1')"><a name="isExplicit1Anchor">isExplicit</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor, conversion function, and deduction guide declarations |
| that have an explicit specifier if this explicit specifier is resolved to |
| true. |
| |
| Given |
| template<bool b> |
| struct S { |
| S(int); // #1 |
| explicit S(double); // #2 |
| operator int(); // #3 |
| explicit operator bool(); // #4 |
| explicit(false) S(bool) // # 7 |
| explicit(true) S(char) // # 8 |
| explicit(b) S(S) // # 9 |
| }; |
| S(int) -> S<true> // #5 |
| explicit S(double) -> S<false> // #6 |
| cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. |
| cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5. |
| </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('isBaseInitializer0')"><a name="isBaseInitializer0Anchor">isBaseInitializer</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as |
| opposed to a member. |
| |
| Given |
| struct B {}; |
| struct D : B { |
| int I; |
| D(int i) : I(i) {} |
| }; |
| struct E : B { |
| E() : B() {} |
| }; |
| cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) |
| will match E(), but not match D(int). |
| </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('isMemberInitializer0')"><a name="isMemberInitializer0Anchor">isMemberInitializer</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as |
| opposed to a base. |
| |
| Given |
| struct B {}; |
| struct D : B { |
| int I; |
| D(int i) : I(i) {} |
| }; |
| struct E : B { |
| E() : B() {} |
| }; |
| cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) |
| will match D(int), but not match E(). |
| </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('isWritten0')"><a name="isWritten0Anchor">isWritten</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in |
| code (as opposed to implicitly added by the compiler). |
| |
| Given |
| struct Foo { |
| Foo() { } |
| Foo(int) : foo_("A") { } |
| string foo_; |
| }; |
| cxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) |
| will match Foo(int), but not Foo() |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDeductionGuideDecl.html">CXXDeductionGuideDecl</a>></td><td class="name" onclick="toggle('isExplicit2')"><a name="isExplicit2Anchor">isExplicit</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isExplicit2"><pre>Matches constructor, conversion function, and deduction guide declarations |
| that have an explicit specifier if this explicit specifier is resolved to |
| true. |
| |
| Given |
| template<bool b> |
| struct S { |
| S(int); // #1 |
| explicit S(double); // #2 |
| operator int(); // #3 |
| explicit operator bool(); // #4 |
| explicit(false) S(bool) // # 7 |
| explicit(true) S(char) // # 8 |
| explicit(b) S(S) // # 9 |
| }; |
| S(int) -> S<true> // #5 |
| explicit S(double) -> S<false> // #6 |
| cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. |
| cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>></td><td class="name" onclick="toggle('isArrow2')"><a name="isArrow2Anchor">isArrow</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isArrow2"><pre>Matches member expressions that are called with '->' as opposed |
| to '.'. |
| |
| Member calls on the implicit this pointer match as called with '->'. |
| |
| Given |
| class Y { |
| void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| template <class T> void f() { this->f<T>(); f<T>(); } |
| int a; |
| static int b; |
| }; |
| template <class T> |
| class Z { |
| void x() { this->m; } |
| }; |
| memberExpr(isArrow()) |
| matches this->x, x, y.x, a, this->b |
| cxxDependentScopeMemberExpr(isArrow()) |
| matches this->m |
| unresolvedMemberExpr(isArrow()) |
| matches this->f<T>, f<T> |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isConst0')"><a name="isConst0Anchor">isConst</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. |
| |
| Given |
| struct A { |
| void foo() const; |
| void bar(); |
| }; |
| |
| cxxMethodDecl(isConst()) matches A::foo() but not A::bar() |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isCopyAssignmentOperator0')"><a name="isCopyAssignmentOperator0Anchor">isCopyAssignmentOperator</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment |
| operator. |
| |
| Given |
| struct A { |
| A &operator=(const A &); |
| A &operator=(A &&); |
| }; |
| |
| cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not |
| the second one. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isFinal1')"><a name="isFinal1Anchor">isFinal</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. |
| |
| Given: |
| class A final {}; |
| |
| struct B { |
| virtual void f(); |
| }; |
| |
| struct C : B { |
| void f() final; |
| }; |
| matches A and C::f, but not B, C, or B::f |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isMoveAssignmentOperator0')"><a name="isMoveAssignmentOperator0Anchor">isMoveAssignmentOperator</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment |
| operator. |
| |
| Given |
| struct A { |
| A &operator=(const A &); |
| A &operator=(A &&); |
| }; |
| |
| cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not |
| the first one. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isOverride0')"><a name="isOverride0Anchor">isOverride</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. |
| |
| Given |
| class A { |
| public: |
| virtual void x(); |
| }; |
| class B : public A { |
| public: |
| virtual void x(); |
| }; |
| matches B::x |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isPure0')"><a name="isPure0Anchor">isPure</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. |
| |
| Given |
| class A { |
| public: |
| virtual void x() = 0; |
| }; |
| matches A::x |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isUserProvided0')"><a name="isUserProvided0Anchor">isUserProvided</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided. |
| |
| Given |
| struct S { |
| S(); // #1 |
| S(const S &) = default; // #2 |
| S(S &&) = delete; // #3 |
| }; |
| cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isVirtual0')"><a name="isVirtual0Anchor">isVirtual</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. |
| |
| Given |
| class A { |
| public: |
| virtual void x(); |
| }; |
| matches A::x |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isVirtualAsWritten0')"><a name="isVirtualAsWritten0Anchor">isVirtualAsWritten</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual". |
| |
| Given |
| class A { |
| public: |
| virtual void x(); |
| }; |
| class B : public A { |
| public: |
| void x(); |
| }; |
| matches A::x but not B::x |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('isArray0')"><a name="isArray0Anchor">isArray</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions. |
| |
| Given: |
| MyClass *p1 = new MyClass[10]; |
| cxxNewExpr(isArray()) |
| matches the expression 'new MyClass[10]'. |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName1')"><a name="hasOverloadedOperatorName1Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> |
| <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. |
| |
| Matches overloaded operator names specified in strings without the |
| "operator" prefix: e.g. "<<". |
| |
| Given: |
| class A { int operator*(); }; |
| const A &operator<<(const A &a, const A &b); |
| A a; |
| a << a; // <-- This matches |
| |
| cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the |
| specified line and |
| cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) |
| matches the declaration of A. |
| |
| Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('isAssignmentOperator1')"><a name="isAssignmentOperator1Anchor">isAssignmentOperator</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators. |
| |
| Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) |
| if (a == b) |
| a += b; |
| |
| Example 2: matches s1 = s2 |
| (matcher = cxxOperatorCallExpr(isAssignmentOperator())) |
| struct S { S& operator=(const S&); }; |
| void x() { S s1, s2; s1 = s2; }) |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('hasDefinition0')"><a name="hasDefinition0Anchor">hasDefinition</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined. |
| |
| Example matches x (matcher = cxxRecordDecl(hasDefinition())) |
| class x {}; |
| class y; |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isDerivedFrom2')"><a name="isDerivedFrom2Anchor">isDerivedFrom</a></td><td>std::string BaseName</td></tr> |
| <tr><td colspan="4" class="doc" id="isDerivedFrom2"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isDirectlyDerivedFrom2')"><a name="isDirectlyDerivedFrom2Anchor">isDirectlyDerivedFrom</a></td><td>std::string BaseName</td></tr> |
| <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom2"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)). |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization2')"><a name="isExplicitTemplateSpecialization2Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or |
| static member variable template instantiations. |
| |
| Given |
| template<typename T> void A(T t) { } |
| template<> void A(int N) { } |
| functionDecl(isExplicitTemplateSpecialization()) |
| matches the specialization A<int>(). |
| |
| Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isFinal0')"><a name="isFinal0Anchor">isFinal</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. |
| |
| Given: |
| class A final {}; |
| |
| struct B { |
| virtual void f(); |
| }; |
| |
| struct C : B { |
| void f() final; |
| }; |
| matches A and C::f, but not B, C, or B::f |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isLambda0')"><a name="isLambda0Anchor">isLambda</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions. |
| |
| Given: |
| auto x = []{}; |
| |
| cxxRecordDecl(isLambda()) matches the implicit class declaration of |
| decltype(x) |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isSameOrDerivedFrom2')"><a name="isSameOrDerivedFrom2Anchor">isSameOrDerivedFrom</a></td><td>std::string BaseName</td></tr> |
| <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom2"><pre>Overloaded method as shortcut for |
| isSameOrDerivedFrom(hasName(...)). |
| </pre></td></tr> |
| |
| |
| <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation2')"><a name="isTemplateInstantiation2Anchor">isTemplateInstantiation</a></td><td></td></tr> |
| <tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static |
| member variable template instantiations. |
| |
| Given |
| template <typename T> class X {}; class A {}; X<A> x; |
| or |
| template <typename T> class X {}; class A {}; template class X<A>; |
| or |
| template <typename T> class X {}; class A {}; extern template class X<A>; |
| cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| matches the template instantiation of X<A>. |
|