The code was assuming all incomplete types don't have meaningful alignment, but that clearly isn't true.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/CodeGen/CodeGenFunction.cpp | ||
---|---|---|
176 ↗ | (On Diff #260792) | 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. |
clang/lib/CodeGen/CodeGenFunction.cpp | ||
---|---|---|
176 ↗ | (On Diff #260792) | 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. |
clang/lib/CodeGen/CodeGenFunction.cpp | ||
---|---|---|
176 ↗ | (On Diff #260792) | If there's a getTypeAlignIfKnown(), it would be better to use it. |
"Address" the review comments. Not really happy with this, but not sure what else to do.