<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Dec 5, 2014 at 5:12 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Fri, Dec 5, 2014 at 1:00 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, Dec 5, 2014 at 12:37 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div>On Fri, Dec 5, 2014 at 11:55 AM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, Dec 5, 2014 at 11:47 AM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div>On Fri, Dec 5, 2014 at 11:41 AM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Fri, Dec 5, 2014 at 11:25 AM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Fri, Dec 5, 2014 at 12:56 AM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: majnemer<br>
Date: Fri Dec 5 02:56:55 2014<br>
New Revision: 223455<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=223455&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=223455&view=rev</a><br>
Log:<br>
Driver: Objective-C should respect -fno-exceptions<br>
<br>
Clang attempted to replicate a GCC bug: -fobjc-exceptions forces<br>
-fexceptions to be enabled. However, this has unintended effects and<br>
other awkard side effects that Clang doesn't "correctly" ape (e.g. it's<br>
impossible to turn off C++ exceptions in ObjC++ mode</blockquote><div><br></div></span><div>What does "impossible to turn off exceptions" mean here?</div><div><br></div><div><div>$ clang -c <a href="http://test.mm" target="_blank">test.mm</a> -fno-exceptions</div><div>test.mm:2:3: error: cannot use 'try' with exceptions disabled</div><div> try {} catch (...) {}</div><div> ^</div><div>1 error generated.</div></div></div></div></div></blockquote><div><br></div></span><div>You should try that with GCC, not clang :)</div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">).<br>
<br>
Instead, -f[no]objc-exceptions and -f[no]cxx-exceptions now have an<br>
identical relationship with -f[no]exceptions.<br></blockquote><div><br></div></span><div>Did anyone from Apple review this? I thought the intention was that -fno-exceptions disables c++ exceptions but keeps objc exceptions enabled, since a) many people don't want c++ exceptions so they use -fno-exceptions but b) cocoa uses exceptions so you can't really build without objc exceptions.</div><div><br></div><div>(I'm guessing I'm misunderstanding the patch somehow.)</div></div></div></div></blockquote></span><div><div><br>The original code was trying to mimic GCC's behavior where -fobjc-exceptions _ignores_ -fno-exceptions.</div><div>In GCC, this means that ObjC++ code cannot _ever_ opt out of C++ exceptions because they don't have a -fcxx-exceptions, they just have -fexceptions. Clang has a different dichotomy of exception enabling/disabling flags and it doesn't make sense to copy GCC's arbitrary behavior.<br></div></div><div> </div><div>If you want Objective-C exceptions but not C++ exceptions, -fobjc-exceptions -fno-cxx-exceptions should do the trick.</div></div></div></div></blockquote><div><br></div></div></div><div>I'm somewhat sure that when these flags got added they were explicitly put in a state where -fno-exceptions disables c++ exceptions but not objc exceptions, for the reason I mentioned above. I don't remember anything about gcc compatibility.</div></div></div></div></blockquote><div><br></div></div></div><div><a href="http://llvm.org/klaus/clang/commit/d47ea693706f7b0ffa68e879b73a71609a337786/" target="_blank">http://llvm.org/klaus/clang/commit/d47ea693706f7b0ffa68e879b73a71609a337786/</a><br><br>"Be compatible with GCC behavior in that -fno-exceptions *does not* disable Obj-C exceptions."<br>"This is not necessarily sensible, but follows GCC."</div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Most software doesn't use Objective-C, and when folks say -fno-exceptions they mean "no c++ exceptions".</div></div></div></div></blockquote><div><br></div></span><div>Sure, but that's not what -fno-exceptions does in GCC.<br><br>In C, it disables -fexceptions; this will ensure that calls to __gcc_personality_v0 will not occur. It also changes the behavior of __attribute__((cleanup)).<br>In Objective C, it does nothing.</div><div>In C++, it disables -fexceptions; this will ensure that calls to __gxx_personality_v0 will not occur. It makes it illegal to mention 'try' and 'catch'.</div><div>In Objective C++, it does nothing.</div></div></div></div></blockquote><div><br></div></div></div><div>What gcc does for Objective-C nowadays doesn't matter much, almost everyone building Objective-C code uses clang. The gcc behavior is nonsensical, clang's previous behavior wasn't.</div><div><br></div><div>This commit changes behavior fairly severely, without much of a motivation from what I understand.</div><div><br></div><div>I think clang's previous behavior makes a lot of sense: You have -fno-exceptions in all your build files, and you want that to disable c++ exceptions on linux. You want the same flag mean the same thing on OS X in .mm files. If you're writing regular mac apps, you can't realistically disable objc exceptions as some framework apis use them.</div><div><br></div><div>Having said that, from what I can tell this commit doesn't help with what I think it was supposed to help with:</div><div><br></div><div><div>$ ~/src/llvm-build/bin/clang -fno-exceptions -fobjc-exceptions -fno-cxx-exceptions -E -dM -x objective-c++ /dev/null | grep EXCEP</div><div>#define OBJC_ZEROCOST_EXCEPTIONS 1</div><div>#define __EXCEPTIONS 1</div></div></div></div></div></blockquote><div><br></div></div></div><div>The only thing __EXCEPTIONS really *reliably* corresponds to whether or not __attribute__((cleanup)) does special stuff if an exception is thrown. Why? Because __EXCEPTIONS *must* be set to 1 in 'C' mode if -fexceptions is enabled.</div></div></div></div></blockquote><div><br></div></div></div><div>Code in the wild uses is to check if it's ok to use try / catch.<br></div></div></div></div></blockquote><div><br></div><div>We were able to agree that code which uses __EXCEPTIONS to determine if try / catch can be used is broken but the old interaction between -fobjc-exceptions and -fexceptions should be preserved.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>-fobjc-exceptions enables this functionality in clang and gcc, both before *and* after my change.<br></div><div><br></div><div>The best way to determine if C++ exceptions are available is __has_feature(cxx_exceptions).</div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Added:<br>
cfe/trunk/test/Driver/<a href="http://exceptions.mm" target="_blank">exceptions.mm</a><br>
Removed:<br>
cfe/trunk/test/Driver/exceptions.m<br>
Modified:<br>
cfe/trunk/lib/Driver/Tools.cpp<br>
cfe/trunk/test/Driver/rewrite-legacy-objc.m<br>
<br>
Modified: cfe/trunk/lib/Driver/Tools.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=223455&r1=223454&r2=223455&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=223455&r1=223454&r2=223455&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Tools.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Dec 5 02:56:55 2014<br>
@@ -1894,23 +1894,6 @@ static void getTargetFeatures(const Driv<br>
}<br>
}<br>
<br>
-static bool<br>
-shouldUseExceptionTablesForObjCExceptions(const ObjCRuntime &runtime,<br>
- const llvm::Triple &Triple) {<br>
- // We use the zero-cost exception tables for Objective-C if the non-fragile<br>
- // ABI is enabled or when compiling for x86_64 and ARM on Snow Leopard and<br>
- // later.<br>
- if (runtime.isNonFragile())<br>
- return true;<br>
-<br>
- if (!Triple.isMacOSX())<br>
- return false;<br>
-<br>
- return (!Triple.isMacOSXVersionLT(10,5) &&<br>
- (Triple.getArch() == llvm::Triple::x86_64 ||<br>
- Triple.getArch() == llvm::Triple::arm));<br>
-}<br>
-<br>
// exceptionSettings() exists to share the logic between -cc1 and linker<br>
// invocations.<br>
static bool exceptionSettings(const ArgList &Args, const llvm::Triple &Triple) {<br>
@@ -1947,15 +1930,21 @@ static void addExceptionArgs(const ArgLi<br>
// Gather the exception settings from the command line arguments.<br>
bool EH = exceptionSettings(Args, Triple);<br>
<br>
- // Obj-C exceptions are enabled by default, regardless of -fexceptions. This<br>
- // is not necessarily sensible, but follows GCC.<br>
- if (types::isObjC(InputType) &&<br>
- Args.hasFlag(options::OPT_fobjc_exceptions,<br>
- options::OPT_fno_objc_exceptions,<br>
- true)) {<br>
- CmdArgs.push_back("-fobjc-exceptions");<br>
+ if (types::isObjC(InputType)) {<br>
+ bool ObjCExceptionsEnabled = true;<br>
+ if (Arg *A = Args.getLastArg(options::OPT_fobjc_exceptions,<br>
+ options::OPT_fno_objc_exceptions,<br>
+ options::OPT_fexceptions,<br>
+ options::OPT_fno_exceptions))<br>
+ ObjCExceptionsEnabled =<br>
+ A->getOption().matches(options::OPT_fobjc_exceptions) ||<br>
+ A->getOption().matches(options::OPT_fexceptions);<br>
+<br>
+ if (ObjCExceptionsEnabled) {<br>
+ CmdArgs.push_back("-fobjc-exceptions");<br>
<br>
- EH |= shouldUseExceptionTablesForObjCExceptions(objcRuntime, Triple);<br>
+ EH = true;<br>
+ }<br>
}<br>
<br>
if (types::isCXX(InputType)) {<br>
<br>
Removed: cfe/trunk/test/Driver/exceptions.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/exceptions.m?rev=223454&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/exceptions.m?rev=223454&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/exceptions.m (original)<br>
+++ cfe/trunk/test/Driver/exceptions.m (removed)<br>
@@ -1,19 +0,0 @@<br>
-// RUN: %clang -target x86_64-apple-darwin9 \<br>
-// RUN: -fsyntax-only -fno-exceptions %s<br>
-<br>
-void f1() {<br>
- @throw @"A";<br>
-}<br>
-<br>
-void f0() {<br>
- @try {<br>
- f1();<br>
- } @catch (id x) {<br>
- ;<br>
- }<br>
-}<br>
-<br>
-int main() {<br>
- f0();<br>
- return 0;<br>
-}<br>
<br>
Added: cfe/trunk/test/Driver/<a href="http://exceptions.mm" target="_blank">exceptions.mm</a><br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/exceptions.mm?rev=223455&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/exceptions.mm?rev=223455&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/<a href="http://exceptions.mm" target="_blank">exceptions.mm</a> (added)<br>
+++ cfe/trunk/test/Driver/<a href="http://exceptions.mm" target="_blank">exceptions.mm</a> Fri Dec 5 02:56:55 2014<br>
@@ -0,0 +1,6 @@<br>
+// RUN: %clang -target x86_64-apple-darwin11 -fno-exceptions %s -o - -### 2>&1 | \<br>
+// RUN: FileCheck %s<br>
+<br>
+CHECK-NOT: "-fobjc-exceptions"<br>
+CHECK-NOT: "-fcxx-exceptions"<br>
+CHECK-NOT: "-fexceptions"<br>
<br>
Modified: cfe/trunk/test/Driver/rewrite-legacy-objc.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rewrite-legacy-objc.m?rev=223455&r1=223454&r2=223455&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rewrite-legacy-objc.m?rev=223455&r1=223454&r2=223455&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/rewrite-legacy-objc.m (original)<br>
+++ cfe/trunk/test/Driver/rewrite-legacy-objc.m Fri Dec 5 02:56:55 2014<br>
@@ -9,5 +9,5 @@<br>
// RUN: FileCheck -check-prefix=TEST1 %s<br>
// RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \<br>
// RUN: FileCheck -check-prefix=TEST2 %s<br>
-// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"<br>
-// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"<br>
+// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"<br>
+// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div><br></div></div>
</blockquote></div></div></div><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 5, 2014 at 11:25 AM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Fri, Dec 5, 2014 at 12:56 AM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: majnemer<br>
Date: Fri Dec 5 02:56:55 2014<br>
New Revision: 223455<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=223455&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=223455&view=rev</a><br>
Log:<br>
Driver: Objective-C should respect -fno-exceptions<br>
<br>
Clang attempted to replicate a GCC bug: -fobjc-exceptions forces<br>
-fexceptions to be enabled. However, this has unintended effects and<br>
other awkard side effects that Clang doesn't "correctly" ape (e.g. it's<br>
impossible to turn off C++ exceptions in ObjC++ mode</blockquote><div><br></div></span><div>What does "impossible to turn off exceptions" mean here?</div><div><br></div><div><div>$ clang -c <a href="http://test.mm" target="_blank">test.mm</a> -fno-exceptions</div><div>test.mm:2:3: error: cannot use 'try' with exceptions disabled</div><div> try {} catch (...) {}</div><div> ^</div><div>1 error generated.</div></div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">).<br>
<br>
Instead, -f[no]objc-exceptions and -f[no]cxx-exceptions now have an<br>
identical relationship with -f[no]exceptions.<br></blockquote><div><br></div></span><div>Did anyone from Apple review this? I thought the intention was that -fno-exceptions disables c++ exceptions but keeps objc exceptions enabled, since a) many people don't want c++ exceptions so they use -fno-exceptions but b) cocoa uses exceptions so you can't really build without objc exceptions.</div><div><br></div><div>(I'm guessing I'm misunderstanding the patch somehow.)</div><div><div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Added:<br>
cfe/trunk/test/Driver/<a href="http://exceptions.mm" target="_blank">exceptions.mm</a><br>
Removed:<br>
cfe/trunk/test/Driver/exceptions.m<br>
Modified:<br>
cfe/trunk/lib/Driver/Tools.cpp<br>
cfe/trunk/test/Driver/rewrite-legacy-objc.m<br>
<br>
Modified: cfe/trunk/lib/Driver/Tools.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=223455&r1=223454&r2=223455&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=223455&r1=223454&r2=223455&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Tools.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Dec 5 02:56:55 2014<br>
@@ -1894,23 +1894,6 @@ static void getTargetFeatures(const Driv<br>
}<br>
}<br>
<br>
-static bool<br>
-shouldUseExceptionTablesForObjCExceptions(const ObjCRuntime &runtime,<br>
- const llvm::Triple &Triple) {<br>
- // We use the zero-cost exception tables for Objective-C if the non-fragile<br>
- // ABI is enabled or when compiling for x86_64 and ARM on Snow Leopard and<br>
- // later.<br>
- if (runtime.isNonFragile())<br>
- return true;<br>
-<br>
- if (!Triple.isMacOSX())<br>
- return false;<br>
-<br>
- return (!Triple.isMacOSXVersionLT(10,5) &&<br>
- (Triple.getArch() == llvm::Triple::x86_64 ||<br>
- Triple.getArch() == llvm::Triple::arm));<br>
-}<br>
-<br>
// exceptionSettings() exists to share the logic between -cc1 and linker<br>
// invocations.<br>
static bool exceptionSettings(const ArgList &Args, const llvm::Triple &Triple) {<br>
@@ -1947,15 +1930,21 @@ static void addExceptionArgs(const ArgLi<br>
// Gather the exception settings from the command line arguments.<br>
bool EH = exceptionSettings(Args, Triple);<br>
<br>
- // Obj-C exceptions are enabled by default, regardless of -fexceptions. This<br>
- // is not necessarily sensible, but follows GCC.<br>
- if (types::isObjC(InputType) &&<br>
- Args.hasFlag(options::OPT_fobjc_exceptions,<br>
- options::OPT_fno_objc_exceptions,<br>
- true)) {<br>
- CmdArgs.push_back("-fobjc-exceptions");<br>
+ if (types::isObjC(InputType)) {<br>
+ bool ObjCExceptionsEnabled = true;<br>
+ if (Arg *A = Args.getLastArg(options::OPT_fobjc_exceptions,<br>
+ options::OPT_fno_objc_exceptions,<br>
+ options::OPT_fexceptions,<br>
+ options::OPT_fno_exceptions))<br>
+ ObjCExceptionsEnabled =<br>
+ A->getOption().matches(options::OPT_fobjc_exceptions) ||<br>
+ A->getOption().matches(options::OPT_fexceptions);<br>
+<br>
+ if (ObjCExceptionsEnabled) {<br>
+ CmdArgs.push_back("-fobjc-exceptions");<br>
<br>
- EH |= shouldUseExceptionTablesForObjCExceptions(objcRuntime, Triple);<br>
+ EH = true;<br>
+ }<br>
}<br>
<br>
if (types::isCXX(InputType)) {<br>
<br>
Removed: cfe/trunk/test/Driver/exceptions.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/exceptions.m?rev=223454&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/exceptions.m?rev=223454&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/exceptions.m (original)<br>
+++ cfe/trunk/test/Driver/exceptions.m (removed)<br>
@@ -1,19 +0,0 @@<br>
-// RUN: %clang -target x86_64-apple-darwin9 \<br>
-// RUN: -fsyntax-only -fno-exceptions %s<br>
-<br>
-void f1() {<br>
- @throw @"A";<br>
-}<br>
-<br>
-void f0() {<br>
- @try {<br>
- f1();<br>
- } @catch (id x) {<br>
- ;<br>
- }<br>
-}<br>
-<br>
-int main() {<br>
- f0();<br>
- return 0;<br>
-}<br>
<br>
Added: cfe/trunk/test/Driver/<a href="http://exceptions.mm" target="_blank">exceptions.mm</a><br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/exceptions.mm?rev=223455&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/exceptions.mm?rev=223455&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/<a href="http://exceptions.mm" target="_blank">exceptions.mm</a> (added)<br>
+++ cfe/trunk/test/Driver/<a href="http://exceptions.mm" target="_blank">exceptions.mm</a> Fri Dec 5 02:56:55 2014<br>
@@ -0,0 +1,6 @@<br>
+// RUN: %clang -target x86_64-apple-darwin11 -fno-exceptions %s -o - -### 2>&1 | \<br>
+// RUN: FileCheck %s<br>
+<br>
+CHECK-NOT: "-fobjc-exceptions"<br>
+CHECK-NOT: "-fcxx-exceptions"<br>
+CHECK-NOT: "-fexceptions"<br>
<br>
Modified: cfe/trunk/test/Driver/rewrite-legacy-objc.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rewrite-legacy-objc.m?rev=223455&r1=223454&r2=223455&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rewrite-legacy-objc.m?rev=223455&r1=223454&r2=223455&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/rewrite-legacy-objc.m (original)<br>
+++ cfe/trunk/test/Driver/rewrite-legacy-objc.m Fri Dec 5 02:56:55 2014<br>
@@ -9,5 +9,5 @@<br>
// RUN: FileCheck -check-prefix=TEST1 %s<br>
// RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \<br>
// RUN: FileCheck -check-prefix=TEST2 %s<br>
-// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"<br>
-// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"<br>
+// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"<br>
+// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>