From 7926226534f7c61807c48f53af1ac8d2f6c6c1ca Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Thu, 24 Aug 2017 16:21:49 +0000 Subject: Merging r311601: ------------------------------------------------------------------------ r311601 | adrian | 2017-08-23 14:24:12 -0700 (Wed, 23 Aug 2017) | 5 lines Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to be parented in function declarations. Fixes PR33997. https://bugs.llvm.org/show_bug.cgi?id=33997 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@311671 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 2 +- test/CodeGenCXX/debug-info-inlined.cpp | 45 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 test/CodeGenCXX/debug-info-inlined.cpp diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index c9c450c32e..18b1d10a92 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -3260,7 +3260,7 @@ void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD) { llvm::DISubprogram *SP = nullptr; if (FI != SPCache.end()) SP = dyn_cast_or_null(FI->second); - if (!SP) + if (!SP || !SP->isDefinition()) SP = getFunctionStub(GD); FnBeginRegionCount.push_back(LexicalBlockStack.size()); LexicalBlockStack.emplace_back(SP); diff --git a/test/CodeGenCXX/debug-info-inlined.cpp b/test/CodeGenCXX/debug-info-inlined.cpp new file mode 100644 index 0000000000..9969ef79ca --- /dev/null +++ b/test/CodeGenCXX/debug-info-inlined.cpp @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -emit-llvm -triple i686-pc-windows-msvc19.0.24213 -gcodeview -debug-info-kind=limited -std=c++14 %s -o - | FileCheck %s +// PR33997. +struct already_AddRefed { + ~already_AddRefed(); +}; +struct RefPtr { + operator int *(); +}; +struct ServoCssRulesStrong { + already_AddRefed Consume(); +}; +struct GroupRule { + GroupRule(already_AddRefed); +}; +class ConditionRule : GroupRule { + using GroupRule::GroupRule; +}; +class CSSMediaRule : ConditionRule { + using ConditionRule::ConditionRule; +}; +class CSSMozDocumentRule : ConditionRule { + using ConditionRule::ConditionRule; +}; +class ServoDocumentRule : CSSMozDocumentRule { + ServoDocumentRule(RefPtr); +}; +class ServoMediaRule : CSSMediaRule { + ServoMediaRule(RefPtr); +}; +ServoCssRulesStrong Servo_MediaRule_GetRules(int *); +ServoCssRulesStrong Servo_DocumentRule_GetRules(int *); +ServoDocumentRule::ServoDocumentRule(RefPtr aRawRule) + : CSSMozDocumentRule(Servo_DocumentRule_GetRules(aRawRule).Consume()) {} + +ServoMediaRule::ServoMediaRule(RefPtr aRawRule) + : CSSMediaRule(Servo_MediaRule_GetRules(aRawRule).Consume()) {} + +// CHECK: define{{.*}}ServoMediaRule +// CHECK-NOT: {{ ret }} +// CHECK: store %class.ConditionRule* % +// CHECK-SAME: %class.ConditionRule** % +// CHECK-SAME: !dbg ![[INL:[0-9]+]] + +// CHECK: ![[INL]] = !DILocation(line: 16, scope: ![[SP:[0-9]+]], inlinedAt: +// CHECK: ![[SP]] = distinct !DISubprogram(name: "GroupRule", {{.*}}isDefinition: true -- cgit v1.2.3