]> granicus.if.org Git - clang/commitdiff
Use -rewrite-legacy-objc as clang argument for translating
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 2 Apr 2012 15:59:19 +0000 (15:59 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 2 Apr 2012 15:59:19 +0000 (15:59 +0000)
objective-c's fragile abi, Use -rewrite-objc for translating
objective-c's modern abi.  // rdar://11143173

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153877 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Options.td
include/clang/Driver/Types.def
lib/Driver/Driver.cpp
lib/Driver/Tools.cpp
lib/Driver/Types.cpp
test/Driver/rewrite-legacy-objc.m [new file with mode: 0644]
test/Driver/rewrite-objc.m

index 97872f7af546897c839076a48826e979f61bdc53..24e481c8dba8af9b14e6a1fc048916752843547d 100644 (file)
@@ -737,6 +737,8 @@ def read__only__relocs : Separate<"-read_only_relocs">;
 def remap : Flag<"-remap">;
 def rewrite_objc : Flag<"-rewrite-objc">, Flags<[DriverOption]>,
   HelpText<"Rewrite Objective-C source to C++">;
+def rewrite_legacy_objc : Flag<"-rewrite-legacy-objc">, Flags<[DriverOption]>,
+  HelpText<"Rewrite Legacy Objective-C source to C++">;
 def rdynamic : Flag<"-rdynamic">;
 def rpath : Separate<"-rpath">, Flags<[LinkerInput]>;
 def rtlib_EQ : Joined<"-rtlib=">;
index bba888ca4a79ce781becca0037de8b223843a942..b107dfb247b1ca0f1528bd6e236e50f03bd2cd74 100644 (file)
@@ -82,6 +82,7 @@ TYPE("lto-bc",                   LTO_BC,       INVALID,         "o",     "")
 TYPE("ast",                      AST,          INVALID,         "ast",   "u")
 TYPE("plist",                    Plist,        INVALID,         "plist", "")
 TYPE("rewritten-objc",           RewrittenObjC,INVALID,         "cpp",   "")
+TYPE("rewritten-legacy-objc",    RewrittenLegacyObjC,INVALID,   "cpp",   "")
 TYPE("remap",                    Remap,        INVALID,         "remap", "")
 TYPE("precompiled-header",       PCH,          INVALID,         "gch",   "A")
 TYPE("object",                   Object,       INVALID,         "o",     "")
index 7fd365fbe9032f7be5d56c9cddceb1d6210ec259..35e63989a3c2b49463d38e4c718b9561149e9e46 100644 (file)
@@ -141,6 +141,7 @@ const {
     // -{fsyntax-only,-analyze,emit-ast,S} only run up to the compiler.
   } else if ((PhaseArg = DAL.getLastArg(options::OPT_fsyntax_only)) ||
              (PhaseArg = DAL.getLastArg(options::OPT_rewrite_objc)) ||
+             (PhaseArg = DAL.getLastArg(options::OPT_rewrite_legacy_objc)) ||
              (PhaseArg = DAL.getLastArg(options::OPT__migrate)) ||
              (PhaseArg = DAL.getLastArg(options::OPT__analyze,
                                         options::OPT__analyze_auto)) ||
@@ -1143,6 +1144,8 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase,
       return new CompileJobAction(Input, types::TY_Nothing);
     } else if (Args.hasArg(options::OPT_rewrite_objc)) {
       return new CompileJobAction(Input, types::TY_RewrittenObjC);
+    } else if (Args.hasArg(options::OPT_rewrite_legacy_objc)) {
+      return new CompileJobAction(Input, types::TY_RewrittenLegacyObjC);
     } else if (Args.hasArg(options::OPT__analyze, options::OPT__analyze_auto)) {
       return new AnalyzeJobAction(Input, types::TY_Plist);
     } else if (Args.hasArg(options::OPT__migrate)) {
index aaa73c1436a71c565fcfba78fc7ad12da59786c1..94ff5b1f1bdf52c718ec73307162d372a5db6a98 100644 (file)
@@ -1349,6 +1349,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
       CmdArgs.push_back("-emit-pch");
     } else if (JA.getType() == types::TY_RewrittenObjC) {
       CmdArgs.push_back("-rewrite-objc");
+    } else if (JA.getType() == types::TY_RewrittenLegacyObjC) {
+      CmdArgs.push_back("-rewrite-objc");
       IsRewriter = true;
     } else {
       assert(JA.getType() == types::TY_PP_Asm &&
index d61ab68c90ad0320b6dc74c47bf75fbba6ffcfd2..50742fe25e4e44b2f14ea7ed0a4f20930b78f80e 100644 (file)
@@ -102,6 +102,7 @@ bool types::isOnlyAcceptedByClang(ID Id) {
   case TY_LLVM_IR:
   case TY_LLVM_BC:
   case TY_RewrittenObjC:
+  case TY_RewrittenLegacyObjC:
     return true;
   }
 }
diff --git a/test/Driver/rewrite-legacy-objc.m b/test/Driver/rewrite-legacy-objc.m
new file mode 100644 (file)
index 0000000..af59ff6
--- /dev/null
@@ -0,0 +1,15 @@
+// RUN: %clang -no-canonical-prefixes -target x86_64-apple-macosx10.7.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=TEST0 %s
+// TEST0: clang{{.*}}" "-cc1"
+// TEST0: "-rewrite-objc"
+// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-fragile-abi" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
+// TEST0: rewrite-legacy-objc.m"
+
+// RUN: not %clang -ccc-no-clang -target unknown -rewrite-legacy-objc %s -o - -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=TEST1 %s
+// TEST1: invalid output type 'rewritten-legacy-objc' for use with gcc
+
+// RUN: not %clang -ccc-no-clang -target i386-apple-darwin10 -rewrite-legacy-objc %s -o - -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=TEST2 %s
+// TEST2: invalid output type 'rewritten-legacy-objc' for use with gcc
index 30883f3bf517f762e0b4fc8d1c661fa219a6ff55..c5712609d797fcc204b6e7538474c94e0663d01b 100644 (file)
@@ -3,7 +3,7 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-fragile-abi" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
 // TEST0: rewrite-objc.m"
 
 // RUN: not %clang -ccc-no-clang -target unknown -rewrite-objc %s -o - -### 2>&1 | \