From 976e319e14ed7977d17a9931cc6f49ee02bc6054 Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Wed, 20 Dec 2023 15:56:08 +0000 Subject: [PATCH] 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. --- oi/type_graph/ClangTypeParser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/oi/type_graph/ClangTypeParser.cpp b/oi/type_graph/ClangTypeParser.cpp index 2025c84..62b3cc2 100644 --- a/oi/type_graph/ClangTypeParser.cpp +++ b/oi/type_graph/ClangTypeParser.cpp @@ -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); }