зеркало из https://github.com/microsoft/clang-1.git
Use a more appropriate LLVM type for the vtable pointer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103078 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
71b1d0e5f0
Коммит
68e3013ade
|
@ -439,12 +439,14 @@ void CGRecordLayoutBuilder::LayoutBases(const CXXRecordDecl *RD,
|
|||
const ASTRecordLayout &Layout) {
|
||||
// Check if we need to add a vtable pointer.
|
||||
if (RD->isDynamicClass() && !Layout.getPrimaryBase()) {
|
||||
const llvm::Type *Int8PtrTy =
|
||||
llvm::Type::getInt8PtrTy(Types.getLLVMContext());
|
||||
const llvm::Type *FunctionType =
|
||||
llvm::FunctionType::get(llvm::Type::getInt32Ty(Types.getLLVMContext()),
|
||||
/*isVarArg=*/true);
|
||||
const llvm::Type *VTableTy = FunctionType->getPointerTo();
|
||||
|
||||
assert(NextFieldOffsetInBytes == 0 &&
|
||||
"VTable pointer must come first!");
|
||||
AppendField(NextFieldOffsetInBytes, Int8PtrTy->getPointerTo());
|
||||
AppendField(NextFieldOffsetInBytes, VTableTy->getPointerTo());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
|
||||
|
||||
// An extra byte shoudl be allocated for an empty class.
|
||||
// An extra byte should be allocated for an empty class.
|
||||
// CHECK: %struct.A = type { i8 }
|
||||
struct A { } a;
|
||||
|
||||
|
@ -9,5 +9,5 @@ struct A { } a;
|
|||
struct B { void *a; int b; } b;
|
||||
|
||||
// C should have a vtable pointer.
|
||||
// CHECK: %struct.C = type { i8**, i32 }
|
||||
// CHECK: %struct.C = type { i32 (...)**, i32 }
|
||||
struct C { virtual void f(); int a; } *c;
|
||||
|
|
Загрузка…
Ссылка в новой задаче