[cfe-commits] r127836 - in /cfe/trunk: lib/Driver/Tools.cpp test/Driver/exceptions.m
Daniel Dunbar
daniel at zuster.org
Thu Mar 17 16:28:31 PDT 2011
Author: ddunbar
Date: Thu Mar 17 18:28:31 2011
New Revision: 127836
URL: http://llvm.org/viewvc/llvm-project?rev=127836&view=rev
Log:
Driver/Obj-C: Be compatible with GCC behavior in that -fno-exceptions *does not*
disable Obj-C exceptions.
Added:
cfe/trunk/test/Driver/exceptions.m
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=127836&r1=127835&r2=127836&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Mar 17 18:28:31 2011
@@ -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)) {
Added: cfe/trunk/test/Driver/exceptions.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/exceptions.m?rev=127836&view=auto
==============================================================================
--- cfe/trunk/test/Driver/exceptions.m (added)
+++ cfe/trunk/test/Driver/exceptions.m Thu Mar 17 18:28:31 2011
@@ -0,0 +1,19 @@
+// RUN: %clang -ccc-host-triple x86_64-apple-darwin9 \
+// RUN: -fsyntax-only -fno-exceptions %s
+
+void f1() {
+ @throw @"A";
+}
+
+void f0() {
+ @try {
+ f1();
+ } @catch (id x) {
+ ;
+ }
+}
+
+int main() {
+ f0();
+ return 0;
+}
More information about the cfe-commits
mailing list