]> granicus.if.org Git - clang/commitdiff
[DebugInfo] Set DISubprogram ThisAdjustment in the MS ABI
authorReid Kleckner <rnk@google.com>
Fri, 1 Jul 2016 02:41:25 +0000 (02:41 +0000)
committerReid Kleckner <rnk@google.com>
Fri, 1 Jul 2016 02:41:25 +0000 (02:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274326 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXXABI.h
lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/MicrosoftCXXABI.cpp

index 8c0f6c2efd51a19322683b69d8c75697e36e7f46..9e10ec068e094fb1eb479d6871e49cd813b8ce85 100644 (file)
@@ -336,6 +336,12 @@ public:
   virtual void addImplicitStructorParams(CodeGenFunction &CGF, QualType &ResTy,
                                          FunctionArgList &Params) = 0;
 
+  /// Get the ABI-specific "this" parameter adjustment to apply in the prologue
+  /// of a virtual function.
+  virtual CharUnits getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD) {
+    return CharUnits::Zero();
+  }
+
   /// Perform ABI-specific "this" parameter adjustment in a virtual function
   /// prologue.
   virtual llvm::Value *adjustThisParameterInVirtualFunctionPrologue(
index ab0ee6cdbe936c90201e6edae7d1270ae8de3b3b..13461980a4b4c0d550de533035f196fe7b81f78b 100644 (file)
@@ -1206,6 +1206,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
   unsigned Virtuality = 0;
   unsigned VIndex = 0;
   unsigned Flags = 0;
+  int ThisAdjustment = 0;
 
   if (Method->isVirtual()) {
     if (Method->isPure())
@@ -1235,9 +1236,12 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
       if (Method->begin_overridden_methods() == Method->end_overridden_methods())
         Flags |= llvm::DINode::FlagIntroducedVirtual;
 
-      // FIXME: Pass down ML.VFPtrOffset and ML.VBTableIndex. The debugger needs
-      // these to synthesize a call to a virtual method in a complex inheritance
-      // hierarchy.
+      // The 'this' adjustment accounts for both the virtual and non-virtual
+      // portions of the adjustment. Presumably the debugger only uses it when
+      // it knows the dynamic type of an object.
+      ThisAdjustment = CGM.getCXXABI()
+                           .getVirtualFunctionPrologueThisAdjustment(GD)
+                           .getQuantity();
     }
     ContainingType = RecordTy;
   }
@@ -1263,9 +1267,9 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
   llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
   llvm::DISubprogram *SP = DBuilder.createMethod(
       RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine,
-      MethodTy, /*isLocalToUnit=*/false,
-      /* isDefinition=*/false, Virtuality, VIndex, ContainingType, Flags,
-      CGM.getLangOpts().Optimize, TParamsArray.get());
+      MethodTy, /*isLocalToUnit=*/false, /*isDefinition=*/false, Virtuality,
+      VIndex, ThisAdjustment, ContainingType, Flags, CGM.getLangOpts().Optimize,
+      TParamsArray.get());
 
   SPCache[Method->getCanonicalDecl()].reset(SP);
 
index 31bfbf0cdfb25bef0ce74f4844ccc305ac4c10d4..e86d7eb77351128a1a9bf55d2396885e9fcb355d 100644 (file)
@@ -551,7 +551,7 @@ private:
     return  llvm::Constant::getAllOnesValue(CGM.IntTy);
   }
 
-  CharUnits getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD);
+  CharUnits getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD) override;
 
   void
   GetNullMemberPointerFields(const MemberPointerType *MPT,