Author: rnk
Date: Wed Feb  8 10:09:32 2017
New Revision: 294465

URL: http://llvm.org/viewvc/llvm-project?rev=294465&view=rev
Log:
[MS] Fix C++ destructor thunk line info for a declaration

Sometimes the MS ABI needs to emit thunks for declarations that don't
have bodies. Destructor thunks make calls to inlinable functions, so
they need line info or LLVM will complain.

Fixes PR31893

Added:
    cfe/trunk/test/CodeGenCXX/debug-info-ms-dtor-thunks.cpp
Modified:
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=294465&r1=294464&r2=294465&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Feb  8 10:09:32 2017
@@ -1089,8 +1089,13 @@ void CodeGenFunction::GenerateCode(Globa
   if (FD->hasAttr<NoDebugAttr>())
     DebugInfo = nullptr; // disable debug info indefinitely for this function
 
+  // The function might not have a body if we're generating thunks for a
+  // function declaration.
   SourceRange BodyRange;
-  if (Stmt *Body = FD->getBody()) BodyRange = Body->getSourceRange();
+  if (Stmt *Body = FD->getBody())
+    BodyRange = Body->getSourceRange();
+  else
+    BodyRange = FD->getLocation();
   CurEHLocation = BodyRange.getEnd();
 
   // Use the location of the start of the function to determine where

Added: cfe/trunk/test/CodeGenCXX/debug-info-ms-dtor-thunks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-ms-dtor-thunks.cpp?rev=294465&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-ms-dtor-thunks.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-ms-dtor-thunks.cpp Wed Feb  8 10:09:32 
2017
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple i686--windows -emit-llvm 
-debug-info-kind=line-tables-only -x c++ %s -fms-extensions -o - | FileCheck %s
+
+struct __declspec(dllexport) S { virtual ~S(); };
+struct __declspec(dllexport) T { virtual ~T(); };
+struct __declspec(dllexport) U : S, T { virtual ~U(); };
+
+// CHECK-LABEL: define {{.*}} @"\01??_GS@@UAEPAXI@Z"
+// CHECK: call x86_thiscallcc void @"\01??_DS@@UAE@XZ"(%struct.S* 
%this1){{.*}}!dbg !{{[0-9]+}}
+
+// CHECK-LABEL: define {{.*}} @"\01??_GT@@UAEPAXI@Z"
+// CHECK: call x86_thiscallcc void @"\01??_DT@@UAE@XZ"(%struct.T* 
%this1){{.*}}!dbg !{{[0-9]+}}
+
+// CHECK-LABEL: define {{.*}} @"\01??_GU@@UAEPAXI@Z"
+// CHECK: call x86_thiscallcc void @"\01??_DU@@UAE@XZ"(%struct.U* 
%this1){{.*}}!dbg !{{[0-9]+}}


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to