diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-12-09 00:12:30 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-12-09 00:12:30 +0000 |
commit | ae394819c817c20c37cc8f7c4b5180c331321abd (patch) | |
tree | 15d250dbde6e3924db7b640451eb18a540df50b0 /clang/lib | |
parent | 3e41dc419c1eb5b281fc68f9e933d9a4e3f53626 (diff) | |
download | bcm5719-llvm-ae394819c817c20c37cc8f7c4b5180c331321abd.tar.gz bcm5719-llvm-ae394819c817c20c37cc8f7c4b5180c331321abd.zip |
Revert "Driver: Objective-C should respect -fno-exceptions"
This reverts commit r223455. It's been succesfully argued that
-fexceptions (at the driver level) is a misnomer and has little to do
with -fobjc-exceptions.
llvm-svn: 223723
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 9924bb8896d..151d87b50de 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1894,6 +1894,23 @@ static void getTargetFeatures(const Driver &D, const llvm::Triple &Triple, } } +static bool +shouldUseExceptionTablesForObjCExceptions(const ObjCRuntime &runtime, + const llvm::Triple &Triple) { + // We use the zero-cost exception tables for Objective-C if the non-fragile + // ABI is enabled or when compiling for x86_64 and ARM on Snow Leopard and + // later. + if (runtime.isNonFragile()) + return true; + + if (!Triple.isMacOSX()) + return false; + + return (!Triple.isMacOSXVersionLT(10,5) && + (Triple.getArch() == llvm::Triple::x86_64 || + Triple.getArch() == llvm::Triple::arm)); +} + // exceptionSettings() exists to share the logic between -cc1 and linker // invocations. static bool exceptionSettings(const ArgList &Args, const llvm::Triple &Triple) { @@ -1930,21 +1947,15 @@ static void addExceptionArgs(const ArgList &Args, types::ID InputType, // Gather the exception settings from the command line arguments. bool EH = exceptionSettings(Args, Triple); - if (types::isObjC(InputType)) { - bool ObjCExceptionsEnabled = true; - if (Arg *A = Args.getLastArg(options::OPT_fobjc_exceptions, - options::OPT_fno_objc_exceptions, - options::OPT_fexceptions, - options::OPT_fno_exceptions)) - ObjCExceptionsEnabled = - A->getOption().matches(options::OPT_fobjc_exceptions) || - A->getOption().matches(options::OPT_fexceptions); - - if (ObjCExceptionsEnabled) { - CmdArgs.push_back("-fobjc-exceptions"); + // Obj-C exceptions are enabled by default, regardless of -fexceptions. This + // is not necessarily sensible, but follows GCC. + if (types::isObjC(InputType) && + Args.hasFlag(options::OPT_fobjc_exceptions, + options::OPT_fno_objc_exceptions, + true)) { + CmdArgs.push_back("-fobjc-exceptions"); - EH = true; - } + EH |= shouldUseExceptionTablesForObjCExceptions(objcRuntime, Triple); } if (types::isCXX(InputType)) { |