might have a smaller size as compared to the stand-alone type of the base class.
This is possible when the derived class is packed and hence might have smaller
alignment requirement than the base class.
Differential Revision: http://llvm-reviews.chandlerc.com/D2599
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200031
91177308-0d34-0410-b5e6-
96231b3b80d8
if (getTypeAlignment(subobjectType) > Alignment)
return false;
- AppendField(baseOffset, subobjectType);
+ if (LastLaidOutBase.NonVirtualSize < CharUnits::fromQuantity(
+ Types.getDataLayout().getStructLayout(subobjectType)->getSizeInBytes()))
+ AppendBytes(LastLaidOutBase.NonVirtualSize);
+ else
+ AppendField(baseOffset, subobjectType);
+
return true;
}
--- /dev/null
+// RUN: %clang_cc1 %s -triple=i686-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+struct Base {
+ char a;
+};
+
+struct Derived_1 : virtual Base
+{
+ char b;
+};
+
+#pragma pack(1)
+struct Derived_2 : Derived_1 {
+ // CHECK: %struct.Derived_2 = type <{ [5 x i8], %struct.Base }>
+};
+
+Derived_2 x;