clangparser: provide alignment info for members

Unlike DWARF, the Clang AST is capable of correctly calculating the alignment
for each member. If we do this then AlignmentCalc doesn't traverse into the
member to attempt to calculate the alignment.

This check might be wrong if the field has explicit alignment. That case can be
covered when we have proper integration testing and a repro.

Test plan:
- Without this lots of static asserts occur. With this it's okay.
This commit is contained in:
Jake Hillion 2023-12-20 15:56:08 +00:00
parent 6c192f7e58
commit 976e319e14

View File

@ -294,6 +294,7 @@ void ClangTypeParser::enumerateClassMembers(const clang::RecordType& ty,
auto& mtype = enumerateType(*qualType); auto& mtype = enumerateType(*qualType);
Member m{mtype, std::move(member_name), offset_in_bits, size_in_bits}; Member m{mtype, std::move(member_name), offset_in_bits, size_in_bits};
m.align = decl->getASTContext().getTypeAlign(qualType) / 8;
members.push_back(m); members.push_back(m);
} }