rjmccall 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.
----------------
efriedma wrote:
> 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.
If there's a `getTypeAlignIfKnown()`, it would be better to use it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79052/new/
https://reviews.llvm.org/D79052
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits