summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2015-09-17 13:30:52 +0000
committerAaron Ballman <aaron@aaronballman.com>2015-09-17 13:30:52 +0000
commit512fb64765c7d61e89531b8ff697a85d815d9a13 (patch)
tree13b547afff599de69cc832efbd2d67313e33f98b /clang/unittests/ASTMatchers
parent6c1f0933ac1490cc44083c7f1063d1d280a6310f (diff)
downloadbcm5719-llvm-512fb64765c7d61e89531b8ff697a85d815d9a13.tar.gz
bcm5719-llvm-512fb64765c7d61e89531b8ff697a85d815d9a13.zip
Rename AST node matchers to match the AST node names directly. Part of this rename also splits recordDecl() (which used to match CXXRecordDecl) into recordDecl() (that matches RecordDecl) and cxxRecordDecl (that matches CXXRecordDecl). Also adds isStruct(), isUnion(), and isClass() narrowing matchers for RecordDecl objects.
llvm-svn: 247885
Diffstat (limited to 'clang/unittests/ASTMatchers')
-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
3 files changed, 278 insertions, 269 deletions
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")),
OpenPOWER on IntegriCloud