aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ARCMigrate/ARCMT.cpp10
-rw-r--r--test/ARCMT/with-arc-mode-check.m9
-rw-r--r--test/ARCMT/with-arc-mode-migrate.m12
-rw-r--r--test/ARCMT/with-arc-mode-migrate.m.result11
-rw-r--r--test/ARCMT/with-arc-mode-modify.m13
-rw-r--r--test/ARCMT/with-arc-mode-modify.m.result12
6 files changed, 66 insertions, 1 deletions
diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp
index 73c8dbd6a4..f1d947da67 100644
--- a/lib/ARCMigrate/ARCMT.cpp
+++ b/lib/ARCMigrate/ARCMT.cpp
@@ -262,6 +262,10 @@ bool arcmt::checkForManualIssues(CompilerInvocation &origCI,
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 @@ static bool applyTransforms(CompilerInvocation &origCI,
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,
diff --git a/test/ARCMT/with-arc-mode-check.m b/test/ARCMT/with-arc-mode-check.m
new file mode 100644
index 0000000000..c3146ef3b6
--- /dev/null
+++ b/test/ARCMT/with-arc-mode-check.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -arcmt-check -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c %s
+
+@protocol NSObject
+- (oneway void)release;
+@end
+
+void test1(id p) {
+ [p release];
+}
diff --git a/test/ARCMT/with-arc-mode-migrate.m b/test/ARCMT/with-arc-mode-migrate.m
new file mode 100644
index 0000000000..3851bc7731
--- /dev/null
+++ b/test/ARCMT/with-arc-mode-migrate.m
@@ -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
+
+@protocol NSObject
+- (oneway void)release;
+@end
+
+void test1(id p) {
+ [p release];
+}
diff --git a/test/ARCMT/with-arc-mode-migrate.m.result b/test/ARCMT/with-arc-mode-migrate.m.result
new file mode 100644
index 0000000000..c2222ae7b6
--- /dev/null
+++ b/test/ARCMT/with-arc-mode-migrate.m.result
@@ -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
+
+@protocol NSObject
+- (oneway void)release;
+@end
+
+void test1(id p) {
+}
diff --git a/test/ARCMT/with-arc-mode-modify.m b/test/ARCMT/with-arc-mode-modify.m
new file mode 100644
index 0000000000..17a398072e
--- /dev/null
+++ b/test/ARCMT/with-arc-mode-modify.m
@@ -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
+
+@protocol NSObject
+- (oneway void)release;
+@end
+
+void test1(id p) {
+ [p release];
+}
diff --git a/test/ARCMT/with-arc-mode-modify.m.result b/test/ARCMT/with-arc-mode-modify.m.result
new file mode 100644
index 0000000000..97c5128cd9
--- /dev/null
+++ b/test/ARCMT/with-arc-mode-modify.m.result
@@ -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
+
+@protocol NSObject
+- (oneway void)release;
+@end
+
+void test1(id p) {
+}