[ASTMatchers] Move the 'isImplicit' matcher from CXXConstructorDecl to Decl.

llvm-svn: 209006
This commit is contained in:
Joey Gouly 2014-05-16 19:31:08 +00:00
parent 2e9ce4c565
commit 0d9a2b2205
2 changed files with 9 additions and 6 deletions

View File

@ -311,6 +311,12 @@ AST_MATCHER(Decl, isPrivate) {
return Node.getAccess() == AS_private;
}
/// \brief Matches a declaration that has been implicitly added
/// by the compiler (eg. implicit default/copy constructors).
AST_MATCHER(Decl, isImplicit) {
return Node.isImplicit();
}
/// \brief Matches classTemplateSpecializations that have at least one
/// TemplateArgument matching the given InnerMatcher.
///
@ -2187,12 +2193,6 @@ AST_MATCHER(CXXCtorInitializer, isWritten) {
return Node.isWritten();
}
/// \brief Matches a constructor declaration that has been implicitly added
/// by the compiler (eg. implicit default/copy constructors).
AST_MATCHER(CXXConstructorDecl, isImplicit) {
return Node.isImplicit();
}
/// \brief Matches any argument of a call expression or a constructor call
/// expression.
///

View File

@ -1773,6 +1773,9 @@ TEST(ConstructorDeclaration, IsImplicit) {
constructorDecl(isImplicit())));
EXPECT_TRUE(matches("class Foo { Foo(){} };",
constructorDecl(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="))));
}
TEST(DestructorDeclaration, MatchesVirtualDestructor) {