]> granicus.if.org Git - clang/commitdiff
Improve this adjustment pointer calculation.
authorAnders Carlsson <andersca@mac.com>
Wed, 24 Feb 2010 22:27:12 +0000 (22:27 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 24 Feb 2010 22:27:12 +0000 (22:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97067 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVtable.cpp

index f0a95b92da6b7d2a77554cec39938375b0e9ca93..17c21f40f9152a251e591fc4adcf53eaf542a621 100644 (file)
@@ -1432,12 +1432,23 @@ VtableBuilder::AddMethods(BaseSubobject Base,
     ReturnAdjustment ReturnAdjustment = 
       ComputeReturnAdjustment(ReturnAdjustmentOffset);
     
-    // Check if this overrider needs a 'this' pointer adjustment.
-    BaseOffset ThisAdjustmentOffset =
-      Overriders.getThisAdjustmentOffset(Base, MD);
+    ThisAdjustment ThisAdjustment;
     
-    ThisAdjustment ThisAdjustment = ComputeThisAdjustment(Overrider.Method,
-                                                          ThisAdjustmentOffset);
+    // Check if this overrider needs a 'this' pointer adjustment.
+    // (We use the base offset of the first base in the primary base chain here,
+    // because Base will not have the right offset if it is a primary virtual
+    // base that is not a primary base in the complete class.
+    if (FirstBaseInPrimaryBaseChain.getBaseOffset() != Overrider.BaseOffset) {
+      BaseSubobject OverriderBaseSubobject(Overrider.Method->getParent(),
+                                           Overrider.BaseOffset);
+      
+      BaseOffset ThisAdjustmentOffset =
+        Overriders.ComputeThisAdjustmentBaseOffset(FirstBaseInPrimaryBaseChain,
+                                                   OverriderBaseSubobject);
+
+      ThisAdjustment = ComputeThisAdjustment(Overrider.Method,
+                                             ThisAdjustmentOffset);
+    }
     
     AddMethod(Overrider.Method, ReturnAdjustment, ThisAdjustment);
   }