[cfe-commits] r78413 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/virt.cpp
Mike Stump
mrs at apple.com
Fri Aug 7 14:54:03 PDT 2009
Author: mrs
Date: Fri Aug 7 16:54:03 2009
New Revision: 78413
URL: http://llvm.org/viewvc/llvm-project?rev=78413&view=rev
Log:
Add vbase offsets to the vtable. Wow, having an rbegin was so
fortuitous. WIP.
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/test/CodeGenCXX/virt.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=78413&r1=78412&r2=78413&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Fri Aug 7 16:54:03 2009
@@ -616,6 +616,18 @@
const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase();
const bool PrimaryBaseWasVirtual = Layout.getPrimaryBaseWasVirtual();
+ // The virtual base offsets come first.
+ for (CXXRecordDecl::reverse_base_class_const_iterator i = RD->vbases_rbegin(),
+ e = RD->vbases_rend(); i != e; ++i) {
+ const CXXRecordDecl *Base =
+ cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
+ int64_t BaseOffset = Layout.getBaseClassOffset(Base) / 8;
+ llvm::Constant *m;
+ m = llvm::ConstantInt::get(llvm::Type::Int64Ty, BaseOffset);
+ m = llvm::ConstantExpr::getIntToPtr(m, Ptr8Ty);
+ methods.push_back(m);
+ }
+
// The primary base comes first.
GenerateVtableForBase(PrimaryBase, RD, rtti, methods, true,
PrimaryBaseWasVirtual);
Modified: cfe/trunk/test/CodeGenCXX/virt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virt.cpp?rev=78413&r1=78412&r2=78413&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/virt.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/virt.cpp Fri Aug 7 16:54:03 2009
@@ -123,7 +123,7 @@
// CHECK-LP32:__ZTV1F:
// CHECK-LP32: .space 4
-// CHECK-LP32 .long 8
+// CHECK-LP32: .long 8
// CHECK-LP32: .space 4
// CHECK-LP32: .space 4
// CHECK-LP32: .long __ZTI1F
@@ -144,7 +144,7 @@
// CHECK-LP64: __ZTV1F:
// CHECK-LP64: .space 8
-// CHECK-LP64 .quad 16
+// CHECK-LP64: .quad 16
// CHECK-LP64: .space 8
// CHECK-LP64: .space 8
// CHECK-LP64: .quad __ZTI1F
More information about the cfe-commits
mailing list