]> granicus.if.org Git - clang/commitdiff
Implement VTableContext::createConstructionVTableLayout
authorPeter Collingbourne <peter@pcc.me.uk>
Mon, 26 Sep 2011 01:56:55 +0000 (01:56 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Mon, 26 Sep 2011 01:56:55 +0000 (01:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140507 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVTables.cpp
lib/CodeGen/CGVTables.h

index 2b187fdca7f86258630325db13a8dbef2d00bb82..44ac56a0aad8a4f68c118cb88256260a65abdb51 100644 (file)
@@ -2821,6 +2821,18 @@ void CodeGenVTables::EmitThunks(GlobalDecl GD)
               /*UseAvailableExternallyLinkage=*/false);
 }
 
+static VTableLayout *CreateVTableLayout(const VTableBuilder &Builder) {
+  llvm::SmallVector<VTableLayout::VTableThunkTy, 1>
+    VTableThunks(Builder.vtable_thunks_begin(), Builder.vtable_thunks_end());
+  std::sort(VTableThunks.begin(), VTableThunks.end());
+
+  return new VTableLayout(Builder.getNumVTableComponents(),
+                          Builder.vtable_component_begin(),
+                          VTableThunks.size(),
+                          VTableThunks.data(),
+                          Builder.getAddressPoints());
+}
+
 void VTableContext::ComputeVTableRelatedInformation(const CXXRecordDecl *RD) {
   const VTableLayout *&Entry = VTableLayouts[RD];
 
@@ -2830,16 +2842,7 @@ void VTableContext::ComputeVTableRelatedInformation(const CXXRecordDecl *RD) {
 
   VTableBuilder Builder(*this, RD, CharUnits::Zero(), 
                         /*MostDerivedClassIsVirtual=*/0, RD);
-
-  llvm::SmallVector<VTableLayout::VTableThunkTy, 1>
-    VTableThunks(Builder.vtable_thunks_begin(), Builder.vtable_thunks_end());
-  std::sort(VTableThunks.begin(), VTableThunks.end());
-
-  Entry = new VTableLayout(Builder.getNumVTableComponents(),
-                           Builder.vtable_component_begin(),
-                           VTableThunks.size(),
-                           VTableThunks.data(),
-                           Builder.getAddressPoints());
+  Entry = CreateVTableLayout(Builder);
 
   // Add the known thunks.
   Thunks.insert(Builder.thunks_begin(), Builder.thunks_end());
@@ -2867,6 +2870,16 @@ void VTableContext::ComputeVTableRelatedInformation(const CXXRecordDecl *RD) {
   }
 }
 
+VTableLayout *VTableContext::createConstructionVTableLayout(
+                                          const CXXRecordDecl *MostDerivedClass,
+                                          CharUnits MostDerivedClassOffset,
+                                          bool MostDerivedClassIsVirtual,
+                                          const CXXRecordDecl *LayoutClass) {
+  VTableBuilder Builder(*this, MostDerivedClass, MostDerivedClassOffset, 
+                        MostDerivedClassIsVirtual, LayoutClass);
+  return CreateVTableLayout(Builder);
+}
+
 llvm::Constant *
 CodeGenVTables::CreateVTableInitializer(const CXXRecordDecl *RD,
                                         const VTableComponent *Components, 
index 537ce383ce12750a76c99990f24ac745ee6b7295..2691b4361141e86b166793cecbe5c9de06e9a966 100644 (file)
@@ -314,6 +314,12 @@ public:
     return *VTableLayouts[RD];
   }
 
+  VTableLayout *
+  createConstructionVTableLayout(const CXXRecordDecl *MostDerivedClass,
+                                 CharUnits MostDerivedClassOffset,
+                                 bool MostDerivedClassIsVirtual,
+                                 const CXXRecordDecl *LayoutClass);
+
   const ThunkInfoVectorTy *getThunkInfo(const CXXMethodDecl *MD) {
     ComputeVTableRelatedInformation(MD->getParent());