[cfe-commits] [PATCH] Add -fobjc-direct-class-refs

John McCall rjmccall at apple.com
Wed Jul 11 17:58:34 PDT 2012


On Jul 11, 2012, at 2:46 AM, Jonathan Schleifer wrote:
> Am 11.07.2012 um 11:43 schrieb Jonathan Schleifer:
>> I implemented my runtime now using the new method for selecting runtimes implemented by John. Thanks a lot, John, it was very straightforward to add the runtime now!
>> 
>> Attached is a patch that adds -fobjc-runtime=objfw. It would be nice if this could be imported upstream.
>> 
>> It also allows subscripting using my runtime. I did not see any reason why this was restricted to the non-fragile ABI. I assume this was done in order to prevent the use of subscripts on old OS X systems which are missing the library part for them? If so, wouldn't it make sense to only forbid if when the runtime is the fragile Apple runtime?

Subscripting on objects has an existing meaning in fragile runtimes:  it's pointer arithmetic.  Is that meaning useful?  Well, possibly not, but nonetheless such code has historically been valid.

Now, technically that only applies to subscripts of integral type;  subscripts of pointer type are ill-formed, so we could have given them the new behavior and left the integral case as pointer arithmetic.  We felt that that would add a lot of confusion for little gain, and I think that's still true for objfw.

IIRC, you were considering making objfw use the non-fragile runtime.  In that case, you might want to proactively forbid pointer arithmetic.  I'd be fine with you adding a new predicate (allowsPointerArithmetic()) on ObjCRuntime for this, if you then change Sema to use it in all the appropriate places.  (You seem to have a good feel for how to do this.)  You should also add another predicate (isSubscriptPointerArithmetic()), with the invariant that it's only true if allowsPointerArithmetic() is, which Sema would use to decide how to interpret subscripting on ObjC pointers.

I'd prefer that that be a separate patch, anyway.  The rest of your patch looks fine to me, so if you wouldn't mind preparing a patch without the subscript changes, I'd be happy to commit that for you.

John.



More information about the cfe-commits mailing list