diff options
-rw-r--r-- | docs/LibASTMatchersReference.html | 1899 |
1 files changed, 1899 insertions, 0 deletions
diff --git a/docs/LibASTMatchersReference.html b/docs/LibASTMatchersReference.html new file mode 100644 index 0000000000..a371b3bfcf --- /dev/null +++ b/docs/LibASTMatchersReference.html @@ -0,0 +1,1899 @@ +<!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) { + row = document.getElementById(id); + if (row.style.display != 'table-cell') + row.style.display = 'table-cell'; + else + row.style.display = 'none'; +} +</script> +</head> +<body> + +<!--#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> + +<!-- ======================================================================= --> +<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> + +<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_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('classTemplate0')">classTemplate</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="classTemplate0"><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('classTemplateSpecialization0')">classTemplateSpecialization</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="classTemplateSpecialization0"><pre>Matches C++ class template specializations. + +Given + template<typename T> class A {}; + template<> class A<double> {}; + A<int> a; +classTemplateSpecialization() + 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('constructor0')">constructor</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="constructor0"><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('decl0')">decl</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('destructor0')">destructor</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="destructor0"><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('enumConstant0')">enumConstant</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="enumConstant0"><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')">enumDecl</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('field0')">field</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="field0"><pre>Matches field declarations. + +Given + class X { int m; }; +field() + 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('function0')">function</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="function0"><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('functionTemplate0')">functionTemplate</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="functionTemplate0"><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('method0')">method</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="method0"><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('nameableDeclaration0')">nameableDeclaration</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="nameableDeclaration0"><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('record0')">record</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="record0"><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('usingDecl0')">usingDecl</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('variable0')">variable</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="variable0"><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_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('boolLiteral0')">boolLiteral</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="boolLiteral0"><pre>Matches bool literals. + +Example matches true + true +</pre></td></tr> + + +<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('castExpr0')">castExpr</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_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('characterLiteral0')">characterLiteral</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_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('constCast0')">constCast</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="constCast0"><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_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('dynamicCast0')">dynamicCast</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="dynamicCast0"><pre>Matches a dynamic_cast expression. + +Example: + dynamicCast() +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_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('explicitCast0')">explicitCast</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="explicitCast0"><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_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('functionalCast0')">functionalCast</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="functionalCast0"><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_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('implicitCast0')">implicitCast</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="implicitCast0"><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_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('integerLiteral0')">integerLiteral</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. + +Not matching character-encoded integers such as L'a'. + +Example matches 1, 1L, 0x1, 1U +</pre></td></tr> + + +<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('reinterpretCast0')">reinterpretCast</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="reinterpretCast0"><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_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('staticCast0')">staticCast</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="staticCast0"><pre>Matches a C++ static_cast expression. + +hasDestinationType +reinterpretCast + +Example: + staticCast() +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_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('stringLiteral0')">stringLiteral</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('arraySubscriptExpr0')">arraySubscriptExpr</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('binaryOperator0')">binaryOperator</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('bindTemporaryExpression0')">bindTemporaryExpression</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="bindTemporaryExpression0"><pre>Matches nodes where temporaries are created. + +Example matches FunctionTakesString(GetStringByValue()) + (matcher = bindTemporaryExpression()) + 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('call0')">call</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="call0"><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('compoundStatement0')">compoundStatement</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="compoundStatement0"><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')">conditionalOperator</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('constructorCall0')">constructorCall</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="constructorCall0"><pre>Matches constructor call expressions (including implicit ones). + +Example matches string(ptr, n) and ptr within arguments of f + (matcher = constructorCall()) + 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('declarationReference0')">declarationReference</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="declarationReference0"><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('declarationStatement0')">declarationStatement</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="declarationStatement0"><pre>Matches declaration statements. + +Given + int a; +declarationStatement() + 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('defaultArgument0')">defaultArgument</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="defaultArgument0"><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 = defaultArgument()) + 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('deleteExpression0')">deleteExpression</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="deleteExpression0"><pre>Matches delete expressions. + +Given + delete X; +deleteExpression() + 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('doStmt0')">doStmt</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('expression0')">expression</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="expression0"><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('forStmt0')">forStmt</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 (;;) {} +</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')">ifStmt</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('initListExpr0')">initListExpr</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 }; +initList() + 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('memberCall0')">memberCall</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="memberCall0"><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('memberExpression0')">memberExpression</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="memberExpression0"><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; + }; +memberExpression() + 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('newExpression0')">newExpression</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="newExpression0"><pre>Matches new expressions. + +Given + new X; +newExpression() + 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('overloadedOperatorCall0')">overloadedOperatorCall</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="overloadedOperatorCall0"><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 = overloadedOperatorCall()) + 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('statement0')">statement</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="statement0"><pre>Matches statements. + +Given + { ++a; } +statement() + 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('switchCase0')">switchCase</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('unaryExprOrTypeTraitExpr0')">unaryExprOrTypeTraitExpr</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')">unaryOperator</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('whileStmt0')">whileStmt</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> + +<!--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')">allOf</td><td>Matcher<*> P1, Matcher<*> P2</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')">anyOf</td><td>Matcher<*> P1, Matcher<*> P2</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')">anything</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')">unless</td><td>Matcher<*> InnerMatcher</td></tr> +<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. + +Example matches Y (matcher = record(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')">hasOperatorName</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')">equals</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 = boolLiteral(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_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isImplicit0')">isImplicit</td><td></td></tr> +<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a constructor 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_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isWritten0')">isWritten</td><td></td></tr> +<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a contructor 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_; + }; +constructor(hasAnyConstructorInitializer(isWritten())) + will match Foo(int), but not Foo() +</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('hasOverloadedOperatorName0')">hasOverloadedOperatorName</td><td>std::string 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, such as "<<", for OverloadedOperatorCall's. + +Example matches a << b + (matcher == overloadedOperatorCall(hasOverloadedOperatorName("<<"))) + a << b; + c && d; assuming both operator<< + and operator&& are overloaded somewhere. +</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')">isDerivedFrom</td><td>StringRef 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('isExplicitTemplateSpecialization0')">isExplicitTemplateSpecialization</td><td></td></tr> +<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or +static |