mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 16:06:05 +00:00

Clang uses two types to talk about a C++ class, the NonVirtualBaseLLVMType and the LLVMType. Previously, we would allow one of these to be packed and the other not. This is problematic. If both don't agree on a common subset of fields, then routines like getLLVMFieldNo will point to the wrong field. Solve this by copying the 'packed'-ness of the complete type to the non-virtual subobject. For this to work, we need to take into account the non-virtual subobject's size and alignment when we are computing the layout of the complete object. This fixes PR21089. llvm-svn: 218577
33 lines
819 B
C++
33 lines
819 B
C++
// RUN: %clang_cc1 -triple i686-linux-gnu %s -emit-llvm -o - | FileCheck %s
|
|
|
|
class A {
|
|
// append has to have the same prototype as fn1 to tickle the bug.
|
|
void (*append)(A *);
|
|
};
|
|
|
|
class B {};
|
|
class D;
|
|
|
|
// C has to be non-C++98 POD with available tail padding, making the LLVM base
|
|
// type differ from the complete LLVM type.
|
|
class C {
|
|
// This member creates a circular LLVM type reference to %class.D.
|
|
D *m_group;
|
|
B changeListeners;
|
|
};
|
|
class D : C {};
|
|
|
|
void fn1(A *p1) {
|
|
}
|
|
|
|
void
|
|
fn2(C *) {
|
|
}
|
|
|
|
// We end up using an opaque type for 'append' to avoid circular references.
|
|
// CHECK: %class.A = type { {}* }
|
|
// CHECK: %class.C = type <{ %class.D*, %class.B, [3 x i8] }>
|
|
// CHECK: %class.D = type { %class.C.base, [3 x i8] }
|
|
// CHECK: %class.C.base = type <{ %class.D*, %class.B }>
|
|
// CHECK: %class.B = type { i8 }
|