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

Ken Dyck kd at kendyck.com
Wed Mar 30 18:08:46 PDT 2011


Author: kjdyck
Date: Wed Mar 30 20:08:46 2011
New Revision: 128603

URL: http://llvm.org/viewvc/llvm-project?rev=128603&view=rev
Log:
Convert the return value of
VCallAndVBaseOffsetBuilder::getCurrentOffsetOffset() 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=128603&r1=128602&r2=128603&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Mar 30 20:08:46 2011
@@ -753,8 +753,8 @@
                        CharUnits OffsetInLayoutClass);
   
   /// getCurrentOffsetOffset - Get the current vcall or vbase offset offset in
-  /// bytes, relative to the vtable address point.
-  int64_t getCurrentOffsetOffset() const;
+  /// chars, relative to the vtable address point.
+  CharUnits getCurrentOffsetOffset() const;
   
 public:
   VCallAndVBaseOffsetBuilder(const CXXRecordDecl *MostDerivedClass,
@@ -829,17 +829,16 @@
     AddVCallOffsets(Base, RealBaseOffset);
 }
 
-int64_t VCallAndVBaseOffsetBuilder::getCurrentOffsetOffset() const {
+CharUnits VCallAndVBaseOffsetBuilder::getCurrentOffsetOffset() const {
   // OffsetIndex is the index of this vcall or vbase offset, relative to the 
   // vtable address point. (We subtract 3 to account for the information just
   // above the address point, the RTTI info, the offset to top, and the
   // vcall offset itself).
   int64_t OffsetIndex = -(int64_t)(3 + Components.size());
     
-  // FIXME: We shouldn't use / 8 here.
-  int64_t OffsetOffset = OffsetIndex * 
-    (int64_t)Context.Target.getPointerWidth(0) / 8;
-
+  CharUnits PointerWidth = 
+    Context.toCharUnitsFromBits(Context.Target.getPointerWidth(0));
+  CharUnits OffsetOffset = PointerWidth * OffsetIndex;
   return OffsetOffset;
 }
 
@@ -870,11 +869,11 @@
     if (!MD->isVirtual())
       continue;
 
-    int64_t OffsetOffset = getCurrentOffsetOffset();
+    CharUnits OffsetOffset = getCurrentOffsetOffset();
     
     // Don't add a vcall offset if we already have one for this member function
     // signature.
-    if (!VCallOffsets.AddVCallOffset(MD, OffsetOffset))
+    if (!VCallOffsets.AddVCallOffset(MD, OffsetOffset.getQuantity()))
       continue;
 
     CharUnits Offset = CharUnits::Zero();
@@ -935,8 +934,9 @@
       assert(!VBaseOffsetOffsets.count(BaseDecl) &&
              "vbase offset offset already exists!");
 
-      int64_t VBaseOffsetOffset = getCurrentOffsetOffset();
-      VBaseOffsetOffsets.insert(std::make_pair(BaseDecl, VBaseOffsetOffset));
+      CharUnits VBaseOffsetOffset = getCurrentOffsetOffset();
+      VBaseOffsetOffsets.insert(
+          std::make_pair(BaseDecl, VBaseOffsetOffset.getQuantity()));
 
       Components.push_back(
           VTableComponent::MakeVBaseOffset(Offset.getQuantity()));





More information about the cfe-commits mailing list