diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-07-14 00:17:54 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-07-14 00:17:54 +0000 |
commit | a944b123e49790e4cb0a8f4d6ee3a65e185127aa (patch) | |
tree | d199f350675b205e7c334ecd702a0436c45db8fb | |
parent | 4f264950e51ef1e41ada0f6a3a25197cd141b571 (diff) |
[arcmt] Make sure migrating to ARC works even if '-fobjc-arc' is included in command-line flags. rdar://9567824
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135115 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/ARCMigrate/ARCMT.cpp | 10 | ||||
-rw-r--r-- | test/ARCMT/with-arc-mode-check.m | 9 | ||||
-rw-r--r-- | test/ARCMT/with-arc-mode-migrate.m | 12 | ||||
-rw-r--r-- | test/ARCMT/with-arc-mode-migrate.m.result | 11 | ||||
-rw-r--r-- | test/ARCMT/with-arc-mode-modify.m | 13 | ||||
-rw-r--r-- | test/ARCMT/with-arc-mode-modify.m.result | 12 |
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) { +} |