[cfe-commits] r128129 - in /cfe/trunk/lib/CodeGen: CGClass.cpp CodeGenFunction.h

Ken Dyck kd at kendyck.com
Tue Mar 22 18:04:18 PDT 2011


Author: kjdyck
Date: Tue Mar 22 20:04:18 2011
New Revision: 128129

URL: http://llvm.org/viewvc/llvm-project?rev=128129&view=rev
Log:
Convert OffsetFromNearestVBast parameter of InitializeVTablePointer(s) to
CharUnits. No change in functionality intended.

Modified:
    cfe/trunk/lib/CodeGen/CGClass.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=128129&r1=128128&r2=128129&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Tue Mar 22 20:04:18 2011
@@ -1338,7 +1338,7 @@
 void
 CodeGenFunction::InitializeVTablePointer(BaseSubobject Base, 
                                          const CXXRecordDecl *NearestVBase,
-                                         uint64_t OffsetFromNearestVBase,
+                                         CharUnits OffsetFromNearestVBase,
                                          llvm::Constant *VTable,
                                          const CXXRecordDecl *VTableClass) {
   const CXXRecordDecl *RD = Base.getBase();
@@ -1375,8 +1375,7 @@
     // might have a different offset in the most derived class.
     VirtualOffset = GetVirtualBaseClassOffset(LoadCXXThis(), VTableClass, 
                                               NearestVBase);
-    NonVirtualOffset = 
-      CGM.getContext().toCharUnitsFromBits(OffsetFromNearestVBase);
+    NonVirtualOffset = OffsetFromNearestVBase;
   } else {
     // We can just use the base offset in the complete class.
     NonVirtualOffset = 
@@ -1401,7 +1400,7 @@
 void
 CodeGenFunction::InitializeVTablePointers(BaseSubobject Base, 
                                           const CXXRecordDecl *NearestVBase,
-                                          uint64_t OffsetFromNearestVBase,
+                                          CharUnits OffsetFromNearestVBase,
                                           bool BaseIsNonVirtualPrimaryBase,
                                           llvm::Constant *VTable,
                                           const CXXRecordDecl *VTableClass,
@@ -1426,8 +1425,8 @@
     if (!BaseDecl->isDynamicClass())
       continue;
 
-    uint64_t BaseOffset;
-    uint64_t BaseOffsetFromNearestVBase;
+    CharUnits BaseOffset;
+    CharUnits BaseOffsetFromNearestVBase;
     bool BaseDeclIsNonVirtualPrimaryBase;
 
     if (I->isVirtual()) {
@@ -1438,20 +1437,22 @@
       const ASTRecordLayout &Layout = 
         getContext().getASTRecordLayout(VTableClass);
 
-      BaseOffset = Layout.getVBaseClassOffsetInBits(BaseDecl);
-      BaseOffsetFromNearestVBase = 0;
+      BaseOffset = Layout.getVBaseClassOffset(BaseDecl);
+      BaseOffsetFromNearestVBase = CharUnits::Zero();
       BaseDeclIsNonVirtualPrimaryBase = false;
     } else {
       const ASTRecordLayout &Layout = getContext().getASTRecordLayout(RD);
 
       BaseOffset = 
-        Base.getBaseOffset() + Layout.getBaseClassOffsetInBits(BaseDecl);
+        getContext().toCharUnitsFromBits(Base.getBaseOffset()) + 
+        Layout.getBaseClassOffset(BaseDecl);
       BaseOffsetFromNearestVBase = 
-        OffsetFromNearestVBase + Layout.getBaseClassOffsetInBits(BaseDecl);
+        OffsetFromNearestVBase + Layout.getBaseClassOffset(BaseDecl);
       BaseDeclIsNonVirtualPrimaryBase = Layout.getPrimaryBase() == BaseDecl;
     }
     
-    InitializeVTablePointers(BaseSubobject(BaseDecl, BaseOffset), 
+    InitializeVTablePointers(BaseSubobject(BaseDecl, 
+                                           getContext().toBits(BaseOffset)), 
                              I->isVirtual() ? BaseDecl : NearestVBase,
                              BaseOffsetFromNearestVBase,
                              BaseDeclIsNonVirtualPrimaryBase, 
@@ -1470,7 +1471,7 @@
   // Initialize the vtable pointers for this class and all of its bases.
   VisitedVirtualBasesSetTy VBases;
   InitializeVTablePointers(BaseSubobject(RD, 0), /*NearestVBase=*/0, 
-                           /*OffsetFromNearestVBase=*/0,
+                           /*OffsetFromNearestVBase=*/CharUnits::Zero(),
                            /*BaseIsNonVirtualPrimaryBase=*/false, 
                            VTable, RD, VBases);
 }

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=128129&r1=128128&r2=128129&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Mar 22 20:04:18 2011
@@ -1161,14 +1161,14 @@
   ///
   void InitializeVTablePointer(BaseSubobject Base,
                                const CXXRecordDecl *NearestVBase,
-                               uint64_t OffsetFromNearestVBase,
+                               CharUnits OffsetFromNearestVBase,
                                llvm::Constant *VTable,
                                const CXXRecordDecl *VTableClass);
 
   typedef llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedVirtualBasesSetTy;
   void InitializeVTablePointers(BaseSubobject Base,
                                 const CXXRecordDecl *NearestVBase,
-                                uint64_t OffsetFromNearestVBase,
+                                CharUnits OffsetFromNearestVBase,
                                 bool BaseIsNonVirtualPrimaryBase,
                                 llvm::Constant *VTable,
                                 const CXXRecordDecl *VTableClass,





More information about the cfe-commits mailing list