This is an archive of the discontinued LLVM Phabricator instance.

Make Objective-C++ match Objective-C's behavior on implicit ivar access when `self` is shadowed
Needs ReviewPublic

Authored by mwyman on Jun 24 2022, 1:28 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

When compiling Objective-C++, name lookup uses the C++ lookup behavior that skips the filtering of non-implicit-self references, and will use a shadowed name that matches the type. As a result implicit ivar access behavior differs between Objective-C and Objective-C++, which can impact local access but also block captures.

This addresses the issue #56193 as reported on Github.

Unfortunately it appears the behavior has differed for 11 years (since the original fix for ObjC was applied in 2011).

Diff Detail

Event Timeline

mwyman created this revision.Jun 24 2022, 1:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2022, 1:28 PM
mwyman requested review of this revision.Jun 24 2022, 1:28 PM

Please add a test.

mwyman updated this revision to Diff 440311.Jun 27 2022, 10:50 AM

Added codegen test.

Unit test passes both pre- and post- this change for -x objective-c, fails pre-change with -x objective-c++ and passes post-change.

mwyman updated this revision to Diff 441270.Jun 29 2022, 11:06 PM

Change to use a unit test on the semantic lookup code, rather than a codegen test; I realized the name lookup behavior could be more directly checked by inspecting the internal references in the generated AST to ensure the found "self" is the implicit parameter "self".