r215137 - Debug info: Use record layout to find vbase offsets instead of vtables

Reid Kleckner reid at kleckner.net
Thu Aug 7 12:43:02 PDT 2014


Author: rnk
Date: Thu Aug  7 14:43:01 2014
New Revision: 215137

URL: http://llvm.org/viewvc/llvm-project?rev=215137&view=rev
Log:
Debug info: Use record layout to find vbase offsets instead of vtables

This fixes an assertion when generating full debug info in the MS ABI
for classes with virtual bases.

Fixes PR20579.

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/test/CodeGenCXX/debug-info.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=215137&r1=215136&r2=215137&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Aug  7 14:43:01 2014
@@ -1195,9 +1195,7 @@ CollectCXXBases(const CXXRecordDecl *RD,
     if (BI.isVirtual()) {
       // virtual base offset offset is -ve. The code generator emits dwarf
       // expression where it expects +ve number.
-      BaseOffset =
-        0 - CGM.getItaniumVTableContext()
-               .getVirtualBaseOffsetOffset(RD, Base).getQuantity();
+      BaseOffset = 0 - RL.getVBaseClassOffset(Base).getQuantity();
       BFlags = llvm::DIDescriptor::FlagVirtual;
     } else
       BaseOffset = CGM.getContext().toBits(RL.getBaseClassOffset(Base));

Modified: cfe/trunk/test/CodeGenCXX/debug-info.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info.cpp?rev=215137&r1=215136&r2=215137&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info.cpp Thu Aug  7 14:43:01 2014
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -g %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-pc-windows-msvc -emit-llvm -g %s -o - | FileCheck %s --check-prefix=MSVC
+
 template<typename T> struct Identity {
   typedef T Type;
 };
@@ -43,14 +45,18 @@ namespace VirtualDtor {
 }
 
 namespace VirtualBase {
-  struct A { };
-  struct B : virtual A { };
+  struct A { int a; };
+  struct B : virtual A { int b; };
 
   void f() {
     B b;
   }
 }
 
+// MSVC: [[VBASE_B:![0-9]+]] = metadata !{i32 {{.*}}, metadata !"B", i32 {{[0-9]*}}, i64 96, i64 32, i32 0, i32 0, null, metadata [[ZZZ:![0-9]+]], i32 0, {{.*}}} ; [ DW_TAG_structure_type ] [B] [line 49, size 96, align 32, offset 0] [def] [from ]
+// MSVC: [[ZZZ]] = metadata !{metadata [[VBASE_A_IN_B:![0-9]+]],
+// MSVC: [[VBASE_A_IN_B]] = metadata !{i32 786460, null, metadata [[VBASE_B]], null, i32 0, i64 0, i64 0, i64 -8, i32 32, metadata !{{[0-9]*}}} ; [ DW_TAG_inheritance ] [line 0, size 0, align 0, offset 18446744073709551608] [from A]
+
 namespace b5249287 {
 template <typename T> class A {
   struct B;





More information about the cfe-commits mailing list