summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2016-04-13 11:13:08 +0000
committerAlexander Kornienko <alexfh@google.com>2016-04-13 11:13:08 +0000
commit7d20a5afdbe77bccea3d854de2b6d86ee8fc8c8c (patch)
tree49989857a9ea5dbd5ed8cbb43a5a0e15f029772a /clang/unittests/ASTMatchers/ASTMatchersTest.cpp
parent074edd7c1e5f1df4a538a1efe19f4753f367c96e (diff)
downloadbcm5719-llvm-7d20a5afdbe77bccea3d854de2b6d86ee8fc8c8c.tar.gz
bcm5719-llvm-7d20a5afdbe77bccea3d854de2b6d86ee8fc8c8c.zip
Add AST Matchers for CXXConstructorDecl::isDelegatingConstructor and CXXMethodDecl::isUserProvided.
Summary: Added two AST matchers: isDelegatingConstructor for CXXConstructorDecl::IsDelegatingConstructor; and isUserProvided corresponding to CXXMethodDecl::isUserProvided. Reviewers: aaron.ballman, alexfh Subscribers: klimek, cfe-commits Patch by Michael Miller! Differential Revision: http://reviews.llvm.org/D19038 llvm-svn: 266189
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index e4b6bb17033..df818ba9422 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2327,6 +2327,32 @@ TEST(ConstructorDeclaration, Kinds) {
cxxConstructorDecl(isMoveConstructor())));
}
+TEST(ConstructorDeclaration, IsUserProvided) {
+ EXPECT_TRUE(notMatches("struct S { int X = 0; };",
+ cxxConstructorDecl(isUserProvided())));
+ EXPECT_TRUE(notMatches("struct S { S() = default; };",
+ cxxConstructorDecl(isUserProvided())));
+ EXPECT_TRUE(notMatches("struct S { S() = delete; };",
+ cxxConstructorDecl(isUserProvided())));
+ EXPECT_TRUE(
+ matches("struct S { S(); };", cxxConstructorDecl(isUserProvided())));
+ EXPECT_TRUE(matches("struct S { S(); }; S::S(){}",
+ cxxConstructorDecl(isUserProvided())));
+}
+
+TEST(ConstructorDeclaration, IsDelegatingConstructor) {
+ EXPECT_TRUE(notMatches("struct S { S(); S(int); int X; };",
+ cxxConstructorDecl(isDelegatingConstructor())));
+ EXPECT_TRUE(notMatches("struct S { S(){} S(int X) : X(X) {} int X; };",
+ cxxConstructorDecl(isDelegatingConstructor())));
+ EXPECT_TRUE(matches(
+ "struct S { S() : S(0) {} S(int X) : X(X) {} int X; };",
+ cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(0))));
+ EXPECT_TRUE(matches(
+ "struct S { S(); S(int X); int X; }; S::S(int X) : S() {}",
+ cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(1))));
+}
+
TEST(DestructorDeclaration, MatchesVirtualDestructor) {
EXPECT_TRUE(matches("class Foo { virtual ~Foo(); };",
cxxDestructorDecl(ofClass(hasName("Foo")))));
OpenPOWER on IntegriCloud