forked from OSchip/llvm-project
Add isListInitialization matcher.
Differential Revision: http://llvm-reviews.chandlerc.com/D2708 llvm-svn: 200949
This commit is contained in:
parent
3d584b0ced
commit
1fec3dfe43
|
@ -2186,6 +2186,11 @@ AST_POLYMORPHIC_MATCHER_P(hasAnyArgument, AST_POLYMORPHIC_SUPPORTED_TYPES_2(
|
||||||
return false;
|
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.
|
/// \brief Matches the n'th parameter of a function declaration.
|
||||||
///
|
///
|
||||||
/// Given
|
/// Given
|
||||||
|
|
|
@ -231,6 +231,7 @@ RegistryMaps::RegistryMaps() {
|
||||||
REGISTER_MATCHER(isExternC);
|
REGISTER_MATCHER(isExternC);
|
||||||
REGISTER_MATCHER(isImplicit);
|
REGISTER_MATCHER(isImplicit);
|
||||||
REGISTER_MATCHER(isInteger);
|
REGISTER_MATCHER(isInteger);
|
||||||
|
REGISTER_MATCHER(isListInitialization);
|
||||||
REGISTER_MATCHER(isOverride);
|
REGISTER_MATCHER(isOverride);
|
||||||
REGISTER_MATCHER(isPrivate);
|
REGISTER_MATCHER(isPrivate);
|
||||||
REGISTER_MATCHER(isProtected);
|
REGISTER_MATCHER(isProtected);
|
||||||
|
|
|
@ -1637,6 +1637,17 @@ TEST(Matcher, ConstructorArgumentCount) {
|
||||||
Constructor1Arg));
|
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) {
|
TEST(Matcher,ThisExpr) {
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
matches("struct X { int a; int f () { return a; } };", thisExpr()));
|
matches("struct X { int a; int f () { return a; } };", thisExpr()));
|
||||||
|
|
Loading…
Reference in New Issue