summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2015-08-11 21:09:52 +0000
committerAaron Ballman <aaron@aaronballman.com>2015-08-11 21:09:52 +0000
commit6f6d0b6c5a37a42f17591e37a30c911ec1c52898 (patch)
treea457a591951a63edbd746ac32a1e420dc0b63f92 /clang/unittests/ASTMatchers/ASTMatchersTest.cpp
parentda06bce8b50d47ca841d694e10c12638157b2093 (diff)
downloadbcm5719-llvm-6f6d0b6c5a37a42f17591e37a30c911ec1c52898.tar.gz
bcm5719-llvm-6f6d0b6c5a37a42f17591e37a30c911ec1c52898.zip
Add a polymorphic AST matcher for testing whether a constructor or a conversion declaration is marked as explicit or not.
llvm-svn: 244666
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index d51a5e28b5e..f0eede8a788 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1420,6 +1420,13 @@ TEST(Callee, MatchesDeclarations) {
CallMethodX));
}
+TEST(ConversionDeclaration, IsExplicit) {
+ EXPECT_TRUE(matches("struct S { explicit operator int(); };",
+ conversionDecl(isExplicit())));
+ EXPECT_TRUE(notMatches("struct S { operator int(); };",
+ conversionDecl(isExplicit())));
+}
+
TEST(Callee, MatchesMemberExpressions) {
EXPECT_TRUE(matches("class Y { void x() { this->x(); } };",
callExpr(callee(memberExpr()))));
@@ -1992,6 +1999,13 @@ TEST(ConstructorDeclaration, IsImplicit) {
methodDecl(isImplicit(), hasName("operator="))));
}
+TEST(ConstructorDeclaration, IsExplicit) {
+ EXPECT_TRUE(matches("struct S { explicit S(int); };",
+ constructorDecl(isExplicit())));
+ EXPECT_TRUE(notMatches("struct S { S(int); };",
+ constructorDecl(isExplicit())));
+}
+
TEST(ConstructorDeclaration, Kinds) {
EXPECT_TRUE(matches("struct S { S(); };",
constructorDecl(isDefaultConstructor())));
OpenPOWER on IntegriCloud