[cfe-dev] Typed selectors

David Chisnall csdavec at swansea.ac.uk
Tue May 5 11:49:41 PDT 2009


Hi Everyone,

The attached diff is the start of support for typed selectors in  
clang.  Currently this only generates typed selectors in message  
sends.  GCC generates them whenever type information is available, but  
this is not done yet for this diff.  This is probably the most  
important place for typed selectors, as it's the place that lets us  
detect stack corruption from mismatched selector types at runtime.

David

P.S. Clang currently fails make test for me on codegen-gnu.m, but if  
you delete the last line (the 'RUN: not' one) it works with the diff  
applied and this diff now works with this test case:




$ clang typedsel.m -lobjc && ./a.out
+new type: @8 at 0:4
+logtype type: v8 at 0:4
$ cat typedsel.m#import <objc/Object.h>

@interface A:Object{}
+ (id)new;
- (void)logtype;
@end
@implementation A
+ new
{
     printf("+%s type: %s\n", sel_get_name(_cmd), sel_get_type(_cmd));
     return [super new];
}
- (void)logtype
{
     printf("+%s type: %s\n", sel_get_name(_cmd), sel_get_type(_cmd));
}
@end

int main(void)
{
     [[A new] logtype];
     return 0;
}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang.diff
Type: application/octet-stream
Size: 10726 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090505/19245cb1/attachment.obj>


More information about the cfe-dev mailing list