[PATCH] D57936: [CodeGenObjC] When available, emit a direct call to objc_alloc_init(cls) instead of [objc_alloc(cls) init]
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 13 19:19:28 PST 2019
rjmccall accepted this revision.
rjmccall added inline comments.
This revision is now accepted and ready to land.
================
Comment at: clang/lib/CodeGen/CGObjC.cpp:475-483
case ObjCMessageExpr::Class: {
ReceiverType = E->getClassReceiver();
const ObjCObjectType *ObjTy = ReceiverType->getAs<ObjCObjectType>();
assert(ObjTy && "Invalid Objective-C class message send");
OID = ObjTy->getInterface();
assert(OID && "Invalid Objective-C class message send");
Receiver = Runtime.GetClass(*this, OID);
----------------
erik.pilkington wrote:
> > Also, I think getInterface() can return null here, although it might need to be contrived to fit the other requirements. Class<SomeProtocol>, where that protocol declares +alloc? If there isn't a way to just emit the receiver pointer of a normal message send from an ObjCMessageExpr, that's really too bad.
>
> Are you sure? It looks like we unconditionally dereference getInterface() here, and we would take this path if not for the new check above.
It looks like `ObjCMessageExpr::Class` is only for messages to type names, and Sema rejects types in that case that aren't just an ObjC class, so you're right, I misunderstood.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57936/new/
https://reviews.llvm.org/D57936
More information about the cfe-commits
mailing list