mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
AlignmentCalc: Array alignment should be based on elementType's alignment
This commit is contained in:
parent
dfc0c62749
commit
df5ae4e34c
@ -370,7 +370,7 @@ class Array : public Type {
|
||||
}
|
||||
|
||||
virtual uint64_t align() const override {
|
||||
return elementType_.size();
|
||||
return elementType_.align();
|
||||
}
|
||||
|
||||
virtual NodeId id() const override {
|
||||
|
@ -182,3 +182,41 @@ TEST(AlignmentCalcTest, Bitfields) {
|
||||
Primitive: int64_t
|
||||
)");
|
||||
}
|
||||
|
||||
TEST(AlignmentCalcTest, Array) {
|
||||
test(AlignmentCalc::createPass(), R"(
|
||||
[0] Class: MyClass (size: 1)
|
||||
Member: a (offset: 0)
|
||||
[1] Array: (length: 1)
|
||||
[2] Class: AlignedClass (size: 1)
|
||||
Member: b (offset: 0, align: 16)
|
||||
Primitive: int8_t
|
||||
)",
|
||||
R"(
|
||||
[0] Class: MyClass (size: 1, align: 16, packed)
|
||||
Member: a (offset: 0, align: 16)
|
||||
[1] Array: (length: 1)
|
||||
[2] Class: AlignedClass (size: 1, align: 16, packed)
|
||||
Member: b (offset: 0, align: 16)
|
||||
Primitive: int8_t
|
||||
)");
|
||||
}
|
||||
|
||||
TEST(AlignmentCalcTest, Typedef) {
|
||||
test(AlignmentCalc::createPass(), R"(
|
||||
[0] Class: MyClass (size: 1)
|
||||
Member: a (offset: 0)
|
||||
[1] Typedef: MyTypedef
|
||||
[2] Class: AlignedClass (size: 1)
|
||||
Member: b (offset: 0, align: 16)
|
||||
Primitive: int8_t
|
||||
)",
|
||||
R"(
|
||||
[0] Class: MyClass (size: 1, align: 16, packed)
|
||||
Member: a (offset: 0, align: 16)
|
||||
[1] Typedef: MyTypedef
|
||||
[2] Class: AlignedClass (size: 1, align: 16, packed)
|
||||
Member: b (offset: 0, align: 16)
|
||||
Primitive: int8_t
|
||||
)");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user