This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Add support for IncompleteArrayType in Obj-C ivars.
ClosedPublic

Authored by vsapsai on Oct 10 2017, 5:33 PM.

Details

Summary

Fixes an assertion failure when ivar is a struct containing incomplete
array. Also completes support for direct flexible array members.

rdar://problem/21054495

Diff Detail

Repository
rL LLVM

Event Timeline

vsapsai created this revision.Oct 10 2017, 5:33 PM

This patch depends on sema change https://reviews.llvm.org/D38773

To save reviewers some time. Incomplete array type is not the same as for zero-sized array, it is c"^c\00" while for zero-sized array it is c"[0c]\00". Don't know if it matters, I haven't found any difference in behaviour. Though maybe I wasn't looking in the right place.

rjmccall added inline comments.Oct 22 2017, 8:34 PM
clang/lib/CodeGen/CGObjCMac.cpp
5095 ↗(On Diff #118510)

You can't just use isa<> here; there can be typedefs of incomplete array type.

vsapsai added inline comments.Oct 23 2017, 3:34 PM
clang/lib/CodeGen/CGObjCMac.cpp
5095 ↗(On Diff #118510)

Thanks for catching it.

vsapsai updated this revision to Diff 119951.Oct 23 2017, 3:38 PM
  • Address rjmccall review comment about isa<>.

Decided to keep in test only cases with typedefs because test coverage is the
same and there is less similar code.

vsapsai updated this revision to Diff 119952.Oct 23 2017, 3:42 PM
  • Resubmit my last change without files from underlying branch.
rjmccall added inline comments.Oct 23 2017, 3:44 PM
clang/lib/CodeGen/CGObjCMac.cpp
5095 ↗(On Diff #118510)

Oh, and C allows you to have incomplete arrays of array type, e.g. int x[][4];

vsapsai added inline comments.Oct 25 2017, 4:23 PM
clang/lib/CodeGen/CGObjCMac.cpp
5095 ↗(On Diff #118510)

Right, thanks. I've checked only that int x[][]; isn't accepted but forgot about mixing different arrays.

vsapsai updated this revision to Diff 120337.Oct 25 2017, 4:23 PM
  • Address rjmccall review comment about nested arrays.
rjmccall accepted this revision.Oct 26 2017, 1:08 PM

Thanks, LGTM.

This revision is now accepted and ready to land.Oct 26 2017, 1:08 PM
This revision was automatically updated to reflect the committed changes.