]> granicus.if.org Git - clang/commitdiff
Add vbase offsets to the vtable. Wow, having an rbegin was so
authorMike Stump <mrs@apple.com>
Fri, 7 Aug 2009 21:54:03 +0000 (21:54 +0000)
committerMike Stump <mrs@apple.com>
Fri, 7 Aug 2009 21:54:03 +0000 (21:54 +0000)
fortuitous.  WIP.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78413 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXX.cpp
test/CodeGenCXX/virt.cpp

index cb6a6f8271051ed4edd0a1314ed9026e2db5196a..d79e1cef0951b995103eda06f1eb816039a450ef 100644 (file)
@@ -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<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);
index 04d7333310b1fc31d67ad7288903a6444a9d0942..1b78d89e8fc0086aaa996daba622137b8602b8a9 100644 (file)
@@ -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