]> granicus.if.org Git - clang/commitdiff
[ASTMatchers] Move the 'isImplicit' matcher from CXXConstructorDecl to Decl.
authorJoey Gouly <joey.gouly@gmail.com>
Fri, 16 May 2014 19:31:08 +0000 (19:31 +0000)
committerJoey Gouly <joey.gouly@gmail.com>
Fri, 16 May 2014 19:31:08 +0000 (19:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209006 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/ASTMatchers/ASTMatchers.h
unittests/ASTMatchers/ASTMatchersTest.cpp

index 81fa3d49fb5cd57f1675dcb39c2b73f5420f6858..e7d5e5f1a14fea159f40005d24f4757d795aa801 100644 (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.
 ///
index 5d09700e6e0ec34e33f6af6fe0eff2c32fad0cc9..e7d99242fcf0f69bdfe8434b5766cf9cc45aa9d9 100644 (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) {