This is an archive of the discontinued LLVM Phabricator instance.

[clang] cleanup -fstrict-flex-arrays implementation
ClosedPublic

Authored by serge-sans-paille on Aug 30 2022, 7:53 AM.

Details

Summary

This is a follow up to https://reviews.llvm.org/D126864, addressing some remaining
comments.

It also considers union with a single zero-length array field as FAM for each
value of -fstrict-flex-arrays.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2022, 7:53 AM
serge-sans-paille requested review of this revision.Aug 30 2022, 7:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2022, 7:53 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jyknight added inline comments.Aug 30 2022, 11:49 AM
clang/lib/CodeGen/CGExpr.cpp
910

This is a functional change (which is good, but the commit message needs to be adjusted). In current trunk

union X { int x[0]; };
int foo(X*x) { return x->x[2]; }

built with -fstrict-flex-arrays=2 -fsanitize=array-bounds would incorrectly report ubsan error, and this change fixes that.

I think this testcase can be added to clang/test/CodeGen/bounds-checking-fam.c. Probably this should also be nominated for backport to the 15.x branch (for the first point release I expect)

serge-sans-paille edited the summary of this revision. (Show Details)
jyknight accepted this revision.Aug 31 2022, 8:36 AM
This revision is now accepted and ready to land.Aug 31 2022, 8:36 AM
This comment was removed by jyknight.

(please ignore the last comment, I sent it to the wrong review thread)