Typed selectors

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@0:4
+logtype type: v8@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;
}

clang.diff (10.5 KB)

Are sel_get_name/sel_get_type Gnu extensions? If so, we do not need to support them in the Next runtime.

- Fariborz

Typed selectors are a GNU extension. This patch adds support for them for when -fgnu-runtime is used. The code generation for the NeXT runtime is unchanged..

David

Typed selectors are a GNU extension. This patch adds support for them for when -fgnu-runtime is used. The code generation for the NeXT runtime is unchanged..

I cannot apply this patch and check it out cleanly. It has unrelated diffs in them. Please prepare a patch against TOT.
- Fariborz

I am not sure what problems you were having. I have made a new copy of the diff against a new svn update, but since none of the relevant files had been modified in svn since my last diff was taken, I don't expect your problem to go away...

David

clang.diff (9.47 KB)

Typed selectors are a GNU extension. This patch adds support for them for when -fgnu-runtime is used. The code generation for the NeXT runtime is unchanged..

I cannot apply this patch and check it out cleanly. It has unrelated diffs in them. Please prepare a patch against TOT.
- Fariborz

I am not sure what problems you were having. I have made a new copy of the diff against a new svn update, but since none of the relevant files had been modified in svn since my last diff was taken, I don't expect your problem to go away...

Thanks. This one applied clean.

- Fariborz

Patch applied.

- fariborz