Skip to content

Commit

Permalink
clangparser: provide alignment info for members
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JakeHillion committed Dec 20, 2023
1 parent 20cd48a commit c5ecb9a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions oi/type_graph/ClangTypeParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ void ClangTypeParser::enumerateClassMembers(const clang::RecordType& ty,

auto& mtype = enumerateType(*qualType);
Member m{mtype, std::move(member_name), offset_in_bits, size_in_bits};
m.align = decl->getASTContext().getTypeAlign(qualType) / 8;
members.push_back(m);
}

Expand Down

0 comments on commit c5ecb9a

Please sign in to comment.