[cfe-dev] Initial exception support for the GNU runtime
David Chisnall
csdavec at swansea.ac.uk
Thu May 7 14:52:48 PDT 2009
Hi Everyone,
This patch is a first pass at adding support for exceptions for the
GNU runtime. There are a few limitations at present:
- @synchronized() is not yet supported at all. gcc currently emits
calls to runtime library functions that don't exist for this directive.
- Only id @catch statements are currently working. This is enough for
NS_DURING and friends, but I need to spend more time reading the
output from gcc -S to work out how it finds the class pointer to make
arbitrary class type catch statements work.
- I've tested it with a few common cases[1] and the clang test suite
(which doesn't test exceptions for the GNU runtime, but shows I
haven't broken anything else), but there are probably a lot of cases
I've missed.
David
[1] Simple test program:
#import <objc/Object.h>
#include <stdio.h>
void objc_exception_throw(id);
id e;
void foo(void)
{
e = [Object new];
@throw e;
}
void nest(void)
{
@try {
foo();
}
@finally {
printf("finally 1\n");
}
}
int main(void)
{
@try {
printf("try.\n");
nest();
printf("fail.\n");
}
@catch(id b) {
printf("Caught id %d.\n", e == b);
}
@finally {
printf("finally\n");
}
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang.diff
Type: application/octet-stream
Size: 9779 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090507/4357e355/attachment.obj>
More information about the cfe-dev
mailing list