[cfe-commits] r133763 - in /cfe/trunk: lib/ARCMigrate/TransAutoreleasePool.cpp lib/ARCMigrate/TransRetainReleaseDealloc.cpp lib/ARCMigrate/TransUnusedInitDelegate.cpp lib/ARCMigrate/Transforms.h test/ARCMT/cxx-rewrite.mm test/ARCMT/cxx-rewrite.mm.result

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Jun 23 14:21:33 PDT 2011


Author: akirtzidis
Date: Thu Jun 23 16:21:33 2011
New Revision: 133763

URL: http://llvm.org/viewvc/llvm-project?rev=133763&view=rev
Log:
[arcmt] Fully migrate ObjC++ classes, rdar://9660007.

Added:
    cfe/trunk/test/ARCMT/cxx-rewrite.mm
    cfe/trunk/test/ARCMT/cxx-rewrite.mm.result
Modified:
    cfe/trunk/lib/ARCMigrate/TransAutoreleasePool.cpp
    cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
    cfe/trunk/lib/ARCMigrate/TransUnusedInitDelegate.cpp
    cfe/trunk/lib/ARCMigrate/Transforms.h

Modified: cfe/trunk/lib/ARCMigrate/TransAutoreleasePool.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransAutoreleasePool.cpp?rev=133763&r1=133762&r2=133763&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransAutoreleasePool.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransAutoreleasePool.cpp Thu Jun 23 16:21:33 2011
@@ -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;
 

Modified: cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp?rev=133763&r1=133762&r2=133763&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp Thu Jun 23 16:21:33 2011
@@ -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;

Modified: cfe/trunk/lib/ARCMigrate/TransUnusedInitDelegate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransUnusedInitDelegate.cpp?rev=133763&r1=133762&r2=133763&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransUnusedInitDelegate.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransUnusedInitDelegate.cpp Thu Jun 23 16:21:33 2011
@@ -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;

Modified: cfe/trunk/lib/ARCMigrate/Transforms.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/Transforms.h?rev=133763&r1=133762&r2=133763&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/Transforms.h (original)
+++ cfe/trunk/lib/ARCMigrate/Transforms.h Thu Jun 23 16:21:33 2011
@@ -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;
   }
 };

Added: cfe/trunk/test/ARCMT/cxx-rewrite.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/cxx-rewrite.mm?rev=133763&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/cxx-rewrite.mm (added)
+++ cfe/trunk/test/ARCMT/cxx-rewrite.mm Thu Jun 23 16:21:33 2011
@@ -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"
+
+ at interface NSString : NSObject
++(id)string;
+ at 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;
+}

Added: cfe/trunk/test/ARCMT/cxx-rewrite.mm.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/cxx-rewrite.mm.result?rev=133763&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/cxx-rewrite.mm.result (added)
+++ cfe/trunk/test/ARCMT/cxx-rewrite.mm.result Thu Jun 23 16:21:33 2011
@@ -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"
+
+ at interface NSString : NSObject
++(id)string;
+ at 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;
+}





More information about the cfe-commits mailing list