r222140 - Minor readability tweaks to VFTableBuilder.cpp

Timur Iskhodzhanov timurrrr at google.com
Mon Nov 17 07:53:50 PST 2014


Author: timurrrr
Date: Mon Nov 17 09:53:50 2014
New Revision: 222140

URL: http://llvm.org/viewvc/llvm-project?rev=222140&view=rev
Log:
Minor readability tweaks to VFTableBuilder.cpp

Modified:
    cfe/trunk/lib/AST/VTableBuilder.cpp

Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=222140&r1=222139&r2=222140&view=diff
==============================================================================
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Mon Nov 17 09:53:50 2014
@@ -2831,6 +2831,7 @@ VFTableBuilder::ComputeThisOffset(FinalO
 //   vtordisp
 //   FIXME: if a structor knows it belongs to MDC, why doesn't it use a vftable
 //   without vtordisp thunks?
+//   FIXME: how are vtordisp handled in the presence of nooverride/final?
 //
 // When foo() is called, an object with a layout of class C has a vftable
 // referencing B::f() that assumes a B layout, so the "this" adjustments are
@@ -2893,9 +2894,9 @@ void VFTableBuilder::CalculateVtordispAd
 
   // OK, now we know we need to use a vtordisp thunk.
   // The implicit vtordisp field is located right before the vbase.
-  CharUnits VFPtrVBaseOffset = VBaseMapEntry->second.VBaseOffset;
+  CharUnits OffsetOfVBaseWithVFPtr = VBaseMapEntry->second.VBaseOffset;
   TA.Virtual.Microsoft.VtordispOffset =
-      (VFPtrVBaseOffset - WhichVFPtr.FullOffsetInMDC).getQuantity() - 4;
+      (OffsetOfVBaseWithVFPtr - WhichVFPtr.FullOffsetInMDC).getQuantity() - 4;
 
   // A simple vtordisp thunk will suffice if the final overrider is defined
   // in either the most derived class or its non-virtual base.
@@ -2906,7 +2907,7 @@ void VFTableBuilder::CalculateVtordispAd
   // Otherwise, we need to do use the dynamic offset of the final overrider
   // in order to get "this" adjustment right.
   TA.Virtual.Microsoft.VBPtrOffset =
-      (VFPtrVBaseOffset + WhichVFPtr.NonVirtualOffset -
+      (OffsetOfVBaseWithVFPtr + WhichVFPtr.NonVirtualOffset -
        MostDerivedClassLayout.getVBPtrOffset()).getQuantity();
   TA.Virtual.Microsoft.VBOffsetOffset =
       Context.getTypeSizeInChars(Context.IntTy).getQuantity() *
@@ -3001,20 +3002,21 @@ void VFTableBuilder::AddMethods(BaseSubo
   for (unsigned I = 0, E = VirtualMethods.size(); I != E; ++I) {
     const CXXMethodDecl *MD = VirtualMethods[I];
 
-    FinalOverriders::OverriderInfo Overrider =
+    FinalOverriders::OverriderInfo FinalOverrider =
         Overriders.getOverrider(MD, Base.getBaseOffset());
-    const CXXMethodDecl *OverriderMD = Overrider.Method;
+    const CXXMethodDecl *FinalOverriderMD = FinalOverrider.Method;
     const CXXMethodDecl *OverriddenMD =
         FindNearestOverriddenMethod(MD, VisitedBases);
 
     ThisAdjustment ThisAdjustmentOffset;
     bool ReturnAdjustingThunk = false, ForceReturnAdjustmentMangling = false;
-    CharUnits ThisOffset = ComputeThisOffset(Overrider);
+    CharUnits ThisOffset = ComputeThisOffset(FinalOverrider);
     ThisAdjustmentOffset.NonVirtual =
         (ThisOffset - WhichVFPtr.FullOffsetInMDC).getQuantity();
-    if ((OverriddenMD || OverriderMD != MD) &&
+    if ((OverriddenMD || FinalOverriderMD != MD) &&
         WhichVFPtr.getVBaseWithVPtr())
-      CalculateVtordispAdjustment(Overrider, ThisOffset, ThisAdjustmentOffset);
+      CalculateVtordispAdjustment(FinalOverrider, ThisOffset,
+                                  ThisAdjustmentOffset);
 
     if (OverriddenMD) {
       // If MD overrides anything in this vftable, we need to update the entries.
@@ -3056,7 +3058,7 @@ void VFTableBuilder::AddMethods(BaseSubo
       // Force a special name mangling for a return-adjusting thunk
       // unless the method is the final overrider without this adjustment.
       ForceReturnAdjustmentMangling =
-          !(MD == OverriderMD && ThisAdjustmentOffset.isEmpty());
+          !(MD == FinalOverriderMD && ThisAdjustmentOffset.isEmpty());
     } else if (Base.getBaseOffset() != WhichVFPtr.FullOffsetInMDC ||
                MD->size_overridden_methods()) {
       // Skip methods that don't belong to the vftable of the current class,
@@ -3081,9 +3083,9 @@ void VFTableBuilder::AddMethods(BaseSubo
     // We don't want to do this for pure virtual member functions.
     BaseOffset ReturnAdjustmentOffset;
     ReturnAdjustment ReturnAdjustment;
-    if (!OverriderMD->isPure()) {
+    if (!FinalOverriderMD->isPure()) {
       ReturnAdjustmentOffset =
-          ComputeReturnAdjustmentBaseOffset(Context, OverriderMD, MD);
+          ComputeReturnAdjustmentBaseOffset(Context, FinalOverriderMD, MD);
     }
     if (!ReturnAdjustmentOffset.isEmpty()) {
       ForceReturnAdjustmentMangling = true;
@@ -3100,7 +3102,7 @@ void VFTableBuilder::AddMethods(BaseSubo
       }
     }
 
-    AddMethod(OverriderMD,
+    AddMethod(FinalOverriderMD,
               ThunkInfo(ThisAdjustmentOffset, ReturnAdjustment,
                         ForceReturnAdjustmentMangling ? MD : nullptr));
   }





More information about the cfe-commits mailing list