Files
swift-mirror/test/SILGen/guardlet_debuginfo.swift
Felipe de Azevedo Piovezan 8baf933114 [DebugInfo][SILGen] Ensure "guard let" is lowered with a non-implicit location
Prior to this patch, a "guard let" was being lowered with an implicit debug
location, causing it to be dropped in later stages of the compiler, and making
it impossible to set a breakpoint in that line.

This was tracked down to a piece of code in `SILGenFunction::emitExprInto`,
which takes an optional Location parameter that was being ignored in one code
path.
2023-11-30 09:14:36 -08:00

18 lines
456 B
Swift

// RUN: %target-swift-emit-silgen -g -Xllvm -sil-print-debuginfo %s | %FileCheck %s
class A {
func foo() {
{ [weak self] in
// Check that column 14 -- the start "guard" -- is used as the debug location,
// as other locations are considered implicit.
// CHECK: switch_enum
// CHECK-SAME: guardlet_debuginfo.swift":[[@LINE+1]]:13
guard let self else { return }
print(self)
}()
}
}
let a = A()
a.foo()