[arcmt] Fully migrate ObjC++ classes, rdar://9660007.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133763 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ARCMigrate/TransAutoreleasePool.cpp b/lib/ARCMigrate/TransAutoreleasePool.cpp
index 602ac0c..5b84854 100644
--- a/lib/ARCMigrate/TransAutoreleasePool.cpp
+++ b/lib/ARCMigrate/TransAutoreleasePool.cpp
@@ -69,8 +69,8 @@
 class AutoreleasePoolRewriter
                          : public RecursiveASTVisitor<AutoreleasePoolRewriter> {
 public:
-  AutoreleasePoolRewriter(Decl *D, MigrationPass &pass)
-    : Dcl(D), Body(0), Pass(pass) {
+  AutoreleasePoolRewriter(MigrationPass &pass)
+    : Body(0), Pass(pass) {
     PoolII = &pass.Ctx.Idents.get("NSAutoreleasePool");
     DrainSel = pass.Ctx.Selectors.getNullarySelector(
                                                  &pass.Ctx.Idents.get("drain"));
@@ -411,7 +411,6 @@
     return S;
   }
 
-  Decl *Dcl;
   Stmt *Body;
   MigrationPass &Pass;
 
diff --git a/lib/ARCMigrate/TransRetainReleaseDealloc.cpp b/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
index f03ab5a..c177363 100644
--- a/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
+++ b/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
@@ -31,7 +31,6 @@
 
 class RetainReleaseDeallocRemover :
                        public RecursiveASTVisitor<RetainReleaseDeallocRemover> {
-  Decl *Dcl;
   Stmt *Body;
   MigrationPass &Pass;
 
@@ -39,8 +38,8 @@
   llvm::OwningPtr<ParentMap> StmtMap;
 
 public:
-  RetainReleaseDeallocRemover(Decl *D, MigrationPass &pass)
-    : Dcl(D), Body(0), Pass(pass) { }
+  RetainReleaseDeallocRemover(MigrationPass &pass)
+    : Body(0), Pass(pass) { }
 
   void transformBody(Stmt *body) {
     Body = body;
diff --git a/lib/ARCMigrate/TransUnusedInitDelegate.cpp b/lib/ARCMigrate/TransUnusedInitDelegate.cpp
index 2fa18a3..1019ab4 100644
--- a/lib/ARCMigrate/TransUnusedInitDelegate.cpp
+++ b/lib/ARCMigrate/TransUnusedInitDelegate.cpp
@@ -32,15 +32,14 @@
 namespace {
 
 class UnusedInitRewriter : public RecursiveASTVisitor<UnusedInitRewriter> {
-  Decl *Dcl;
   Stmt *Body;
   MigrationPass &Pass;
 
   ExprSet Removables;
 
 public:
-  UnusedInitRewriter(Decl *D, MigrationPass &pass)
-    : Dcl(D), Body(0), Pass(pass) { }
+  UnusedInitRewriter(MigrationPass &pass)
+    : Body(0), Pass(pass) { }
 
   void transformBody(Stmt *body) {
     Body = body;
diff --git a/lib/ARCMigrate/Transforms.h b/lib/ARCMigrate/Transforms.h
index 06d7f2b..2106497 100644
--- a/lib/ARCMigrate/Transforms.h
+++ b/lib/ARCMigrate/Transforms.h
@@ -59,25 +59,8 @@
 public:
   BodyTransform(MigrationPass &pass) : Pass(pass) { }
 
-  void handleBody(Decl *D) {
-    Stmt *body = D->getBody();
-    if (body) {
-      BODY_TRANS(D, Pass).transformBody(body);
-    }
-  }
-
-  bool TraverseBlockDecl(BlockDecl *D) {
-    handleBody(D);
-    return true;
-  }
-  bool TraverseObjCMethodDecl(ObjCMethodDecl *D) {
-    if (D->isThisDeclarationADefinition())
-      handleBody(D);
-    return true;
-  }
-  bool TraverseFunctionDecl(FunctionDecl *D) {
-    if (D->isThisDeclarationADefinition())
-      handleBody(D);
+  bool TraverseStmt(Stmt *rootS) {
+    BODY_TRANS(Pass).transformBody(rootS);
     return true;
   }
 };
diff --git a/test/ARCMT/cxx-rewrite.mm b/test/ARCMT/cxx-rewrite.mm
new file mode 100644
index 0000000..ab402e4
--- /dev/null
+++ b/test/ARCMT/cxx-rewrite.mm
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c++ %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -x objective-c++ %s > %t
+// RUN: diff %t %s.result
+
+#include "Common.h"
+
+@interface NSString : NSObject
++(id)string;
+@end
+
+struct foo {
+    NSString *s;
+    foo(NSString *s): s([s retain]){
+        NSAutoreleasePool *pool = [NSAutoreleasePool new];
+        [[NSString string] autorelease];
+        [pool drain];
+    }
+    ~foo(){ [s release]; }
+private:
+    foo(foo const &);
+    foo &operator=(foo const &);
+};
+
+int main(){
+    NSAutoreleasePool *pool = [NSAutoreleasePool new];
+
+    foo f([[NSString string] autorelease]);
+
+    [pool drain];
+    return 0;
+}
diff --git a/test/ARCMT/cxx-rewrite.mm.result b/test/ARCMT/cxx-rewrite.mm.result
new file mode 100644
index 0000000..145ccd3
--- /dev/null
+++ b/test/ARCMT/cxx-rewrite.mm.result
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c++ %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -x objective-c++ %s > %t
+// RUN: diff %t %s.result
+
+#include "Common.h"
+
+@interface NSString : NSObject
++(id)string;
+@end
+
+struct foo {
+    NSString *s;
+    foo(NSString *s): s(s){
+        @autoreleasepool {
+            [NSString string];
+        }
+    }
+    ~foo(){ s; }
+private:
+    foo(foo const &);
+    foo &operator=(foo const &);
+};
+
+int main(){
+    @autoreleasepool {
+
+        foo f([NSString string]);
+
+    }
+    return 0;
+}