This is an archive of the discontinued LLVM Phabricator instance.

[objc_direct] Allow for direct messages be sent to `self` when it is a Class
ClosedPublic

Authored by MadCoder on Jan 14 2020, 8:32 PM.

Details

Summary

Sending a message to self when it is const and within a class method is safe because we know that self is the Class itself.

We can only relax this error in ARC.

Radar-Id: rdar://problem/58581965

Diff Detail

Event Timeline

MadCoder created this revision.Jan 14 2020, 8:32 PM
MadCoder updated this revision to Diff 238698.Jan 16 2020, 11:26 PM

Added some more tests to make sure it works along inheritance chains as expected

arphaman added a comment.EditedJan 21 2020, 1:48 PM

Please add a test that exercises path without ARC enabled.

clang/lib/Sema/SemaExprObjC.cpp
3019

NIT: It feels easier to read if the condition is && !(Receiver->isObjCSelfExpr() && getLangOpts().ObjCAutoRefCount).

MadCoder updated this revision to Diff 239477.Jan 21 2020, 7:07 PM

fixed @ahatanak feedback

MadCoder marked an inline comment as done.Jan 21 2020, 7:07 PM
MadCoder updated this revision to Diff 239610.Jan 22 2020, 8:37 AM

adding the non ARC test I forgot to add

MadCoder updated this revision to Diff 239615.Jan 22 2020, 8:46 AM

with the test for real

This revision is now accepted and ready to land.Jan 22 2020, 11:19 AM
This revision was automatically updated to reflect the committed changes.