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());
}
}
// 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;
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;