[cfe-commits] r135115 - in /cfe/trunk: lib/ARCMigrate/ARCMT.cpp test/ARCMT/with-arc-mode-check.m test/ARCMT/with-arc-mode-migrate.m test/ARCMT/with-arc-mode-migrate.m.result test/ARCMT/with-arc-mode-modify.m test/ARCMT/with-arc-mode-modify.m.result

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Jul 13 17:17:54 PDT 2011


Author: akirtzidis
Date: Wed Jul 13 19:17:54 2011
New Revision: 135115

URL: http://llvm.org/viewvc/llvm-project?rev=135115&view=rev
Log:
[arcmt] Make sure migrating to ARC works even if '-fobjc-arc' is included in command-line flags. rdar://9567824

Added:
    cfe/trunk/test/ARCMT/with-arc-mode-check.m
    cfe/trunk/test/ARCMT/with-arc-mode-migrate.m
    cfe/trunk/test/ARCMT/with-arc-mode-migrate.m.result
    cfe/trunk/test/ARCMT/with-arc-mode-modify.m
    cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result
Modified:
    cfe/trunk/lib/ARCMigrate/ARCMT.cpp

Modified: cfe/trunk/lib/ARCMigrate/ARCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ARCMT.cpp?rev=135115&r1=135114&r2=135115&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ARCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ARCMT.cpp Wed Jul 13 19:17:54 2011
@@ -262,6 +262,10 @@
 
   DiagClient->EndSourceFile();
 
+  // If we are migrating code that gets the '-fobjc-arc' flag, make sure
+  // to remove it so that we don't get errors from normal compilation.
+  origCI.getLangOpts().ObjCAutoRefCount = false;
+
   return capturedDiags.hasErrors();
 }
 
@@ -302,8 +306,12 @@
   if (outputDir.empty()) {
     origCI.getLangOpts().ObjCAutoRefCount = true;
     return migration.getRemapper().overwriteOriginal(*Diags);
-  } else
+  } else {
+    // If we are migrating code that gets the '-fobjc-arc' flag, make sure
+    // to remove it so that we don't get errors from normal compilation.
+    origCI.getLangOpts().ObjCAutoRefCount = false;
     return migration.getRemapper().flushToDisk(outputDir, *Diags);
+  }
 }
 
 bool arcmt::applyTransformations(CompilerInvocation &origCI,

Added: cfe/trunk/test/ARCMT/with-arc-mode-check.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/with-arc-mode-check.m?rev=135115&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/with-arc-mode-check.m (added)
+++ cfe/trunk/test/ARCMT/with-arc-mode-check.m Wed Jul 13 19:17:54 2011
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -arcmt-check -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c %s
+
+ at protocol NSObject
+- (oneway void)release;
+ at end
+
+void test1(id p) {
+  [p release];
+}

Added: cfe/trunk/test/ARCMT/with-arc-mode-migrate.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/with-arc-mode-migrate.m?rev=135115&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/with-arc-mode-migrate.m (added)
+++ cfe/trunk/test/ARCMT/with-arc-mode-migrate.m Wed Jul 13 19:17:54 2011
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c %s.result
+// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc %s
+// RUN: c-arcmt-test -arcmt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+// RUN: rm -rf %t
+
+ at protocol NSObject
+- (oneway void)release;
+ at end
+
+void test1(id p) {
+  [p release];
+}

Added: cfe/trunk/test/ARCMT/with-arc-mode-migrate.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/with-arc-mode-migrate.m.result?rev=135115&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/with-arc-mode-migrate.m.result (added)
+++ cfe/trunk/test/ARCMT/with-arc-mode-migrate.m.result Wed Jul 13 19:17:54 2011
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c %s.result
+// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc %s
+// RUN: c-arcmt-test -arcmt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+// RUN: rm -rf %t
+
+ at protocol NSObject
+- (oneway void)release;
+ at end
+
+void test1(id p) {
+}

Added: cfe/trunk/test/ARCMT/with-arc-mode-modify.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/with-arc-mode-modify.m?rev=135115&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/with-arc-mode-modify.m (added)
+++ cfe/trunk/test/ARCMT/with-arc-mode-modify.m Wed Jul 13 19:17:54 2011
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c %s.result
+// RUN: cp %s %t
+// RUN: %clang_cc1 -arcmt-modify -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c %t
+// RUN: diff %t %s.result
+// RUN: rm %t
+
+ at protocol NSObject
+- (oneway void)release;
+ at end
+
+void test1(id p) {
+  [p release];
+}

Added: cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result?rev=135115&view=auto
==============================================================================
--- cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result (added)
+++ cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result Wed Jul 13 19:17:54 2011
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c %s.result
+// RUN: cp %s %t
+// RUN: %clang_cc1 -arcmt-modify -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c %t
+// RUN: diff %t %s.result
+// RUN: rm %t
+
+ at protocol NSObject
+- (oneway void)release;
+ at end
+
+void test1(id p) {
+}





More information about the cfe-commits mailing list