From f6e13ce923d836fb3866ac524422475d82ef027e Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 22 Jun 2016 18:34:45 +0000 Subject: [PATCH] [codeview] Set the new IntroducedVirtual debug info flag git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273454 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 9 +++++++++ test/CodeGenCXX/debug-info-ms-abi.cpp | 17 ++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 441135dc90..5448d7b1c5 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1195,6 +1195,15 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction( MicrosoftVTableContext::MethodVFTableLocation ML = CGM.getMicrosoftVTableContext().getMethodVFTableLocation(GD); VIndex = ML.Index; + + // CodeView only records the vftable offset in the class that introduces + // the virtual method. This is possible because, unlike Itanium, the MS + // C++ ABI does not include all virtual methods from non-primary bases in + // the vtable for the most derived class. For example, if C inherits from + // A and B, C's primary vftable will not include B's virtual methods. + 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. diff --git a/test/CodeGenCXX/debug-info-ms-abi.cpp b/test/CodeGenCXX/debug-info-ms-abi.cpp index 1664da38a8..a146ce9417 100644 --- a/test/CodeGenCXX/debug-info-ms-abi.cpp +++ b/test/CodeGenCXX/debug-info-ms-abi.cpp @@ -10,10 +10,21 @@ struct Foo { }; Foo f; Foo::Nested n; + // CHECK: ![[Foo:[^ ]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", // CHECK-SAME: identifier: ".?AUFoo@@" -// CHECK: !DISubprogram(name: "f", {{.*}} containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0, {{.*}}) -// CHECK: !DISubprogram(name: "g", {{.*}} containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 1, {{.*}}) -// CHECK: !DISubprogram(name: "h", {{.*}} containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 2, {{.*}}) + +// CHECK: !DISubprogram(name: "f", +// CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0, +// CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual, + +// CHECK: !DISubprogram(name: "g", +// CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 1, +// CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual, + +// CHECK: !DISubprogram(name: "h", +// CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 2, +// CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual, + // CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested", // CHECK-SAME: identifier: ".?AUNested@Foo@@" -- 2.40.0