Page MenuHomePhabricator

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

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



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)'.


Diff Detail


Event Timeline

ahatanak created this revision.May 29 2019, 9:36 PM
rjmccall added inline comments.May 29 2019, 9:50 PM
376 ↗(On Diff #202113)

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.

460 ↗(On Diff #202821)

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

528 ↗(On Diff #202821)


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