Skip to content

Commit 479545d

Browse files
authored
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.
1 parent 472a736 commit 479545d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

oi/type_graph/ClangTypeParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ void ClangTypeParser::enumerateClassParents(const clang::RecordType& ty,
335335
if (baseCxxDecl == nullptr)
336336
continue;
337337

338-
auto offset = layout.getBaseClassOffset(baseCxxDecl).getQuantity();
338+
auto offset =
339+
layout.getBaseClassOffset(baseCxxDecl).getQuantity() * CHAR_BIT;
339340
auto& ptype = enumerateType(*baseType);
340341
parents.emplace_back(Parent{ptype, static_cast<uint64_t>(offset)});
341342
}

0 commit comments

Comments
 (0)