[PATCH] D79052: [clang codegen] Fix alignment of "Address" for incomplete array pointer.
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 28 17:50:21 PDT 2020
efriedma marked an inline comment as done.
efriedma added inline comments.
================
Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:176
CharUnits Alignment;
- if (T->isIncompleteType()) {
+ if (T->getBaseElementTypeUnsafe()->isIncompleteType()) {
Alignment = CharUnits::One(); // Shouldn't be used, but pessimistic is best.
----------------
rsmith wrote:
> I don't know if it matters in practice, but this is still wrong. An incomplete type can have a known alignment, for a case like `struct alignas(32) S;`. Perhaps we should remove this test entirely and call `getTypeAlignIfKnown` instead of `getTypeAlign[InChars]` below.
I can't think of any way to observe the alignment computed by getNaturalTypeAlignment for an incomplete class. We usually only use the alignment computed by getNaturalTypeAlignment() to set the alignment of memory operations, and you can't do any memory operations with an incomplete class.
But the result might be easier to read, in any case.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79052/new/
https://reviews.llvm.org/D79052
More information about the cfe-commits
mailing list