mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Mangling this information for future directions like component lifetimes becomes complex and the current mangling scheme isn't scalable anyway. Deleting this support for now.
56 lines
2.2 KiB
Swift
56 lines
2.2 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/def_explicit_lifetime_dependence.swift \
|
|
// RUN: -enable-experimental-feature NonescapableTypes \
|
|
// RUN: -disable-lifetime-dependence-diagnostics
|
|
|
|
// RUN: llvm-bcanalyzer %t/def_explicit_lifetime_dependence.swiftmodule
|
|
|
|
// RUN: %target-swift-frontend -module-name lifetime-dependence -emit-sil -I %t %s \
|
|
// RUN: -enable-experimental-feature NonescapableTypes | %FileCheck %s
|
|
|
|
import def_explicit_lifetime_dependence
|
|
func testBasic() {
|
|
let capacity = 4
|
|
let a = Array(0..<capacity)
|
|
a.withUnsafeBytes {
|
|
let view = BufferView($0)
|
|
let derivedView = derive(view)
|
|
let consumedView = consumeAndCreate(derivedView)
|
|
let borrowedView = borrowAndCreate(consumedView)
|
|
let mysteryView = deriveThisOrThat(borrowedView, consumedView)
|
|
use(mysteryView)
|
|
}
|
|
}
|
|
|
|
func testInitializers() {
|
|
let capacity = 4
|
|
let a = Array(0..<capacity)
|
|
let b = Array(0..<capacity)
|
|
a.withUnsafeBytes {
|
|
let view1 = BufferView($0, a)
|
|
let view2 = BufferView($0, b)
|
|
let mysteryView = deriveThisOrThat(view1, view2)
|
|
use(mysteryView)
|
|
}
|
|
}
|
|
|
|
func testReadAccessor() {
|
|
let capacity = 4
|
|
let a = Array(0..<capacity)
|
|
a.withUnsafeBytes {
|
|
let view = BufferView($0, a)
|
|
let w = Wrapper(view)
|
|
use(w.view)
|
|
}
|
|
}
|
|
|
|
func testFakeOptional() {
|
|
_ = FakeOptional<Int>(())
|
|
}
|
|
|
|
// CHECK-LABEL: sil @$s32def_explicit_lifetime_dependence6deriveyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _scope(0) @owned BufferView
|
|
// CHECK-LABEL: sil @$s32def_explicit_lifetime_dependence16consumeAndCreateyAA10BufferViewVADnF : $@convention(thin) (@owned BufferView) -> _inherit(0) @owned BufferView
|
|
// CHECK-LABEL: sil @$s32def_explicit_lifetime_dependence15borrowAndCreateyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _scope(0) @owned BufferView
|
|
// CHECK-LABEL: sil @$s32def_explicit_lifetime_dependence16deriveThisOrThatyAA10BufferViewVAD_ADtF : $@convention(thin) (@guaranteed BufferView, @guaranteed BufferView) -> _scope(0, 1) @owned BufferView
|
|
// CHECK-LABEL: sil @$s32def_explicit_lifetime_dependence10BufferViewVyACSW_SaySiGhtcfC : $@convention(method) (UnsafeRawBufferPointer, @guaranteed Array<Int>, @thin BufferView.Type) -> _scope(1) @owned BufferView
|