]> granicus.if.org Git - clang/commitdiff
Use a more appropriate LLVM type for the vtable pointer.
authorAnders Carlsson <andersca@mac.com>
Wed, 5 May 2010 05:47:36 +0000 (05:47 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 5 May 2010 05:47:36 +0000 (05:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103078 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGRecordLayoutBuilder.cpp
test/CodeGenCXX/class-layout.cpp

index 6302cf8d1fc0f670319b67fe8f71d2195e26c882..0966678f3e633b10c21762b80737f421a3da7d3c 100644 (file)
@@ -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());
   }
 }
 
index 31091c5f45431dec97c3d8a52c03ca363e266682..9303bdaba8bc50ea35212ede28ca0ed9d778c872 100644 (file)
@@ -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;