[cfe-dev] Fixing super lookup in class methods (GNU ObjC runtime)

David Chisnall csdavec at swansea.ac.uk
Mon Apr 20 05:24:58 PDT 2009


Hi Steve,

On 19 Apr 2009, at 18:36, steve naroff wrote:

> I don't believe this is a recent regression.
>
> The struct body was removed ~10 months ago (6/21/08), when the code
> moved from Sema::Sema to Sema::ActOnTranslationUnitScope.

No, it's not recent - I didn't notice it when it was committed.

> I don't see why you think this is incorrect. It doesn't seem to be
> biting anyone else...

It is incorrect for two reasons:

1) The code does not match the comment (not a huge problem, but at the  
very least the comment should be changed to reflect what the code is  
actually doing).

2) The code does not define id as a valid type for an object pointer.

I suspect it is not biting anyone else because this implicit typedef  
is only ever used in Objective-C programs that do not import the  
standard header files, which is a set which does not include any  
Objective-C programs in the real world.  When I tested the diff that  
was committed and since reverted, I only tested it on real code that  
was experiencing the problem of messages to super not working  
correctly.  By reverting the diff, we have gone from having real code  
working but the test failing to having real code and the test both  
generating incorrect code which will fail at run time, but the test  
working passing.  To me, this does not seem like an improvement.

As I said, I can work around this change in CodeGen by explicitly  
casting the id to a type which is guaranteed to be valid, but it seems  
like an ugly hack and a better fix would be to ensure that an id is  
always a pointer to a struct containing a pointer to a class (which is  
opaque unless declared otherwise in a header).

David



More information about the cfe-dev mailing list