From: Mike Stump Date: Fri, 7 Aug 2009 21:54:03 +0000 (+0000) Subject: Add vbase offsets to the vtable. Wow, having an rbegin was so X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=57cf2f3abad1c3541cd388d9b7882d65cf6daa7c;p=clang Add vbase offsets to the vtable. Wow, having an rbegin was so fortuitous. WIP. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78413 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index cb6a6f8271..d79e1cef09 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -616,6 +616,18 @@ llvm::Value *CodeGenFunction::GenerateVtable(const CXXRecordDecl *RD) { 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(i->getType()->getAs()->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); diff --git a/test/CodeGenCXX/virt.cpp b/test/CodeGenCXX/virt.cpp index 04d7333310..1b78d89e8f 100644 --- a/test/CodeGenCXX/virt.cpp +++ b/test/CodeGenCXX/virt.cpp @@ -123,7 +123,7 @@ int main() { // 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 @@ int main() { // 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