diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2014-12-05 08:56:55 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2014-12-05 08:56:55 +0000 |
| commit | 153c3948f15f8a7b3e603f240fc2cbb93d8ddfb7 (patch) | |
| tree | ebdf89f5ee2e320a88ed8658321ae1fa40b22fe8 /clang/lib/Driver/Tools.cpp | |
| parent | c96e95c157f1f5a5755944804731a8ab07711672 (diff) | |
| download | bcm5719-llvm-153c3948f15f8a7b3e603f240fc2cbb93d8ddfb7.tar.gz bcm5719-llvm-153c3948f15f8a7b3e603f240fc2cbb93d8ddfb7.zip | |
Driver: Objective-C should respect -fno-exceptions
Clang attempted to replicate a GCC bug: -fobjc-exceptions forces
-fexceptions to be enabled. However, this has unintended effects and
other awkard side effects that Clang doesn't "correctly" ape (e.g. it's
impossible to turn off C++ exceptions in ObjC++ mode).
Instead, -f[no]objc-exceptions and -f[no]cxx-exceptions now have an
identical relationship with -f[no]exceptions.
llvm-svn: 223455
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
| -rw-r--r-- | clang/lib/Driver/Tools.cpp | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 151d87b50de..9924bb8896d 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1894,23 +1894,6 @@ 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) { @@ -1947,15 +1930,21 @@ static void addExceptionArgs(const ArgList &Args, types::ID InputType, // Gather the exception settings from the command line arguments. bool EH = exceptionSettings(Args, Triple); - // 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"); + 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); - EH |= shouldUseExceptionTablesForObjCExceptions(objcRuntime, Triple); + if (ObjCExceptionsEnabled) { + CmdArgs.push_back("-fobjc-exceptions"); + + EH = true; + } } if (types::isCXX(InputType)) { |

