[cfe-commits] r103078 - in /cfe/trunk: lib/CodeGen/CGRecordLayoutBuilder.cpp test/CodeGenCXX/class-layout.cpp
Anders Carlsson
andersca at mac.com
Tue May 4 22:47:36 PDT 2010
Author: andersca
Date: Wed May 5 00:47:36 2010
New Revision: 103078
URL: http://llvm.org/viewvc/llvm-project?rev=103078&view=rev
Log:
Use a more appropriate LLVM type for the vtable pointer.
Modified:
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
cfe/trunk/test/CodeGenCXX/class-layout.cpp
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=103078&r1=103077&r2=103078&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Wed May 5 00:47:36 2010
@@ -439,12 +439,14 @@
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());
}
}
Modified: cfe/trunk/test/CodeGenCXX/class-layout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/class-layout.cpp?rev=103078&r1=103077&r2=103078&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/class-layout.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/class-layout.cpp Wed May 5 00:47:36 2010
@@ -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 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;
More information about the cfe-commits
mailing list