Skip to content

Commit ac85703

Browse files
Merge pull request #70111 from felipepiovezan/felipe/fix_incorrect_debug_loc
[DebugInfo][SILGen] Ensure "guard let" is lowered with a non-implicit location
2 parents 2aa8d56 + 8baf933 commit ac85703

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/SILGen/SILGenExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ void SILGenFunction::emitExprInto(Expr *E, Initialization *I,
405405
FormalEvaluationScope writeback(*this);
406406
auto lv = emitLValue(load->getSubExpr(),
407407
SGFAccessKind::BorrowedAddressRead);
408-
emitCopyLValueInto(E, std::move(lv), I);
408+
emitCopyLValueInto(L ? *L : E, std::move(lv), I);
409409
return;
410410
}
411411

test/SILGen/guardlet_debuginfo.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-swift-emit-silgen -g -Xllvm -sil-print-debuginfo %s | %FileCheck %s
2+
3+
class A {
4+
func foo() {
5+
{ [weak self] in
6+
// Check that column 14 -- the start "guard" -- is used as the debug location,
7+
// as other locations are considered implicit.
8+
// CHECK: switch_enum
9+
// CHECK-SAME: guardlet_debuginfo.swift":[[@LINE+1]]:13
10+
guard let self else { return }
11+
print(self)
12+
}()
13+
}
14+
}
15+
16+
let a = A()
17+
a.foo()

0 commit comments

Comments
 (0)