[PATCH] D123826: Fix size of flexible array initializers, and re-enable assertions.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 14 16:04:43 PDT 2022


efriedma created this revision.
efriedma added a reviewer: erichkeane.
Herald added a project: All.
efriedma requested review of this revision.
Herald added a project: clang.

In D123649 <https://reviews.llvm.org/D123649>, I got the formula for getFlexibleArrayInitChars slightly wrong: the flexible array elements can be contained in the tail padding of the struct.  Fix the formula to account for that.

With the fixed formula, we run into another issue: in some cases, we were emitting extra padding for flexible arrray initializers. Fix CGExprConstant so it uses a packed struct when necessary, to avoid this extra padding.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123826

Files:
  clang/include/clang/AST/Decl.h
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/flexible-array-init.c
  clang/test/CodeGenCXX/flexible-array-init.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123826.422979.patch
Type: text/x-patch
Size: 10153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220414/a43e9ea1/attachment-0001.bin>


More information about the cfe-commits mailing list