[cfe-dev] Fix for ObjC Class / id definition regression

David Chisnall csdavec at swan.ac.uk
Sat Aug 8 13:04:22 PDT 2009


On 8 Aug 2009, at 20:40, Daniel Dunbar wrote:

> Hi David,
>
> On Sat, Aug 8, 2009 at 10:07 AM, David Chisnall<theraven at sucs.org>  
> wrote:
>> The current code, which simply ignores the definition for any type
>> named id or Class, is obviously wrong (and breaks lots of existing
>> code, for example anything that includes the standard GNU runtime
>> headers).
>
> Probably makes sense to file a PR with a preprocessed input attached
> to it for Steve to look at.

Done: http://llvm.org/bugs/show_bug.cgi?id=4701

>> A fix needs to allow fields on variables of type id and Class to be
>> accessed with normal C semantics, but also allow the pointers with  
>> the
>> id and Class types to be receivers for messages.
>
> Which pointers within the types are used? We support isa via the
> custom ObjCIsaExpr, but are there other fields which are used in
> common code?

isa, unfortunately, is no use.  On the GNU runtime, id contains one  
field which is called class_pointer.  While this is irritating, there  
is a lot of legacy code that depends on it.

Class (struct objc_class*) contains a number of fields which code  
accesses directly.  With the legacy Apple runtime these are deprecated  
but still accessible.  With GNU runtime they are all public.  To make  
matters worse, the GNU objc-api.h includes some inline functions for  
setting and getting these fields which means any code that includes  
this file (i.e. all Objective-C code.h) will fail to compile with clang.

David



More information about the cfe-dev mailing list