Skip to content

Commit 1f5301f

Browse files
authored
Merge pull request #3869 from adrian-prantl/25427596
2 parents 65f933e + 4136f07 commit 1f5301f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ class IRGenSILFunction :
723723
Alignment align(layout->getAlignment());
724724

725725
auto alloca = createAlloca(aggregateType, align, Name + ".debug");
726+
ArtificialLocation AutoRestore(getDebugScope(), IGM.DebugInfo, Builder);
726727
size_t i = 0;
727728
for (auto val : vals) {
728729
auto addr = Builder.CreateStructGEP(alloca, i,

test/DebugInfo/guard-let.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-swift-frontend %s -emit-ir -g -o - | FileCheck %s
2+
// RUN: %target-swift-frontend %s -emit-ir -g -o - | FileCheck %s --check-prefix=CHECK2
23
func use<T>(_ t: T) {}
34

45
public func f(_ i : Int?)
@@ -14,3 +15,14 @@ public func f(_ i : Int?)
1415
guard let val = i else { return }
1516
use(val)
1617
}
18+
19+
public func g(_ s : String?)
20+
{
21+
// CHECK2: define {{.*}}@_TF4main1gFGSqSS_T_
22+
// The shadow copy store should not have a location.
23+
// CHECK2: getelementptr inbounds {{.*}} %s.debug, {{.*}}, !dbg ![[DBG0:.*]]
24+
// CHECK2: ![[G:.*]] = distinct !DISubprogram(name: "g",
25+
// CHECK2: ![[DBG0]] = !DILocation(line: 0, scope: ![[G]])
26+
guard let val = s else { return }
27+
use(val)
28+
}

0 commit comments

Comments
 (0)