From 479545d4b8245e37f252ffdb79b913deebef8e94 Mon Sep 17 00:00:00 2001 From: Jon Haslam Date: Tue, 23 Apr 2024 14:31:16 +0100 Subject: [PATCH] Correct offset calculation with multiple base classes (#494) If a class inherits from more than one base class Clang Parser currently calculates incorrect offsets for everything but the first base class. This is owing to the fact that TypeGraph needs offsets in bits but ClangParser is providing them in bytes. --- oi/type_graph/ClangTypeParser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oi/type_graph/ClangTypeParser.cpp b/oi/type_graph/ClangTypeParser.cpp index 222c9e7..9c406b8 100644 --- a/oi/type_graph/ClangTypeParser.cpp +++ b/oi/type_graph/ClangTypeParser.cpp @@ -335,7 +335,8 @@ void ClangTypeParser::enumerateClassParents(const clang::RecordType& ty, if (baseCxxDecl == nullptr) continue; - auto offset = layout.getBaseClassOffset(baseCxxDecl).getQuantity(); + auto offset = + layout.getBaseClassOffset(baseCxxDecl).getQuantity() * CHAR_BIT; auto& ptype = enumerateType(*baseType); parents.emplace_back(Parent{ptype, static_cast(offset)}); }