This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Fix the type of the constant that is used to zero-initialize a flexible array member
ClosedPublic

Authored by ahatanak on May 22 2023, 5:16 PM.

Details

Summary

EmitArrayConstant was incorrectly returning a zeroinitializer of zero-element array type when the initializer expression wasn't empty.

This fixes an assertion added in https://reviews.llvm.org/D123649. See the discussion here: https://reviews.llvm.org/D123649#4362210

Diff Detail

Event Timeline

ahatanak created this revision.May 22 2023, 5:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2023, 5:16 PM
ahatanak requested review of this revision.May 22 2023, 5:16 PM
efriedma added inline comments.May 22 2023, 5:40 PM
clang/lib/CodeGen/CGExprConstant.cpp
964

Not sure I like this fix. If we're going to pass in the DesiredType to indicate the correct result type, the caller should make sure it uses the correct type; we shouldn't need to correct it after the fact.

ahatanak updated this revision to Diff 524746.May 23 2023, 8:58 AM

Fix the desired type of incomplete arrays that is passed to EmitArrayConstant.

LGTM, but I'll leave it to @efriedma to do the final sign-off.

This revision is now accepted and ready to land.May 23 2023, 12:38 PM