]> granicus.if.org Git - clang/commitdiff
Push ctor vtable construction down further. WIP.
authorMike Stump <mrs@apple.com>
Wed, 11 Nov 2009 20:26:26 +0000 (20:26 +0000)
committerMike Stump <mrs@apple.com>
Wed, 11 Nov 2009 20:26:26 +0000 (20:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86878 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVtable.cpp
lib/CodeGen/CGVtable.h
lib/CodeGen/CodeGenModule.h

index 4d3c3a595dda969619daffc0a4018e27e6754d33..233bdafd4f69ecd35ac463a5ff254aa2dc1bde98 100644 (file)
@@ -681,10 +681,15 @@ int64_t CGVtableInfo::getVirtualBaseOffsetIndex(const CXXRecordDecl *RD,
   return I->second;
 }
 
-llvm::Constant *CodeGenModule::GenerateVtable(const CXXRecordDecl *RD) {
+llvm::Constant *CodeGenModule::GenerateVtable(const CXXRecordDecl *RD,
+                                              const CXXRecordDecl *LayoutClass,
+                                              uint64_t Offset) {
   llvm::SmallString<256> OutName;
   llvm::raw_svector_ostream Out(OutName);
-  mangleCXXVtable(getMangleContext(), RD, Out);
+  if (LayoutClass)
+    mangleCXXCtorVtable(getMangleContext(), RD, Offset, LayoutClass, Out);
+  else
+    mangleCXXVtable(getMangleContext(), RD, Out);
 
   llvm::GlobalVariable::LinkageTypes linktype;
   linktype = llvm::GlobalValue::LinkOnceODRLinkage;
@@ -754,7 +759,7 @@ class VTTBuilder {
           && !NonVirtualPrimaryBase) {
         // FIXME: Slightly too many of these for __ZTT8test8_B2
         llvm::Constant *vtbl;
-        vtbl = CGM.getVtableInfo().getVtable(Base, Class, BaseOffset/8);
+        vtbl = CGM.getVtableInfo().getCtorVtable(Base, Class, BaseOffset/8);
         Inits.push_back(vtbl);
       }
       Secondary(Base, BaseOffset, BaseMorallyVirtual);
@@ -768,7 +773,7 @@ class VTTBuilder {
       return;
 
     // First comes the primary virtual table pointer...
-    Inits.push_back(CGM.getVtableInfo().getVtable(RD, Class, Offset));
+    Inits.push_back(CGM.getVtableInfo().getCtorVtable(RD, Class, Offset));
 
     // then the secondary VTTs....
     SecondaryVTTs(RD, MorallyVirtual);
@@ -852,10 +857,7 @@ llvm::Constant *CodeGenModule::GenerateVTT(const CXXRecordDecl *RD) {
   return vtt;
 }
 
-llvm::Constant *CGVtableInfo::getVtable(const CXXRecordDecl *RD,
-                                        const CXXRecordDecl *Class,
-                                        uint64_t Offset) {
-  // FIXME: Add ctor vtable support
+llvm::Constant *CGVtableInfo::getVtable(const CXXRecordDecl *RD) {
   llvm::Constant *&vtbl = Vtables[RD];
   if (vtbl)
     return vtbl;
@@ -863,3 +865,9 @@ llvm::Constant *CGVtableInfo::getVtable(const CXXRecordDecl *RD,
   CGM.GenerateVTT(RD);
   return vtbl;
 }
+
+llvm::Constant *CGVtableInfo::getCtorVtable(const CXXRecordDecl *RD,
+                                            const CXXRecordDecl *Class,
+                                            uint64_t Offset) {
+  return CGM.GenerateVtable(RD, Class, Offset);
+}
index 9620e42aab68f53dc4a40c15fc5fec2f499043fa..7ad42b59fb6e5ebdf3729f78fdf26be47f02dc50 100644 (file)
@@ -57,8 +57,9 @@ public:
   int64_t getVirtualBaseOffsetIndex(const CXXRecordDecl *RD, 
                                     const CXXRecordDecl *VBase);
 
-  llvm::Constant *getVtable(const CXXRecordDecl *RD,
-                            const CXXRecordDecl *Class=0, uint64_t Offset=0);
+  llvm::Constant *getVtable(const CXXRecordDecl *RD);
+  llvm::Constant *getCtorVtable(const CXXRecordDecl *RD,
+                                const CXXRecordDecl *Class, uint64_t Offset);
 };
   
 }
index 6c433d9d66b4dc6ee6668506e43c26a19706ab67..990706d11fc448e3bedc813ae977297e1f5cdec1 100644 (file)
@@ -253,7 +253,9 @@ public:
                                     const llvm::Type *Ty = 0);
 
   /// GenerateVtable - Generate the vtable for the given type.
-  llvm::Constant *GenerateVtable(const CXXRecordDecl *RD);
+  llvm::Constant *GenerateVtable(const CXXRecordDecl *RD,
+                                 const CXXRecordDecl *Class=0,
+                                 uint64_t Offset=0);
 
   /// GenerateVTT - Generate the VTT for the given type.
   llvm::Constant *GenerateVTT(const CXXRecordDecl *RD);