From: Daniel Dunbar Date: Mon, 20 Sep 2010 18:19:55 +0000 (+0000) Subject: Driver/Objective-C: Retool Objective-C ABI flags to be more usable, and actually X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dea63134a51d463cf32f3eec3c359d9215359d69;p=clang Driver/Objective-C: Retool Objective-C ABI flags to be more usable, and actually document behavior. Will wonders never cease. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114334 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/tools/clang.pod b/docs/tools/clang.pod index 8284d319e7..8a43731abf 100644 --- a/docs/tools/clang.pod +++ b/docs/tools/clang.pod @@ -191,7 +191,6 @@ Allow loose type checking rules for implicit vector conversions. 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 @@ works when Objective-C Garbage Collection is enabled. 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 + +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 + +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 diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 8b78220fe8..6451e4ce72 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -342,15 +342,19 @@ def fno_unwind_tables : Flag<"-fno-unwind-tables">, Group; def fno_verbose_asm : Flag<"-fno-verbose-asm">, Group; def fno_working_directory : Flag<"-fno-working-directory">, Group; def fno_zero_initialized_in_bss : Flag<"-fno-zero-initialized-in-bss">, Group; -def fobjc_abi_version_EQ : Joined<"-fobjc-abi-version=">, Group; def fobjc_atdefs : Flag<"-fobjc-atdefs">, Group; def fobjc_call_cxx_cdtors : Flag<"-fobjc-call-cxx-cdtors">, Group; def fobjc_gc_only : Flag<"-fobjc-gc-only">, Group; def fobjc_gc : Flag<"-fobjc-gc">, Group; def fobjc_legacy_dispatch : Flag<"-fobjc-legacy-dispatch">, Group; def fobjc_new_property : Flag<"-fobjc-new-property">, Group; + +// Objective-C ABI options. +def fobjc_abi_version_EQ : Joined<"-fobjc-abi-version=">, Group; +def fobjc_nonfragile_abi_version_EQ : Joined<"-fobjc-nonfragile-abi-version=">, Group; def fobjc_nonfragile_abi : Flag<"-fobjc-nonfragile-abi">, Group; -def fobjc_nonfragile_abi2 : Flag<"-fobjc-nonfragile-abi2">, Group; +def fno_objc_nonfragile_abi : Flag<"-fno-objc-nonfragile-abi">, Group; + def fobjc_sender_dependent_dispatch : Flag<"-fobjc-sender-dependent-dispatch">, Group; def fobjc : Flag<"-fobjc">, Group; def fomit_frame_pointer : Flag<"-fomit-frame-pointer">, Group; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 58f55655f1..bfb42d81ec 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1287,12 +1287,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // -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 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, 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) {