summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/docs/LibASTMatchersReference.html741
-rw-r--r--clang/include/clang/ASTMatchers/ASTMatchers.h303
-rw-r--r--clang/lib/ASTMatchers/Dynamic/Registry.cpp58
-rw-r--r--clang/unittests/AST/ASTContextParentMapTest.cpp26
-rw-r--r--clang/unittests/AST/DeclPrinterTest.cpp46
-rw-r--r--clang/unittests/AST/SourceLocationTest.cpp26
-rw-r--r--clang/unittests/AST/StmtPrinterTest.cpp4
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.cpp524
-rw-r--r--clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp4
-rw-r--r--clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp19
-rw-r--r--clang/unittests/Tooling/RefactoringCallbacksTest.cpp4
11 files changed, 954 insertions, 801 deletions
diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html
index 80f22fa6d17..47666a13867 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -100,8 +100,8 @@ recordDecl(decl().bind("id"), hasName("::MyClass"))
<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
<!-- START_DECL_MATCHERS -->
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('ctorInitializer0')"><a name="ctorInitializer0Anchor">ctorInitializer</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="ctorInitializer0"><pre>Matches constructor initializers.
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('cxxCtorInitializer0')"><a name="cxxCtorInitializer0Anchor">cxxCtorInitializer</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;...</td></tr>
+<tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers.
Examples matches i(42).
class C {
@@ -144,8 +144,8 @@ classTemplateSpecializationDecl()
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('constructorDecl0')"><a name="constructorDecl0Anchor">constructorDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="constructorDecl0"><pre>Matches C++ constructor declarations.
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxConstructorDecl0')"><a name="cxxConstructorDecl0Anchor">cxxConstructorDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;...</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 {
@@ -157,14 +157,42 @@ Example matches Foo::Foo() and Foo::Foo(int)
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('conversionDecl0')"><a name="conversionDecl0Anchor">conversionDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="conversionDecl0"><pre>Matches conversion operator declarations.
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxConversionDecl0')"><a name="cxxConversionDecl0Anchor">cxxConversionDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxDestructorDecl0')"><a name="cxxDestructorDecl0Anchor">cxxDestructorDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxMethodDecl0')"><a name="cxxMethodDecl0Anchor">cxxMethodDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxRecordDecl0')"><a name="cxxRecordDecl0Anchor">cxxRecordDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;...</td></tr>
+<tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations.
+
+Example matches X, Z
+ class X;
+ template&lt;class T&gt; class Z {};
+</pre></td></tr>
+
+
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('decl0')"><a name="decl0Anchor">decl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations.
@@ -187,17 +215,6 @@ declaratorDecl()
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('destructorDecl0')"><a name="destructorDecl0Anchor">destructorDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="destructorDecl0"><pre>Matches explicit C++ destructor declarations.
-
-Example matches Foo::~Foo()
- class Foo {
- public:
- virtual ~Foo();
- };
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('enumConstantDecl0')"><a name="enumConstantDecl0Anchor">enumConstantDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html">EnumConstantDecl</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants.
@@ -264,14 +281,6 @@ linkageSpecDecl()
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('methodDecl0')"><a name="methodDecl0Anchor">methodDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="methodDecl0"><pre>Matches method declarations.
-
-Example matches y
- class X { void y(); };
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('namedDecl0')"><a name="namedDecl0Anchor">namedDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name.
@@ -326,12 +335,14 @@ parmVarDecl()
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('recordDecl0')"><a name="recordDecl0Anchor">recordDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches C++ class declarations.
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('recordDecl0')"><a name="recordDecl0Anchor">recordDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>&gt;...</td></tr>
+<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations.
-Example matches X, Z
+Example matches X, Z, U, and S
class X;
template&lt;class T&gt; class Z {};
+ struct S {};
+ union U {};
</pre></td></tr>
@@ -466,14 +477,6 @@ nestedNameSpecifier()
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('CUDAKernelCallExpr0')"><a name="CUDAKernelCallExpr0Anchor">CUDAKernelCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="CUDAKernelCallExpr0"><pre>Matches CUDA kernel call expression.
-
-Example matches,
- kernel&lt;&lt;&lt;i,j&gt;&gt;&gt;();
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('arraySubscriptExpr0')"><a name="arraySubscriptExpr0Anchor">arraySubscriptExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions.
@@ -502,24 +505,6 @@ Example matches a || b
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('bindTemporaryExpr0')"><a name="bindTemporaryExpr0Anchor">bindTemporaryExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="bindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
-
-Example matches FunctionTakesString(GetStringByValue())
- (matcher = bindTemporaryExpr())
- FunctionTakesString(GetStringByValue());
- FunctionTakesStringByPointer(GetStringPointer());
-</pre></td></tr>
-
-
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('boolLiteral0')"><a name="boolLiteral0Anchor">boolLiteral</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="boolLiteral0"><pre>Matches bool literals.
-
-Example matches true
- true
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('breakStmt0')"><a name="breakStmt0Anchor">breakStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BreakStmt.html">BreakStmt</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements.
@@ -571,15 +556,6 @@ but does not match
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('catchStmt0')"><a name="catchStmt0Anchor">catchStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="catchStmt0"><pre>Matches catch statements.
-
- try {} catch(int i) {}
-catchStmt()
- matches 'catch(int i)'
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('characterLiteral0')"><a name="characterLiteral0Anchor">characterLiteral</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t).
@@ -615,8 +591,53 @@ Example matches a ? b : c
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('constCastExpr0')"><a name="constCastExpr0Anchor">constCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="constCastExpr0"><pre>Matches a const_cast expression.
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('continueStmt0')"><a name="continueStmt0Anchor">continueStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ContinueStmt.html">ContinueStmt</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cudaKernelCallExpr0')"><a name="cudaKernelCallExpr0Anchor">cudaKernelCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr</a>&gt;...</td></tr>
+<tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression.
+
+Example matches,
+ kernel&lt;&lt;&lt;i,j&gt;&gt;&gt;();
+</pre></td></tr>
+
+
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxBindTemporaryExpr0')"><a name="cxxBindTemporaryExpr0Anchor">cxxBindTemporaryExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxBoolLiteral0')"><a name="cxxBoolLiteral0Anchor">cxxBoolLiteral</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;...</td></tr>
+<tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals.
+
+Example matches true
+ true
+</pre></td></tr>
+
+
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxCatchStmt0')"><a name="cxxCatchStmt0Anchor">cxxCatchStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxConstCastExpr0')"><a name="cxxConstCastExpr0Anchor">cxxConstCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>&gt;...</td></tr>
+<tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression.
Example: Matches const_cast&lt;int*&gt;(&amp;r) in
int n = 42;
@@ -625,11 +646,11 @@ Example: Matches const_cast&lt;int*&gt;(&amp;r) in
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('constructExpr0')"><a name="constructExpr0Anchor">constructExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="constructExpr0"><pre>Matches constructor call expressions (including implicit ones).
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxConstructExpr0')"><a name="cxxConstructExpr0Anchor">cxxConstructExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;...</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 = constructExpr())
+ (matcher = cxxConstructExpr())
void f(const string &amp;a, const string &amp;b);
char *ptr;
int n;
@@ -637,13 +658,172 @@ Example matches string(ptr, n) and ptr within arguments of f
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('continueStmt0')"><a name="continueStmt0Anchor">continueStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ContinueStmt.html">ContinueStmt</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements.
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxDefaultArgExpr0')"><a name="cxxDefaultArgExpr0Anchor">cxxDefaultArgExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxDeleteExpr0')"><a name="cxxDeleteExpr0Anchor">cxxDeleteExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>&gt;...</td></tr>
+<tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions.
Given
- while (true) { continue; }
-continueStmt()
- matches 'continue'
+ delete X;
+cxxDeleteExpr()
+ matches 'delete X'.
+</pre></td></tr>
+
+
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxDynamicCastExpr0')"><a name="cxxDynamicCastExpr0Anchor">cxxDynamicCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>&gt;...</td></tr>
+<tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression.
+
+Example:
+ cxxDynamicCastExpr()
+matches
+ dynamic_cast&lt;D*&gt;(&amp;b);
+in
+ struct B { virtual ~B() {} }; struct D : B {};
+ B b;
+ D* p = dynamic_cast&lt;D*&gt;(&amp;b);
+</pre></td></tr>
+
+
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxForRangeStmt0')"><a name="cxxForRangeStmt0Anchor">cxxForRangeStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;...</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 &lt; 5; ++j);
+</pre></td></tr>
+
+
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxFunctionalCastExpr0')"><a name="cxxFunctionalCastExpr0Anchor">cxxFunctionalCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxMemberCallExpr0')"><a name="cxxMemberCallExpr0Anchor">cxxMemberCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxNewExpr0')"><a name="cxxNewExpr0Anchor">cxxNewExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxNullPtrLiteralExpr0')"><a name="cxxNullPtrLiteralExpr0Anchor">cxxNullPtrLiteralExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>&gt;...</td></tr>
+<tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal.
+</pre></td></tr>
+
+
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxOperatorCallExpr0')"><a name="cxxOperatorCallExpr0Anchor">cxxOperatorCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;...</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&lt;&lt;((o &lt;&lt; b), c) and operator&lt;&lt;(o, b)
+ (matcher = cxxOperatorCallExpr())
+ ostream &amp;operator&lt;&lt; (ostream &amp;out, int i) { };
+ ostream &amp;o; int b = 1, c = 1;
+ o &lt;&lt; b &lt;&lt; c;
+</pre></td></tr>
+
+
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxReinterpretCastExpr0')"><a name="cxxReinterpretCastExpr0Anchor">cxxReinterpretCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>&gt;...</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&lt;char*&gt;(&amp;p) in
+ void* p = reinterpret_cast&lt;char*&gt;(&amp;p);
+</pre></td></tr>
+
+
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxStaticCastExpr0')"><a name="cxxStaticCastExpr0Anchor">cxxStaticCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>&gt;...</td></tr>
+<tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression.
+
+hasDestinationType
+reinterpretCast
+
+Example:
+ cxxStaticCastExpr()
+matches
+ static_cast&lt;long&gt;(8)
+in
+ long eight(static_cast&lt;long&gt;(8));
+</pre></td></tr>
+
+
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxTemporaryObjectExpr0')"><a name="cxxTemporaryObjectExpr0Anchor">cxxTemporaryObjectExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxThisExpr0')"><a name="cxxThisExpr0Anchor">cxxThisExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxThrowExpr0')"><a name="cxxThrowExpr0Anchor">cxxThrowExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxTryStmt0')"><a name="cxxTryStmt0Anchor">cxxTryStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>&gt;...</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxUnresolvedConstructExpr0')"><a name="cxxUnresolvedConstructExpr0Anchor">cxxUnresolvedConstructExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;...</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 &lt;typename T&gt;
+ void f(const T&amp; t) { return T(t); }
</pre></td></tr>
@@ -666,17 +846,6 @@ declStmt()
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('defaultArgExpr0')"><a name="defaultArgExpr0Anchor">defaultArgExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="defaultArgExpr0"><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 = defaultArgExpr())
- void f(int x, int y = 0);
- f(42);
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('defaultStmt0')"><a name="defaultStmt0Anchor">defaultStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DefaultStmt.html">DefaultStmt</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements.
@@ -687,16 +856,6 @@ defaultStmt()
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('deleteExpr0')"><a name="deleteExpr0Anchor">deleteExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="deleteExpr0"><pre>Matches delete expressions.
-
-Given
- delete X;
-deleteExpr()
- matches 'delete X'.
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('doStmt0')"><a name="doStmt0Anchor">doStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements.
@@ -707,20 +866,6 @@ doStmt()
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('dynamicCastExpr0')"><a name="dynamicCastExpr0Anchor">dynamicCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="dynamicCastExpr0"><pre>Matches a dynamic_cast expression.
-
-Example:
- dynamicCastExpr()
-matches
- dynamic_cast&lt;D*&gt;(&amp;b);
-in
- struct B { virtual ~B() {} }; struct D : B {};
- B b;
- D* p = dynamic_cast&lt;D*&gt;(&amp;b);
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('explicitCastExpr0')"><a name="explicitCastExpr0Anchor">explicitCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions.
@@ -768,15 +913,6 @@ Does not match implicit conversions such as
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('forRangeStmt0')"><a name="forRangeStmt0Anchor">forRangeStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="forRangeStmt0"><pre>Matches range-based for statements.
-
-forRangeStmt() matches 'for (auto a : i)'
- int i[] = {1, 2, 3}; for (auto a : i);
- for(int j = 0; j &lt; 5; ++j);
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('forStmt0')"><a name="forStmt0Anchor">forStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements.
@@ -786,16 +922,6 @@ Example matches 'for (;;) {}'
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('functionalCastExpr0')"><a name="functionalCastExpr0Anchor">functionalCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="functionalCastExpr0"><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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('gnuNullExpr0')"><a name="gnuNullExpr0Anchor">gnuNullExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1GNUNullExpr.html">GNUNullExpr</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression.
</pre></td></tr>
@@ -883,15 +1009,6 @@ but does not match
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('memberCallExpr0')"><a name="memberCallExpr0Anchor">memberCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="memberCallExpr0"><pre>Matches member call expressions.
-
-Example matches x.y()
- X x;
- x.y();
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('memberExpr0')"><a name="memberExpr0Anchor">memberExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions.
@@ -905,21 +1022,6 @@ memberExpr()
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('newExpr0')"><a name="newExpr0Anchor">newExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="newExpr0"><pre>Matches new expressions.
-
-Given
- new X;
-newExpr()
- matches 'new X'.
-</pre></td></tr>
-
-
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('nullPtrLiteralExpr0')"><a name="nullPtrLiteralExpr0Anchor">nullPtrLiteralExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="nullPtrLiteralExpr0"><pre>Matches nullptr literal.
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('nullStmt0')"><a name="nullStmt0Anchor">nullStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NullStmt.html">NullStmt</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements.
@@ -940,34 +1042,6 @@ NSString's "alloc". This matcher should match both message sends.
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('operatorCallExpr0')"><a name="operatorCallExpr0Anchor">operatorCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="operatorCallExpr0"><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&lt;&lt;((o &lt;&lt; b), c) and operator&lt;&lt;(o, b)
- (matcher = operatorCallExpr())
- ostream &amp;operator&lt;&lt; (ostream &amp;out, int i) { };
- ostream &amp;o; int b = 1, c = 1;
- o &lt;&lt; b &lt;&lt; c;
-</pre></td></tr>
-
-
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('reinterpretCastExpr0')"><a name="reinterpretCastExpr0Anchor">reinterpretCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="reinterpretCastExpr0"><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&lt;char*&gt;(&amp;p) in
- void* p = reinterpret_cast&lt;char*&gt;(&amp;p);
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('returnStmt0')"><a name="returnStmt0Anchor">returnStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements.
@@ -978,21 +1052,6 @@ returnStmt()
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('staticCastExpr0')"><a name="staticCastExpr0Anchor">staticCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="staticCastExpr0"><pre>Matches a C++ static_cast expression.
-
-hasDestinationType
-reinterpretCast
-
-Example:
- staticCastExpr()
-matches
- static_cast&lt;long&gt;(8)
-in
- long eight(static_cast&lt;long&gt;(8));
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('stmt0')"><a name="stmt0Anchor">stmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements.
@@ -1043,44 +1102,6 @@ switchStmt()
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('temporaryObjectExpr0')"><a name="temporaryObjectExpr0Anchor">temporaryObjectExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="temporaryObjectExpr0"><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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('thisExpr0')"><a name="thisExpr0Anchor">thisExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="thisExpr0"><pre>Matches implicit and explicit this expressions.
-
-Example matches the implicit this expression in "return i".
- (matcher = thisExpr())
-struct foo {
- int i;
- int f() { return i; }
-};
-</pre></td></tr>
-
-
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('throwExpr0')"><a name="throwExpr0Anchor">throwExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="throwExpr0"><pre>Matches throw expressions.
-
- try { throw 5; } catch(int i) {}
-throwExpr()
- matches 'throw 5'
-</pre></td></tr>
-
-
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('tryStmt0')"><a name="tryStmt0Anchor">tryStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="tryStmt0"><pre>Matches try statements.
-
- try {} catch(int i) {}
-tryStmt()
- matches 'try {}'
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('unaryExprOrTypeTraitExpr0')"><a name="unaryExprOrTypeTraitExpr0Anchor">unaryExprOrTypeTraitExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
@@ -1100,16 +1121,6 @@ Example matches !a
</pre></td></tr>
-<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('unresolvedConstructExpr0')"><a name="unresolvedConstructExpr0Anchor">unresolvedConstructExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;...</td></tr>
-<tr><td colspan="4" class="doc" id="unresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions.
-
-Example matches T(t) in return statement of f
- (matcher = unresolvedConstructExpr())
- template &lt;typename T&gt;
- void f(const T&amp; t) { return T(t); }
-</pre></td></tr>
-
-
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('userDefinedLiteral0')"><a name="userDefinedLiteral0Anchor">userDefinedLiteral</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UserDefinedLiteral.html">UserDefinedLiteral</a>&gt;...</td></tr>
<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
@@ -1537,7 +1548,7 @@ Usable as: Any Matcher
<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher&lt;*&gt;</td></tr>
<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match.
-Example matches Y (matcher = recordDecl(unless(hasName("X"))))
+Example matches Y (matcher = cxxRecordDecl(unless(hasName("X"))))
class X {};
class Y {};
@@ -1557,7 +1568,7 @@ Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
<tr><td>Matcher&lt;CXXBoolLiteral&gt;</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 = boolLiteral(equals(true)))
+Example matches true (matcher = cxxBoolLiteral(equals(true)))
true
Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
@@ -1577,7 +1588,7 @@ Given
...
}
endcode
-catchStmt(isCatchAll()) matches catch(...) but not catch(int).
+cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
</pre></td></tr>
@@ -1605,7 +1616,7 @@ Given
S(const S &amp;); #2
S(S &amp;&amp;); #3
};
-constructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
+cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
</pre></td></tr>
@@ -1618,7 +1629,7 @@ Given
S(const S &amp;); #2
S(S &amp;&amp;); #3
};
-constructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
+cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
</pre></td></tr>
@@ -1633,8 +1644,8 @@ Given
operator int(); #3
explicit operator bool(); #4
};
-constructorDecl(isExplicit()) will match #2, but not #1.
-conversionDecl(isExplicit()) will match #4, but not #3.
+cxxConstructorDecl(isExplicit()) will match #2, but not #1.
+cxxConversionDecl(isExplicit()) will match #4, but not #3.
</pre></td></tr>
@@ -1647,7 +1658,7 @@ Given
S(const S &amp;); #2
S(S &amp;&amp;); #3
};
-constructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
+cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
</pre></td></tr>
@@ -1662,8 +1673,8 @@ Given
operator int(); #3
explicit operator bool(); #4
};
-constructorDecl(isExplicit()) will match #2, but not #1.
-conversionDecl(isExplicit()) will match #4, but not #3.
+cxxConstructorDecl(isExplicit()) will match #2, but not #1.
+cxxConversionDecl(isExplicit()) will match #4, but not #3.
</pre></td></tr>
@@ -1680,7 +1691,7 @@ Given
struct E : B {
E() : B() {}
};
-constructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
+cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
will match E(), but not match D(int).
</pre></td></tr>
@@ -1698,7 +1709,7 @@ Given
struct E : B {
E() : B() {}
};
-constructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
+cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
will match D(int), but not match E().
</pre></td></tr>
@@ -1713,7 +1724,7 @@ Given
Foo(int) : foo_("A") { }
string foo_;
};
-constructorDecl(hasAnyConstructorInitializer(isWritten()))
+cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
will match Foo(int), but not Foo()
</pre></td></tr>
@@ -1727,7 +1738,7 @@ struct A {
void bar();
};
-methodDecl(isConst()) matches A::foo() but not A::bar()
+cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
</pre></td></tr>
@@ -1800,9 +1811,10 @@ Given:
A a;
a &lt;&lt; a; &lt;-- This matches
-operatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the specified
-line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches
-the declaration of A.
+cxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
+specified line and
+cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
+matches the declaration of A.
Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;
</pre></td></tr>
@@ -1858,13 +1870,13 @@ Given
template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
or
template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
-recordDecl(hasName("::X"), isTemplateInstantiation())
+cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
matches the template instantiation of X&lt;A&gt;.
But given
template &lt;typename T&gt; class X {}; class A {};
template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
-recordDecl(hasName("::X"), isTemplateInstantiation())
+cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
does not match, as X&lt;A&gt; is an explicit template specialization.
Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
@@ -1884,7 +1896,7 @@ Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;</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 = boolLiteral(equals(true)))
+Example matches true (matcher = cxxBoolLiteral(equals(true)))
true
Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
@@ -1947,7 +1959,7 @@ Matches a node if it equals the node previously bound to ID.
Given
class X { int a; int b; };
-recordDecl(
+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.
@@ -1979,7 +1991,7 @@ passed as a quoted string. e.g., hasAttr("attr::CUDADevice").
partially matching a given regex.
Example matches Y but not X
- (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
+ (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
#include "ASTMatcher.h"
class X {};
ASTMatcher.h:
@@ -1992,7 +2004,8 @@ Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.h
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</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 = recordDecl(isExpansionInMainFile())
+Example matches X but not Y
+ (matcher = cxxRecordDecl(isExpansionInMainFile())
#include &lt;Y.h&gt;
class X {};
Y.h:
@@ -2006,7 +2019,7 @@ Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.h
<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 = recordDecl(isExpansionInSystemHeader())
+ (matcher = cxxRecordDecl(isExpansionInSystemHeader())
#include &lt;SystemHeader.h&gt;
class X {};
SystemHeader.h:
@@ -2067,7 +2080,7 @@ fieldDecl(isPublic())
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;</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 = boolLiteral(equals(true)))
+Example matches true (matcher = cxxBoolLiteral(equals(true)))
true
Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
@@ -2087,9 +2100,10 @@ Given:
A a;
a &lt;&lt; a; &lt;-- This matches
-operatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the specified
-line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches
-the declaration of A.
+cxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
+specified line and
+cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
+matches the declaration of A.
Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;
</pre></td></tr>
@@ -2183,13 +2197,13 @@ Given
template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
or
template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
-recordDecl(hasName("::X"), isTemplateInstantiation())
+cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
matches the template instantiation of X&lt;A&gt;.
But given
template &lt;typename T&gt; class X {}; class A {};
template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
-recordDecl(hasName("::X"), isTemplateInstantiation())
+cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
does not match, as X&lt;A&gt; is an explicit template specialization.
Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
@@ -2210,7 +2224,7 @@ functionDecl(parameterCountIs(2))
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;</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 = boolLiteral(equals(true)))
+Example matches true (matcher = cxxBoolLiteral(equals(true)))
true
Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
@@ -2303,7 +2317,17 @@ Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</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></pre></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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasNullSelector0')"><a name="hasNullSelector0Anchor">hasNullSelector</a></td><td></td></tr>
@@ -2362,7 +2386,7 @@ a substring matched by the given RegExp.
Given
class Y { public: void x(); };
void z() { Y* y; y-&gt;x(); }
-memberCallExpr(on(hasType(asString("class Y *"))))
+cxxMemberCallExpr(on(hasType(asString("class Y *"))))
matches y-&gt;x()
</pre></td></tr>
@@ -2374,7 +2398,7 @@ Matches a node if it equals the node previously bound to ID.
Given
class X { int a; int b; };
-recordDecl(
+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.
@@ -2434,6 +2458,36 @@ matches "a(int)", "b(long)", but not "c(double)".
</pre></td></tr>
+<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>&gt;</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>&gt;</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>&gt;</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&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</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.
@@ -2441,7 +2495,7 @@ Matches a node if it equals the node previously bound to ID.
Given
class X { int a; int b; };
-recordDecl(
+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.
@@ -2462,7 +2516,7 @@ and reference to that variable declaration within a compound statement.
partially matching a given regex.
Example matches Y but not X
- (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
+ (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
#include "ASTMatcher.h"
class X {};
ASTMatcher.h:
@@ -2475,7 +2529,8 @@ Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.h
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</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 = recordDecl(isExpansionInMainFile())
+Example matches X but not Y
+ (matcher = cxxRecordDecl(isExpansionInMainFile())
#include &lt;Y.h&gt;
class X {};
Y.h:
@@ -2489,7 +2544,7 @@ Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.h
<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 = recordDecl(isExpansionInSystemHeader())
+ (matcher = cxxRecordDecl(isExpansionInSystemHeader())
#include &lt;SystemHeader.h&gt;
class X {};
SystemHeader.h:
@@ -2559,7 +2614,7 @@ classTemplateSpecializationDecl(templateArgumentCountIs(1))
partially matching a given regex.
Example matches Y but not X
- (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
+ (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
#include "ASTMatcher.h"
class X {};
ASTMatcher.h:
@@ -2572,7 +2627,8 @@ Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.h
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('isExpansionInMainFile2')"><a name="isExpansionInMainFile2Anchor">isExpansionInMainFile</a></td><td></td></tr>
<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file.
-Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
+Example matches X but not Y
+ (matcher = cxxRecordDecl(isExpansionInMainFile())
#include &lt;Y.h&gt;
class X {};
Y.h:
@@ -2586,7 +2642,7 @@ Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.h
<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files.
Example matches Y but not X
- (matcher = recordDecl(isExpansionInSystemHeader())
+ (matcher = cxxRecordDecl(isExpansionInSystemHeader())
#include &lt;SystemHeader.h&gt;
class X {};
SystemHeader.h:
@@ -2603,7 +2659,7 @@ Matches a node if it equals the node previously bound to ID.
Given
class X { int a; int b; };
-recordDecl(
+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.
@@ -2737,13 +2793,13 @@ Given
template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
or
template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
-recordDecl(hasName("::X"), isTemplateInstantiation())
+cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
matches the template instantiation of X&lt;A&gt;.
But given
template &lt;typename T&gt; class X {}; class A {};
template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
-recordDecl(hasName("::X"), isTemplateInstantiation())
+cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
does not match, as X&lt;A&gt; is an explicit template specialization.
Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
@@ -2805,8 +2861,8 @@ matching submatcher.
For example, in:
class A { int a; int b; };
The matcher:
- recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
- has(fieldDecl(hasName("b")).bind("v"))))
+ cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
+ has(fieldDecl(hasName("b")).bind("v"))))
will generate two results binding "v", the first of which binds
the field declaration of a, the second the field declaration of
b.
@@ -2820,7 +2876,7 @@ Usable as: Any Matcher
provided matcher.
Example matches X, A, B, C
- (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X")))))
+ (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
class X {}; Matches X, because X::X is a class of name X inside X.
class A { class X {}; };
class B { class C { class X {}; }; };
@@ -2831,7 +2887,9 @@ As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
each result that matches instead of only on the first one.
Note: Recursively combined ForEachDescendant can cause many matches:
- recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl()))))
+ cxxRecordDecl(forEachDescendant(cxxRecordDecl(
+ forEachDescendant(cxxRecordDecl())
+ )))
will match 10 times (plus injected class name matches) on:
class A { class B { class C { class D { class E {}; }; }; }; };
@@ -2843,7 +2901,8 @@ Usable as: Any Matcher
<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
provided matcher.
-Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X")))
+Example matches X, Y
+ (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
class X {}; Matches X, because X::X is a class of name X inside X.
class Y { class X {}; };
class Z { class Y { class X {}; }; }; Does not match Z.
@@ -2875,7 +2934,7 @@ Usable as: Any Matcher
provided matcher.
Example matches X, Y, Z
- (matcher = recordDecl(hasDescendant(recordDecl(hasName("X")))))
+ (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))
class X {}; Matches X, because X::X is a class of name X inside X.
class Y { class X {}; };
class Z { class Y { class X {}; }; };
@@ -2890,7 +2949,8 @@ Usable as: Any Matcher
<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the
provided matcher.
-Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X")))
+Example matches X, Y
+ (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))
class X {}; Matches X, because X::X is a class of name X inside X.
class Y { class X {}; };
class Z { class Y { class X {}; }; }; Does not match Z.
@@ -3117,7 +3177,9 @@ Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallEx
Given
class A { A() : i(42), j(42) {} int i; int j; };
-constructorDecl(forEachConstructorInitializer(forField(decl().bind("x"))))
+cxxConstructorDecl(forEachConstructorInitializer(
+ forField(decl().bind("x"))
+))
will trigger two matches, binding for 'i' and 'j' respectively.
</pre></td></tr>
@@ -3130,7 +3192,9 @@ Given
Foo() : foo_(1) { }
int foo_;
};
-recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything()))))
+cxxRecordDecl(has(cxxConstructorDecl(
+ hasAnyConstructorInitializer(anything())
+)))
record matches Foo, hasAnyConstructorInitializer matches foo_(1)
</pre></td></tr>
@@ -3143,7 +3207,7 @@ Given
Foo() : foo_(1) { }
int foo_;
};
-recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
+cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
forField(hasName("foo_"))))))
matches Foo
with forField matching foo_
@@ -3158,7 +3222,7 @@ Given
Foo() : foo_(1) { }
int foo_;
};
-recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
+cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
withInitializer(integerLiteral(equals(1)))))))
matches Foo
with withInitializer matching (1)
@@ -3206,7 +3270,7 @@ matches 'a' in
<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression.
Example matches y.x()
- (matcher = memberCallExpr(on(hasType(recordDecl(hasName("Y"))))))
+ (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))))))
class Y { public: void x(); };
void z() { Y y; y.x(); }",
@@ -3234,7 +3298,7 @@ FIXME: What other kind of declarations would we need to generalize
this to?
Example matches A() in the last line
- (matcher = constructExpr(hasDeclaration(methodDecl(
+ (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
ofClass(hasName("A"))))))
class A {
public:
@@ -3251,8 +3315,8 @@ Given:
class A { void func(); };
class B { void member(); };
-recordDecl(hasMethod(hasName("func"))) matches the declaration of A
-but not B.
+cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of
+A but not B.
</pre></td></tr>
@@ -3287,7 +3351,8 @@ match Base.
<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the
given matcher.
-Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x")))))
+Example matches y.x() (matcher = callExpr(callee(
+ cxxMethodDecl(hasName("x")))))
class Y { public: void x(); };
void z() { Y y; y.x(); }
</pre></td></tr>
@@ -3376,7 +3441,7 @@ caseStmt(hasCaseConstant(integerLiteral()))
<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher.
Example: matches "a string" (matcher =
- hasSourceExpression(constructExpr()))
+ hasSourceExpression(cxxConstructExpr()))
class URL { URL(string); };
URL url = "a string";
</pre></td></tr>
@@ -3457,7 +3522,7 @@ with compoundStmt()
<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop,
or conditional operator.
-Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
+Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
if (true) {}
</pre></td></tr>
@@ -3579,7 +3644,7 @@ Given
}
}
-recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
+cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
declaration of class D.
</pre></td></tr>
@@ -3601,7 +3666,7 @@ with compoundStmt()
<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop,
or conditional operator.
-Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
+Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
if (true) {}
</pre></td></tr>
@@ -3676,12 +3741,12 @@ declaration's type.
In case of a value declaration (for example a variable declaration),
this resolves one layer of indirection. For example, in the value
-declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
-while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
-of x."
+declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
+X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
+declaration of x.
-Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
- and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
+Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
+ and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
class X {};
void y(X &amp;x) { x; X z; }
@@ -3693,8 +3758,8 @@ Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.h
<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type
matcher.
-Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
- and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
+Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
+ and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
class X {};
void y(X &amp;x) { x; X z; }
</pre></td></tr>
@@ -3782,7 +3847,7 @@ with compoundStmt()
<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop,
or conditional operator.
-Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
+Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
if (true) {}
</pre></td></tr>
@@ -3814,7 +3879,7 @@ Does not match the 'this' parameter of a method.
Given
class X { void f(int x, int y, int z) {} };
-methodDecl(hasAnyParameter(hasName("y")))
+cxxMethodDecl(hasAnyParameter(hasName("y")))
matches f(int x, int y, int z) {}
with hasAnyParameter(...)
matching int y
@@ -3826,7 +3891,7 @@ with hasAnyParameter(...)
Given
class X { void f(int x) {} };
-methodDecl(hasParameter(0, hasType(varDecl())))
+cxxMethodDecl(hasParameter(0, hasType(varDecl())))
matches f(int x) {}
with hasParameter(...)
matching int x
@@ -3838,7 +3903,7 @@ with hasParameter(...)
Given:
class X { int f() { return 1; } };
-methodDecl(returns(asString("int")))
+cxxMethodDecl(returns(asString("int")))
matches int f() { return 1; }
</pre></td></tr>
@@ -3847,7 +3912,7 @@ methodDecl(returns(asString("int")))
<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop,
or conditional operator.
-Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
+Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
if (true) {}
</pre></td></tr>
@@ -3866,7 +3931,7 @@ hasConditionVariableStatement(...)
<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement.
Examples matches the if statement
- (matcher = ifStmt(hasElse(boolLiteral(equals(true)))))
+ (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))
if (false) false; else true;
</pre></td></tr>
@@ -3875,7 +3940,7 @@ Examples matches the if statement
<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement.
Examples matches the if statement
- (matcher = ifStmt(hasThen(boolLiteral(equals(true)))))
+ (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))
if (false) true; else false;
</pre></td></tr>
@@ -3961,7 +4026,7 @@ matched by a given matcher.
Given
struct X { int m; };
void f(X x) { x.m; m; }
-memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))))
+memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))))
matches "x.m" and "m"
with hasObjectExpression(...)
matching "x" and the implicit object expression of "m" which has type X*.
@@ -4033,7 +4098,7 @@ Given
struct A { struct B { struct C {}; }; };
A::B::C c;
nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
- hasDeclaration(recordDecl(hasName("A")))))))
+ hasDeclaration(cxxRecordDecl(hasName("A")))))))
matches "A::"
</pre></td></tr>
@@ -4068,7 +4133,9 @@ given QualType matcher without qualifiers.
Given
struct A { struct B { struct C {}; }; };
A::B::C c;
-nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A")))))
+nestedNameSpecifier(specifiesType(
+ hasDeclaration(cxxRecordDecl(hasName("A")))
+))
matches "A::"
</pre></td></tr>
@@ -4186,8 +4253,8 @@ Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallEx
matches the specified matcher.
Example matches y-&gt;x()
- (matcher = memberCallExpr(on(hasType(pointsTo
- recordDecl(hasName("Y")))))))
+ (matcher = cxxMemberCallExpr(on(hasType(pointsTo
+ cxxRecordDecl(hasName("Y")))))))
class Y { public: void x(); };
void z() { Y *y; y-&gt;x(); }
</pre></td></tr>
@@ -4203,7 +4270,7 @@ Example matches y-&gt;x()
type matches the specified matcher.
Example matches X &amp;x and const X &amp;y
- (matcher = varDecl(hasType(references(recordDecl(hasName("X"))))))
+ (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X"))))))
class X {
void a(X b) {
X &amp;x = b;
@@ -4448,7 +4515,8 @@ Generates results for each match.
For example, in:
class A { class B {}; class C {}; };
The matcher:
- recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m")))
+ cxxRecordDecl(hasName("::A"),
+ findAll(cxxRecordDecl(isDefinition()).bind("m")))
will generate results for A, B and C.
Usable as: Any Matcher
@@ -4490,7 +4558,8 @@ unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasUnaryOperand0')"><a name="hasUnaryOperand0Anchor">hasUnaryOperand</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches.
-Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true))))
+Example matches true (matcher = hasUnaryOperand(
+ cxxBoolLiteral(equals(true))))
!true
</pre></td></tr>
@@ -4545,12 +4614,12 @@ declaration's type.
In case of a value declaration (for example a variable declaration),
this resolves one layer of indirection. For example, in the value
-declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
-while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
-of x."
+declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
+X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
+declaration of x.
-Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
- and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
+Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
+ and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
class X {};
void y(X &amp;x) { x; X z; }
@@ -4562,8 +4631,8 @@ Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.h
<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type
matcher.
-Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
- and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
+Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
+ and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
class X {};
void y(X &amp;x) { x; X z; }
</pre></td></tr>
@@ -4610,7 +4679,7 @@ with compoundStmt()
<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop,
or conditional operator.
-Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
+Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
if (true) {}
</pre></td></tr>
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index ad21d1f3afd..5a14eef72a8 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -14,7 +14,7 @@
// a functional in-language DSL to express queries over the C++ AST.
//
// For example, to match a class with a certain name, one would call:
-// recordDecl(hasName("MyClass"))
+// cxxRecordDecl(hasName("MyClass"))
// which returns a matcher that can be used to find all AST nodes that declare
// a class named 'MyClass'.
//
@@ -25,13 +25,13 @@
//
// For example, when we're interested in child classes of a certain class, we
// would write:
-// recordDecl(hasName("MyClass"), hasChild(id("child", recordDecl())))
+// cxxRecordDecl(hasName("MyClass"), hasChild(id("child", recordDecl())))
// When the match is found via the MatchFinder, a user provided callback will
// be called with a BoundNodes instance that contains a mapping from the
// strings that we provided for the id(...) calls to the nodes that were
// matched.
// In the given example, each time our matcher finds a match we get a callback
-// where "child" is bound to the CXXRecordDecl node of the matching child
+// where "child" is bound to the RecordDecl node of the matching child
// class declaration.
//
// See ASTMatchersInternal.h for a more in-depth explanation of the
@@ -170,7 +170,8 @@ const internal::VariadicDynCastAllOfMatcher<Decl, TypedefDecl> typedefDecl;
/// \brief Matches AST nodes that were expanded within the main-file.
///
-/// Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
+/// Example matches X but not Y
+/// (matcher = cxxRecordDecl(isExpansionInMainFile())
/// \code
/// #include <Y.h>
/// class X {};
@@ -191,7 +192,7 @@ AST_POLYMORPHIC_MATCHER(isExpansionInMainFile,
/// \brief Matches AST nodes that were expanded within system-header-files.
///
/// Example matches Y but not X
-/// (matcher = recordDecl(isExpansionInSystemHeader())
+/// (matcher = cxxRecordDecl(isExpansionInSystemHeader())
/// \code
/// #include <SystemHeader.h>
/// class X {};
@@ -216,7 +217,7 @@ AST_POLYMORPHIC_MATCHER(isExpansionInSystemHeader,
/// partially matching a given regex.
///
/// Example matches Y but not X
-/// (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
+/// (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
/// \code
/// #include "ASTMatcher.h"
/// class X {};
@@ -304,6 +305,19 @@ const internal::VariadicDynCastAllOfMatcher<Decl, NamespaceDecl> namespaceDecl;
const internal::VariadicDynCastAllOfMatcher<Decl, NamespaceAliasDecl>
namespaceAliasDecl;
+/// \brief Matches class, struct, and union declarations.
+///
+/// Example matches \c X, \c Z, \c U, and \c S
+/// \code
+/// class X;
+/// template<class T> class Z {};
+/// struct S {};
+/// union U {};
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher<
+ Decl,
+ RecordDecl> recordDecl;
+
/// \brief Matches C++ class declarations.
///
/// Example matches \c X, \c Z
@@ -313,7 +327,7 @@ const internal::VariadicDynCastAllOfMatcher<Decl, NamespaceAliasDecl>
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Decl,
- CXXRecordDecl> recordDecl;
+ CXXRecordDecl> cxxRecordDecl;
/// \brief Matches C++ class template declarations.
///
@@ -385,7 +399,7 @@ const internal::VariadicDynCastAllOfMatcher<
/// int i;
/// };
/// \endcode
-const internal::VariadicAllOfMatcher<CXXCtorInitializer> ctorInitializer;
+const internal::VariadicAllOfMatcher<CXXCtorInitializer> cxxCtorInitializer;
/// \brief Matches template arguments.
///
@@ -724,7 +738,7 @@ const internal::VariadicDynCastAllOfMatcher<Decl, ValueDecl> valueDecl;
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Decl,
- CXXConstructorDecl> constructorDecl;
+ CXXConstructorDecl> cxxConstructorDecl;
/// \brief Matches explicit C++ destructor declarations.
///
@@ -737,7 +751,7 @@ const internal::VariadicDynCastAllOfMatcher<
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Decl,
- CXXDestructorDecl> destructorDecl;
+ CXXDestructorDecl> cxxDestructorDecl;
/// \brief Matches enum declarations.
///
@@ -767,7 +781,7 @@ const internal::VariadicDynCastAllOfMatcher<
/// \code
/// class X { void y(); };
/// \endcode
-const internal::VariadicDynCastAllOfMatcher<Decl, CXXMethodDecl> methodDecl;
+const internal::VariadicDynCastAllOfMatcher<Decl, CXXMethodDecl> cxxMethodDecl;
/// \brief Matches conversion operator declarations.
///
@@ -776,7 +790,7 @@ const internal::VariadicDynCastAllOfMatcher<Decl, CXXMethodDecl> methodDecl;
/// class X { operator int() const; };
/// \endcode
const internal::VariadicDynCastAllOfMatcher<Decl, CXXConversionDecl>
- conversionDecl;
+ cxxConversionDecl;
/// \brief Matches variable declarations.
///
@@ -889,7 +903,7 @@ const internal::VariadicDynCastAllOfMatcher<Stmt, LambdaExpr> lambdaExpr;
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXMemberCallExpr> memberCallExpr;
+ CXXMemberCallExpr> cxxMemberCallExpr;
/// \brief Matches ObjectiveC Message invocation expressions.
///
@@ -922,8 +936,9 @@ const internal::VariadicDynCastAllOfMatcher<
/// \code
/// const std::string str = std::string();
/// \endcode
-const internal::VariadicDynCastAllOfMatcher<Stmt, ExprWithCleanups>
-exprWithCleanups;
+const internal::VariadicDynCastAllOfMatcher<
+ Stmt,
+ ExprWithCleanups> exprWithCleanups;
/// \brief Matches init list expressions.
///
@@ -947,8 +962,9 @@ const internal::VariadicDynCastAllOfMatcher<Stmt, InitListExpr> initListExpr;
/// \endcode
/// substNonTypeTemplateParmExpr()
/// matches "N" in the right-hand side of "static const int n = N;"
-const internal::VariadicDynCastAllOfMatcher<Stmt, SubstNonTypeTemplateParmExpr>
-substNonTypeTemplateParmExpr;
+const internal::VariadicDynCastAllOfMatcher<
+ Stmt,
+ SubstNonTypeTemplateParmExpr> substNonTypeTemplateParmExpr;
/// \brief Matches using declarations.
///
@@ -970,8 +986,9 @@ const internal::VariadicDynCastAllOfMatcher<Decl, UsingDecl> usingDecl;
/// \endcode
/// usingDirectiveDecl()
/// matches \code using namespace X \endcode
-const internal::VariadicDynCastAllOfMatcher<Decl, UsingDirectiveDecl>
- usingDirectiveDecl;
+const internal::VariadicDynCastAllOfMatcher<
+ Decl,
+ UsingDirectiveDecl> usingDirectiveDecl;
/// \brief Matches unresolved using value declarations.
///
@@ -1010,7 +1027,7 @@ const internal::VariadicDynCastAllOfMatcher<
/// \brief Matches constructor call expressions (including implicit ones).
///
/// Example matches string(ptr, n) and ptr within arguments of f
-/// (matcher = constructExpr())
+/// (matcher = cxxConstructExpr())
/// \code
/// void f(const string &a, const string &b);
/// char *ptr;
@@ -1019,43 +1036,43 @@ const internal::VariadicDynCastAllOfMatcher<
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXConstructExpr> constructExpr;
+ CXXConstructExpr> cxxConstructExpr;
/// \brief Matches unresolved constructor call expressions.
///
/// Example matches T(t) in return statement of f
-/// (matcher = unresolvedConstructExpr())
+/// (matcher = cxxUnresolvedConstructExpr())
/// \code
/// template <typename T>
/// void f(const T& t) { return T(t); }
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXUnresolvedConstructExpr> unresolvedConstructExpr;
+ CXXUnresolvedConstructExpr> cxxUnresolvedConstructExpr;
/// \brief Matches implicit and explicit this expressions.
///
/// Example matches the implicit this expression in "return i".
-/// (matcher = thisExpr())
+/// (matcher = cxxThisExpr())
/// \code
/// struct foo {
/// int i;
/// int f() { return i; }
/// };
/// \endcode
-const internal::VariadicDynCastAllOfMatcher<Stmt, CXXThisExpr> thisExpr;
+const internal::VariadicDynCastAllOfMatcher<Stmt, CXXThisExpr> cxxThisExpr;
/// \brief Matches nodes where temporaries are created.
///
/// Example matches FunctionTakesString(GetStringByValue())
-/// (matcher = bindTemporaryExpr())
+/// (matcher = cxxBindTemporaryExpr())
/// \code
/// FunctionTakesString(GetStringByValue());
/// FunctionTakesStringByPointer(GetStringPointer());
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXBindTemporaryExpr> bindTemporaryExpr;
+ CXXBindTemporaryExpr> cxxBindTemporaryExpr;
/// \brief Matches nodes where temporaries are materialized.
///
@@ -1085,9 +1102,9 @@ const internal::VariadicDynCastAllOfMatcher<
/// \code
/// new X;
/// \endcode
-/// newExpr()
+/// cxxNewExpr()
/// matches 'new X'.
-const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNewExpr> newExpr;
+const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNewExpr> cxxNewExpr;
/// \brief Matches delete expressions.
///
@@ -1095,9 +1112,9 @@ const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNewExpr> newExpr;
/// \code
/// delete X;
/// \endcode
-/// deleteExpr()
+/// cxxDeleteExpr()
/// matches 'delete X'.
-const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDeleteExpr> deleteExpr;
+const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDeleteExpr> cxxDeleteExpr;
/// \brief Matches array subscript expressions.
///
@@ -1115,14 +1132,14 @@ const internal::VariadicDynCastAllOfMatcher<
///
/// Example matches the CXXDefaultArgExpr placeholder inserted for the
/// default value of the second parameter in the call expression f(42)
-/// (matcher = defaultArgExpr())
+/// (matcher = cxxDefaultArgExpr())
/// \code
/// void f(int x, int y = 0);
/// f(42);
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXDefaultArgExpr> defaultArgExpr;
+ CXXDefaultArgExpr> cxxDefaultArgExpr;
/// \brief Matches overloaded operator calls.
///
@@ -1132,7 +1149,7 @@ const internal::VariadicDynCastAllOfMatcher<
/// FIXME: figure out why these do not match?
///
/// Example matches both operator<<((o << b), c) and operator<<(o, b)
-/// (matcher = operatorCallExpr())
+/// (matcher = cxxOperatorCallExpr())
/// \code
/// ostream &operator<< (ostream &out, int i) { };
/// ostream &o; int b = 1, c = 1;
@@ -1140,7 +1157,7 @@ const internal::VariadicDynCastAllOfMatcher<
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXOperatorCallExpr> operatorCallExpr;
+ CXXOperatorCallExpr> cxxOperatorCallExpr;
/// \brief Matches expressions.
///
@@ -1207,12 +1224,14 @@ AST_MATCHER_P(ForStmt, hasLoopInit, internal::Matcher<Stmt>,
/// \brief Matches range-based for statements.
///
-/// forRangeStmt() matches 'for (auto a : i)'
+/// cxxForRangeStmt() matches 'for (auto a : i)'
/// \code
/// int i[] = {1, 2, 3}; for (auto a : i);
/// for(int j = 0; j < 5; ++j);
/// \endcode
-const internal::VariadicDynCastAllOfMatcher<Stmt, CXXForRangeStmt> forRangeStmt;
+const internal::VariadicDynCastAllOfMatcher<
+ Stmt,
+ CXXForRangeStmt> cxxForRangeStmt;
/// \brief Matches the initialization statement of a for loop.
///
@@ -1367,27 +1386,27 @@ const internal::VariadicDynCastAllOfMatcher<Stmt, CompoundStmt> compoundStmt;
/// \code
/// try {} catch(int i) {}
/// \endcode
-/// catchStmt()
+/// cxxCatchStmt()
/// matches 'catch(int i)'
-const internal::VariadicDynCastAllOfMatcher<Stmt, CXXCatchStmt> catchStmt;
+const internal::VariadicDynCastAllOfMatcher<Stmt, CXXCatchStmt> cxxCatchStmt;
/// \brief Matches try statements.
///
/// \code
/// try {} catch(int i) {}
/// \endcode
-/// tryStmt()
+/// cxxTryStmt()
/// matches 'try {}'
-const internal::VariadicDynCastAllOfMatcher<Stmt, CXXTryStmt> tryStmt;
+const internal::VariadicDynCastAllOfMatcher<Stmt, CXXTryStmt> cxxTryStmt;
/// \brief Matches throw expressions.
///
/// \code
/// try { throw 5; } catch(int i) {}
/// \endcode
-/// throwExpr()
+/// cxxThrowExpr()
/// matches 'throw 5'
-const internal::VariadicDynCastAllOfMatcher<Stmt, CXXThrowExpr> throwExpr;
+const internal::VariadicDynCastAllOfMatcher<Stmt, CXXThrowExpr> cxxThrowExpr;
/// \brief Matches null statements.
///
@@ -1416,7 +1435,7 @@ const internal::VariadicDynCastAllOfMatcher<Stmt, AsmStmt> asmStmt;
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXBoolLiteralExpr> boolLiteral;
+ CXXBoolLiteralExpr> cxxBoolLiteral;
/// \brief Matches string literals (also matches wide string literals).
///
@@ -1480,7 +1499,7 @@ const internal::VariadicDynCastAllOfMatcher<
/// \brief Matches nullptr literal.
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXNullPtrLiteralExpr> nullPtrLiteralExpr;
+ CXXNullPtrLiteralExpr> cxxNullPtrLiteralExpr;
/// \brief Matches GNU __null expression.
const internal::VariadicDynCastAllOfMatcher<
@@ -1546,7 +1565,7 @@ const internal::VariadicDynCastAllOfMatcher<
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXReinterpretCastExpr> reinterpretCastExpr;
+ CXXReinterpretCastExpr> cxxReinterpretCastExpr;
/// \brief Matches a C++ static_cast expression.
///
@@ -1554,7 +1573,7 @@ const internal::VariadicDynCastAllOfMatcher<
/// \see reinterpretCast
///
/// Example:
-/// staticCastExpr()
+/// cxxStaticCastExpr()
/// matches
/// static_cast<long>(8)
/// in
@@ -1563,12 +1582,12 @@ const internal::VariadicDynCastAllOfMatcher<
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXStaticCastExpr> staticCastExpr;
+ CXXStaticCastExpr> cxxStaticCastExpr;
/// \brief Matches a dynamic_cast expression.
///
/// Example:
-/// dynamicCastExpr()
+/// cxxDynamicCastExpr()
/// matches
/// dynamic_cast<D*>(&b);
/// in
@@ -1579,7 +1598,7 @@ const internal::VariadicDynCastAllOfMatcher<
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXDynamicCastExpr> dynamicCastExpr;
+ CXXDynamicCastExpr> cxxDynamicCastExpr;
/// \brief Matches a const_cast expression.
///
@@ -1591,7 +1610,7 @@ const internal::VariadicDynCastAllOfMatcher<
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXConstCastExpr> constCastExpr;
+ CXXConstCastExpr> cxxConstCastExpr;
/// \brief Matches a C-style cast expression.
///
@@ -1661,7 +1680,7 @@ const internal::VariadicDynCastAllOfMatcher<Stmt, CastExpr> castExpr;
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXFunctionalCastExpr> functionalCastExpr;
+ CXXFunctionalCastExpr> cxxFunctionalCastExpr;
/// \brief Matches functional cast expressions having N != 1 arguments
///
@@ -1671,7 +1690,7 @@ const internal::VariadicDynCastAllOfMatcher<
/// \endcode
const internal::VariadicDynCastAllOfMatcher<
Stmt,
- CXXTemporaryObjectExpr> temporaryObjectExpr;
+ CXXTemporaryObjectExpr> cxxTemporaryObjectExpr;
/// \brief Matches \c QualTypes in the clang AST.
const internal::VariadicAllOfMatcher<QualType> qualType;
@@ -1693,8 +1712,8 @@ const internal::VariadicAllOfMatcher<TypeLoc> typeLoc;
/// \endcode
/// The matcher:
/// \code
-/// recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
-/// has(fieldDecl(hasName("b")).bind("v"))))
+/// cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
+/// has(fieldDecl(hasName("b")).bind("v"))))
/// \endcode
/// will generate two results binding "v", the first of which binds
/// the field declaration of \c a, the second the field declaration of
@@ -1830,9 +1849,10 @@ AST_MATCHER_P(NamedDecl, matchesName, std::string, RegExp) {
/// a << a; // <-- This matches
/// \endcode
///
-/// \c operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified
-/// line and \c recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches
-/// the declaration of \c A.
+/// \c cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the
+/// specified line and
+/// \c cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
+/// matches the declaration of \c A.
///
/// Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl>
inline internal::PolymorphicMatcherWithParam1<
@@ -1901,8 +1921,8 @@ AST_MATCHER_P_OVERLOAD(CXXRecordDecl, isSameOrDerivedFrom, std::string,
/// class B { void member(); };
/// \endcode
///
-/// \c recordDecl(hasMethod(hasName("func"))) matches the declaration of \c A
-/// but not \c B.
+/// \c cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of
+/// \c A but not \c B.
AST_MATCHER_P(CXXRecordDecl, hasMethod, internal::Matcher<CXXMethodDecl>,
InnerMatcher) {
return matchesFirstInPointerRange(InnerMatcher, Node.method_begin(),
@@ -1912,7 +1932,8 @@ AST_MATCHER_P(CXXRecordDecl, hasMethod, internal::Matcher<CXXMethodDecl>,
/// \brief Matches AST nodes that have child AST nodes that match the
/// provided matcher.
///
-/// Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X")))
+/// Example matches X, Y
+/// (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))
/// \code
/// class X {}; // Matches X, because X::X is a class of name X inside X.
/// class Y { class X {}; };
@@ -1929,7 +1950,7 @@ LLVM_ATTRIBUTE_UNUSED has = {};
/// provided matcher.
///
/// Example matches X, Y, Z
-/// (matcher = recordDecl(hasDescendant(recordDecl(hasName("X")))))
+/// (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))
/// \code
/// class X {}; // Matches X, because X::X is a class of name X inside X.
/// class Y { class X {}; };
@@ -1945,7 +1966,8 @@ LLVM_ATTRIBUTE_UNUSED hasDescendant = {};
/// \brief Matches AST nodes that have child AST nodes that match the
/// provided matcher.
///
-/// Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X")))
+/// Example matches X, Y
+/// (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
/// \code
/// class X {}; // Matches X, because X::X is a class of name X inside X.
/// class Y { class X {}; };
@@ -1965,7 +1987,7 @@ LLVM_ATTRIBUTE_UNUSED forEach = {};
/// provided matcher.
///
/// Example matches X, A, B, C
-/// (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X")))))
+/// (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
/// \code
/// class X {}; // Matches X, because X::X is a class of name X inside X.
/// class A { class X {}; };
@@ -1978,7 +2000,9 @@ LLVM_ATTRIBUTE_UNUSED forEach = {};
/// each result that matches instead of only on the first one.
///
/// Note: Recursively combined ForEachDescendant can cause many matches:
-/// recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl()))))
+/// cxxRecordDecl(forEachDescendant(cxxRecordDecl(
+/// forEachDescendant(cxxRecordDecl())
+/// )))
/// will match 10 times (plus injected class name matches) on:
/// \code
/// class A { class B { class C { class D { class E {}; }; }; }; };
@@ -1998,7 +2022,8 @@ LLVM_ATTRIBUTE_UNUSED forEachDescendant = {};
/// \endcode
/// The matcher:
/// \code
-/// recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m")))
+/// cxxRecordDecl(hasName("::A"),
+/// findAll(cxxRecordDecl(isDefinition()).bind("m")))
/// \endcode
/// will generate results for \c A, \c B and \c C.
///
@@ -2039,7 +2064,7 @@ const internal::ArgumentAdaptingMatcherFunc<
/// \brief Matches if the provided matcher does not match.
///
-/// Example matches Y (matcher = recordDecl(unless(hasName("X"))))
+/// Example matches Y (matcher = cxxRecordDecl(unless(hasName("X"))))
/// \code
/// class X {};
/// class Y {};
@@ -2080,7 +2105,7 @@ hasDeclaration(const internal::Matcher<Decl> &InnerMatcher) {
/// \brief Matches on the implicit object argument of a member call expression.
///
/// Example matches y.x()
-/// (matcher = memberCallExpr(on(hasType(recordDecl(hasName("Y"))))))
+/// (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))))))
/// \code
/// class Y { public: void x(); };
/// void z() { Y y; y.x(); }",
@@ -2120,7 +2145,7 @@ AST_MATCHER_P(ObjCMessageExpr, hasReceiverType, internal::Matcher<QualType>,
/// \code
/// [self.bodyView loadHTMLString:html baseURL:NULL];
/// \endcode
- AST_MATCHER_P(ObjCMessageExpr, hasSelector, std::string, BaseName) {
+AST_MATCHER_P(ObjCMessageExpr, hasSelector, std::string, BaseName) {
Selector Sel = Node.getSelector();
return BaseName.compare(Sel.getAsString()) == 0;
}
@@ -2173,7 +2198,6 @@ AST_MATCHER(ObjCMessageExpr, hasUnarySelector) {
/// webView.frame = bodyFrame;
/// // ^---- matches here
/// \endcode
-
AST_MATCHER(ObjCMessageExpr, hasKeywordSelector) {
return Node.getSelector().isKeywordSelector();
}
@@ -2219,7 +2243,8 @@ AST_MATCHER_P(CallExpr, callee, internal::Matcher<Stmt>,
/// \brief Matches if the call expression's callee's declaration matches the
/// given matcher.
///
-/// Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x")))))
+/// Example matches y.x() (matcher = callExpr(callee(
+/// cxxMethodDecl(hasName("x")))))
/// \code
/// class Y { public: void x(); };
/// void z() { Y y; y.x(); }
@@ -2232,8 +2257,8 @@ AST_MATCHER_P_OVERLOAD(CallExpr, callee, internal::Matcher<Decl>, InnerMatcher,
/// \brief Matches if the expression's or declaration's type matches a type
/// matcher.
///
-/// Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
-/// and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
+/// Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
+/// and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
/// \code
/// class X {};
/// void y(X &x) { x; X z; }
@@ -2249,12 +2274,12 @@ AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
///
/// In case of a value declaration (for example a variable declaration),
/// this resolves one layer of indirection. For example, in the value
-/// declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
-/// while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
-/// of x."
+/// declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
+/// X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
+/// declaration of x.
///
-/// Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
-/// and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
+/// Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
+/// and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
/// \code
/// class X {};
/// void y(X &x) { x; X z; }
@@ -2292,7 +2317,7 @@ AST_MATCHER_P(DeclaratorDecl, hasTypeLoc, internal::Matcher<TypeLoc>, Inner) {
/// class Y { public: void x(); };
/// void z() { Y* y; y->x(); }
/// \endcode
-/// memberCallExpr(on(hasType(asString("class Y *"))))
+/// cxxMemberCallExpr(on(hasType(asString("class Y *"))))
/// matches y->x()
AST_MATCHER_P(QualType, asString, std::string, Name) {
return Name == Node.getAsString();
@@ -2302,8 +2327,8 @@ AST_MATCHER_P(QualType, asString, std::string, Name) {
/// matches the specified matcher.
///
/// Example matches y->x()
-/// (matcher = memberCallExpr(on(hasType(pointsTo
-/// recordDecl(hasName("Y")))))))
+/// (matcher = cxxMemberCallExpr(on(hasType(pointsTo
+/// cxxRecordDecl(hasName("Y")))))))
/// \code
/// class Y { public: void x(); };
/// void z() { Y *y; y->x(); }
@@ -2326,7 +2351,7 @@ AST_MATCHER_P_OVERLOAD(QualType, pointsTo, internal::Matcher<Decl>,
/// type matches the specified matcher.
///
/// Example matches X &x and const X &y
-/// (matcher = varDecl(hasType(references(recordDecl(hasName("X"))))))
+/// (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X"))))))
/// \code
/// class X {
/// void a(X b) {
@@ -2596,7 +2621,7 @@ AST_MATCHER_P2(DeclStmt, containsDeclaration, unsigned, N,
/// // ...
/// }
/// /endcode
-/// catchStmt(isCatchAll()) matches catch(...) but not catch(int).
+/// cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
AST_MATCHER(CXXCatchStmt, isCatchAll) {
return Node.getExceptionDecl() == nullptr;
}
@@ -2610,7 +2635,9 @@ AST_MATCHER(CXXCatchStmt, isCatchAll) {
/// int foo_;
/// };
/// \endcode
-/// recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything()))))
+/// cxxRecordDecl(has(cxxConstructorDecl(
+/// hasAnyConstructorInitializer(anything())
+/// )))
/// record matches Foo, hasAnyConstructorInitializer matches foo_(1)
AST_MATCHER_P(CXXConstructorDecl, hasAnyConstructorInitializer,
internal::Matcher<CXXCtorInitializer>, InnerMatcher) {
@@ -2627,7 +2654,7 @@ AST_MATCHER_P(CXXConstructorDecl, hasAnyConstructorInitializer,
/// int foo_;
/// };
/// \endcode
-/// recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
+/// cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
/// forField(hasName("foo_"))))))
/// matches Foo
/// with forField matching foo_
@@ -2647,7 +2674,7 @@ AST_MATCHER_P(CXXCtorInitializer, forField,
/// int foo_;
/// };
/// \endcode
-/// recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
+/// cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
/// withInitializer(integerLiteral(equals(1)))))))
/// matches Foo
/// with withInitializer matching (1)
@@ -2669,7 +2696,7 @@ AST_MATCHER_P(CXXCtorInitializer, withInitializer,
/// string foo_;
/// };
/// \endcode
-/// constructorDecl(hasAnyConstructorInitializer(isWritten()))
+/// cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
/// will match Foo(int), but not Foo()
AST_MATCHER(CXXCtorInitializer, isWritten) {
return Node.isWritten();
@@ -2689,7 +2716,7 @@ AST_MATCHER(CXXCtorInitializer, isWritten) {
/// E() : B() {}
/// };
/// \endcode
-/// constructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
+/// cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
/// will match E(), but not match D(int).
AST_MATCHER(CXXCtorInitializer, isBaseInitializer) {
return Node.isBaseInitializer();
@@ -2709,7 +2736,7 @@ AST_MATCHER(CXXCtorInitializer, isBaseInitializer) {
/// E() : B() {}
/// };
/// \endcode
-/// constructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
+/// cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
/// will match D(int), but not match E().
AST_MATCHER(CXXCtorInitializer, isMemberInitializer) {
return Node.isMemberInitializer();
@@ -2756,7 +2783,7 @@ AST_MATCHER(CXXConstructExpr, isListInitialization) {
/// \code
/// class X { void f(int x) {} };
/// \endcode
-/// methodDecl(hasParameter(0, hasType(varDecl())))
+/// cxxMethodDecl(hasParameter(0, hasType(varDecl())))
/// matches f(int x) {}
/// with hasParameter(...)
/// matching int x
@@ -2776,7 +2803,7 @@ AST_MATCHER_P2(FunctionDecl, hasParameter,
/// \code
/// class X { void f(int x, int y, int z) {} };
/// \endcode
-/// methodDecl(hasAnyParameter(hasName("y")))
+/// cxxMethodDecl(hasAnyParameter(hasName("y")))
/// matches f(int x, int y, int z) {}
/// with hasAnyParameter(...)
/// matching int y
@@ -2805,7 +2832,7 @@ AST_MATCHER_P(FunctionDecl, parameterCountIs, unsigned, N) {
/// \code
/// class X { int f() { return 1; } };
/// \endcode
-/// methodDecl(returns(asString("int")))
+/// cxxMethodDecl(returns(asString("int")))
/// matches int f() { return 1; }
AST_MATCHER_P(FunctionDecl, returns,
internal::Matcher<QualType>, InnerMatcher) {
@@ -2859,7 +2886,7 @@ AST_POLYMORPHIC_MATCHER(isConstexpr,
/// \brief Matches the condition expression of an if statement, for loop,
/// or conditional operator.
///
-/// Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
+/// Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
/// \code
/// if (true) {}
/// \endcode
@@ -2876,7 +2903,7 @@ AST_POLYMORPHIC_MATCHER_P(hasCondition,
/// \brief Matches the then-statement of an if statement.
///
/// Examples matches the if statement
-/// (matcher = ifStmt(hasThen(boolLiteral(equals(true)))))
+/// (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))
/// \code
/// if (false) true; else false;
/// \endcode
@@ -2888,7 +2915,7 @@ AST_MATCHER_P(IfStmt, hasThen, internal::Matcher<Stmt>, InnerMatcher) {
/// \brief Matches the else-statement of an if statement.
///
/// Examples matches the if statement
-/// (matcher = ifStmt(hasElse(boolLiteral(equals(true)))))
+/// (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))
/// \code
/// if (false) false; else true;
/// \endcode
@@ -2905,7 +2932,7 @@ AST_MATCHER_P(IfStmt, hasElse, internal::Matcher<Stmt>, InnerMatcher) {
/// \code
/// class X { int a; int b; };
/// \endcode
-/// recordDecl(
+/// cxxRecordDecl(
/// has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
/// has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
/// matches the class \c X, as \c a and \c b have the same type.
@@ -3037,7 +3064,7 @@ AST_MATCHER_P(CompoundStmt, statementCountIs, unsigned, N) {
/// \brief Matches literals that are equal to the given value.
///
-/// Example matches true (matcher = boolLiteral(equals(true)))
+/// Example matches true (matcher = cxxBoolLiteral(equals(true)))
/// \code
/// true
/// \endcode
@@ -3101,7 +3128,8 @@ inline internal::Matcher<BinaryOperator> hasEitherOperand(
/// \brief Matches if the operand of a unary operator matches.
///
-/// Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true))))
+/// Example matches true (matcher = hasUnaryOperand(
+/// cxxBoolLiteral(equals(true))))
/// \code
/// !true
/// \endcode
@@ -3115,7 +3143,7 @@ AST_MATCHER_P(UnaryOperator, hasUnaryOperand,
/// \brief Matches if the cast's source expression matches the given matcher.
///
/// Example: matches "a string" (matcher =
-/// hasSourceExpression(constructExpr()))
+/// hasSourceExpression(cxxConstructExpr()))
/// \code
/// class URL { URL(string); };
/// URL url = "a string";
@@ -3146,6 +3174,42 @@ AST_MATCHER_P(ImplicitCastExpr, hasImplicitDestinationType,
return InnerMatcher.matches(Node.getType(), Finder, Builder);
}
+/// \brief Matches RecordDecl object that are spelled with "struct."
+///
+/// Example matches S, but not C or U.
+/// \code
+/// struct S {};
+/// class C {};
+/// union U {};
+/// \endcode
+AST_MATCHER(RecordDecl, isStruct) {
+ return Node.isStruct();
+}
+
+/// \brief Matches RecordDecl object that are spelled with "union."
+///
+/// Example matches U, but not C or S.
+/// \code
+/// struct S {};
+/// class C {};
+/// union U {};
+/// \endcode
+AST_MATCHER(RecordDecl, isUnion) {
+ return Node.isUnion();
+}
+
+/// \brief Matches RecordDecl object that are spelled with "class."
+///
+/// Example matches C, but not S or U.
+/// \code
+/// struct S {};
+/// class C {};
+/// union U {};
+/// \endcode
+AST_MATCHER(RecordDecl, isClass) {
+ return Node.isClass();
+}
+
/// \brief Matches the true branch expression of a conditional operator.
///
/// Example matches a
@@ -3199,7 +3263,7 @@ AST_POLYMORPHIC_MATCHER(isDefinition,
/// this to?
///
/// Example matches A() in the last line
-/// (matcher = constructExpr(hasDeclaration(methodDecl(
+/// (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
/// ofClass(hasName("A"))))))
/// \code
/// class A {
@@ -3274,7 +3338,7 @@ AST_MATCHER(CXXMethodDecl, isPure) {
/// };
/// \endcode
///
-/// methodDecl(isConst()) matches A::foo() but not A::bar()
+/// cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
AST_MATCHER(CXXMethodDecl, isConst) {
return Node.isConst();
}
@@ -3391,7 +3455,7 @@ AST_MATCHER_P(MemberExpr, member,
/// struct X { int m; };
/// void f(X x) { x.m; m; }
/// \endcode
-/// memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))))
+/// memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))))
/// matches "x.m" and "m"
/// with hasObjectExpression(...)
/// matching "x" and the implicit object expression of "m" which has type X*.
@@ -3443,7 +3507,7 @@ AST_MATCHER_P(UsingShadowDecl, hasTargetDecl,
/// \code
/// template <typename T> class X {}; class A {}; template class X<A>;
/// \endcode
-/// recordDecl(hasName("::X"), isTemplateInstantiation())
+/// cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
/// matches the template instantiation of X<A>.
///
/// But given
@@ -3451,7 +3515,7 @@ AST_MATCHER_P(UsingShadowDecl, hasTargetDecl,
/// template <typename T> class X {}; class A {};
/// template <> class X<A> {}; X<A> x;
/// \endcode
-/// recordDecl(hasName("::X"), isTemplateInstantiation())
+/// cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
/// does not match, as X<A> is an explicit template specialization.
///
/// Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
@@ -3475,7 +3539,7 @@ AST_POLYMORPHIC_MATCHER(isTemplateInstantiation,
/// functionDecl(isInstantiated())
/// matches 'A(int) {...};' and 'A(unsigned) {...}'.
AST_MATCHER_FUNCTION(internal::Matcher<Decl>, isInstantiated) {
- auto IsInstantiation = decl(anyOf(recordDecl(isTemplateInstantiation()),
+ auto IsInstantiation = decl(anyOf(cxxRecordDecl(isTemplateInstantiation()),
functionDecl(isTemplateInstantiation())));
return decl(anyOf(IsInstantiation, hasAncestor(IsInstantiation)));
}
@@ -3496,7 +3560,7 @@ AST_MATCHER_FUNCTION(internal::Matcher<Decl>, isInstantiated) {
/// instantiation.
AST_MATCHER_FUNCTION(internal::Matcher<Stmt>, isInTemplateInstantiation) {
return stmt(
- hasAncestor(decl(anyOf(recordDecl(isTemplateInstantiation()),
+ hasAncestor(decl(anyOf(cxxRecordDecl(isTemplateInstantiation()),
functionDecl(isTemplateInstantiation())))));
}
@@ -4045,7 +4109,7 @@ AST_TYPE_MATCHER(InjectedClassNameType, injectedClassNameType);
/// }
/// \endcode
///
-/// \c recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
+/// \c cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
/// declaration of \c class \c D.
AST_MATCHER_P(Decl, hasDeclContext, internal::Matcher<Decl>, InnerMatcher) {
const DeclContext *DC = Node.getDeclContext();
@@ -4090,7 +4154,9 @@ AST_MATCHER_FUNCTION_P_OVERLOAD(
/// struct A { struct B { struct C {}; }; };
/// A::B::C c;
/// \endcode
-/// nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A")))))
+/// nestedNameSpecifier(specifiesType(
+/// hasDeclaration(cxxRecordDecl(hasName("A")))
+/// ))
/// matches "A::"
AST_MATCHER_P(NestedNameSpecifier, specifiesType,
internal::Matcher<QualType>, InnerMatcher) {
@@ -4108,7 +4174,7 @@ AST_MATCHER_P(NestedNameSpecifier, specifiesType,
/// A::B::C c;
/// \endcode
/// nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
-/// hasDeclaration(recordDecl(hasName("A")))))))
+/// hasDeclaration(cxxRecordDecl(hasName("A")))))))
/// matches "A::"
AST_MATCHER_P(NestedNameSpecifierLoc, specifiesTypeLoc,
internal::Matcher<TypeLoc>, InnerMatcher) {
@@ -4226,7 +4292,9 @@ AST_MATCHER_P(SwitchStmt, forEachSwitchCase, internal::Matcher<SwitchCase>,
/// \code
/// class A { A() : i(42), j(42) {} int i; int j; };
/// \endcode
-/// constructorDecl(forEachConstructorInitializer(forField(decl().bind("x"))))
+/// cxxConstructorDecl(forEachConstructorInitializer(
+/// forField(decl().bind("x"))
+/// ))
/// will trigger two matches, binding for 'i' and 'j' respectively.
AST_MATCHER_P(CXXConstructorDecl, forEachConstructorInitializer,
internal::Matcher<CXXCtorInitializer>, InnerMatcher) {
@@ -4253,7 +4321,7 @@ AST_MATCHER_P(CXXConstructorDecl, forEachConstructorInitializer,
/// S(S &&); // #3
/// };
/// \endcode
-/// constructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
+/// cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
AST_MATCHER(CXXConstructorDecl, isCopyConstructor) {
return Node.isCopyConstructor();
}
@@ -4268,7 +4336,7 @@ AST_MATCHER(CXXConstructorDecl, isCopyConstructor) {
/// S(S &&); // #3
/// };
/// \endcode
-/// constructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
+/// cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
AST_MATCHER(CXXConstructorDecl, isMoveConstructor) {
return Node.isMoveConstructor();
}
@@ -4283,7 +4351,7 @@ AST_MATCHER(CXXConstructorDecl, isMoveConstructor) {
/// S(S &&); // #3
/// };
/// \endcode
-/// constructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
+/// cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
AST_MATCHER(CXXConstructorDecl, isDefaultConstructor) {
return Node.isDefaultConstructor();
}
@@ -4300,8 +4368,8 @@ AST_MATCHER(CXXConstructorDecl, isDefaultConstructor) {
/// explicit operator bool(); // #4
/// };
/// \endcode
-/// constructorDecl(isExplicit()) will match #2, but not #1.
-/// conversionDecl(isExplicit()) will match #4, but not #3.
+/// cxxConstructorDecl(isExplicit()) will match #2, but not #1.
+/// cxxConversionDecl(isExplicit()) will match #4, but not #3.
AST_POLYMORPHIC_MATCHER(isExplicit,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXConstructorDecl,
CXXConversionDecl)) {
@@ -4386,8 +4454,9 @@ AST_MATCHER_P(Decl, hasAttr, attr::Kind, AttrKind) {
/// \code
/// kernel<<<i,j>>>();
/// \endcode
-const internal::VariadicDynCastAllOfMatcher<Stmt, CUDAKernelCallExpr>
- CUDAKernelCallExpr;
+const internal::VariadicDynCastAllOfMatcher<
+ Stmt,
+ CUDAKernelCallExpr> cudaKernelCallExpr;
} // end namespace ast_matchers
} // end namespace clang
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 6b44ef7e5b2..67a9d8abbb4 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -107,15 +107,12 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(atomicType);
REGISTER_MATCHER(autoType);
REGISTER_MATCHER(binaryOperator);
- REGISTER_MATCHER(bindTemporaryExpr);
REGISTER_MATCHER(blockPointerType);
- REGISTER_MATCHER(boolLiteral);
REGISTER_MATCHER(breakStmt);
REGISTER_MATCHER(builtinType);
REGISTER_MATCHER(callExpr);
REGISTER_MATCHER(caseStmt);
REGISTER_MATCHER(castExpr);
- REGISTER_MATCHER(catchStmt);
REGISTER_MATCHER(characterLiteral);
REGISTER_MATCHER(classTemplateDecl);
REGISTER_MATCHER(classTemplateSpecializationDecl);
@@ -124,27 +121,45 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(compoundStmt);
REGISTER_MATCHER(conditionalOperator);
REGISTER_MATCHER(constantArrayType);
- REGISTER_MATCHER(constCastExpr);
- REGISTER_MATCHER(constructExpr);
- REGISTER_MATCHER(constructorDecl);
REGISTER_MATCHER(containsDeclaration);
REGISTER_MATCHER(continueStmt);
- REGISTER_MATCHER(conversionDecl);
REGISTER_MATCHER(cStyleCastExpr);
- REGISTER_MATCHER(ctorInitializer);
- REGISTER_MATCHER(CUDAKernelCallExpr);
+ REGISTER_MATCHER(cudaKernelCallExpr);
+ REGISTER_MATCHER(cxxBindTemporaryExpr);
+ REGISTER_MATCHER(cxxBoolLiteral);
+ REGISTER_MATCHER(cxxCatchStmt);
+ REGISTER_MATCHER(cxxConstCastExpr);
+ REGISTER_MATCHER(cxxConstructExpr);
+ REGISTER_MATCHER(cxxConstructorDecl);
+ REGISTER_MATCHER(cxxConversionDecl);
+ REGISTER_MATCHER(cxxCtorInitializer);
+ REGISTER_MATCHER(cxxDefaultArgExpr);
+ REGISTER_MATCHER(cxxDeleteExpr);
+ REGISTER_MATCHER(cxxDestructorDecl);
+ REGISTER_MATCHER(cxxDynamicCastExpr);
+ REGISTER_MATCHER(cxxForRangeStmt);
+ REGISTER_MATCHER(cxxFunctionalCastExpr);
+ REGISTER_MATCHER(cxxMemberCallExpr);
+ REGISTER_MATCHER(cxxMethodDecl);
+ REGISTER_MATCHER(cxxNewExpr);
+ REGISTER_MATCHER(cxxNullPtrLiteralExpr);
+ REGISTER_MATCHER(cxxOperatorCallExpr);
+ REGISTER_MATCHER(cxxRecordDecl);
+ REGISTER_MATCHER(cxxReinterpretCastExpr);
+ REGISTER_MATCHER(cxxStaticCastExpr);
+ REGISTER_MATCHER(cxxTemporaryObjectExpr);
+ REGISTER_MATCHER(cxxThisExpr);
+ REGISTER_MATCHER(cxxThrowExpr);
+ REGISTER_MATCHER(cxxTryStmt);
+ REGISTER_MATCHER(cxxUnresolvedConstructExpr);
REGISTER_MATCHER(decl);
REGISTER_MATCHER(declaratorDecl);
REGISTER_MATCHER(declCountIs);
REGISTER_MATCHER(declRefExpr);
REGISTER_MATCHER(declStmt);
- REGISTER_MATCHER(defaultArgExpr);
REGISTER_MATCHER(defaultStmt);
- REGISTER_MATCHER(deleteExpr);
REGISTER_MATCHER(dependentSizedArrayType);
- REGISTER_MATCHER(destructorDecl);
REGISTER_MATCHER(doStmt);
- REGISTER_MATCHER(dynamicCastExpr);
REGISTER_MATCHER(eachOf);
REGISTER_MATCHER(elaboratedType);
REGISTER_MATCHER(enumConstantDecl);
@@ -161,10 +176,8 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(forEachDescendant);
REGISTER_MATCHER(forEachSwitchCase);
REGISTER_MATCHER(forField);
- REGISTER_MATCHER(forRangeStmt);
REGISTER_MATCHER(forStmt);
REGISTER_MATCHER(friendDecl);
- REGISTER_MATCHER(functionalCastExpr);
REGISTER_MATCHER(functionDecl);
REGISTER_MATCHER(functionTemplateDecl);
REGISTER_MATCHER(functionType);
@@ -245,6 +258,7 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(isArrow);
REGISTER_MATCHER(isBaseInitializer);
REGISTER_MATCHER(isCatchAll);
+ REGISTER_MATCHER(isClass);
REGISTER_MATCHER(isConst);
REGISTER_MATCHER(isConstQualified);
REGISTER_MATCHER(isCopyConstructor);
@@ -274,7 +288,9 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(isProtected);
REGISTER_MATCHER(isPublic);
REGISTER_MATCHER(isPure);
+ REGISTER_MATCHER(isStruct);
REGISTER_MATCHER(isTemplateInstantiation);
+ REGISTER_MATCHER(isUnion);
REGISTER_MATCHER(isVirtual);
REGISTER_MATCHER(isWritten);
REGISTER_MATCHER(labelStmt);
@@ -284,18 +300,14 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(matchesSelector);
REGISTER_MATCHER(materializeTemporaryExpr);
REGISTER_MATCHER(member);
- REGISTER_MATCHER(memberCallExpr);
REGISTER_MATCHER(memberExpr);
REGISTER_MATCHER(memberPointerType);
- REGISTER_MATCHER(methodDecl);
REGISTER_MATCHER(namedDecl);
REGISTER_MATCHER(namespaceAliasDecl);
REGISTER_MATCHER(namespaceDecl);
REGISTER_MATCHER(namesType);
REGISTER_MATCHER(nestedNameSpecifier);
REGISTER_MATCHER(nestedNameSpecifierLoc);
- REGISTER_MATCHER(newExpr);
- REGISTER_MATCHER(nullPtrLiteralExpr);
REGISTER_MATCHER(nullStmt);
REGISTER_MATCHER(numSelectorArgs);
REGISTER_MATCHER(ofClass);
@@ -304,7 +316,6 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(objcObjectPointerType);
REGISTER_MATCHER(on);
REGISTER_MATCHER(onImplicitObjectArgument);
- REGISTER_MATCHER(operatorCallExpr);
REGISTER_MATCHER(parameterCountIs);
REGISTER_MATCHER(parenType);
REGISTER_MATCHER(parmVarDecl);
@@ -317,7 +328,6 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(refersToDeclaration);
REGISTER_MATCHER(refersToIntegralType);
REGISTER_MATCHER(refersToType);
- REGISTER_MATCHER(reinterpretCastExpr);
REGISTER_MATCHER(returns);
REGISTER_MATCHER(returnStmt);
REGISTER_MATCHER(rValueReferenceType);
@@ -326,7 +336,6 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(specifiesType);
REGISTER_MATCHER(specifiesTypeLoc);
REGISTER_MATCHER(statementCountIs);
- REGISTER_MATCHER(staticCastExpr);
REGISTER_MATCHER(staticAssertDecl);
REGISTER_MATCHER(stmt);
REGISTER_MATCHER(stringLiteral);
@@ -338,13 +347,9 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(templateArgumentCountIs);
REGISTER_MATCHER(templateSpecializationType);
REGISTER_MATCHER(templateTypeParmType);
- REGISTER_MATCHER(temporaryObjectExpr);
- REGISTER_MATCHER(thisExpr);
REGISTER_MATCHER(throughUsingDecl);
- REGISTER_MATCHER(throwExpr);
REGISTER_MATCHER(to);
REGISTER_MATCHER(translationUnitDecl);
- REGISTER_MATCHER(tryStmt);
REGISTER_MATCHER(type);
REGISTER_MATCHER(typedefDecl);
REGISTER_MATCHER(typedefType);
@@ -353,7 +358,6 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(unaryOperator);
REGISTER_MATCHER(unaryTransformType);
REGISTER_MATCHER(unless);
- REGISTER_MATCHER(unresolvedConstructExpr);
REGISTER_MATCHER(unresolvedUsingTypenameDecl);
REGISTER_MATCHER(unresolvedUsingValueDecl);
REGISTER_MATCHER(userDefinedLiteral);
diff --git a/clang/unittests/AST/ASTContextParentMapTest.cpp b/clang/unittests/AST/ASTContextParentMapTest.cpp
index 0dcb175e07b..94e9735654c 100644
--- a/clang/unittests/AST/ASTContextParentMapTest.cpp
+++ b/clang/unittests/AST/ASTContextParentMapTest.cpp
@@ -27,8 +27,9 @@ using clang::tooling::FrontendActionFactory;
TEST(GetParents, ReturnsParentForDecl) {
MatchVerifier<Decl> Verifier;
- EXPECT_TRUE(Verifier.match("class C { void f(); };",
- methodDecl(hasParent(recordDecl(hasName("C"))))));
+ EXPECT_TRUE(
+ Verifier.match("class C { void f(); };",
+ cxxMethodDecl(hasParent(recordDecl(hasName("C"))))));
}
TEST(GetParents, ReturnsParentForStmt) {
@@ -42,19 +43,20 @@ TEST(GetParents, ReturnsParentInsideTemplateInstantiations) {
EXPECT_TRUE(DeclVerifier.match(
"template<typename T> struct C { void f() {} };"
"void g() { C<int> c; c.f(); }",
- methodDecl(hasName("f"),
- hasParent(recordDecl(isTemplateInstantiation())))));
+ cxxMethodDecl(hasName("f"),
+ hasParent(cxxRecordDecl(isTemplateInstantiation())))));
EXPECT_TRUE(DeclVerifier.match(
"template<typename T> struct C { void f() {} };"
"void g() { C<int> c; c.f(); }",
- methodDecl(hasName("f"),
- hasParent(recordDecl(unless(isTemplateInstantiation()))))));
+ cxxMethodDecl(hasName("f"),
+ hasParent(cxxRecordDecl(unless(isTemplateInstantiation()))))));
EXPECT_FALSE(DeclVerifier.match(
"template<typename T> struct C { void f() {} };"
"void g() { C<int> c; c.f(); }",
- methodDecl(hasName("f"),
- allOf(hasParent(recordDecl(unless(isTemplateInstantiation()))),
- hasParent(recordDecl(isTemplateInstantiation()))))));
+ cxxMethodDecl(
+ hasName("f"),
+ allOf(hasParent(cxxRecordDecl(unless(isTemplateInstantiation()))),
+ hasParent(cxxRecordDecl(isTemplateInstantiation()))))));
}
TEST(GetParents, ReturnsMultipleParentsInTemplateInstantiations) {
@@ -62,9 +64,9 @@ TEST(GetParents, ReturnsMultipleParentsInTemplateInstantiations) {
EXPECT_TRUE(TemplateVerifier.match(
"template<typename T> struct C { void f() {} };"
"void g() { C<int> c; c.f(); }",
- compoundStmt(
- allOf(hasAncestor(recordDecl(isTemplateInstantiation())),
- hasAncestor(recordDecl(unless(isTemplateInstantiation())))))));
+ compoundStmt(allOf(
+ hasAncestor(cxxRecordDecl(isTemplateInstantiation())),
+ hasAncestor(cxxRecordDecl(unless(isTemplateInstantiation())))))));
}
} // end namespace ast_matchers
diff --git a/clang/unittests/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp
index d8cb9770922..d06fbfea6f5 100644
--- a/clang/unittests/AST/DeclPrinterTest.cpp
+++ b/clang/unittests/AST/DeclPrinterTest.cpp
@@ -471,7 +471,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl1) {
"struct A {"
" A();"
"};",
- constructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxConstructorDecl(ofClass(hasName("A"))).bind("id"),
"A()"));
}
@@ -480,7 +480,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl2) {
"struct A {"
" A(int a);"
"};",
- constructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxConstructorDecl(ofClass(hasName("A"))).bind("id"),
"A(int a)"));
}
@@ -489,7 +489,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl3) {
"struct A {"
" A(const A &a);"
"};",
- constructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxConstructorDecl(ofClass(hasName("A"))).bind("id"),
"A(const A &a)"));
}
@@ -498,7 +498,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl4) {
"struct A {"
" A(const A &a, int = 0);"
"};",
- constructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxConstructorDecl(ofClass(hasName("A"))).bind("id"),
"A(const A &a, int = 0)"));
}
@@ -507,7 +507,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl5) {
"struct A {"
" A(const A &&a);"
"};",
- constructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxConstructorDecl(ofClass(hasName("A"))).bind("id"),
"A(const A &&a)"));
}
@@ -516,7 +516,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl6) {
"struct A {"
" explicit A(int a);"
"};",
- constructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxConstructorDecl(ofClass(hasName("A"))).bind("id"),
"explicit A(int a)"));
}
@@ -525,7 +525,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl7) {
"struct A {"
" constexpr A();"
"};",
- constructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxConstructorDecl(ofClass(hasName("A"))).bind("id"),
"constexpr A()"));
}
@@ -534,7 +534,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl8) {
"struct A {"
" A() = default;"
"};",
- constructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxConstructorDecl(ofClass(hasName("A"))).bind("id"),
"A() = default"));
}
@@ -543,7 +543,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl9) {
"struct A {"
" A() = delete;"
"};",
- constructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxConstructorDecl(ofClass(hasName("A"))).bind("id"),
"A() = delete"));
}
@@ -553,7 +553,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl10) {
"struct A {"
" A(const A &a);"
"};",
- constructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxConstructorDecl(ofClass(hasName("A"))).bind("id"),
"A<T...>(const A<T...> &a)"));
// WRONG; Should be: "A(const A<T...> &a);"
}
@@ -564,7 +564,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl11) {
"struct A : public T... {"
" A(T&&... ts) : T(ts)... {}"
"};",
- constructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxConstructorDecl(ofClass(hasName("A"))).bind("id"),
"A<T...>(T &&...ts) : T(ts)..."));
// WRONG; Should be: "A(T &&...ts) : T(ts)... {}"
}
@@ -574,7 +574,7 @@ TEST(DeclPrinter, TestCXXDestructorDecl1) {
"struct A {"
" ~A();"
"};",
- destructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxDestructorDecl(ofClass(hasName("A"))).bind("id"),
"~A()"));
}
@@ -583,7 +583,7 @@ TEST(DeclPrinter, TestCXXDestructorDecl2) {
"struct A {"
" virtual ~A();"
"};",
- destructorDecl(ofClass(hasName("A"))).bind("id"),
+ cxxDestructorDecl(ofClass(hasName("A"))).bind("id"),
"virtual ~A()"));
}
@@ -592,7 +592,7 @@ TEST(DeclPrinter, TestCXXConversionDecl1) {
"struct A {"
" operator int();"
"};",
- methodDecl(ofClass(hasName("A"))).bind("id"),
+ cxxMethodDecl(ofClass(hasName("A"))).bind("id"),
"operator int()"));
}
@@ -601,7 +601,7 @@ TEST(DeclPrinter, TestCXXConversionDecl2) {
"struct A {"
" operator bool();"
"};",
- methodDecl(ofClass(hasName("A"))).bind("id"),
+ cxxMethodDecl(ofClass(hasName("A"))).bind("id"),
"operator bool()"));
}
@@ -611,7 +611,7 @@ TEST(DeclPrinter, TestCXXConversionDecl3) {
"struct A {"
" operator Z();"
"};",
- methodDecl(ofClass(hasName("A"))).bind("id"),
+ cxxMethodDecl(ofClass(hasName("A"))).bind("id"),
"operator Z()"));
}
@@ -621,7 +621,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction1) {
"struct Z {"
" void *operator new(std::size_t);"
"};",
- methodDecl(ofClass(hasName("Z"))).bind("id"),
+ cxxMethodDecl(ofClass(hasName("Z"))).bind("id"),
"void *operator new(std::size_t)"));
// Should be: with semicolon
}
@@ -632,7 +632,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction2) {
"struct Z {"
" void *operator new[](std::size_t);"
"};",
- methodDecl(ofClass(hasName("Z"))).bind("id"),
+ cxxMethodDecl(ofClass(hasName("Z"))).bind("id"),
"void *operator new[](std::size_t)"));
// Should be: with semicolon
}
@@ -642,7 +642,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction3) {
"struct Z {"
" void operator delete(void *);"
"};",
- methodDecl(ofClass(hasName("Z"))).bind("id"),
+ cxxMethodDecl(ofClass(hasName("Z"))).bind("id"),
"void operator delete(void *) noexcept"));
// Should be: with semicolon, without noexcept?
}
@@ -652,7 +652,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction4) {
"struct Z {"
" void operator delete(void *);"
"};",
- methodDecl(ofClass(hasName("Z"))).bind("id"),
+ cxxMethodDecl(ofClass(hasName("Z"))).bind("id"),
"void operator delete(void *)"));
// Should be: with semicolon
}
@@ -662,7 +662,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction5) {
"struct Z {"
" void operator delete[](void *);"
"};",
- methodDecl(ofClass(hasName("Z"))).bind("id"),
+ cxxMethodDecl(ofClass(hasName("Z"))).bind("id"),
"void operator delete[](void *) noexcept"));
// Should be: with semicolon, without noexcept?
}
@@ -690,7 +690,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_Operator1) {
ASSERT_TRUE(PrintedDeclCXX98Matches(
Code,
- methodDecl(ofClass(hasName("Z"))).bind("id"),
+ cxxMethodDecl(ofClass(hasName("Z"))).bind("id"),
Expected));
}
}
@@ -714,7 +714,7 @@ TEST(DeclPrinter, TestCXXMethodDecl_Operator2) {
ASSERT_TRUE(PrintedDeclCXX98Matches(
Code,
- methodDecl(ofClass(hasName("Z"))).bind("id"),
+ cxxMethodDecl(ofClass(hasName("Z"))).bind("id"),
Expected));
}
}
diff --git a/clang/unittests/AST/SourceLocationTest.cpp b/clang/unittests/AST/SourceLocationTest.cpp
index b0a8f85f0e4..4c77def61bc 100644
--- a/clang/unittests/AST/SourceLocationTest.cpp
+++ b/clang/unittests/AST/SourceLocationTest.cpp
@@ -92,13 +92,13 @@ TEST(ParmVarDecl, KNRRange) {
TEST(CXXNewExpr, ArrayRange) {
RangeVerifier<CXXNewExpr> Verifier;
Verifier.expectRange(1, 12, 1, 22);
- EXPECT_TRUE(Verifier.match("void f() { new int[10]; }", newExpr()));
+ EXPECT_TRUE(Verifier.match("void f() { new int[10]; }", cxxNewExpr()));
}
TEST(CXXNewExpr, ParenRange) {
RangeVerifier<CXXNewExpr> Verifier;
Verifier.expectRange(1, 12, 1, 20);
- EXPECT_TRUE(Verifier.match("void f() { new int(); }", newExpr()));
+ EXPECT_TRUE(Verifier.match("void f() { new int(); }", cxxNewExpr()));
}
TEST(MemberExpr, ImplicitMemberRange) {
@@ -221,7 +221,7 @@ TEST(TemplateSpecializationTypeLoc, AngleBracketLocations) {
TEST(CXXNewExpr, TypeParenRange) {
RangeVerifier<CXXNewExpr> Verifier;
Verifier.expectRange(1, 10, 1, 18);
- EXPECT_TRUE(Verifier.match("int* a = new (int);", newExpr()));
+ EXPECT_TRUE(Verifier.match("int* a = new (int);", cxxNewExpr()));
}
class UnaryTransformTypeLocParensRangeVerifier : public RangeVerifier<TypeLoc> {
@@ -252,7 +252,7 @@ TEST(CXXFunctionalCastExpr, SourceRange) {
"int foo() {\n"
" return int{};\n"
"}",
- functionalCastExpr(), Lang_CXX11));
+ cxxFunctionalCastExpr(), Lang_CXX11));
}
TEST(CXXConstructExpr, SourceRange) {
@@ -262,7 +262,7 @@ TEST(CXXConstructExpr, SourceRange) {
"struct A { A(int, int); };\n"
"void f(A a);\n"
"void g() { f({0, 0}); }",
- constructExpr(), Lang_CXX11));
+ cxxConstructExpr(), Lang_CXX11));
}
TEST(CXXTemporaryObjectExpr, SourceRange) {
@@ -271,7 +271,7 @@ TEST(CXXTemporaryObjectExpr, SourceRange) {
EXPECT_TRUE(Verifier.match(
"struct A { A(int, int); };\n"
"A a( A{0, 0} );",
- temporaryObjectExpr(), Lang_CXX11));
+ cxxTemporaryObjectExpr(), Lang_CXX11));
}
TEST(CXXUnresolvedConstructExpr, SourceRange) {
@@ -284,7 +284,7 @@ TEST(CXXUnresolvedConstructExpr, SourceRange) {
"U foo() {\n"
" return U{};\n"
"}",
- unresolvedConstructExpr(), Args, Lang_CXX11));
+ cxxUnresolvedConstructExpr(), Args, Lang_CXX11));
}
TEST(UsingDecl, SourceRange) {
@@ -434,11 +434,11 @@ TEST(FriendDecl, FriendConstructorDestructorLocation) {
LocationVerifier<FriendDecl> ConstructorVerifier;
ConstructorVerifier.expectLocation(6, 11);
EXPECT_TRUE(ConstructorVerifier.match(
- Code, friendDecl(has(constructorDecl(ofClass(hasName("B")))))));
+ Code, friendDecl(has(cxxConstructorDecl(ofClass(hasName("B")))))));
LocationVerifier<FriendDecl> DestructorVerifier;
DestructorVerifier.expectLocation(6, 19);
EXPECT_TRUE(DestructorVerifier.match(
- Code, friendDecl(has(destructorDecl(ofClass(hasName("B")))))));
+ Code, friendDecl(has(cxxDestructorDecl(ofClass(hasName("B")))))));
}
TEST(FriendDecl, FriendConstructorDestructorRange) {
@@ -452,11 +452,11 @@ TEST(FriendDecl, FriendConstructorDestructorRange) {
RangeVerifier<FriendDecl> ConstructorVerifier;
ConstructorVerifier.expectRange(6, 1, 6, 13);
EXPECT_TRUE(ConstructorVerifier.match(
- Code, friendDecl(has(constructorDecl(ofClass(hasName("B")))))));
+ Code, friendDecl(has(cxxConstructorDecl(ofClass(hasName("B")))))));
RangeVerifier<FriendDecl> DestructorVerifier;
DestructorVerifier.expectRange(6, 1, 6, 22);
EXPECT_TRUE(DestructorVerifier.match(
- Code, friendDecl(has(destructorDecl(ofClass(hasName("B")))))));
+ Code, friendDecl(has(cxxDestructorDecl(ofClass(hasName("B")))))));
}
TEST(FriendDecl, FriendTemplateFunctionLocation) {
@@ -527,7 +527,7 @@ TEST(FriendDecl, InstantiationSourceRange) {
" friend void operator+<>(S<T> src);\n"
"};\n"
"void test(S<double> s) { +s; }",
- friendDecl(hasParent(recordDecl(isTemplateInstantiation())))));
+ friendDecl(hasParent(cxxRecordDecl(isTemplateInstantiation())))));
}
TEST(ObjCMessageExpr, CXXConstructExprRange) {
@@ -539,7 +539,7 @@ TEST(ObjCMessageExpr, CXXConstructExprRange) {
"+ (void) f1: (A)arg;\n"
"@end\n"
"void f2() { A a; [B f1: (a)]; }\n",
- constructExpr(), Lang_OBJCXX));
+ cxxConstructExpr(), Lang_OBJCXX));
}
} // end namespace ast_matchers
diff --git a/clang/unittests/AST/StmtPrinterTest.cpp b/clang/unittests/AST/StmtPrinterTest.cpp
index b1fd2c1eb42..bc7fd54e4ad 100644
--- a/clang/unittests/AST/StmtPrinterTest.cpp
+++ b/clang/unittests/AST/StmtPrinterTest.cpp
@@ -196,7 +196,7 @@ TEST(StmtPrinter, TestCXXConversionDeclImplicit) {
"void foo(A a, A b) {"
" bar(a & b);"
"}",
- memberCallExpr(anything()).bind("id"),
+ cxxMemberCallExpr(anything()).bind("id"),
"a & b"));
}
@@ -210,7 +210,7 @@ TEST(StmtPrinter, TestCXXConversionDeclExplicit) {
"void foo(A a, A b) {"
" auto x = (a & b).operator void *();"
"}",
- memberCallExpr(anything()).bind("id"),
+ cxxMemberCallExpr(anything()).bind("id"),
"(a & b)"));
// WRONG; Should be: (a & b).operator void *()
}
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index 8f2123ac9c4..7f553513daa 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -36,7 +36,7 @@ TEST(HasNameDeathTest, DiesOnEmptyPattern) {
TEST(IsDerivedFromDeathTest, DiesOnEmptyBaseName) {
ASSERT_DEBUG_DEATH({
- DeclarationMatcher IsDerivedFromEmpty = recordDecl(isDerivedFrom(""));
+ DeclarationMatcher IsDerivedFromEmpty = cxxRecordDecl(isDerivedFrom(""));
EXPECT_TRUE(notMatches("class X {};", IsDerivedFromEmpty));
}, "");
}
@@ -122,7 +122,7 @@ TEST(DeclarationMatcher, MatchClass) {
}
TEST(DeclarationMatcher, ClassIsDerived) {
- DeclarationMatcher IsDerivedFromX = recordDecl(isDerivedFrom("X"));
+ DeclarationMatcher IsDerivedFromX = cxxRecordDecl(isDerivedFrom("X"));
EXPECT_TRUE(matches("class X {}; class Y : public X {};", IsDerivedFromX));
EXPECT_TRUE(notMatches("class X {};", IsDerivedFromX));
@@ -130,7 +130,7 @@ TEST(DeclarationMatcher, ClassIsDerived) {
EXPECT_TRUE(notMatches("class Y;", IsDerivedFromX));
EXPECT_TRUE(notMatches("", IsDerivedFromX));
- DeclarationMatcher IsAX = recordDecl(isSameOrDerivedFrom("X"));
+ DeclarationMatcher IsAX = cxxRecordDecl(isSameOrDerivedFrom("X"));
EXPECT_TRUE(matches("class X {}; class Y : public X {};", IsAX));
EXPECT_TRUE(matches("class X {};", IsAX));
@@ -139,7 +139,7 @@ TEST(DeclarationMatcher, ClassIsDerived) {
EXPECT_TRUE(notMatches("", IsAX));
DeclarationMatcher ZIsDerivedFromX =
- recordDecl(hasName("Z"), isDerivedFrom("X"));
+ cxxRecordDecl(hasName("Z"), isDerivedFrom("X"));
EXPECT_TRUE(
matches("class X {}; class Y : public X {}; class Z : public Y {};",
ZIsDerivedFromX));
@@ -258,14 +258,14 @@ TEST(DeclarationMatcher, ClassIsDerived) {
EXPECT_TRUE(
notMatches("template<int> struct X;"
"template<int i> struct X : public X<i-1> {};",
- recordDecl(isDerivedFrom(recordDecl(hasName("Some"))))));
+ cxxRecordDecl(isDerivedFrom(recordDecl(hasName("Some"))))));
EXPECT_TRUE(matches(
"struct A {};"
"template<int> struct X;"
"template<int i> struct X : public X<i-1> {};"
"template<> struct X<0> : public A {};"
"struct B : public X<42> {};",
- recordDecl(hasName("B"), isDerivedFrom(recordDecl(hasName("A"))))));
+ cxxRecordDecl(hasName("B"), isDerivedFrom(recordDecl(hasName("A"))))));
// FIXME: Once we have better matchers for template type matching,
// get rid of the Variable(...) matching and match the right template
@@ -282,15 +282,15 @@ TEST(DeclarationMatcher, ClassIsDerived) {
EXPECT_TRUE(matches(
RecursiveTemplateOneParameter,
varDecl(hasName("z_float"),
- hasInitializer(hasType(recordDecl(isDerivedFrom("Base1")))))));
+ hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1")))))));
EXPECT_TRUE(notMatches(
RecursiveTemplateOneParameter,
varDecl(hasName("z_float"),
- hasInitializer(hasType(recordDecl(isDerivedFrom("Base2")))))));
+ hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base2")))))));
EXPECT_TRUE(matches(
RecursiveTemplateOneParameter,
varDecl(hasName("z_char"),
- hasInitializer(hasType(recordDecl(isDerivedFrom("Base1"),
+ hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1"),
isDerivedFrom("Base2")))))));
const char *RecursiveTemplateTwoParameters =
@@ -307,39 +307,39 @@ TEST(DeclarationMatcher, ClassIsDerived) {
EXPECT_TRUE(matches(
RecursiveTemplateTwoParameters,
varDecl(hasName("z_float"),
- hasInitializer(hasType(recordDecl(isDerivedFrom("Base1")))))));
+ hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1")))))));
EXPECT_TRUE(notMatches(
RecursiveTemplateTwoParameters,
varDecl(hasName("z_float"),
- hasInitializer(hasType(recordDecl(isDerivedFrom("Base2")))))));
+ hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base2")))))));
EXPECT_TRUE(matches(
RecursiveTemplateTwoParameters,
varDecl(hasName("z_char"),
- hasInitializer(hasType(recordDecl(isDerivedFrom("Base1"),
+ hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1"),
isDerivedFrom("Base2")))))));
EXPECT_TRUE(matches(
"namespace ns { class X {}; class Y : public X {}; }",
- recordDecl(isDerivedFrom("::ns::X"))));
+ cxxRecordDecl(isDerivedFrom("::ns::X"))));
EXPECT_TRUE(notMatches(
"class X {}; class Y : public X {};",
- recordDecl(isDerivedFrom("::ns::X"))));
+ cxxRecordDecl(isDerivedFrom("::ns::X"))));
EXPECT_TRUE(matches(
"class X {}; class Y : public X {};",
- recordDecl(isDerivedFrom(recordDecl(hasName("X")).bind("test")))));
+ cxxRecordDecl(isDerivedFrom(recordDecl(hasName("X")).bind("test")))));
EXPECT_TRUE(matches(
"template<typename T> class X {};"
"template<typename T> using Z = X<T>;"
"template <typename T> class Y : Z<T> {};",
- recordDecl(isDerivedFrom(namedDecl(hasName("X"))))));
+ cxxRecordDecl(isDerivedFrom(namedDecl(hasName("X"))))));
}
TEST(DeclarationMatcher, hasMethod) {
EXPECT_TRUE(matches("class A { void func(); };",
- recordDecl(hasMethod(hasName("func")))));
+ cxxRecordDecl(hasMethod(hasName("func")))));
EXPECT_TRUE(notMatches("class A { void func(); };",
- recordDecl(hasMethod(isPublic()))));
+ cxxRecordDecl(hasMethod(isPublic()))));
}
TEST(DeclarationMatcher, ClassDerivedFromDependentTemplateSpecialization) {
@@ -349,7 +349,7 @@ TEST(DeclarationMatcher, ClassDerivedFromDependentTemplateSpecialization) {
"};"
"template <typename T> struct B : A<T>::template F<T> {};"
"B<int> b;",
- recordDecl(hasName("B"), isDerivedFrom(recordDecl()))));
+ cxxRecordDecl(hasName("B"), isDerivedFrom(recordDecl()))));
}
TEST(DeclarationMatcher, hasDeclContext) {
@@ -464,10 +464,9 @@ TEST(ConstructVariadic, MismatchedTypes_Regression) {
}
TEST(DeclarationMatcher, MatchAnyOf) {
- DeclarationMatcher YOrZDerivedFromX =
- recordDecl(anyOf(hasName("Y"), allOf(isDerivedFrom("X"), hasName("Z"))));
- EXPECT_TRUE(
- matches("class X {}; class Z : public X {};", YOrZDerivedFromX));
+ DeclarationMatcher YOrZDerivedFromX = cxxRecordDecl(
+ anyOf(hasName("Y"), allOf(isDerivedFrom("X"), hasName("Z"))));
+ EXPECT_TRUE(matches("class X {}; class Z : public X {};", YOrZDerivedFromX));
EXPECT_TRUE(matches("class Y {};", YOrZDerivedFromX));
EXPECT_TRUE(
notMatches("class X {}; class W : public X {};", YOrZDerivedFromX));
@@ -495,7 +494,7 @@ TEST(DeclarationMatcher, MatchAnyOf) {
EXPECT_TRUE(
matches("void f() try { } catch (int) { } catch (...) { }",
- catchStmt(anyOf(hasDescendant(varDecl()), isCatchAll()))));
+ cxxCatchStmt(anyOf(hasDescendant(varDecl()), isCatchAll()))));
}
TEST(DeclarationMatcher, MatchHas) {
@@ -602,7 +601,7 @@ TEST(DeclarationMatcher, MatchHasRecursiveAnyOf) {
TEST(DeclarationMatcher, MatchNot) {
DeclarationMatcher NotClassX =
- recordDecl(
+ cxxRecordDecl(
isDerivedFrom("Y"),
unless(hasName("X")));
EXPECT_TRUE(notMatches("", NotClassX));
@@ -719,11 +718,11 @@ TEST(DeclarationMatcher, HasAttr) {
TEST(DeclarationMatcher, MatchCudaDecl) {
EXPECT_TRUE(matchesWithCuda("__global__ void f() { }"
"void g() { f<<<1, 2>>>(); }",
- CUDAKernelCallExpr()));
+ cudaKernelCallExpr()));
EXPECT_TRUE(matchesWithCuda("__attribute__((device)) void f() {}",
hasAttr(clang::attr::CUDADevice)));
EXPECT_TRUE(notMatchesWithCuda("void f() {}",
- CUDAKernelCallExpr()));
+ cudaKernelCallExpr()));
EXPECT_FALSE(notMatchesWithCuda("__attribute__((global)) void f() {}",
hasAttr(clang::attr::CUDAGlobal)));
}
@@ -908,7 +907,8 @@ TEST(TypeMatcher, MatchesClassType) {
EXPECT_TRUE(matches("class A { public: A *a; };", TypeA));
EXPECT_TRUE(notMatches("class A {};", TypeA));
- TypeMatcher TypeDerivedFromA = hasDeclaration(recordDecl(isDerivedFrom("A")));
+ TypeMatcher TypeDerivedFromA =
+ hasDeclaration(cxxRecordDecl(isDerivedFrom("A")));
EXPECT_TRUE(matches("class A {}; class B : public A { public: B *b; };",
TypeDerivedFromA));
@@ -989,7 +989,7 @@ TEST(Matcher, BindMatchedNodes) {
new VerifyIdIsBoundTo<Decl>("b")));
StatementMatcher MethodX =
- callExpr(callee(methodDecl(hasName("x")))).bind("x");
+ callExpr(callee(cxxMethodDecl(hasName("x")))).bind("x");
EXPECT_TRUE(matchAndVerifyResultTrue("class A { void x() { x(); } };",
MethodX,
@@ -1103,13 +1103,14 @@ TEST(HasTypeLoc, MatchesDeclaratorDecls) {
TEST(Matcher, Call) {
// FIXME: Do we want to overload Call() to directly take
// Matcher<Decl>, too?
- StatementMatcher MethodX = callExpr(hasDeclaration(methodDecl(hasName("x"))));
+ StatementMatcher MethodX =
+ callExpr(hasDeclaration(cxxMethodDecl(hasName("x"))));
EXPECT_TRUE(matches("class Y { void x() { x(); } };", MethodX));
EXPECT_TRUE(notMatches("class Y { void x() {} };", MethodX));
StatementMatcher MethodOnY =
- memberCallExpr(on(hasType(recordDecl(hasName("Y")))));
+ cxxMemberCallExpr(on(hasType(recordDecl(hasName("Y")))));
EXPECT_TRUE(
matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
@@ -1128,7 +1129,7 @@ TEST(Matcher, Call) {
MethodOnY));
StatementMatcher MethodOnYPointer =
- memberCallExpr(on(hasType(pointsTo(recordDecl(hasName("Y"))))));
+ cxxMemberCallExpr(on(hasType(pointsTo(recordDecl(hasName("Y"))))));
EXPECT_TRUE(
matches("class Y { public: void x(); }; void z() { Y *y; y->x(); }",
@@ -1155,9 +1156,9 @@ TEST(Matcher, Lambda) {
TEST(Matcher, ForRange) {
EXPECT_TRUE(matches("int as[] = { 1, 2, 3 };"
"void f() { for (auto &a : as); }",
- forRangeStmt()));
+ cxxForRangeStmt()));
EXPECT_TRUE(notMatches("void f() { for (int i; i<5; ++i); }",
- forRangeStmt()));
+ cxxForRangeStmt()));
}
TEST(Matcher, SubstNonTypeTemplateParm) {
@@ -1191,9 +1192,10 @@ TEST(Matcher, FlowControl) {
TEST(HasType, MatchesAsString) {
EXPECT_TRUE(
matches("class Y { public: void x(); }; void z() {Y* y; y->x(); }",
- memberCallExpr(on(hasType(asString("class Y *"))))));
- EXPECT_TRUE(matches("class X { void x(int x) {} };",
- methodDecl(hasParameter(0, hasType(asString("int"))))));
+ cxxMemberCallExpr(on(hasType(asString("class Y *"))))));
+ EXPECT_TRUE(
+ matches("class X { void x(int x) {} };",
+ cxxMethodDecl(hasParameter(0, hasType(asString("int"))))));
EXPECT_TRUE(matches("namespace ns { struct A {}; } struct B { ns::A a; };",
fieldDecl(hasType(asString("ns::A")))));
EXPECT_TRUE(matches("namespace { struct A {}; } struct B { A a; };",
@@ -1201,7 +1203,7 @@ TEST(HasType, MatchesAsString) {
}
TEST(Matcher, OverloadedOperatorCall) {
- StatementMatcher OpCall = operatorCallExpr();
+ StatementMatcher OpCall = cxxOperatorCallExpr();
// Unary operator
EXPECT_TRUE(matches("class Y { }; "
"bool operator!(Y x) { return false; }; "
@@ -1228,22 +1230,22 @@ TEST(Matcher, OverloadedOperatorCall) {
TEST(Matcher, HasOperatorNameForOverloadedOperatorCall) {
StatementMatcher OpCallAndAnd =
- operatorCallExpr(hasOverloadedOperatorName("&&"));
+ cxxOperatorCallExpr(hasOverloadedOperatorName("&&"));
EXPECT_TRUE(matches("class Y { }; "
"bool operator&&(Y x, Y y) { return true; }; "
"Y a; Y b; bool c = a && b;", OpCallAndAnd));
StatementMatcher OpCallLessLess =
- operatorCallExpr(hasOverloadedOperatorName("<<"));
+ cxxOperatorCallExpr(hasOverloadedOperatorName("<<"));
EXPECT_TRUE(notMatches("class Y { }; "
"bool operator&&(Y x, Y y) { return true; }; "
"Y a; Y b; bool c = a && b;",
OpCallLessLess));
StatementMatcher OpStarCall =
- operatorCallExpr(hasOverloadedOperatorName("*"));
+ cxxOperatorCallExpr(hasOverloadedOperatorName("*"));
EXPECT_TRUE(matches("class Y; int operator*(Y &); void f(Y &y) { *y; }",
OpStarCall));
DeclarationMatcher ClassWithOpStar =
- recordDecl(hasMethod(hasOverloadedOperatorName("*")));
+ cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")));
EXPECT_TRUE(matches("class Y { int operator*(); };",
ClassWithOpStar));
EXPECT_TRUE(notMatches("class Y { void myOperator(); };",
@@ -1255,26 +1257,25 @@ TEST(Matcher, HasOperatorNameForOverloadedOperatorCall) {
TEST(Matcher, NestedOverloadedOperatorCalls) {
EXPECT_TRUE(matchAndVerifyResultTrue(
- "class Y { }; "
- "Y& operator&&(Y& x, Y& y) { return x; }; "
- "Y a; Y b; Y c; Y d = a && b && c;",
- operatorCallExpr(hasOverloadedOperatorName("&&")).bind("x"),
- new VerifyIdIsBoundTo<CXXOperatorCallExpr>("x", 2)));
- EXPECT_TRUE(matches(
- "class Y { }; "
- "Y& operator&&(Y& x, Y& y) { return x; }; "
- "Y a; Y b; Y c; Y d = a && b && c;",
- operatorCallExpr(hasParent(operatorCallExpr()))));
- EXPECT_TRUE(matches(
- "class Y { }; "
- "Y& operator&&(Y& x, Y& y) { return x; }; "
- "Y a; Y b; Y c; Y d = a && b && c;",
- operatorCallExpr(hasDescendant(operatorCallExpr()))));
+ "class Y { }; "
+ "Y& operator&&(Y& x, Y& y) { return x; }; "
+ "Y a; Y b; Y c; Y d = a && b && c;",
+ cxxOperatorCallExpr(hasOverloadedOperatorName("&&")).bind("x"),
+ new VerifyIdIsBoundTo<CXXOperatorCallExpr>("x", 2)));
+ EXPECT_TRUE(matches("class Y { }; "
+ "Y& operator&&(Y& x, Y& y) { return x; }; "
+ "Y a; Y b; Y c; Y d = a && b && c;",
+ cxxOperatorCallExpr(hasParent(cxxOperatorCallExpr()))));
+ EXPECT_TRUE(
+ matches("class Y { }; "
+ "Y& operator&&(Y& x, Y& y) { return x; }; "
+ "Y a; Y b; Y c; Y d = a && b && c;",
+ cxxOperatorCallExpr(hasDescendant(cxxOperatorCallExpr()))));
}
TEST(Matcher, ThisPointerType) {
StatementMatcher MethodOnY =
- memberCallExpr(thisPointerType(recordDecl(hasName("Y"))));
+ cxxMemberCallExpr(thisPointerType(recordDecl(hasName("Y"))));
EXPECT_TRUE(
matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
@@ -1306,7 +1307,7 @@ TEST(Matcher, VariableUsage) {
StatementMatcher Reference =
declRefExpr(to(
varDecl(hasInitializer(
- memberCallExpr(thisPointerType(recordDecl(hasName("Y"))))))));
+ cxxMemberCallExpr(thisPointerType(recordDecl(hasName("Y"))))))));
EXPECT_TRUE(matches(
"class Y {"
@@ -1348,7 +1349,7 @@ TEST(Matcher, FindsVarDeclInFunctionParameter) {
TEST(Matcher, CalledVariable) {
StatementMatcher CallOnVariableY =
- memberCallExpr(on(declRefExpr(to(varDecl(hasName("y"))))));
+ cxxMemberCallExpr(on(declRefExpr(to(varDecl(hasName("y"))))));
EXPECT_TRUE(matches(
"class Y { public: void x() { Y y; y.x(); } };", CallOnVariableY));
@@ -1459,12 +1460,12 @@ TEST(IsArrow, MatchesMemberCallsViaArrow) {
}
TEST(Callee, MatchesDeclarations) {
- StatementMatcher CallMethodX = callExpr(callee(methodDecl(hasName("x"))));
+ StatementMatcher CallMethodX = callExpr(callee(cxxMethodDecl(hasName("x"))));
EXPECT_TRUE(matches("class Y { void x() { x(); } };", CallMethodX));
EXPECT_TRUE(notMatches("class Y { void x() {} };", CallMethodX));
- CallMethodX = callExpr(callee(conversionDecl()));
+ CallMethodX = callExpr(callee(cxxConversionDecl()));
EXPECT_TRUE(
matches("struct Y { operator int() const; }; int i = Y();", CallMethodX));
EXPECT_TRUE(notMatches("struct Y { operator int() const; }; Y y = Y();",
@@ -1473,9 +1474,9 @@ TEST(Callee, MatchesDeclarations) {
TEST(ConversionDeclaration, IsExplicit) {
EXPECT_TRUE(matches("struct S { explicit operator int(); };",
- conversionDecl(isExplicit())));
+ cxxConversionDecl(isExplicit())));
EXPECT_TRUE(notMatches("struct S { operator int(); };",
- conversionDecl(isExplicit())));
+ cxxConversionDecl(isExplicit())));
}
TEST(Callee, MatchesMemberExpressions) {
@@ -1613,34 +1614,38 @@ TEST(QualType, hasLocalQualifiers) {
TEST(HasParameter, CallsInnerMatcher) {
EXPECT_TRUE(matches("class X { void x(int) {} };",
- methodDecl(hasParameter(0, varDecl()))));
+ cxxMethodDecl(hasParameter(0, varDecl()))));
EXPECT_TRUE(notMatches("class X { void x(int) {} };",
- methodDecl(hasParameter(0, hasName("x")))));
+ cxxMethodDecl(hasParameter(0, hasName("x")))));
}
TEST(HasParameter, DoesNotMatchIfIndexOutOfBounds) {
EXPECT_TRUE(notMatches("class X { void x(int) {} };",
- methodDecl(hasParameter(42, varDecl()))));
+ cxxMethodDecl(hasParameter(42, varDecl()))));
}
TEST(HasType, MatchesParameterVariableTypesStrictly) {
- EXPECT_TRUE(matches("class X { void x(X x) {} };",
- methodDecl(hasParameter(0, hasType(recordDecl(hasName("X")))))));
- EXPECT_TRUE(notMatches("class X { void x(const X &x) {} };",
- methodDecl(hasParameter(0, hasType(recordDecl(hasName("X")))))));
+ EXPECT_TRUE(matches(
+ "class X { void x(X x) {} };",
+ cxxMethodDecl(hasParameter(0, hasType(recordDecl(hasName("X")))))));
+ EXPECT_TRUE(notMatches(
+ "class X { void x(const X &x) {} };",
+ cxxMethodDecl(hasParameter(0, hasType(recordDecl(hasName("X")))))));
EXPECT_TRUE(matches("class X { void x(const X *x) {} };",
- methodDecl(hasParameter(0,
- hasType(pointsTo(recordDecl(hasName("X"))))))));
+ cxxMethodDecl(hasParameter(
+ 0, hasType(pointsTo(recordDecl(hasName("X"))))))));
EXPECT_TRUE(matches("class X { void x(const X &x) {} };",
- methodDecl(hasParameter(0,
- hasType(references(recordDecl(hasName("X"))))))));
+ cxxMethodDecl(hasParameter(
+ 0, hasType(references(recordDecl(hasName("X"))))))));
}
TEST(HasAnyParameter, MatchesIndependentlyOfPosition) {
- EXPECT_TRUE(matches("class Y {}; class X { void x(X x, Y y) {} };",
- methodDecl(hasAnyParameter(hasType(recordDecl(hasName("X")))))));
- EXPECT_TRUE(matches("class Y {}; class X { void x(Y y, X x) {} };",
- methodDecl(hasAnyParameter(hasType(recordDecl(hasName("X")))))));
+ EXPECT_TRUE(matches(
+ "class Y {}; class X { void x(X x, Y y) {} };",
+ cxxMethodDecl(hasAnyParameter(hasType(recordDecl(hasName("X")))))));
+ EXPECT_TRUE(matches(
+ "class Y {}; class X { void x(Y y, X x) {} };",
+ cxxMethodDecl(hasAnyParameter(hasType(recordDecl(hasName("X")))))));
}
TEST(Returns, MatchesReturnTypes) {
@@ -1675,21 +1680,22 @@ TEST(isConstexpr, MatchesConstexprDeclarations) {
}
TEST(HasAnyParameter, DoesntMatchIfInnerMatcherDoesntMatch) {
- EXPECT_TRUE(notMatches("class Y {}; class X { void x(int) {} };",
- methodDecl(hasAnyParameter(hasType(recordDecl(hasName("X")))))));
+ EXPECT_TRUE(notMatches(
+ "class Y {}; class X { void x(int) {} };",
+ cxxMethodDecl(hasAnyParameter(hasType(recordDecl(hasName("X")))))));
}
TEST(HasAnyParameter, DoesNotMatchThisPointer) {
EXPECT_TRUE(notMatches("class Y {}; class X { void x() {} };",
- methodDecl(hasAnyParameter(hasType(pointsTo(
- recordDecl(hasName("X"))))))));
+ cxxMethodDecl(hasAnyParameter(
+ hasType(pointsTo(recordDecl(hasName("X"))))))));
}
TEST(HasName, MatchesParameterVariableDeclarations) {
EXPECT_TRUE(matches("class Y {}; class X { void x(int x) {} };",
- methodDecl(hasAnyParameter(hasName("x")))));
+ cxxMethodDecl(hasAnyParameter(hasName("x")))));
EXPECT_TRUE(notMatches("class Y {}; class X { void x(int) {} };",
- methodDecl(hasAnyParameter(hasName("x")))));
+ cxxMethodDecl(hasAnyParameter(hasName("x")))));
}
TEST(Matcher, MatchesClassTemplateSpecialization) {
@@ -1843,54 +1849,52 @@ TEST(Matcher, MatchesAccessSpecDecls) {
}
TEST(Matcher, MatchesFinal) {
- EXPECT_TRUE(matches("class X final {};", recordDecl(isFinal())));
+ EXPECT_TRUE(matches("class X final {};", cxxRecordDecl(isFinal())));
EXPECT_TRUE(matches("class X { virtual void f() final; };",
- methodDecl(isFinal())));
- EXPECT_TRUE(notMatches("class X {};", recordDecl(isFinal())));
- EXPECT_TRUE(notMatches("class X { virtual void f(); };",
- methodDecl(isFinal())));
+ cxxMethodDecl(isFinal())));
+ EXPECT_TRUE(notMatches("class X {};", cxxRecordDecl(isFinal())));
+ EXPECT_TRUE(
+ notMatches("class X { virtual void f(); };", cxxMethodDecl(isFinal())));
}
TEST(Matcher, MatchesVirtualMethod) {
EXPECT_TRUE(matches("class X { virtual int f(); };",
- methodDecl(isVirtual(), hasName("::X::f"))));
- EXPECT_TRUE(notMatches("class X { int f(); };",
- methodDecl(isVirtual())));
+ cxxMethodDecl(isVirtual(), hasName("::X::f"))));
+ EXPECT_TRUE(notMatches("class X { int f(); };", cxxMethodDecl(isVirtual())));
}
TEST(Matcher, MatchesPureMethod) {
EXPECT_TRUE(matches("class X { virtual int f() = 0; };",
- methodDecl(isPure(), hasName("::X::f"))));
- EXPECT_TRUE(notMatches("class X { int f(); };",
- methodDecl(isPure())));
+ cxxMethodDecl(isPure(), hasName("::X::f"))));
+ EXPECT_TRUE(notMatches("class X { int f(); };", cxxMethodDecl(isPure())));
}
TEST(Matcher, MatchesConstMethod) {
- EXPECT_TRUE(matches("struct A { void foo() const; };",
- methodDecl(isConst())));
- EXPECT_TRUE(notMatches("struct A { void foo(); };",
- methodDecl(isConst())));
+ EXPECT_TRUE(
+ matches("struct A { void foo() const; };", cxxMethodDecl(isConst())));
+ EXPECT_TRUE(
+ notMatches("struct A { void foo(); };", cxxMethodDecl(isConst())));
}
TEST(Matcher, MatchesOverridingMethod) {
EXPECT_TRUE(matches("class X { virtual int f(); }; "
"class Y : public X { int f(); };",
- methodDecl(isOverride(), hasName("::Y::f"))));
+ cxxMethodDecl(isOverride(), hasName("::Y::f"))));
EXPECT_TRUE(notMatches("class X { virtual int f(); }; "
- "class Y : public X { int f(); };",
- methodDecl(isOverride(), hasName("::X::f"))));
+ "class Y : public X { int f(); };",
+ cxxMethodDecl(isOverride(), hasName("::X::f"))));
EXPECT_TRUE(notMatches("class X { int f(); }; "
"class Y : public X { int f(); };",
- methodDecl(isOverride())));
+ cxxMethodDecl(isOverride())));
EXPECT_TRUE(notMatches("class X { int f(); int f(int); }; ",
- methodDecl(isOverride())));
+ cxxMethodDecl(isOverride())));
EXPECT_TRUE(
matches("template <typename Base> struct Y : Base { void f() override;};",
- methodDecl(isOverride(), hasName("::Y::f"))));
+ cxxMethodDecl(isOverride(), hasName("::Y::f"))));
}
TEST(Matcher, ConstructorCall) {
- StatementMatcher Constructor = constructExpr();
+ StatementMatcher Constructor = cxxConstructExpr();
EXPECT_TRUE(
matches("class X { public: X(); }; void x() { X x; }", Constructor));
@@ -1904,7 +1908,7 @@ TEST(Matcher, ConstructorCall) {
}
TEST(Matcher, ConstructorArgument) {
- StatementMatcher Constructor = constructExpr(
+ StatementMatcher Constructor = cxxConstructExpr(
hasArgument(0, declRefExpr(to(varDecl(hasName("y"))))));
EXPECT_TRUE(
@@ -1920,7 +1924,7 @@ TEST(Matcher, ConstructorArgument) {
notMatches("class X { public: X(int); }; void x() { int z; X x(z); }",
Constructor));
- StatementMatcher WrongIndex = constructExpr(
+ StatementMatcher WrongIndex = cxxConstructExpr(
hasArgument(42, declRefExpr(to(varDecl(hasName("y"))))));
EXPECT_TRUE(
notMatches("class X { public: X(int); }; void x() { int y; X x(y); }",
@@ -1928,7 +1932,7 @@ TEST(Matcher, ConstructorArgument) {
}
TEST(Matcher, ConstructorArgumentCount) {
- StatementMatcher Constructor1Arg = constructExpr(argumentCountIs(1));
+ StatementMatcher Constructor1Arg = cxxConstructExpr(argumentCountIs(1));
EXPECT_TRUE(
matches("class X { public: X(int); }; void x() { X x(0); }",
@@ -1945,7 +1949,8 @@ TEST(Matcher, ConstructorArgumentCount) {
}
TEST(Matcher, ConstructorListInitialization) {
- StatementMatcher ConstructorListInit = constructExpr(isListInitialization());
+ StatementMatcher ConstructorListInit =
+ cxxConstructExpr(isListInitialization());
EXPECT_TRUE(
matches("class X { public: X(int); }; void x() { X x{0}; }",
@@ -1957,13 +1962,13 @@ TEST(Matcher, ConstructorListInitialization) {
TEST(Matcher,ThisExpr) {
EXPECT_TRUE(
- matches("struct X { int a; int f () { return a; } };", thisExpr()));
+ matches("struct X { int a; int f () { return a; } };", cxxThisExpr()));
EXPECT_TRUE(
- notMatches("struct X { int f () { int a; return a; } };", thisExpr()));
+ notMatches("struct X { int f () { int a; return a; } };", cxxThisExpr()));
}
TEST(Matcher, BindTemporaryExpression) {
- StatementMatcher TempExpression = bindTemporaryExpr();
+ StatementMatcher TempExpression = cxxBindTemporaryExpr();
std::string ClassString = "class string { public: string(); ~string(); }; ";
@@ -2030,76 +2035,76 @@ TEST(MaterializeTemporaryExpr, MatchesTemporary) {
TEST(ConstructorDeclaration, SimpleCase) {
EXPECT_TRUE(matches("class Foo { Foo(int i); };",
- constructorDecl(ofClass(hasName("Foo")))));
+ cxxConstructorDecl(ofClass(hasName("Foo")))));
EXPECT_TRUE(notMatches("class Foo { Foo(int i); };",
- constructorDecl(ofClass(hasName("Bar")))));
+ cxxConstructorDecl(ofClass(hasName("Bar")))));
}
TEST(ConstructorDeclaration, IsImplicit) {
// This one doesn't match because the constructor is not added by the
// compiler (it is not needed).
EXPECT_TRUE(notMatches("class Foo { };",
- constructorDecl(isImplicit())));
+ cxxConstructorDecl(isImplicit())));
// The compiler added the implicit default constructor.
EXPECT_TRUE(matches("class Foo { }; Foo* f = new Foo();",
- constructorDecl(isImplicit())));
+ cxxConstructorDecl(isImplicit())));
EXPECT_TRUE(matches("class Foo { Foo(){} };",
- constructorDecl(unless(isImplicit()))));
+ cxxConstructorDecl(unless(isImplicit()))));
// The compiler added an implicit assignment operator.
EXPECT_TRUE(matches("struct A { int x; } a = {0}, b = a; void f() { a = b; }",
- methodDecl(isImplicit(), hasName("operator="))));
+ cxxMethodDecl(isImplicit(), hasName("operator="))));
}
TEST(ConstructorDeclaration, IsExplicit) {
EXPECT_TRUE(matches("struct S { explicit S(int); };",
- constructorDecl(isExplicit())));
+ cxxConstructorDecl(isExplicit())));
EXPECT_TRUE(notMatches("struct S { S(int); };",
- constructorDecl(isExplicit())));
+ cxxConstructorDecl(isExplicit())));
}
TEST(ConstructorDeclaration, Kinds) {
EXPECT_TRUE(matches("struct S { S(); };",
- constructorDecl(isDefaultConstructor())));
+ cxxConstructorDecl(isDefaultConstructor())));
EXPECT_TRUE(notMatches("struct S { S(); };",
- constructorDecl(isCopyConstructor())));
+ cxxConstructorDecl(isCopyConstructor())));
EXPECT_TRUE(notMatches("struct S { S(); };",
- constructorDecl(isMoveConstructor())));
+ cxxConstructorDecl(isMoveConstructor())));
EXPECT_TRUE(notMatches("struct S { S(const S&); };",
- constructorDecl(isDefaultConstructor())));
+ cxxConstructorDecl(isDefaultConstructor())));
EXPECT_TRUE(matches("struct S { S(const S&); };",
- constructorDecl(isCopyConstructor())));
+ cxxConstructorDecl(isCopyConstructor())));
EXPECT_TRUE(notMatches("struct S { S(const S&); };",
- constructorDecl(isMoveConstructor())));
+ cxxConstructorDecl(isMoveConstructor())));
EXPECT_TRUE(notMatches("struct S { S(S&&); };",
- constructorDecl(isDefaultConstructor())));
+ cxxConstructorDecl(isDefaultConstructor())));
EXPECT_TRUE(notMatches("struct S { S(S&&); };",
- constructorDecl(isCopyConstructor())));
+ cxxConstructorDecl(isCopyConstructor())));
EXPECT_TRUE(matches("struct S { S(S&&); };",
- constructorDecl(isMoveConstructor())));
+ cxxConstructorDecl(isMoveConstructor())));
}
TEST(DestructorDeclaration, MatchesVirtualDestructor) {
EXPECT_TRUE(matches("class Foo { virtual ~Foo(); };",
- destructorDecl(ofClass(hasName("Foo")))));
+ cxxDestructorDecl(ofClass(hasName("Foo")))));
}
TEST(DestructorDeclaration, DoesNotMatchImplicitDestructor) {
EXPECT_TRUE(notMatches("class Foo {};",
- destructorDecl(ofClass(hasName("Foo")))));
+ cxxDestructorDecl(ofClass(hasName("Foo")))));
}
TEST(HasAnyConstructorInitializer, SimpleCase) {
- EXPECT_TRUE(notMatches(
- "class Foo { Foo() { } };",
- constructorDecl(hasAnyConstructorInitializer(anything()))));
- EXPECT_TRUE(matches(
- "class Foo {"
- " Foo() : foo_() { }"
- " int foo_;"
- "};",
- constructorDecl(hasAnyConstructorInitializer(anything()))));
+ EXPECT_TRUE(
+ notMatches("class Foo { Foo() { } };",
+ cxxConstructorDecl(hasAnyConstructorInitializer(anything()))));
+ EXPECT_TRUE(
+ matches("class Foo {"
+ " Foo() : foo_() { }"
+ " int foo_;"
+ "};",
+ cxxConstructorDecl(hasAnyConstructorInitializer(anything()))));
}
TEST(HasAnyConstructorInitializer, ForField) {
@@ -2110,11 +2115,11 @@ TEST(HasAnyConstructorInitializer, ForField) {
" Baz foo_;"
" Baz bar_;"
"};";
- EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
+ EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
forField(hasType(recordDecl(hasName("Baz"))))))));
- EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
+ EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
forField(hasName("foo_"))))));
- EXPECT_TRUE(notMatches(Code, constructorDecl(hasAnyConstructorInitializer(
+ EXPECT_TRUE(notMatches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
forField(hasType(recordDecl(hasName("Bar"))))))));
}
@@ -2124,9 +2129,9 @@ TEST(HasAnyConstructorInitializer, WithInitializer) {
" Foo() : foo_(0) { }"
" int foo_;"
"};";
- EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
+ EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
withInitializer(integerLiteral(equals(0)))))));
- EXPECT_TRUE(notMatches(Code, constructorDecl(hasAnyConstructorInitializer(
+ EXPECT_TRUE(notMatches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
withInitializer(integerLiteral(equals(1)))))));
}
@@ -2138,11 +2143,11 @@ TEST(HasAnyConstructorInitializer, IsWritten) {
" Bar foo_;"
" Bar bar_;"
"};";
- EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
+ EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
allOf(forField(hasName("foo_")), isWritten())))));
- EXPECT_TRUE(notMatches(Code, constructorDecl(hasAnyConstructorInitializer(
+ EXPECT_TRUE(notMatches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
allOf(forField(hasName("bar_")), isWritten())))));
- EXPECT_TRUE(matches(Code, constructorDecl(hasAnyConstructorInitializer(
+ EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
allOf(forField(hasName("bar_")), unless(isWritten()))))));
}
@@ -2156,22 +2161,22 @@ TEST(HasAnyConstructorInitializer, IsBaseInitializer) {
"struct E : B {"
" E() : B() {}"
"};";
- EXPECT_TRUE(matches(Code, constructorDecl(allOf(
+ EXPECT_TRUE(matches(Code, cxxConstructorDecl(allOf(
hasAnyConstructorInitializer(allOf(isBaseInitializer(), isWritten())),
hasName("E")))));
- EXPECT_TRUE(notMatches(Code, constructorDecl(allOf(
+ EXPECT_TRUE(notMatches(Code, cxxConstructorDecl(allOf(
hasAnyConstructorInitializer(allOf(isBaseInitializer(), isWritten())),
hasName("D")))));
- EXPECT_TRUE(matches(Code, constructorDecl(allOf(
+ EXPECT_TRUE(matches(Code, cxxConstructorDecl(allOf(
hasAnyConstructorInitializer(allOf(isMemberInitializer(), isWritten())),
hasName("D")))));
- EXPECT_TRUE(notMatches(Code, constructorDecl(allOf(
+ EXPECT_TRUE(notMatches(Code, cxxConstructorDecl(allOf(
hasAnyConstructorInitializer(allOf(isMemberInitializer(), isWritten())),
hasName("E")))));
}
TEST(Matcher, NewExpression) {
- StatementMatcher New = newExpr();
+ StatementMatcher New = cxxNewExpr();
EXPECT_TRUE(matches("class X { public: X(); }; void x() { new X; }", New));
EXPECT_TRUE(
@@ -2182,7 +2187,7 @@ TEST(Matcher, NewExpression) {
}
TEST(Matcher, NewExpressionArgument) {
- StatementMatcher New = constructExpr(
+ StatementMatcher New = cxxConstructExpr(
hasArgument(0, declRefExpr(to(varDecl(hasName("y"))))));
EXPECT_TRUE(
@@ -2195,7 +2200,7 @@ TEST(Matcher, NewExpressionArgument) {
notMatches("class X { public: X(int); }; void x() { int z; new X(z); }",
New));
- StatementMatcher WrongIndex = constructExpr(
+ StatementMatcher WrongIndex = cxxConstructExpr(
hasArgument(42, declRefExpr(to(varDecl(hasName("y"))))));
EXPECT_TRUE(
notMatches("class X { public: X(int); }; void x() { int y; new X(y); }",
@@ -2203,7 +2208,7 @@ TEST(Matcher, NewExpressionArgument) {
}
TEST(Matcher, NewExpressionArgumentCount) {
- StatementMatcher New = constructExpr(argumentCountIs(1));
+ StatementMatcher New = cxxConstructExpr(argumentCountIs(1));
EXPECT_TRUE(
matches("class X { public: X(int); }; void x() { new X(0); }", New));
@@ -2214,11 +2219,11 @@ TEST(Matcher, NewExpressionArgumentCount) {
TEST(Matcher, DeleteExpression) {
EXPECT_TRUE(matches("struct A {}; void f(A* a) { delete a; }",
- deleteExpr()));
+ cxxDeleteExpr()));
}
TEST(Matcher, DefaultArgument) {
- StatementMatcher Arg = defaultArgExpr();
+ StatementMatcher Arg = cxxDefaultArgExpr();
EXPECT_TRUE(matches("void x(int, int = 0) { int y; x(y); }", Arg));
EXPECT_TRUE(
@@ -2283,7 +2288,7 @@ TEST(Matcher, FloatLiterals) {
}
TEST(Matcher, NullPtrLiteral) {
- EXPECT_TRUE(matches("int* i = nullptr;", nullPtrLiteralExpr()));
+ EXPECT_TRUE(matches("int* i = nullptr;", cxxNullPtrLiteralExpr()));
}
TEST(Matcher, GNUNullExpr) {
@@ -2295,7 +2300,8 @@ TEST(Matcher, AsmStatement) {
}
TEST(Matcher, Conditions) {
- StatementMatcher Condition = ifStmt(hasCondition(boolLiteral(equals(true))));
+ StatementMatcher Condition =
+ ifStmt(hasCondition(cxxBoolLiteral(equals(true))));
EXPECT_TRUE(matches("void x() { if (true) {} }", Condition));
EXPECT_TRUE(notMatches("void x() { if (false) {} }", Condition));
@@ -2306,13 +2312,13 @@ TEST(Matcher, Conditions) {
TEST(IfStmt, ChildTraversalMatchers) {
EXPECT_TRUE(matches("void f() { if (false) true; else false; }",
- ifStmt(hasThen(boolLiteral(equals(true))))));
+ ifStmt(hasThen(cxxBoolLiteral(equals(true))))));
EXPECT_TRUE(notMatches("void f() { if (false) false; else true; }",
- ifStmt(hasThen(boolLiteral(equals(true))))));
+ ifStmt(hasThen(cxxBoolLiteral(equals(true))))));
EXPECT_TRUE(matches("void f() { if (false) false; else true; }",
- ifStmt(hasElse(boolLiteral(equals(true))))));
+ ifStmt(hasElse(cxxBoolLiteral(equals(true))))));
EXPECT_TRUE(notMatches("void f() { if (false) true; else false; }",
- ifStmt(hasElse(boolLiteral(equals(true))))));
+ ifStmt(hasElse(cxxBoolLiteral(equals(true))))));
}
TEST(MatchBinaryOperator, HasOperatorName) {
@@ -2324,8 +2330,8 @@ TEST(MatchBinaryOperator, HasOperatorName) {
TEST(MatchBinaryOperator, HasLHSAndHasRHS) {
StatementMatcher OperatorTrueFalse =
- binaryOperator(hasLHS(boolLiteral(equals(true))),
- hasRHS(boolLiteral(equals(false))));
+ binaryOperator(hasLHS(cxxBoolLiteral(equals(true))),
+ hasRHS(cxxBoolLiteral(equals(false))));
EXPECT_TRUE(matches("void x() { true || false; }", OperatorTrueFalse));
EXPECT_TRUE(matches("void x() { true && false; }", OperatorTrueFalse));
@@ -2334,7 +2340,7 @@ TEST(MatchBinaryOperator, HasLHSAndHasRHS) {
TEST(MatchBinaryOperator, HasEitherOperand) {
StatementMatcher HasOperand =
- binaryOperator(hasEitherOperand(boolLiteral(equals(false))));
+ binaryOperator(hasEitherOperand(cxxBoolLiteral(equals(false))));
EXPECT_TRUE(matches("void x() { true || false; }", HasOperand));
EXPECT_TRUE(matches("void x() { false && true; }", HasOperand));
@@ -2451,7 +2457,7 @@ TEST(MatchUnaryOperator, HasOperatorName) {
TEST(MatchUnaryOperator, HasUnaryOperand) {
StatementMatcher OperatorOnFalse =
- unaryOperator(hasUnaryOperand(boolLiteral(equals(false))));
+ unaryOperator(hasUnaryOperand(cxxBoolLiteral(equals(false))));
EXPECT_TRUE(matches("void x() { !false; }", OperatorOnFalse));
EXPECT_TRUE(notMatches("void x() { !true; }", OperatorOnFalse));
@@ -2494,15 +2500,15 @@ TEST(Matcher, UnaryOperatorTypes) {
TEST(Matcher, ConditionalOperator) {
StatementMatcher Conditional = conditionalOperator(
- hasCondition(boolLiteral(equals(true))),
- hasTrueExpression(boolLiteral(equals(false))));
+ hasCondition(cxxBoolLiteral(equals(true))),
+ hasTrueExpression(cxxBoolLiteral(equals(false))));
EXPECT_TRUE(matches("void x() { true ? false : true; }", Conditional));
EXPECT_TRUE(notMatches("void x() { false ? false : true; }", Conditional));
EXPECT_TRUE(notMatches("void x() { true ? true : false; }", Conditional));
StatementMatcher ConditionalFalse = conditionalOperator(
- hasFalseExpression(boolLiteral(equals(false))));
+ hasFalseExpression(cxxBoolLiteral(equals(false))));
EXPECT_TRUE(matches("void x() { true ? true : false; }", ConditionalFalse));
EXPECT_TRUE(
@@ -2609,13 +2615,13 @@ TEST(Matcher, IsDefinition) {
EXPECT_TRUE(notMatches("extern int a;", DefinitionOfVariableA));
DeclarationMatcher DefinitionOfMethodA =
- methodDecl(hasName("a"), isDefinition());
+ cxxMethodDecl(hasName("a"), isDefinition());
EXPECT_TRUE(matches("class A { void a() {} };", DefinitionOfMethodA));
EXPECT_TRUE(notMatches("class A { void a(); };", DefinitionOfMethodA));
}
TEST(Matcher, OfClass) {
- StatementMatcher Constructor = constructExpr(hasDeclaration(methodDecl(
+ StatementMatcher Constructor = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
ofClass(hasName("X")))));
EXPECT_TRUE(
@@ -2633,7 +2639,7 @@ TEST(Matcher, VisitsTemplateInstantiations) {
"class A { public: void x(); };"
"template <typename T> class B { public: void y() { T t; t.x(); } };"
"void f() { B<A> b; b.y(); }",
- callExpr(callee(methodDecl(hasName("x"))))));
+ callExpr(callee(cxxMethodDecl(hasName("x"))))));
EXPECT_TRUE(matches(
"class A { public: void x(); };"
@@ -2644,8 +2650,8 @@ TEST(Matcher, VisitsTemplateInstantiations) {
"void f() {"
" C::B<A> b; b.y();"
"}",
- recordDecl(hasName("C"),
- hasDescendant(callExpr(callee(methodDecl(hasName("x"))))))));
+ recordDecl(hasName("C"), hasDescendant(callExpr(
+ callee(cxxMethodDecl(hasName("x"))))))));
}
TEST(Matcher, HandlesNullQualTypes) {
@@ -2738,10 +2744,10 @@ TEST(For, ForLoopInternals) {
TEST(For, ForRangeLoopInternals) {
EXPECT_TRUE(matches("void f(){ int a[] {1, 2}; for (int i : a); }",
- forRangeStmt(hasLoopVariable(anything()))));
+ cxxForRangeStmt(hasLoopVariable(anything()))));
EXPECT_TRUE(matches(
"void f(){ int a[] {1, 2}; for (int i : a); }",
- forRangeStmt(hasRangeInit(declRefExpr(to(varDecl(hasName("a"))))))));
+ cxxForRangeStmt(hasRangeInit(declRefExpr(to(varDecl(hasName("a"))))))));
}
TEST(For, NegativeForLoopInternals) {
@@ -2781,7 +2787,7 @@ TEST(HasBody, FindsBodyOfForWhileDoLoops) {
EXPECT_TRUE(matches("void f() { do {} while(true); }",
doStmt(hasBody(compoundStmt()))));
EXPECT_TRUE(matches("void f() { int p[2]; for (auto x : p) {} }",
- forRangeStmt(hasBody(compoundStmt()))));
+ cxxForRangeStmt(hasBody(compoundStmt()))));
}
TEST(HasAnySubstatement, MatchesForTopLevelCompoundStatement) {
@@ -2902,16 +2908,16 @@ TEST(Member, MatchesMemberAllocationFunction) {
EXPECT_TRUE(matchesConditionally(
"namespace std { typedef typeof(sizeof(int)) size_t; }"
"class X { void *operator new(std::size_t); };",
- methodDecl(ofClass(hasName("X"))), true, "-std=gnu++98"));
+ cxxMethodDecl(ofClass(hasName("X"))), true, "-std=gnu++98"));
EXPECT_TRUE(matches("class X { void operator delete(void*); };",
- methodDecl(ofClass(hasName("X")))));
+ cxxMethodDecl(ofClass(hasName("X")))));
// Fails in C++11 mode
EXPECT_TRUE(matchesConditionally(
"namespace std { typedef typeof(sizeof(int)) size_t; }"
"class X { void operator delete[](void*, std::size_t); };",
- methodDecl(ofClass(hasName("X"))), true, "-std=gnu++98"));
+ cxxMethodDecl(ofClass(hasName("X"))), true, "-std=gnu++98"));
}
TEST(HasObjectExpression, DoesNotMatchMember) {
@@ -2999,59 +3005,59 @@ TEST(CastExpression, DoesNotMatchNonCasts) {
TEST(ReinterpretCast, MatchesSimpleCase) {
EXPECT_TRUE(matches("char* p = reinterpret_cast<char*>(&p);",
- reinterpretCastExpr()));
+ cxxReinterpretCastExpr()));
}
TEST(ReinterpretCast, DoesNotMatchOtherCasts) {
- EXPECT_TRUE(notMatches("char* p = (char*)(&p);", reinterpretCastExpr()));
+ EXPECT_TRUE(notMatches("char* p = (char*)(&p);", cxxReinterpretCastExpr()));
EXPECT_TRUE(notMatches("char q, *p = const_cast<char*>(&q);",
- reinterpretCastExpr()));
+ cxxReinterpretCastExpr()));
EXPECT_TRUE(notMatches("void* p = static_cast<void*>(&p);",
- reinterpretCastExpr()));
+ cxxReinterpretCastExpr()));
EXPECT_TRUE(notMatches("struct B { virtual ~B() {} }; struct D : B {};"
"B b;"
"D* p = dynamic_cast<D*>(&b);",
- reinterpretCastExpr()));
+ cxxReinterpretCastExpr()));
}
TEST(FunctionalCast, MatchesSimpleCase) {
std::string foo_class = "class Foo { public: Foo(const char*); };";
EXPECT_TRUE(matches(foo_class + "void r() { Foo f = Foo(\"hello world\"); }",
- functionalCastExpr()));
+ cxxFunctionalCastExpr()));
}
TEST(FunctionalCast, DoesNotMatchOtherCasts) {
std::string FooClass = "class Foo { public: Foo(const char*); };";
EXPECT_TRUE(
notMatches(FooClass + "void r() { Foo f = (Foo) \"hello world\"; }",
- functionalCastExpr()));
+ cxxFunctionalCastExpr()));
EXPECT_TRUE(
notMatches(FooClass + "void r() { Foo f = \"hello world\"; }",
- functionalCastExpr()));
+ cxxFunctionalCastExpr()));
}
TEST(DynamicCast, MatchesSimpleCase) {
EXPECT_TRUE(matches("struct B { virtual ~B() {} }; struct D : B {};"
"B b;"
"D* p = dynamic_cast<D*>(&b);",
- dynamicCastExpr()));
+ cxxDynamicCastExpr()));
}
TEST(StaticCast, MatchesSimpleCase) {
EXPECT_TRUE(matches("void* p(static_cast<void*>(&p));",
- staticCastExpr()));
+ cxxStaticCastExpr()));
}
TEST(StaticCast, DoesNotMatchOtherCasts) {
- EXPECT_TRUE(notMatches("char* p = (char*)(&p);", staticCastExpr()));
+ EXPECT_TRUE(notMatches("char* p = (char*)(&p);", cxxStaticCastExpr()));
EXPECT_TRUE(notMatches("char q, *p = const_cast<char*>(&q);",
- staticCastExpr()));
+ cxxStaticCastExpr()));
EXPECT_TRUE(notMatches("void* p = reinterpret_cast<char*>(&p);",
- staticCastExpr()));
+ cxxStaticCastExpr()));
EXPECT_TRUE(notMatches("struct B { virtual ~B() {} }; struct D : B {};"
"B b;"
"D* p = dynamic_cast<D*>(&b);",
- staticCastExpr()));
+ cxxStaticCastExpr()));
}
TEST(CStyleCast, MatchesSimpleCase) {
@@ -3070,7 +3076,7 @@ TEST(CStyleCast, DoesNotMatchOtherCasts) {
TEST(HasDestinationType, MatchesSimpleCase) {
EXPECT_TRUE(matches("char* p = static_cast<char*>(0);",
- staticCastExpr(hasDestinationType(
+ cxxStaticCastExpr(hasDestinationType(
pointsTo(TypeMatcher(anything()))))));
}
@@ -3273,7 +3279,7 @@ TEST(HasSourceExpression, MatchesImplicitCasts) {
EXPECT_TRUE(matches("class string {}; class URL { public: URL(string s); };"
"void r() {string a_string; URL url = a_string; }",
implicitCastExpr(
- hasSourceExpression(constructExpr()))));
+ hasSourceExpression(cxxConstructExpr()))));
}
TEST(HasSourceExpression, MatchesExplicitCasts) {
@@ -3445,21 +3451,22 @@ TEST(SwitchCase, MatchesEachCase) {
TEST(ForEachConstructorInitializer, MatchesInitializers) {
EXPECT_TRUE(matches(
"struct X { X() : i(42), j(42) {} int i, j; };",
- constructorDecl(forEachConstructorInitializer(ctorInitializer()))));
+ cxxConstructorDecl(forEachConstructorInitializer(cxxCtorInitializer()))));
}
TEST(ExceptionHandling, SimpleCases) {
- EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", catchStmt()));
- EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", tryStmt()));
- EXPECT_TRUE(notMatches("void foo() try { } catch(int X) { }", throwExpr()));
+ EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", cxxCatchStmt()));
+ EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", cxxTryStmt()));
+ EXPECT_TRUE(
+ notMatches("void foo() try { } catch(int X) { }", cxxThrowExpr()));
EXPECT_TRUE(matches("void foo() try { throw; } catch(int X) { }",
- throwExpr()));
+ cxxThrowExpr()));
EXPECT_TRUE(matches("void foo() try { throw 5;} catch(int X) { }",
- throwExpr()));
+ cxxThrowExpr()));
EXPECT_TRUE(matches("void foo() try { throw; } catch(...) { }",
- catchStmt(isCatchAll())));
+ cxxCatchStmt(isCatchAll())));
EXPECT_TRUE(notMatches("void foo() try { throw; } catch(int) { }",
- catchStmt(isCatchAll())));
+ cxxCatchStmt(isCatchAll())));
EXPECT_TRUE(matches("void foo() try {} catch(int X) { }",
varDecl(isExceptionVariable())));
EXPECT_TRUE(notMatches("void foo() try { int X; } catch (...) { }",
@@ -3595,12 +3602,12 @@ TEST(LoopingMatchers, DoNotOverwritePreviousMatchResultOnFailure) {
new VerifyIdIsBoundTo<Decl>("x", 1)));
EXPECT_TRUE(matchAndVerifyResultTrue(
"class X { void f(); void g(); };",
- recordDecl(decl().bind("x"), hasMethod(hasName("g"))),
+ cxxRecordDecl(decl().bind("x"), hasMethod(hasName("g"))),
new VerifyIdIsBoundTo<Decl>("x", 1)));
EXPECT_TRUE(matchAndVerifyResultTrue(
"class X { X() : a(1), b(2) {} double a; int b; };",
recordDecl(decl().bind("x"),
- has(constructorDecl(
+ has(cxxConstructorDecl(
hasAnyConstructorInitializer(forField(hasName("b")))))),
new VerifyIdIsBoundTo<Decl>("x", 1)));
EXPECT_TRUE(matchAndVerifyResultTrue(
@@ -3624,12 +3631,12 @@ TEST(LoopingMatchers, DoNotOverwritePreviousMatchResultOnFailure) {
new VerifyIdIsBoundTo<Decl>("x", 1)));
EXPECT_TRUE(matchAndVerifyResultTrue(
"class A{}; class B{}; class C : B, A {};",
- recordDecl(decl().bind("x"), isDerivedFrom("::A")),
+ cxxRecordDecl(decl().bind("x"), isDerivedFrom("::A")),
new VerifyIdIsBoundTo<Decl>("x", 1)));
EXPECT_TRUE(matchAndVerifyResultTrue(
"class A{}; typedef A B; typedef A C; typedef A D;"
"class E : A {};",
- recordDecl(decl().bind("x"), isDerivedFrom("C")),
+ cxxRecordDecl(decl().bind("x"), isDerivedFrom("C")),
new VerifyIdIsBoundTo<Decl>("x", 1)));
EXPECT_TRUE(matchAndVerifyResultTrue(
"class A { class B { void f() {} }; };",
@@ -3648,8 +3655,8 @@ TEST(LoopingMatchers, DoNotOverwritePreviousMatchResultOnFailure) {
new VerifyIdIsBoundTo<Decl>("x", 1)));
EXPECT_TRUE(matchAndVerifyResultTrue(
"class A { A() : s(), i(42) {} const char *s; int i; };",
- constructorDecl(hasName("::A::A"), decl().bind("x"),
- forEachConstructorInitializer(forField(hasName("i")))),
+ cxxConstructorDecl(hasName("::A::A"), decl().bind("x"),
+ forEachConstructorInitializer(forField(hasName("i")))),
new VerifyIdIsBoundTo<Decl>("x", 1)));
}
@@ -3723,11 +3730,11 @@ TEST(IsTemplateInstantiation, MatchesImplicitClassTemplateInstantiation) {
EXPECT_TRUE(matches(
"template <typename T> class X {}; class A {}; X<A> x;",
- recordDecl(hasName("::X"), isTemplateInstantiation())));
+ cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
EXPECT_TRUE(matches(
"template <typename T> class X { T t; }; class A {}; X<A> x;",
- recordDecl(isTemplateInstantiation(), hasDescendant(
+ cxxRecordDecl(isTemplateInstantiation(), hasDescendant(
fieldDecl(hasType(recordDecl(hasName("A"))))))));
}
@@ -3742,7 +3749,7 @@ TEST(IsTemplateInstantiation, MatchesExplicitClassTemplateInstantiation) {
EXPECT_TRUE(matches(
"template <typename T> class X { T t; }; class A {};"
"template class X<A>;",
- recordDecl(isTemplateInstantiation(), hasDescendant(
+ cxxRecordDecl(isTemplateInstantiation(), hasDescendant(
fieldDecl(hasType(recordDecl(hasName("A"))))))));
}
@@ -3751,7 +3758,7 @@ TEST(IsTemplateInstantiation,
EXPECT_TRUE(matches(
"template <typename T> class X {};"
"template <typename T> class X<T*> {}; class A {}; X<A*> x;",
- recordDecl(hasName("::X"), isTemplateInstantiation())));
+ cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
}
TEST(IsTemplateInstantiation,
@@ -3762,7 +3769,7 @@ TEST(IsTemplateInstantiation,
" template <typename U> class Y { U u; };"
" Y<A> y;"
"};",
- recordDecl(hasName("::X::Y"), isTemplateInstantiation())));
+ cxxRecordDecl(hasName("::X::Y"), isTemplateInstantiation())));
}
TEST(IsTemplateInstantiation, DoesNotMatchInstantiationsInsideOfInstantiation) {
@@ -3775,31 +3782,31 @@ TEST(IsTemplateInstantiation, DoesNotMatchInstantiationsInsideOfInstantiation) {
" template <typename U> class Y { U u; };"
" Y<T> y;"
"}; X<A> x;",
- recordDecl(hasName("::X<A>::Y"), unless(isTemplateInstantiation()))));
+ cxxRecordDecl(hasName("::X<A>::Y"), unless(isTemplateInstantiation()))));
}
TEST(IsTemplateInstantiation, DoesNotMatchExplicitClassTemplateSpecialization) {
EXPECT_TRUE(notMatches(
"template <typename T> class X {}; class A {};"
"template <> class X<A> {}; X<A> x;",
- recordDecl(hasName("::X"), isTemplateInstantiation())));
+ cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
}
TEST(IsTemplateInstantiation, DoesNotMatchNonTemplate) {
EXPECT_TRUE(notMatches(
"class A {}; class Y { A a; };",
- recordDecl(isTemplateInstantiation())));
+ cxxRecordDecl(isTemplateInstantiation())));
}
TEST(IsInstantiated, MatchesInstantiation) {
EXPECT_TRUE(
matches("template<typename T> class A { T i; }; class Y { A<int> a; };",
- recordDecl(isInstantiated())));
+ cxxRecordDecl(isInstantiated())));
}
TEST(IsInstantiated, NotMatchesDefinition) {
EXPECT_TRUE(notMatches("template<typename T> class A { T i; };",
- recordDecl(isInstantiated())));
+ cxxRecordDecl(isInstantiated())));
}
TEST(IsInTemplateInstantiation, MatchesInstantiationStmt) {
@@ -3851,7 +3858,7 @@ TEST(IsExplicitTemplateSpecialization,
DoesNotMatchPrimaryTemplate) {
EXPECT_TRUE(notMatches(
"template <typename T> class X {};",
- recordDecl(isExplicitTemplateSpecialization())));
+ cxxRecordDecl(isExplicitTemplateSpecialization())));
EXPECT_TRUE(notMatches(
"template <typename T> void f(T t);",
functionDecl(isExplicitTemplateSpecialization())));
@@ -3862,7 +3869,7 @@ TEST(IsExplicitTemplateSpecialization,
EXPECT_TRUE(notMatches(
"template <typename T> class X {};"
"template class X<int>; extern template class X<long>;",
- recordDecl(isExplicitTemplateSpecialization())));
+ cxxRecordDecl(isExplicitTemplateSpecialization())));
EXPECT_TRUE(notMatches(
"template <typename T> void f(T t) {}"
"template void f(int t); extern template void f(long t);",
@@ -3873,7 +3880,7 @@ TEST(IsExplicitTemplateSpecialization,
DoesNotMatchImplicitTemplateInstantiations) {
EXPECT_TRUE(notMatches(
"template <typename T> class X {}; X<int> x;",
- recordDecl(isExplicitTemplateSpecialization())));
+ cxxRecordDecl(isExplicitTemplateSpecialization())));
EXPECT_TRUE(notMatches(
"template <typename T> void f(T t); void g() { f(10); }",
functionDecl(isExplicitTemplateSpecialization())));
@@ -3884,7 +3891,7 @@ TEST(IsExplicitTemplateSpecialization,
EXPECT_TRUE(matches(
"template <typename T> class X {};"
"template<> class X<int> {};",
- recordDecl(isExplicitTemplateSpecialization())));
+ cxxRecordDecl(isExplicitTemplateSpecialization())));
EXPECT_TRUE(matches(
"template <typename T> void f(T t) {}"
"template<> void f(int t) {}",
@@ -3966,7 +3973,7 @@ TEST(HasAncestor, MatchesInTemplateInstantiations) {
TEST(HasAncestor, MatchesInImplicitCode) {
EXPECT_TRUE(matches(
"struct X {}; struct A { A() {} X x; };",
- constructorDecl(
+ cxxConstructorDecl(
hasAnyConstructorInitializer(withInitializer(expr(
hasAncestor(recordDecl(hasName("A")))))))));
}
@@ -3989,8 +3996,9 @@ TEST(HasAncestor, MatchesAllAncestors) {
"void t() { C<int>::f(); }",
integerLiteral(
equals(42),
- allOf(hasAncestor(recordDecl(isTemplateInstantiation())),
- hasAncestor(recordDecl(unless(isTemplateInstantiation())))))));
+ allOf(
+ hasAncestor(cxxRecordDecl(isTemplateInstantiation())),
+ hasAncestor(cxxRecordDecl(unless(isTemplateInstantiation())))))));
}
TEST(HasParent, MatchesAllParents) {
@@ -4000,23 +4008,23 @@ TEST(HasParent, MatchesAllParents) {
integerLiteral(
equals(42),
hasParent(compoundStmt(hasParent(functionDecl(
- hasParent(recordDecl(isTemplateInstantiation())))))))));
- EXPECT_TRUE(matches(
- "template <typename T> struct C { static void f() { 42; } };"
- "void t() { C<int>::f(); }",
- integerLiteral(
- equals(42),
- hasParent(compoundStmt(hasParent(functionDecl(
- hasParent(recordDecl(unless(isTemplateInstantiation()))))))))));
+ hasParent(cxxRecordDecl(isTemplateInstantiation())))))))));
+ EXPECT_TRUE(
+ matches("template <typename T> struct C { static void f() { 42; } };"
+ "void t() { C<int>::f(); }",
+ integerLiteral(
+ equals(42),
+ hasParent(compoundStmt(hasParent(functionDecl(hasParent(
+ cxxRecordDecl(unless(isTemplateInstantiation()))))))))));
EXPECT_TRUE(matches(
"template <typename T> struct C { static void f() { 42; } };"
"void t() { C<int>::f(); }",
integerLiteral(equals(42),
- hasParent(compoundStmt(allOf(
- hasParent(functionDecl(
- hasParent(recordDecl(isTemplateInstantiation())))),
- hasParent(functionDecl(hasParent(recordDecl(
- unless(isTemplateInstantiation())))))))))));
+ hasParent(compoundStmt(
+ allOf(hasParent(functionDecl(hasParent(
+ cxxRecordDecl(isTemplateInstantiation())))),
+ hasParent(functionDecl(hasParent(cxxRecordDecl(
+ unless(isTemplateInstantiation())))))))))));
EXPECT_TRUE(
notMatches("template <typename T> struct C { static void f() {} };"
"void t() { C<int>::f(); }",
@@ -4049,8 +4057,8 @@ TEST(TypeMatching, MatchesTypes) {
}
TEST(TypeMatching, MatchesVoid) {
- EXPECT_TRUE(
- matches("struct S { void func(); };", methodDecl(returns(voidType()))));
+ EXPECT_TRUE(matches("struct S { void func(); };",
+ cxxMethodDecl(returns(voidType()))));
}
TEST(TypeMatching, MatchesArrayTypes) {
@@ -4813,12 +4821,12 @@ TEST(EqualsBoundNodeMatcher, UnlessDescendantsOfAncestorsMatch) {
"void f(StringRef v) {"
" v.data();"
"}",
- memberCallExpr(
- callee(methodDecl(hasName("data"))),
- on(declRefExpr(to(varDecl(hasType(recordDecl(hasName("StringRef"))))
- .bind("var")))),
- unless(hasAncestor(stmt(hasDescendant(memberCallExpr(
- callee(methodDecl(anyOf(hasName("size"), hasName("length")))),
+ cxxMemberCallExpr(
+ callee(cxxMethodDecl(hasName("data"))),
+ on(declRefExpr(to(
+ varDecl(hasType(recordDecl(hasName("StringRef")))).bind("var")))),
+ unless(hasAncestor(stmt(hasDescendant(cxxMemberCallExpr(
+ callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))),
on(declRefExpr(to(varDecl(equalsBoundNode("var")))))))))))
.bind("data"),
new VerifyIdIsBoundTo<Expr>("data", 1)));
@@ -4829,12 +4837,12 @@ TEST(EqualsBoundNodeMatcher, UnlessDescendantsOfAncestorsMatch) {
" v.data();"
" v.size();"
"}",
- memberCallExpr(
- callee(methodDecl(hasName("data"))),
- on(declRefExpr(to(varDecl(hasType(recordDecl(hasName("StringRef"))))
- .bind("var")))),
- unless(hasAncestor(stmt(hasDescendant(memberCallExpr(
- callee(methodDecl(anyOf(hasName("size"), hasName("length")))),
+ cxxMemberCallExpr(
+ callee(cxxMethodDecl(hasName("data"))),
+ on(declRefExpr(to(
+ varDecl(hasType(recordDecl(hasName("StringRef")))).bind("var")))),
+ unless(hasAncestor(stmt(hasDescendant(cxxMemberCallExpr(
+ callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))),
on(declRefExpr(to(varDecl(equalsBoundNode("var")))))))))))
.bind("data")));
}
diff --git a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
index 45b0910ab0a..d96aa265cdb 100644
--- a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -301,12 +301,12 @@ TEST(ParserTest, CompletionNamedValues) {
EXPECT_EQ("String nameX", Comps[0].MatcherDecl);
// Can complete if there are names in the expression.
- Code = "methodDecl(hasName(nameX), ";
+ Code = "cxxMethodDecl(hasName(nameX), ";
Comps = Parser::completeExpression(Code, Code.size(), nullptr, &NamedValues);
EXPECT_LT(0u, Comps.size());
// Can complete names and registry together.
- Code = "methodDecl(hasP";
+ Code = "cxxMethodDecl(hasP";
Comps = Parser::completeExpression(Code, Code.size(), nullptr, &NamedValues);
ASSERT_EQ(3u, Comps.size());
EXPECT_EQ("aramA", Comps[0].TypedText);
diff --git a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
index a6b0a1b41d6..ca1dfefd538 100644
--- a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -129,7 +129,7 @@ TEST_F(RegistryTest, CanConstructNoArgs) {
Matcher<Stmt> IsArrowValue = constructMatcher(
"memberExpr", constructMatcher("isArrow")).getTypedMatcher<Stmt>();
Matcher<Stmt> BoolValue =
- constructMatcher("boolLiteral").getTypedMatcher<Stmt>();
+ constructMatcher("cxxBoolLiteral").getTypedMatcher<Stmt>();
const std::string ClassSnippet = "struct Foo { int x; };\n"
"Foo *foo = new Foo;\n"
@@ -195,7 +195,7 @@ TEST_F(RegistryTest, OverloadedMatchers) {
"callExpr",
constructMatcher(
"callee",
- constructMatcher("methodDecl",
+ constructMatcher("cxxMethodDecl",
constructMatcher("hasName", StringRef("x")))))
.getTypedMatcher<Stmt>();
@@ -255,11 +255,11 @@ TEST_F(RegistryTest, PolymorphicMatchers) {
EXPECT_FALSE(matches("void Foo(){};", RecordDecl));
Matcher<Stmt> ConstructExpr = constructMatcher(
- "constructExpr",
+ "cxxConstructExpr",
constructMatcher(
"hasDeclaration",
constructMatcher(
- "methodDecl",
+ "cxxMethodDecl",
constructMatcher(
"ofClass", constructMatcher("hasName", StringRef("Foo"))))))
.getTypedMatcher<Stmt>();
@@ -300,7 +300,7 @@ TEST_F(RegistryTest, TypeTraversal) {
TEST_F(RegistryTest, CXXCtorInitializer) {
Matcher<Decl> CtorDecl = constructMatcher(
- "constructorDecl",
+ "cxxConstructorDecl",
constructMatcher(
"hasAnyConstructorInitializer",
constructMatcher("forField",
@@ -416,9 +416,10 @@ TEST_F(RegistryTest, Errors) {
"(Actual = String)",
Error->toString());
Error.reset(new Diagnostics());
- EXPECT_TRUE(constructMatcher("recordDecl", constructMatcher("recordDecl"),
- constructMatcher("parameterCountIs", 3),
- Error.get()).isNull());
+ EXPECT_TRUE(
+ constructMatcher("cxxRecordDecl", constructMatcher("cxxRecordDecl"),
+ constructMatcher("parameterCountIs", 3), Error.get())
+ .isNull());
EXPECT_EQ("Incorrect type for arg 2. (Expected = Matcher<CXXRecordDecl>) != "
"(Actual = Matcher<FunctionDecl>)",
Error->toString());
@@ -432,7 +433,7 @@ TEST_F(RegistryTest, Errors) {
Error->toString());
Error.reset(new Diagnostics());
EXPECT_TRUE(constructMatcher(
- "recordDecl",
+ "cxxRecordDecl",
constructMatcher("allOf",
constructMatcher("isDerivedFrom", StringRef("FOO")),
constructMatcher("isArrow")),
diff --git a/clang/unittests/Tooling/RefactoringCallbacksTest.cpp b/clang/unittests/Tooling/RefactoringCallbacksTest.cpp
index c2b331c70af..ad8aa8f98fe 100644
--- a/clang/unittests/Tooling/RefactoringCallbacksTest.cpp
+++ b/clang/unittests/Tooling/RefactoringCallbacksTest.cpp
@@ -71,7 +71,7 @@ TEST(RefactoringCallbacksTest, ReplacesStmtWithStmt) {
ReplaceStmtWithStmt Callback("always-false", "should-be");
expectRewritten(Code, Expected,
id("always-false", conditionalOperator(
- hasCondition(boolLiteral(equals(false))),
+ hasCondition(cxxBoolLiteral(equals(false))),
hasFalseExpression(id("should-be", expr())))),
Callback);
}
@@ -92,7 +92,7 @@ TEST(RefactoringCallbacksTest, RemovesEntireIfOnEmptyElse) {
std::string Expected = "void f() { }";
ReplaceIfStmtWithItsBody Callback("id", false);
expectRewritten(Code, Expected,
- id("id", ifStmt(hasCondition(boolLiteral(equals(false))))),
+ id("id", ifStmt(hasCondition(cxxBoolLiteral(equals(false))))),
Callback);
}
OpenPOWER on IntegriCloud