Driver/Obj-C: Be compatible with GCC behavior in that -fno-exceptions *does not*
disable Obj-C exceptions.
llvm-svn: 127836
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index cf6a853..45fdd8b 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -843,25 +843,16 @@
if (ExceptionsEnabled && DidHaveExplicitExceptionFlag)
ShouldUseExceptionTables = true;
- if (types::isObjC(InputType)) {
- bool ObjCExceptionsEnabled = ExceptionsEnabled;
+ // 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 (Arg *A = Args.getLastArg(options::OPT_fobjc_exceptions,
- options::OPT_fno_objc_exceptions,
- options::OPT_fexceptions,
- options::OPT_fno_exceptions)) {
- if (A->getOption().matches(options::OPT_fobjc_exceptions))
- ObjCExceptionsEnabled = true;
- else if (A->getOption().matches(options::OPT_fno_objc_exceptions))
- ObjCExceptionsEnabled = false;
- }
-
- if (ObjCExceptionsEnabled) {
- CmdArgs.push_back("-fobjc-exceptions");
-
- ShouldUseExceptionTables |=
- shouldUseExceptionTablesForObjCExceptions(Args, Triple);
- }
+ ShouldUseExceptionTables |=
+ shouldUseExceptionTablesForObjCExceptions(Args, Triple);
}
if (types::isCXX(InputType)) {