[cfe-dev] One more EH patch...

David Chisnall csdavec at swansea.ac.uk
Sat May 9 06:09:08 PDT 2009


On 9 May 2009, at 12:40, David Chisnall wrote:

> This one fixes the case where an exception is thrown inside a  
> @catch() block (GNU runtime).

And this version now emits code for @synchronized.  As with GCC, this  
code doesn't actually work, because the required functions are not  
present in the GNU runtime library.

I've also attached the test case I've been using while working on  
this.  The following two commands should produce the same output:

clang  -lobjc -fexceptions trycatch.m -g && ./a.out
gcc -lobjc -fobjc-exceptions trycatch.m && ./a.out

I don't know if someone wants to add this to the clang test suite.

At the moment, clang has the same behaviour as gcc when -fexceptions  
is not specified; it generates code which aborts at runtime if an  
exception is thrown, rather than handling it.  Although this is the  
same as gcc, it seems like the wrong thing to do.  We should probably  
either:

1) Implicitly turn on -fexceptions when @try/@catch/@throw/ 
@synchronized is encountered, or
2) Emit an error and let the user know at compile-time that they are  
generating broken code.

My personal preference would be (2), because all of the intervening  
functions between the @throw and the @catch should be compiled with  
exception support to work correctly, and it's likely that just turning  
on exceptions for the files that throw or catch them will introduce  
subtle failures.

David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang.diff
Type: application/octet-stream
Size: 3423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090509/2a54fdf5/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: trycatch.m
Type: application/octet-stream
Size: 1428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090509/2a54fdf5/attachment-0001.obj>


More information about the cfe-dev mailing list