]> granicus.if.org Git - clang/commitdiff
Driver: Add support for -fobjc-abi-version=.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 28 Apr 2010 23:25:24 +0000 (23:25 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 28 Apr 2010 23:25:24 +0000 (23:25 +0000)
 - <rdar://problem/7919678>

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

include/clang/Driver/Options.td
lib/Driver/Tools.cpp
test/Driver/darwin-objc-options.m [new file with mode: 0644]

index 844d317846f99850a60b5adb4529c9bacae95683..2127e5724f9798547488d79a2919ef0cad762553 100644 (file)
@@ -329,6 +329,7 @@ def fno_unit_at_a_time : Flag<"-fno-unit-at-a-time">, Group<f_Group>;
 def fno_unwind_tables : Flag<"-fno-unwind-tables">, Group<f_Group>;
 def fno_working_directory : Flag<"-fno-working-directory">, Group<f_Group>;
 def fno_zero_initialized_in_bss : Flag<"-fno-zero-initialized-in-bss">, Group<f_Group>;
+def fobjc_abi_version_EQ : Joined<"-fobjc-abi-version=">, Group<f_Group>;
 def fobjc_atdefs : Flag<"-fobjc-atdefs">, Group<clang_ignored_f_Group>;
 def fobjc_call_cxx_cdtors : Flag<"-fobjc-call-cxx-cdtors">, Group<clang_ignored_f_Group>;
 def fobjc_gc_only : Flag<"-fobjc-gc-only">, Group<f_Group>;
index c407d8c37c46581974bd94cf71ade51bcc2c7f52..450c5692bc90ba23ddbc4b6f4c7adbf6c97e84e9 100644 (file)
@@ -1227,8 +1227,20 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
 
   // -fobjc-nonfragile-abi=0 is default.
   if (types::isObjC(InputType)) {
+    unsigned Version = 1;
     if (Args.hasArg(options::OPT_fobjc_nonfragile_abi) ||
-        getToolChain().IsObjCNonFragileABIDefault()) {
+        getToolChain().IsObjCNonFragileABIDefault())
+      Version = 2;
+    if (Arg *A = Args.getLastArg(options::OPT_fobjc_abi_version_EQ)) {
+      if (llvm::StringRef(A->getValue(Args)) == "1")
+        Version = 1;
+      else if (llvm::StringRef(A->getValue(Args)) == "2")
+        Version = 2;
+      else
+        D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
+    }
+
+    if (Version == 2) {
       CmdArgs.push_back("-fobjc-nonfragile-abi");
 
       // -fobjc-dispatch-method is only relevant with the nonfragile-abi, and
diff --git a/test/Driver/darwin-objc-options.m b/test/Driver/darwin-objc-options.m
new file mode 100644 (file)
index 0000000..bc0b12c
--- /dev/null
@@ -0,0 +1,19 @@
+// Check miscellaneous Objective-C options.
+
+// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN:   -arch x86_64 -fobjc-abi-version=1 2> %t
+// RUN: FileCheck --check-prefix CHECK-X86_64_ABI1 < %t %s
+
+// CHECK-CHECK-X86_64_ABI1: "-cc1"
+// CHECK-CHECK-X86_64_ABI1-NOT: -fobjc-nonfragile-abi
+// CHECK-CHECK-X86_64_ABI1-NOT: -fobjc-dispatch-method
+// CHECK-CHECK-X86_64_ABI1: darwin-objc-options
+
+// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN:   -arch i386 -fobjc-abi-version=2 2> %t
+// RUN: FileCheck --check-prefix CHECK-I386_ABI2 < %t %s
+
+// CHECK-CHECK-I386_ABI2: "-cc1"
+// CHECK-CHECK-I386_ABI2: -fobjc-nonfragile-abi
+// CHECK-CHECK-I386_ABI2-NOT: -fobjc-dispatch-method
+// CHECK-CHECK-I386_ABI2: darwin-objc-options