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.
This commit is contained in:
Jon Haslam 2024-04-23 14:31:16 +01:00 committed by GitHub
parent 472a7366ee
commit 479545d4b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -335,7 +335,8 @@ void ClangTypeParser::enumerateClassParents(const clang::RecordType& ty,
if (baseCxxDecl == nullptr) if (baseCxxDecl == nullptr)
continue; continue;
auto offset = layout.getBaseClassOffset(baseCxxDecl).getQuantity(); auto offset =
layout.getBaseClassOffset(baseCxxDecl).getQuantity() * CHAR_BIT;
auto& ptype = enumerateType(*baseType); auto& ptype = enumerateType(*baseType);
parents.emplace_back(Parent{ptype, static_cast<uint64_t>(offset)}); parents.emplace_back(Parent{ptype, static_cast<uint64_t>(offset)});
} }