[cfe-commits] r114334 - in /cfe/trunk: docs/tools/clang.pod include/clang/Driver/Options.td lib/Driver/Tools.cpp
Daniel Dunbar
daniel at zuster.org
Mon Sep 20 11:19:56 PDT 2010
Author: ddunbar
Date: Mon Sep 20 13:19:55 2010
New Revision: 114334
URL: http://llvm.org/viewvc/llvm-project?rev=114334&view=rev
Log:
Driver/Objective-C: Retool Objective-C ABI flags to be more usable, and actually
document behavior. Will wonders never cease.
Modified:
cfe/trunk/docs/tools/clang.pod
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/docs/tools/clang.pod
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/clang.pod?rev=114334&r1=114333&r2=114334&view=diff
==============================================================================
--- cfe/trunk/docs/tools/clang.pod (original)
+++ cfe/trunk/docs/tools/clang.pod Mon Sep 20 13:19:55 2010
@@ -191,7 +191,6 @@
Enable the "Blocks" language feature.
-
=item B<-fobjc-gc-only>
Indicate that Objective-C code should be compiled in GC-only mode, which only
@@ -202,6 +201,22 @@
Indicate that Objective-C code should be compiled in hybrid-GC mode, which works
with both GC and non-GC mode.
+=item B<-fobjc-abi-version>=I<version>
+
+Select the Objective-C ABI version to use. Available versions are 1 (legacy
+"fragile" ABI), 2 (non-fragile ABI 1), and 3 (non-fragile ABI 2).
+
+=item B<-fobjc-nonfragile-abi-version>=I<version>
+
+Select the Objective-C non-fragile ABI version to use by default. This will only
+be used as the Objective-C ABI when the non-fragile ABI is enabled (either via
+-fobjc-nonfragile-abi, or because it is the platform default).
+
+=item B<-fobjc-nonfragile-abi>
+
+Enable use of the Objective-C non-fragile ABI. On platforms for which this is
+the default ABI, it can be disabled with B<-fno-objc-nonfragile-abi>.
+
=back
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=114334&r1=114333&r2=114334&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Sep 20 13:19:55 2010
@@ -342,15 +342,19 @@
def fno_verbose_asm : Flag<"-fno-verbose-asm">, 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>;
def fobjc_gc : Flag<"-fobjc-gc">, Group<f_Group>;
def fobjc_legacy_dispatch : Flag<"-fobjc-legacy-dispatch">, Group<f_Group>;
def fobjc_new_property : Flag<"-fobjc-new-property">, Group<clang_ignored_f_Group>;
+
+// Objective-C ABI options.
+def fobjc_abi_version_EQ : Joined<"-fobjc-abi-version=">, Group<f_Group>;
+def fobjc_nonfragile_abi_version_EQ : Joined<"-fobjc-nonfragile-abi-version=">, Group<f_Group>;
def fobjc_nonfragile_abi : Flag<"-fobjc-nonfragile-abi">, Group<f_Group>;
-def fobjc_nonfragile_abi2 : Flag<"-fobjc-nonfragile-abi2">, Group<f_Group>;
+def fno_objc_nonfragile_abi : Flag<"-fno-objc-nonfragile-abi">, Group<f_Group>;
+
def fobjc_sender_dependent_dispatch : Flag<"-fobjc-sender-dependent-dispatch">, Group<f_Group>;
def fobjc : Flag<"-fobjc">, Group<f_Group>;
def fomit_frame_pointer : Flag<"-fomit-frame-pointer">, Group<f_Group>;
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=114334&r1=114333&r2=114334&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Sep 20 13:19:55 2010
@@ -1287,12 +1287,13 @@
// -fobjc-nonfragile-abi=0 is default.
if (types::isObjC(InputType)) {
+ // Compute the Objective-C ABI "version" to use. Version numbers are
+ // slightly confusing for historical reasons:
+ // 1 - Traditional "fragile" ABI
+ // 2 - Non-fragile ABI, version 1
+ // 3 - Non-fragile ABI, version 2
unsigned Version = 1;
- if (Args.hasArg(options::OPT_fobjc_nonfragile_abi))
- Version = 2;
- else if (Args.hasArg(options::OPT_fobjc_nonfragile_abi2) ||
- getToolChain().IsObjCNonFragileABIDefault())
- Version = 3;
+ // If -fobjc-abi-version= is present, use that to set the version.
if (Arg *A = Args.getLastArg(options::OPT_fobjc_abi_version_EQ)) {
if (llvm::StringRef(A->getValue(Args)) == "1")
Version = 1;
@@ -1302,6 +1303,29 @@
Version = 3;
else
D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
+ } else {
+ // Otherwise, determine if we are using the non-fragile ABI.
+ if (Args.hasFlag(options::OPT_fobjc_nonfragile_abi,
+ options::OPT_fno_objc_nonfragile_abi,
+ getToolChain().IsObjCNonFragileABIDefault())) {
+ // Determine the non-fragile ABI version to use.
+ unsigned NonFragileABIVersion = 2;
+
+ if (Arg *A = Args.getLastArg(
+ options::OPT_fobjc_nonfragile_abi_version_EQ)) {
+ if (llvm::StringRef(A->getValue(Args)) == "1")
+ NonFragileABIVersion = 1;
+ else if (llvm::StringRef(A->getValue(Args)) == "2")
+ NonFragileABIVersion = 2;
+ else
+ D.Diag(clang::diag::err_drv_clang_unsupported)
+ << A->getAsString(Args);
+ }
+
+ Version = 1 + NonFragileABIVersion;
+ } else {
+ Version = 1;
+ }
}
if (Version == 2 || Version == 3) {
More information about the cfe-commits
mailing list