Differential Revision: http://llvm-reviews.chandlerc.com/D2708
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200949
91177308-0d34-0410-b5e6-
96231b3b80d8
return false;
}
+/// \brief Matches a constructor call expression which uses list initialization.
+AST_MATCHER(CXXConstructExpr, isListInitialization) {
+ return Node.isListInitialization();
+}
+
/// \brief Matches the n'th parameter of a function declaration.
///
/// Given
REGISTER_MATCHER(isExternC);
REGISTER_MATCHER(isImplicit);
REGISTER_MATCHER(isInteger);
+ REGISTER_MATCHER(isListInitialization);
REGISTER_MATCHER(isOverride);
REGISTER_MATCHER(isPrivate);
REGISTER_MATCHER(isProtected);
Constructor1Arg));
}
+TEST(Matcher, ConstructorListInitialization) {
+ StatementMatcher ConstructorListInit = constructExpr(isListInitialization());
+
+ EXPECT_TRUE(
+ matches("class X { public: X(int); }; void x() { X x{0}; }",
+ ConstructorListInit));
+ EXPECT_FALSE(
+ matches("class X { public: X(int); }; void x() { X x(0); }",
+ ConstructorListInit));
+}
+
TEST(Matcher,ThisExpr) {
EXPECT_TRUE(
matches("struct X { int a; int f () { return a; } };", thisExpr()));