CodeGen: Apply "alignas" to all stubbed types

Stubbing types listed in OICodeGen's "typesToStub" leaves them in the
same state as stubbed unions, so they need the same handling.
This commit is contained in:
Alastair Robertson 2023-07-31 11:08:05 -07:00 committed by Alastair Robertson
parent 6d30015764
commit ed2c6f357d

View File

@ -267,10 +267,14 @@ void genDefsClass(const Class& c, std::string& code) {
code += "__attribute__((__packed__)) ";
}
if (c.kind() == Class::Kind::Union) {
// Need to specify alignment manually for unions as their members have been
// removed. It would be nice to do this for all types, but our alignment
// information is not complete, so it would result in some errors.
if (c.members.size() == 1 &&
c.members[0].name.starts_with(AddPadding::MemberPrefix)) {
// Need to specify alignment manually for types which have been stubbed.
// It would be nice to do this for all types, but our alignment information
// is not complete, so it would result in some errors.
//
// Once we are able to read alignment info from DWARF, then this should be
// able to be applied to everything.
code += "alignas(" + std::to_string(c.align()) + ") ";
}