<!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="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('cxxCtorInitializer0')"><a name="cxxCtorInitializer0Anchor">cxxCtorInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('accessSpecDecl0')"><a name="accessSpecDecl0Anchor">accessSpecDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AccessSpecDecl.html">AccessSpecDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('classTemplateDecl0')"><a name="classTemplateDecl0Anchor">classTemplateDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('classTemplateSpecializationDecl0')"><a name="classTemplateSpecializationDecl0Anchor">classTemplateSpecializationDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxConstructorDecl0')"><a name="cxxConstructorDecl0Anchor">cxxConstructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxConversionDecl0')"><a name="cxxConversionDecl0Anchor">cxxConversionDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxDestructorDecl0')"><a name="cxxDestructorDecl0Anchor">cxxDestructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxMethodDecl0')"><a name="cxxMethodDecl0Anchor">cxxMethodDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxRecordDecl0')"><a name="cxxRecordDecl0Anchor">cxxRecordDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('decl0')"><a name="decl0Anchor">decl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('declaratorDecl0')"><a name="declaratorDecl0Anchor">declaratorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('enumConstantDecl0')"><a name="enumConstantDecl0Anchor">enumConstantDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html">EnumConstantDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('enumDecl0')"><a name="enumDecl0Anchor">enumDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('fieldDecl0')"><a name="fieldDecl0Anchor">fieldDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('friendDecl0')"><a name="friendDecl0Anchor">friendDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('functionDecl0')"><a name="functionDecl0Anchor">functionDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('functionTemplateDecl0')"><a name="functionTemplateDecl0Anchor">functionTemplateDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionTemplateDecl.html">FunctionTemplateDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('linkageSpecDecl0')"><a name="linkageSpecDecl0Anchor">linkageSpecDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LinkageSpecDecl.html">LinkageSpecDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('namedDecl0')"><a name="namedDecl0Anchor">namedDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('namespaceAliasDecl0')"><a name="namespaceAliasDecl0Anchor">namespaceAliasDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceAliasDecl.html">NamespaceAliasDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('namespaceDecl0')"><a name="namespaceDecl0Anchor">namespaceDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('nonTypeTemplateParmDecl0')"><a name="nonTypeTemplateParmDecl0Anchor">nonTypeTemplateParmDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NonTypeTemplateParmDecl.html">NonTypeTemplateParmDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcInterfaceDecl0')"><a name="objcInterfaceDecl0Anchor">objcInterfaceDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('parmVarDecl0')"><a name="parmVarDecl0Anchor">parmVarDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('recordDecl0')"><a name="recordDecl0Anchor">recordDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('staticAssertDecl0')"><a name="staticAssertDecl0Anchor">staticAssertDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StaticAssertDecl.html">StaticAssertDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('templateTypeParmDecl0')"><a name="templateTypeParmDecl0Anchor">templateTypeParmDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmDecl.html">TemplateTypeParmDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('translationUnitDecl0')"><a name="translationUnitDecl0Anchor">translationUnitDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TranslationUnitDecl.html">TranslationUnitDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typedefDecl0')"><a name="typedefDecl0Anchor">typedefDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html">TypedefDecl</a>>...</td></tr> | |
<tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations. | |
Given | |
typedef int X; | |
typedefDecl() | |
matches "typedef int X" | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('unresolvedUsingTypenameDecl0')"><a name="unresolvedUsingTypenameDecl0Anchor">unresolvedUsingTypenameDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingTypenameDecl.html">UnresolvedUsingTypenameDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('unresolvedUsingValueDecl0')"><a name="unresolvedUsingValueDecl0Anchor">unresolvedUsingValueDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingValueDecl.html">UnresolvedUsingValueDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('usingDecl0')"><a name="usingDecl0Anchor">usingDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('usingDirectiveDecl0')"><a name="usingDirectiveDecl0Anchor">usingDirectiveDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDirectiveDecl.html">UsingDirectiveDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('valueDecl0')"><a name="valueDecl0Anchor">valueDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('varDecl0')"><a name="varDecl0Anchor">varDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>></td><td class="name" onclick="toggle('nestedNameSpecifierLoc0')"><a name="nestedNameSpecifierLoc0Anchor">nestedNameSpecifierLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>>...</td></tr> | |
<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>></td><td class="name" onclick="toggle('nestedNameSpecifier0')"><a name="nestedNameSpecifier0Anchor">nestedNameSpecifier</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('qualType0')"><a name="qualType0Anchor">qualType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>...</td></tr> | |
<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('arraySubscriptExpr0')"><a name="arraySubscriptExpr0Anchor">arraySubscriptExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('asmStmt0')"><a name="asmStmt0Anchor">asmStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AsmStmt.html">AsmStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('binaryOperator0')"><a name="binaryOperator0Anchor">binaryOperator</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('breakStmt0')"><a name="breakStmt0Anchor">breakStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BreakStmt.html">BreakStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cStyleCastExpr0')"><a name="cStyleCastExpr0Anchor">cStyleCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CStyleCastExpr.html">CStyleCastExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('callExpr0')"><a name="callExpr0Anchor">callExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('caseStmt0')"><a name="caseStmt0Anchor">caseStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>>...</td></tr> | |
<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: break;'. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('castExpr0')"><a name="castExpr0Anchor">castExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('characterLiteral0')"><a name="characterLiteral0Anchor">characterLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('compoundLiteralExpr0')"><a name="compoundLiteralExpr0Anchor">compoundLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('compoundStmt0')"><a name="compoundStmt0Anchor">compoundStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('conditionalOperator0')"><a name="conditionalOperator0Anchor">conditionalOperator</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('continueStmt0')"><a name="continueStmt0Anchor">continueStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ContinueStmt.html">ContinueStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cudaKernelCallExpr0')"><a name="cudaKernelCallExpr0Anchor">cudaKernelCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxBindTemporaryExpr0')"><a name="cxxBindTemporaryExpr0Anchor">cxxBindTemporaryExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxBoolLiteral0')"><a name="cxxBoolLiteral0Anchor">cxxBoolLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>...</td></tr> | |
<tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals. | |
Example matches true | |
true | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxCatchStmt0')"><a name="cxxCatchStmt0Anchor">cxxCatchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxConstCastExpr0')"><a name="cxxConstCastExpr0Anchor">cxxConstCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxConstructExpr0')"><a name="cxxConstructExpr0Anchor">cxxConstructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDefaultArgExpr0')"><a name="cxxDefaultArgExpr0Anchor">cxxDefaultArgExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDeleteExpr0')"><a name="cxxDeleteExpr0Anchor">cxxDeleteExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDynamicCastExpr0')"><a name="cxxDynamicCastExpr0Anchor">cxxDynamicCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxForRangeStmt0')"><a name="cxxForRangeStmt0Anchor">cxxForRangeStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxFunctionalCastExpr0')"><a name="cxxFunctionalCastExpr0Anchor">cxxFunctionalCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxMemberCallExpr0')"><a name="cxxMemberCallExpr0Anchor">cxxMemberCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxNewExpr0')"><a name="cxxNewExpr0Anchor">cxxNewExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxNullPtrLiteralExpr0')"><a name="cxxNullPtrLiteralExpr0Anchor">cxxNullPtrLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>>...</td></tr> | |
<tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxOperatorCallExpr0')"><a name="cxxOperatorCallExpr0Anchor">cxxOperatorCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxReinterpretCastExpr0')"><a name="cxxReinterpretCastExpr0Anchor">cxxReinterpretCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxStaticCastExpr0')"><a name="cxxStaticCastExpr0Anchor">cxxStaticCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>>...</td></tr> | |
<tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression. | |
hasDestinationType | |
reinterpretCast | |
Example: | |
cxxStaticCastExpr() | |
matches | |
static_cast<long>(8) | |
in | |
long eight(static_cast<long>(8)); | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxTemporaryObjectExpr0')"><a name="cxxTemporaryObjectExpr0Anchor">cxxTemporaryObjectExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxThisExpr0')"><a name="cxxThisExpr0Anchor">cxxThisExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxThrowExpr0')"><a name="cxxThrowExpr0Anchor">cxxThrowExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxTryStmt0')"><a name="cxxTryStmt0Anchor">cxxTryStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxUnresolvedConstructExpr0')"><a name="cxxUnresolvedConstructExpr0Anchor">cxxUnresolvedConstructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('declRefExpr0')"><a name="declRefExpr0Anchor">declRefExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('declStmt0')"><a name="declStmt0Anchor">declStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('defaultStmt0')"><a name="defaultStmt0Anchor">defaultStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DefaultStmt.html">DefaultStmt</a>>...</td></tr> | |
<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: break;'. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('doStmt0')"><a name="doStmt0Anchor">doStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('explicitCastExpr0')"><a name="explicitCastExpr0Anchor">explicitCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>...</td></tr> | |
<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. | |
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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('expr0')"><a name="expr0Anchor">expr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('exprWithCleanups0')"><a name="exprWithCleanups0Anchor">exprWithCleanups</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ExprWithCleanups.html">ExprWithCleanups</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('floatLiteral0')"><a name="floatLiteral0Anchor">floatLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('forStmt0')"><a name="forStmt0Anchor">forStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('gnuNullExpr0')"><a name="gnuNullExpr0Anchor">gnuNullExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1GNUNullExpr.html">GNUNullExpr</a>>...</td></tr> | |
<tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('gotoStmt0')"><a name="gotoStmt0Anchor">gotoStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1GotoStmt.html">GotoStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('ifStmt0')"><a name="ifStmt0Anchor">ifStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('implicitCastExpr0')"><a name="implicitCastExpr0Anchor">implicitCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('initListExpr0')"><a name="initListExpr0Anchor">initListExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('integerLiteral0')"><a name="integerLiteral0Anchor">integerLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('labelStmt0')"><a name="labelStmt0Anchor">labelStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('lambdaExpr0')"><a name="lambdaExpr0Anchor">lambdaExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('materializeTemporaryExpr0')"><a name="materializeTemporaryExpr0Anchor">materializeTemporaryExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MaterializeTemporaryExpr.html">MaterializeTemporaryExpr</a>>...</td></tr> | |
<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()); | |
but does not match | |
f(); | |
f().func(); | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('memberExpr0')"><a name="memberExpr0Anchor">memberExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('nullStmt0')"><a name="nullStmt0Anchor">nullStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NullStmt.html">NullStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcMessageExpr0')"><a name="objcMessageExpr0Anchor">objcMessageExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('returnStmt0')"><a name="returnStmt0Anchor">returnStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('stmt0')"><a name="stmt0Anchor">stmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('stringLiteral0')"><a name="stringLiteral0Anchor">stringLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('substNonTypeTemplateParmExpr0')"><a name="substNonTypeTemplateParmExpr0Anchor">substNonTypeTemplateParmExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstNonTypeTemplateParmExpr.html">SubstNonTypeTemplateParmExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('switchCase0')"><a name="switchCase0Anchor">switchCase</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>>...</td></tr> | |
<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: break;' and 'default: break;'. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('switchStmt0')"><a name="switchStmt0Anchor">switchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unaryExprOrTypeTraitExpr0')"><a name="unaryExprOrTypeTraitExpr0Anchor">unaryExprOrTypeTraitExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unaryOperator0')"><a name="unaryOperator0Anchor">unaryOperator</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('userDefinedLiteral0')"><a name="userDefinedLiteral0Anchor">userDefinedLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UserDefinedLiteral.html">UserDefinedLiteral</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('whileStmt0')"><a name="whileStmt0Anchor">whileStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('templateArgument0')"><a name="templateArgument0Anchor">templateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('typeLoc0')"><a name="typeLoc0Anchor">typeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>...</td></tr> | |
<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('arrayType0')"><a name="arrayType0Anchor">arrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('atomicType0')"><a name="atomicType0Anchor">atomicType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('autoType0')"><a name="autoType0Anchor">autoType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('blockPointerType0')"><a name="blockPointerType0Anchor">blockPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('builtinType0')"><a name="builtinType0Anchor">builtinType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BuiltinType.html">BuiltinType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('complexType0')"><a name="complexType0Anchor">complexType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('constantArrayType0')"><a name="constantArrayType0Anchor">constantArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('decayedType0')"><a name="decayedType0Anchor">decayedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('dependentSizedArrayType0')"><a name="dependentSizedArrayType0Anchor">dependentSizedArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html">DependentSizedArrayType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('elaboratedType0')"><a name="elaboratedType0Anchor">elaboratedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('functionType0')"><a name="functionType0Anchor">functionType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionType.html">FunctionType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('incompleteArrayType0')"><a name="incompleteArrayType0Anchor">incompleteArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IncompleteArrayType.html">IncompleteArrayType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('injectedClassNameType0')"><a name="injectedClassNameType0Anchor">injectedClassNameType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('lValueReferenceType0')"><a name="lValueReferenceType0Anchor">lValueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('memberPointerType0')"><a name="memberPointerType0Anchor">memberPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('objcObjectPointerType0')"><a name="objcObjectPointerType0Anchor">objcObjectPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('parenType0')"><a name="parenType0Anchor">parenType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('pointerType0')"><a name="pointerType0Anchor">pointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('rValueReferenceType0')"><a name="rValueReferenceType0Anchor">rValueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('recordType0')"><a name="recordType0Anchor">recordType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('referenceType0')"><a name="referenceType0Anchor">referenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('substTemplateTypeParmType0')"><a name="substTemplateTypeParmType0Anchor">substTemplateTypeParmType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html">SubstTemplateTypeParmType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('templateSpecializationType0')"><a name="templateSpecializationType0Anchor">templateSpecializationType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('templateTypeParmType0')"><a name="templateTypeParmType0Anchor">templateTypeParmType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('type0')"><a name="type0Anchor">type</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>>...</td></tr> | |
<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('typedefType0')"><a name="typedefType0Anchor">typedefType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('unaryTransformType0')"><a name="unaryTransformType0Anchor">unaryTransformType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryTransformType.html">UnaryTransformType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('variableArrayType0')"><a name="variableArrayType0Anchor">variableArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html">VariableArrayType</a>>...</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('hasOperatorName0')"><a name="hasOperatorName0Anchor">hasOperatorName</a></td><td>std::string Name</td></tr> | |
<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<CXXBoolLiteral></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr> | |
<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value. | |
Example matches true (matcher = cxxBoolLiteral(equals(true))) | |
true | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, | |
Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>></td><td class="name" onclick="toggle('isCatchAll0')"><a name="isCatchAll0Anchor">isCatchAll</a></td><td></td></tr> | |
<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 (...) { | |
... | |
} | |
endcode | |
cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('argumentCountIs1')"><a name="argumentCountIs1Anchor">argumentCountIs</a></td><td>unsigned N</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('isListInitialization0')"><a name="isListInitialization0Anchor">isListInitialization</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isCopyConstructor0')"><a name="isCopyConstructor0Anchor">isCopyConstructor</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isDefaultConstructor0')"><a name="isDefaultConstructor0Anchor">isDefaultConstructor</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isExplicit0')"><a name="isExplicit0Anchor">isExplicit</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with | |
the explicit keyword. | |
Given | |
struct S { | |
S(int); #1 | |
explicit S(double); #2 | |
operator int(); #3 | |
explicit operator bool(); #4 | |
}; | |
cxxConstructorDecl(isExplicit()) will match #2, but not #1. | |
cxxConversionDecl(isExplicit()) will match #4, but not #3. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isMoveConstructor0')"><a name="isMoveConstructor0Anchor">isMoveConstructor</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>></td><td class="name" onclick="toggle('isExplicit1')"><a name="isExplicit1Anchor">isExplicit</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with | |
the explicit keyword. | |
Given | |
struct S { | |
S(int); #1 | |
explicit S(double); #2 | |
operator int(); #3 | |
explicit operator bool(); #4 | |
}; | |
cxxConstructorDecl(isExplicit()) will match #2, but not #1. | |
cxxConversionDecl(isExplicit()) will match #4, but not #3. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isBaseInitializer0')"><a name="isBaseInitializer0Anchor">isBaseInitializer</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isMemberInitializer0')"><a name="isMemberInitializer0Anchor">isMemberInitializer</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isWritten0')"><a name="isWritten0Anchor">isWritten</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isConst0')"><a name="isConst0Anchor">isConst</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isFinal1')"><a name="isFinal1Anchor">isFinal</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isOverride0')"><a name="isOverride0Anchor">isOverride</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isPure0')"><a name="isPure0Anchor">isPure</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isVirtual0')"><a name="isVirtual0Anchor">isVirtual</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName1')"><a name="hasOverloadedOperatorName1Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isDerivedFrom1')"><a name="isDerivedFrom1Anchor">isDerivedFrom</a></td><td>std::string BaseName</td></tr> | |
<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization2')"><a name="isExplicitTemplateSpecialization2Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isFinal0')"><a name="isFinal0Anchor">isFinal</a></td><td></td></tr> | |
<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="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isSameOrDerivedFrom1')"><a name="isSameOrDerivedFrom1Anchor">isSameOrDerivedFrom</a></td><td>std::string BaseName</td></tr> | |
<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for | |
isSameOrDerivedFrom(hasName(...)). | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation2')"><a name="isTemplateInstantiation2Anchor">isTemplateInstantiation</a></td><td></td></tr> | |
<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>; | |
cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) | |
matches the template instantiation of X<A>. | |
But given | |
template <typename T> class X {}; class A {}; | |
template <> class X<A> {}; X<A> x; | |
cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) | |
does not match, as X<A> is an explicit template specialization. | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('argumentCountIs0')"><a name="argumentCountIs0Anchor">argumentCountIs</a></td><td>unsigned N</td></tr> | |
<tr><td colspan="4" class="doc" id="argumentCountIs0"><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="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals3')"><a name="equals3Anchor">equals</a></td><td>ValueT Value</td></tr> | |
<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value. | |
Example matches true (matcher = cxxBoolLiteral(equals(true))) | |
true | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, | |
Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('templateArgumentCountIs0')"><a name="templateArgumentCountIs0Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> | |
<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. | |
Given | |
template<typename T> struct C {}; | |
C<int> c; | |
classTemplateSpecializationDecl(templateArgumentCountIs(1)) | |
matches C<int>. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>></td><td class="name" onclick="toggle('statementCountIs0')"><a name="statementCountIs0Anchor">statementCountIs</a></td><td>unsigned N</td></tr> | |
<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of | |
child statements. | |
Example: Given | |
{ for (;;) {} } | |
compoundStmt(statementCountIs(0))) | |
matches '{}' | |
but does not match the outer compound statement. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>></td><td class="name" onclick="toggle('hasSize0')"><a name="hasSize0Anchor">hasSize</a></td><td>unsigned N</td></tr> | |
<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size. | |
Given | |
int a[42]; | |
int b[2 * 21]; | |
int c[41], d[43]; | |
constantArrayType(hasSize(42)) | |
matches "int a[42]" and "int b[2 * 21]" | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>></td><td class="name" onclick="toggle('declCountIs0')"><a name="declCountIs0Anchor">declCountIs</a></td><td>unsigned N</td></tr> | |
<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of | |
declarations. | |
Example: Given | |
int a, b; | |
int c; | |
int d = 2, e; | |
declCountIs(2) | |
matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('equalsBoundNode1')"><a name="equalsBoundNode1Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr> | |
<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. | |
Matches a node if it equals the node previously bound to ID. | |
Given | |
class X { int a; int b; }; | |
cxxRecordDecl( | |
has(fieldDecl(hasName("a"), hasType(type().bind("t")))), | |
has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) | |
matches the class X, as a and b have the same type. | |
Note that when multiple matches are involved via forEach* matchers, | |
equalsBoundNodes acts as a filter. | |
For example: | |
compoundStmt( | |
forEachDescendant(varDecl().bind("d")), | |
forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) | |
will trigger a match for each combination of variable declaration | |
and reference to that variable declaration within a compound statement. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('hasAttr0')"><a name="hasAttr0Anchor">hasAttr</a></td><td>attr::Kind AttrKind</td></tr> | |
<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. | |
Given | |
__attribute__((device)) void f() { ... } | |
decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of | |
f. If the matcher is use from clang-query, attr::Kind parameter should be | |
passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching0')"><a name="isExpansionInFileMatching0Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr> | |
<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is | |
partially matching a given regex. | |
Example matches Y but not X | |
(matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) | |
#include "ASTMatcher.h" | |
class X {}; | |
ASTMatcher.h: | |
class Y {}; | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInMainFile0')"><a name="isExpansionInMainFile0Anchor">isExpansionInMainFile</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. | |
Example matches X but not Y | |
(matcher = cxxRecordDecl(isExpansionInMainFile()) | |
#include <Y.h> | |
class X {}; | |
Y.h: | |
class Y {}; | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader0')"><a name="isExpansionInSystemHeader0Anchor">isExpansionInSystemHeader</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. | |
Example matches Y but not X | |
(matcher = cxxRecordDecl(isExpansionInSystemHeader()) | |
#include <SystemHeader.h> | |
class X {}; | |
SystemHeader.h: | |
class Y {}; | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added | |
by the compiler (eg. implicit defaultcopy constructors). | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isPrivate0')"><a name="isPrivate0Anchor">isPrivate</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. | |
Given | |
class C { | |
public: int a; | |
protected: int b; | |
private: int c; | |
}; | |
fieldDecl(isPrivate()) | |
matches 'int c;' | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isProtected0')"><a name="isProtected0Anchor">isProtected</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. | |
Given | |
class C { | |
public: int a; | |
protected: int b; | |
private: int c; | |
}; | |
fieldDecl(isProtected()) | |
matches 'int b;' | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isPublic0')"><a name="isPublic0Anchor">isPublic</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. | |
Given | |
class C { | |
public: int a; | |
protected: int b; | |
private: int c; | |
}; | |
fieldDecl(isPublic()) | |
matches 'int a;' | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>></td><td class="name" onclick="toggle('equals1')"><a name="equals1Anchor">equals</a></td><td>ValueT Value</td></tr> | |
<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. | |
Example matches true (matcher = cxxBoolLiteral(equals(true))) | |
true | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, | |
Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> | |
<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><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="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isConstexpr1')"><a name="isConstexpr1Anchor">isConstexpr</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations. | |
Given: | |
constexpr int foo = 42; | |
constexpr int bar(); | |
varDecl(isConstexpr()) | |
matches the declaration of foo. | |
functionDecl(isConstexpr()) | |
matches the declaration of bar. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDefinition2')"><a name="isDefinition2Anchor">isDefinition</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. | |
Example matches A, va, fa | |
class A {}; | |
class B; Doesn't match, as it has no body. | |
int va; | |
extern int vb; Doesn't match, as it doesn't define the variable. | |
void fa() {} | |
void fb(); Doesn't match, as it has no body. | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDeleted0')"><a name="isDeleted0Anchor">isDeleted</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. | |
Given: | |
void Func(); | |
void DeletedFunc() = delete; | |
functionDecl(isDeleted()) | |
matches the declaration of DeletedFunc, but not Func. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization0')"><a name="isExplicitTemplateSpecialization0Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><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="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isExternC0')"><a name="isExternC0Anchor">isExternC</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. | |
Given: | |
extern "C" void f() {} | |
extern "C" { void g() {} } | |
void h() {} | |
functionDecl(isExternC()) | |
matches the declaration of f and g, but not the declaration h | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isInline1')"><a name="isInline1Anchor">isInline</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with | |
the inline keyword. | |
Given | |
inline void f(); | |
void g(); | |
namespace n { | |
inline namespace m {} | |
} | |
functionDecl(isInline()) will match ::f(). | |
namespaceDecl(isInline()) will match n::m. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation0')"><a name="isTemplateInstantiation0Anchor">isTemplateInstantiation</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><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>; | |
cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) | |
matches the template instantiation of X<A>. | |
But given | |
template <typename T> class X {}; class A {}; | |
template <> class X<A> {}; X<A> x; | |
cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) | |
does not match, as X<A> is an explicit template specialization. | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isVariadic0')"><a name="isVariadic0Anchor">isVariadic</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. | |
Example matches f, but not g or h. The function i will not match, even when | |
compiled in C mode. | |
void f(...); | |
void g(int); | |
template <typename... Ts> void h(Ts...); | |
void i(); | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('parameterCountIs0')"><a name="parameterCountIs0Anchor">parameterCountIs</a></td><td>unsigned N</td></tr> | |
<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count. | |
Given | |
void f(int i) {} | |
void g(int i, int j) {} | |
functionDecl(parameterCountIs(2)) | |
matches g(int i, int j) {} | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals0')"><a name="equals0Anchor">equals</a></td><td>ValueT Value</td></tr> | |
<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. | |
Example matches true (matcher = cxxBoolLiteral(equals(true))) | |
true | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, | |
Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('isArrow0')"><a name="isArrow0Anchor">isArrow</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isArrow0"><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; } | |
int a; | |
static int b; | |
}; | |
memberExpr(isArrow()) | |
matches this->x, x, y.x, a, this->b | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('hasName0')"><a name="hasName0Anchor">hasName</a></td><td>std::string Name</td></tr> | |
<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. | |
Supports specifying enclosing namespaces or classes by prefixing the name | |
with '<enclosing>::'. | |
Does not match typedefs of an underlying type with the given name. | |
Example matches X (Name == "X") | |
class X; | |
Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") | |
namespace a { namespace b { class X; } } | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('matchesName0')"><a name="matchesName0Anchor">matchesName</a></td><td>std::string RegExp</td></tr> | |
<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain | |
a substring matched by the given RegExp. | |
Supports specifying enclosing namespaces or classes by | |
prefixing the name with '<enclosing>::'. Does not match typedefs | |
of an underlying type with the given name. | |
Example matches X (regexp == "::X") | |
class X; | |
Example matches X (regexp is one of "::X", "^foo::.*X", among others) | |
namespace foo { namespace bar { class X; } } | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>></td><td class="name" onclick="toggle('isAnonymous0')"><a name="isAnonymous0Anchor">isAnonymous</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. | |
Given | |
namespace n { | |
namespace {} #1 | |
} | |
namespaceDecl(isAnonymous()) will match #1 but not ::n. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>></td><td class="name" onclick="toggle('isInline0')"><a name="isInline0Anchor">isInline</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with | |
the inline keyword. | |
Given | |
inline void f(); | |
void g(); | |
namespace n { | |
inline namespace m {} | |
} | |
functionDecl(isInline()) will match ::f(). | |
namespaceDecl(isInline()) will match n::m. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('argumentCountIs2')"><a name="argumentCountIs2Anchor">argumentCountIs</a></td><td>unsigned N</td></tr> | |
<tr><td colspan="4" class="doc" id="argumentCountIs2"><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="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasKeywordSelector0')"><a name="hasKeywordSelector0Anchor">hasKeywordSelector</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector | |
objCMessageExpr(hasKeywordSelector()) matches the generated setFrame | |
message expression in | |
UIWebView *webView = ...; | |
CGRect bodyFrame = webView.frame; | |
bodyFrame.size.height = self.bodyContentHeight; | |
webView.frame = bodyFrame; | |
^---- matches here | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasNullSelector0')"><a name="hasNullSelector0Anchor">hasNullSelector</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector | |
Matches only when the selector of the objCMessageExpr is NULL. This may | |
represent an error condition in the tree! | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasSelector0')"><a name="hasSelector0Anchor">hasSelector</a></td><td>std::string BaseName</td></tr> | |
<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() | |
matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); | |
matches the outer message expr in the code below, but NOT the message | |
invocation for self.bodyView. | |
[self.bodyView loadHTMLString:html baseURL:NULL]; | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasUnarySelector0')"><a name="hasUnarySelector0Anchor">hasUnarySelector</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector | |
matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); | |
matches self.bodyView in the code below, but NOT the outer message | |
invocation of "loadHTMLString:baseURL:". | |
[self.bodyView loadHTMLString:html baseURL:NULL]; | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('matchesSelector0')"><a name="matchesSelector0Anchor">matchesSelector</a></td><td>std::string RegExp</td></tr> | |
<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains | |
a substring matched by the given RegExp. | |
matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message | |
invocation for self.bodyView. | |
[self.bodyView loadHTMLString:html baseURL:NULL]; | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('numSelectorArgs0')"><a name="numSelectorArgs0Anchor">numSelectorArgs</a></td><td>unsigned N</td></tr> | |
<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments | |
matcher = objCMessageExpr(numSelectorArgs(0)); | |
matches self.bodyView in the code below | |
matcher = objCMessageExpr(numSelectorArgs(2)); | |
matches the invocation of "loadHTMLString:baseURL:" but not that | |
of self.bodyView | |
[self.bodyView loadHTMLString:html baseURL:NULL]; | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('asString0')"><a name="asString0Anchor">asString</a></td><td>std::string Name</td></tr> | |
<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. | |
Given | |
class Y { public: void x(); }; | |
void z() { Y* y; y->x(); } | |
cxxMemberCallExpr(on(hasType(asString("class Y *")))) | |
matches y->x() | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('equalsBoundNode3')"><a name="equalsBoundNode3Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr> | |
<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. | |
Matches a node if it equals the node previously bound to ID. | |
Given | |
class X { int a; int b; }; | |
cxxRecordDecl( | |
has(fieldDecl(hasName("a"), hasType(type().bind("t")))), | |
has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) | |
matches the class X, as a and b have the same type. | |
Note that when multiple matches are involved via forEach* matchers, | |
equalsBoundNodes acts as a filter. | |
For example: | |
compoundStmt( | |
forEachDescendant(varDecl().bind("d")), | |
forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) | |
will trigger a match for each combination of variable declaration | |
and reference to that variable declaration within a compound statement. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasLocalQualifiers0')"><a name="hasLocalQualifiers0Anchor">hasLocalQualifiers</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to | |
the node, not hidden within a typedef. | |
Given | |
typedef const int const_int; | |
const_int i; | |
int *const j; | |
int *volatile k; | |
int m; | |
varDecl(hasType(hasLocalQualifiers())) matches only j and k. | |
i is const-qualified but the qualifier is not local. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isConstQualified0')"><a name="isConstQualified0Anchor">isConstQualified</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that | |
include "top-level" const. | |
Given | |
void a(int); | |
void b(int const); | |
void c(const int); | |
void d(const int*); | |
void e(int const) {}; | |
functionDecl(hasAnyParameter(hasType(isConstQualified()))) | |
matches "void b(int const)", "void c(const int)" and | |
"void e(int const) {}". It does not match d as there | |
is no top-level const on the parameter type "const int *". | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isInteger0')"><a name="isInteger0Anchor">isInteger</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. | |
Given | |
void a(int); | |
void b(long); | |
void c(double); | |
functionDecl(hasAnyParameter(hasType(isInteger()))) | |
matches "a(int)", "b(long)", but not "c(double)". | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>></td><td class="name" onclick="toggle('isClass0')"><a name="isClass0Anchor">isClass</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isClass0"><pre>Matches RecordDecl object that are spelled with "class." | |
Example matches C, but not S or U. | |
struct S {}; | |
class C {}; | |
union U {}; | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>></td><td class="name" onclick="toggle('isStruct0')"><a name="isStruct0Anchor">isStruct</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches RecordDecl object that are spelled with "struct." | |
Example matches S, but not C or U. | |
struct S {}; | |
class C {}; | |
union U {}; | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>></td><td class="name" onclick="toggle('isUnion0')"><a name="isUnion0Anchor">isUnion</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches RecordDecl object that are spelled with "union." | |
Example matches U, but not C or S. | |
struct S {}; | |
class C {}; | |
union U {}; | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('equalsBoundNode0')"><a name="equalsBoundNode0Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr> | |
<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. | |
Matches a node if it equals the node previously bound to ID. | |
Given | |
class X { int a; int b; }; | |
cxxRecordDecl( | |
has(fieldDecl(hasName("a"), hasType(type().bind("t")))), | |
has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) | |
matches the class X, as a and b have the same type. | |
Note that when multiple matches are involved via forEach* matchers, | |
equalsBoundNodes acts as a filter. | |
For example: | |
compoundStmt( | |
forEachDescendant(varDecl().bind("d")), | |
forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) | |
will trigger a match for each combination of variable declaration | |
and reference to that variable declaration within a compound statement. | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching1')"><a name="isExpansionInFileMatching1Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr> | |
<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is | |
partially matching a given regex. | |
Example matches Y but not X | |
(matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) | |
#include "ASTMatcher.h" | |
class X {}; | |
ASTMatcher.h: | |
class Y {}; | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInMainFile1')"><a name="isExpansionInMainFile1Anchor">isExpansionInMainFile</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. | |
Example matches X but not Y | |
(matcher = cxxRecordDecl(isExpansionInMainFile()) | |
#include <Y.h> | |
class X {}; | |
Y.h: | |
class Y {}; | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader1')"><a name="isExpansionInSystemHeader1Anchor">isExpansionInSystemHeader</a></td><td></td></tr> | |
<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. | |
Example matches Y but not X | |
(matcher = cxxRecordDecl(isExpansionInSystemHeader()) | |
#include <SystemHeader.h> | |
class X {}; | |
SystemHeader.h: | |
class Y {}; | |
Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> | |
</pre></td></tr> | |
<tr><td>Matcher<<a href="http:/ |