[cfe-commits] r128392 - /cfe/trunk/lib/CodeGen/CGVTables.cpp

Ken Dyck kd at kendyck.com
Sun Mar 27 13:20:29 PDT 2011


Author: kjdyck
Date: Sun Mar 27 15:20:28 2011
New Revision: 128392

URL: http://llvm.org/viewvc/llvm-project?rev=128392&view=rev
Log:
Convert VTableBuilder::MostDerivedClassOffset to CharUnits. No change in
functionality intended.

Modified:
    cfe/trunk/lib/CodeGen/CGVTables.cpp

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=128392&r1=128391&r2=128392&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Sun Mar 27 15:20:28 2011
@@ -970,7 +970,7 @@
 
   /// MostDerivedClassOffset - If we're building a construction vtable, this
   /// holds the offset from the layout class to the most derived class.
-  const uint64_t MostDerivedClassOffset;
+  const CharUnits MostDerivedClassOffset;
   
   /// MostDerivedClassIsVirtual - Whether the most derived class is a virtual 
   /// base. (This only makes sense when building a construction vtable).
@@ -1156,16 +1156,14 @@
 
 public:
   VTableBuilder(CodeGenVTables &VTables, const CXXRecordDecl *MostDerivedClass,
-                uint64_t MostDerivedClassOffset, bool MostDerivedClassIsVirtual,
-                const CXXRecordDecl *LayoutClass)
+                CharUnits MostDerivedClassOffset, 
+                bool MostDerivedClassIsVirtual, const 
+                CXXRecordDecl *LayoutClass)
     : VTables(VTables), MostDerivedClass(MostDerivedClass),
     MostDerivedClassOffset(MostDerivedClassOffset), 
     MostDerivedClassIsVirtual(MostDerivedClassIsVirtual), 
     LayoutClass(LayoutClass), Context(MostDerivedClass->getASTContext()), 
-    Overriders(MostDerivedClass, 
-      MostDerivedClass->getASTContext().toCharUnitsFromBits(
-        MostDerivedClassOffset), 
-      LayoutClass) {
+    Overriders(MostDerivedClass, MostDerivedClassOffset, LayoutClass) {
 
     LayoutVTable();
   }
@@ -1730,13 +1728,13 @@
                                                  CharUnits::Zero()),
                                    /*BaseIsMorallyVirtual=*/false,
                                    MostDerivedClassIsVirtual,
-                                   MostDerivedClassOffset);
+                                   Context.toBits(MostDerivedClassOffset));
   
   VisitedVirtualBasesSetTy VBases;
   
   // Determine the primary virtual bases.
-  DeterminePrimaryVirtualBases(MostDerivedClass, MostDerivedClassOffset,
-                               VBases);
+  DeterminePrimaryVirtualBases(MostDerivedClass, 
+                               Context.toBits(MostDerivedClassOffset), VBases);
   VBases.clear();
   
   LayoutVTablesForVirtualBases(MostDerivedClass, VBases);
@@ -1771,7 +1769,7 @@
   // Add the offset to top.
   // FIXME: We should not use / 8 here.
   int64_t OffsetToTop = -(int64_t)(OffsetInLayoutClass -
-                                   MostDerivedClassOffset) / 8;
+                                   Context.toBits(MostDerivedClassOffset)) / 8;
   Components.push_back(VTableComponent::MakeOffsetToTop(OffsetToTop));
   
   // Next, add the RTTI.
@@ -1986,8 +1984,7 @@
   if (isBuildingConstructorVTable()) {
     Out << "Construction vtable for ('";
     Out << MostDerivedClass->getQualifiedNameAsString() << "', ";
-    // FIXME: Don't use / 8 .
-    Out << MostDerivedClassOffset / 8 << ") in '";
+    Out << MostDerivedClassOffset.getQuantity() << ") in '";
     Out << LayoutClass->getQualifiedNameAsString();
   } else {
     Out << "Vtable for '";
@@ -2835,7 +2832,8 @@
   if (Entry.getPointer())
     return;
 
-  VTableBuilder Builder(*this, RD, 0, /*MostDerivedClassIsVirtual=*/0, RD);
+  VTableBuilder Builder(*this, RD, CharUnits::Zero(), 
+                        /*MostDerivedClassIsVirtual=*/0, RD);
 
   // Add the VTable layout.
   uint64_t NumVTableComponents = Builder.getNumVTableComponents();
@@ -3040,7 +3038,8 @@
                                      const CXXRecordDecl *RD) {
   // Dump the vtable layout if necessary.
   if (CGM.getLangOptions().DumpVTableLayouts) {
-    VTableBuilder Builder(*this, RD, 0, /*MostDerivedClassIsVirtual=*/0, RD);
+    VTableBuilder Builder(*this, RD, CharUnits::Zero(), 
+                          /*MostDerivedClassIsVirtual=*/0, RD);
 
     Builder.dumpLayout(llvm::errs());
   }
@@ -3070,7 +3069,7 @@
                                    llvm::GlobalVariable::LinkageTypes Linkage,
                                       VTableAddressPointsMapTy& AddressPoints) {
   VTableBuilder Builder(*this, Base.getBase(), 
-                        CGM.getContext().toBits(Base.getBaseOffset()), 
+                        Base.getBaseOffset(), 
                         /*MostDerivedClassIsVirtual=*/BaseIsVirtual, RD);
 
   // Dump the vtable layout if necessary.





More information about the cfe-commits mailing list