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.
71 lines
2.8 KiB
Swift
71 lines
2.8 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/def_implicit_lifetime_dependence.swift \
|
|
// RUN: -enable-experimental-feature NonescapableTypes \
|
|
// RUN: -disable-lifetime-dependence-diagnostics
|
|
|
|
// RUN: llvm-bcanalyzer %t/def_implicit_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_implicit_lifetime_dependence
|
|
|
|
func use(_ x: borrowing BufferView) {}
|
|
func mutate(_ x: inout BufferView) {}
|
|
|
|
func testBasic() {
|
|
let a = [Int](repeating: 0, count: 4)
|
|
a.withUnsafeBytes {
|
|
let view = BufferView($0, a.count)
|
|
let derivedView = derive(view)
|
|
let consumedView = consumeAndCreate(derivedView)
|
|
let borrowedView = borrowAndCreate(consumedView)
|
|
use(borrowedView)
|
|
}
|
|
}
|
|
|
|
func testInitializers() {
|
|
let a = [Int](repeating: 0, count: 4)
|
|
a.withUnsafeBytes {
|
|
let view1 = BufferView($0, a.count)
|
|
let view2 = BufferView(view1)
|
|
let view3 = BufferView(view2)
|
|
use(view3)
|
|
}
|
|
}
|
|
|
|
func unsafetest(_ ptr: UnsafeRawBufferPointer, _ c: Int) {
|
|
let view1 = BufferView(ptr, c)
|
|
let view2 = BufferView(view1)
|
|
let view3 = BufferView(view2)
|
|
use(view3)
|
|
}
|
|
|
|
func testGetter() {
|
|
let a = [Int](repeating: 0, count: 4)
|
|
a.withUnsafeBytes {
|
|
let c = Container($0, a.count)
|
|
let view = c.view
|
|
use(view)
|
|
}
|
|
}
|
|
|
|
func testReadMutateAccessors() {
|
|
let a = [Int](repeating: 0, count: 4)
|
|
a.withUnsafeBytes {
|
|
let view = BufferView($0, a.count)
|
|
var c = Wrapper(view)
|
|
use(c.view)
|
|
mutate(&c.view)
|
|
}
|
|
}
|
|
|
|
// CHECK-LABEL: sil @$s32def_implicit_lifetime_dependence10BufferViewVyACSW_SitcfC : $@convention(method) (UnsafeRawBufferPointer, Int, @thin BufferView.Type) -> _scope(0) @owned BufferView
|
|
// CHECK-LABEL: sil @$s32def_implicit_lifetime_dependence6deriveyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _inherit(0) @owned BufferView
|
|
// CHECK-LABEL: sil @$s32def_implicit_lifetime_dependence16consumeAndCreateyAA10BufferViewVADnF : $@convention(thin) (@owned BufferView) -> _inherit(0) @owned BufferView
|
|
// CHECK-LABEL: sil @$s32def_implicit_lifetime_dependence15borrowAndCreateyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _inherit(0) @owned BufferView
|
|
// CHECK-LABEL: sil @$s32def_implicit_lifetime_dependence9ContainerV4viewAA10BufferViewVvg : $@convention(method) (@guaranteed Container) -> _scope(0) @owned BufferView
|
|
// CHECK-LABEL: sil @$s32def_implicit_lifetime_dependence7WrapperV4viewAA10BufferViewVvr : $@yield_once @convention(method) (@guaranteed Wrapper) -> _inherit(0) @yields @guaranteed BufferView
|
|
// CHECK-LABEL: sil @$s32def_implicit_lifetime_dependence7WrapperV4viewAA10BufferViewVvM : $@yield_once @convention(method) (@inout Wrapper) -> _inherit(0) @yields @inout BufferView
|
|
|