Files
swift-mirror/test/SILGen/read_yield_local_variable.swift
Joe Groff 7fed21ae98 SILGen: Handle emitting borrowed lvalues from value bindings.
Replace the "must be an address" assertion with an implementation
that emits and borrows the base value. Fixes #71598.
2024-02-14 16:09:14 -08:00

28 lines
697 B
Swift

// RUN: %target-swift-emit-silgen %s | %FileCheck %s
func foo(x: borrowing String) {}
var last:String
{
// CHECK-LABEL: sil{{.*}} @{{.*}}4lastSSvr :
_read
{
// CHECK: [[X:%.*]] = move_value
let x:String = ""
// CHECK: [[BORROW1:%.*]] = begin_borrow [[X]]
// CHECK: apply {{.*}}([[BORROW1]])
// CHECK: end_borrow [[BORROW1]]
foo(x: x)
// CHECK: [[BORROW2:%.*]] = begin_borrow [[X]]
// CHECK: yield [[BORROW2]] : {{.*}}, resume [[RESUME:bb[0-9]+]],
// CHECK: [[RESUME]]:
// CHECK: end_borrow [[BORROW2]]
yield x
}
_modify {
var x: String = ""
yield &x
}
}