Skip to content

Commit ebc47e4

Browse files
committed
Shadow copies: Use the function's debug scope for the artificial location
instead of the variable's potentially incorrectly not inlined scope. rdar://problem/27206870
1 parent 5cf6006 commit ebc47e4

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ class IRGenSILFunction :
656656
if (!Alloca.isValid())
657657
Alloca = createAlloca(Ty, Align, Name+".addr");
658658

659-
ArtificialLocation AutoRestore(Scope, IGM.DebugInfo, Builder);
659+
ArtificialLocation AutoRestore(getDebugScope(), IGM.DebugInfo, Builder);
660660
Builder.CreateStore(Storage, Alloca.getAddress(), Align);
661661
return Alloca.getAddress();
662662
}

test/DebugInfo/guard-let.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ public func f(_ i : Int?)
88
// The shadow copy store should not have a location.
99
// CHECK: store {{(i32|i64)}} %[[PHI]], {{(i32|i64)}}* %val.addr, align {{(4|8)}}, !dbg ![[DBG0:.*]]
1010
// CHECK: @llvm.dbg.declare(metadata {{(i32|i64)}}* %val.addr, {{.*}}, !dbg ![[DBG1:.*]]
11-
// CHECK: ![[DBG0]] = !DILocation(line: 0,
11+
// CHECK: ![[F:.*]] = distinct !DISubprogram(name: "f",
12+
// CHECK: ![[DBG0]] = !DILocation(line: 0, scope: ![[F]])
1213
// CHECK: ![[DBG1]] = !DILocation(line: [[@LINE+1]],
1314
guard let val = i else { return }
1415
use(val)

0 commit comments

Comments
 (0)