Page MenuHomePhabricator

[CodeGen][ObjC] Convert '[self alloc]' in a class method to 'objc_alloc(self)'
ClosedPublic

Authored by ahatanak on May 29 2019, 9:36 PM.

Details

Summary

In a class method, 'self' points to the class object, so it should be safe to pass it to objc_alloc. Also, convert '[[self alloc] init]' in a class method to 'objc_alloc_init(self)'.

rdar://problem/50855121

Diff Detail

Repository
rC Clang

Event Timeline

ahatanak created this revision.May 29 2019, 9:36 PM
rjmccall added inline comments.May 29 2019, 9:50 PM
lib/CodeGen/CGObjC.cpp
376

I think it's fine to just call this a class message, unless I'm missing a reason to distinguish them in this function.

ahatanak updated this revision to Diff 202821.Jun 3 2019, 4:32 PM
ahatanak marked an inline comment as done.

Just set isClassMessage instead of passing a separate flag to tryGenerateSpecializedMessageSend.

erik.pilkington accepted this revision.Jun 3 2019, 5:09 PM

I thinks this looks good, aside from a null concern.

lib/CodeGen/CGObjC.cpp
461

I think (?) that CurFuncDecl is nullable, might want to dyn_cast_or_null here.

530

(ditto)

This revision is now accepted and ready to land.Jun 3 2019, 5:09 PM
This revision was automatically updated to reflect the committed changes.
ahatanak marked 2 inline comments as done.
Herald added a project: Restricted Project. · View Herald TranscriptJun 4 2019, 9:29 AM