Skip to content

Commit 03843d4

Browse files
committed
Update some dependsOn tests to @Lifetime
1 parent ace32a2 commit 03843d4

File tree

41 files changed

+410
-967
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+410
-967
lines changed

test/Interop/Cxx/class/nonescapable-lifetimebound.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ private:
6969
};
7070

7171
// CHECK: sil [clang makeOwner] {{.*}}: $@convention(c) () -> Owner
72-
// CHECK: sil [clang getView] {{.*}} : $@convention(c) (@in_guaranteed Owner) -> _lifetime(_borrow 0) @autoreleased View
73-
// CHECK: sil [clang getViewFromFirst] {{.*}} : $@convention(c) (@in_guaranteed Owner, @in_guaranteed Owner) -> _lifetime(_borrow 0) @autoreleased View
74-
// CHECK: sil [clang getViewFromEither] {{.*}} : $@convention(c) (@in_guaranteed Owner, @in_guaranteed Owner) -> _lifetime(_borrow 0, _borrow 1) @autoreleased View
75-
// CHECK: sil [clang Owner.handOutView] {{.*}} : $@convention(cxx_method) (@in_guaranteed Owner) -> _lifetime(_borrow 0) @autoreleased View
76-
// CHECK: sil [clang Owner.handOutView2] {{.*}} : $@convention(cxx_method) (View, @in_guaranteed Owner) -> _lifetime(_borrow 1) @autoreleased View
77-
// CHECK: sil [clang getViewFromEither] {{.*}} : $@convention(c) (@guaranteed View, @guaranteed View) -> _lifetime(_copy 0, _copy 1) @autoreleased View
78-
// CHECK: sil [clang View.init] {{.*}} : $@convention(c) () -> @out View
72+
// CHECK: sil [clang getView] {{.*}} : $@convention(c) (@in_guaranteed Owner) -> @lifetime(borrow 0) @autoreleased View
73+
// CHECK: sil [clang getViewFromFirst] {{.*}} : $@convention(c) (@in_guaranteed Owner, @in_guaranteed Owner) -> @lifetime(borrow 0) @autoreleased View
74+
// CHECK: sil [clang getViewFromEither] {{.*}} : $@convention(c) (@in_guaranteed Owner, @in_guaranteed Owner) -> @lifetime(borrow 0, borrow 1) @autoreleased View
75+
// CHECK: sil [clang Owner.handOutView] {{.*}} : $@convention(cxx_method) (@in_guaranteed Owner) -> @lifetime(borrow 0) @autoreleased View
76+
// CHECK: sil [clang Owner.handOutView2] {{.*}} : $@convention(cxx_method) (View, @in_guaranteed Owner) -> @lifetime(borrow 1) @autoreleased View
77+
// CHECK: sil [clang getViewFromEither] {{.*}} : $@convention(c) (@guaranteed View, @guaranteed View) -> @lifetime(copy 0, copy 1) @autoreleased View
78+
// CHECK: sil [clang View.init] {{.*}} : $@convention(c) () -> @lifetime(immortal) @out View
7979

8080
//--- test.swift
8181

test/ModuleInterface/Inputs/lifetime_dependence.swift

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
public struct AnotherView : ~Escapable {
22
@usableFromInline let _ptr: UnsafeRawBufferPointer
33
@usableFromInline let _count: Int
4-
internal init(_ ptr: UnsafeRawBufferPointer, _ count: Int) -> dependsOn(ptr) Self {
4+
@lifetime(ptr)
5+
internal init(_ ptr: UnsafeRawBufferPointer, _ count: Int) {
56
self._ptr = ptr
67
self._count = count
78
}
@@ -11,38 +12,42 @@ public struct BufferView : ~Escapable {
1112
@usableFromInline let _ptr: UnsafeRawBufferPointer
1213
@usableFromInline let _count: Int
1314
@usableFromInline
14-
internal init(_ ptr: UnsafeRawBufferPointer, _ count: Int) -> dependsOn(ptr) Self {
15+
@lifetime(ptr)
16+
internal init(_ ptr: UnsafeRawBufferPointer, _ count: Int) {
1517
self._ptr = ptr
1618
self._count = count
1719
}
1820

1921
@inlinable
20-
internal init(_ ptr: UnsafeRawBufferPointer, _ a: borrowing Array<Int>) -> dependsOn(a) Self {
22+
@lifetime(borrow a)
23+
internal init(_ ptr: UnsafeRawBufferPointer, _ a: borrowing Array<Int>) {
2124
self.init(ptr, a.count)
22-
return self
2325
}
2426
@inlinable
25-
internal init(_ ptr: UnsafeRawBufferPointer, _ a: consuming AnotherView) -> dependsOn(a) Self {
27+
@lifetime(a)
28+
internal init(_ ptr: UnsafeRawBufferPointer, _ a: consuming AnotherView) {
2629
self.init(ptr, a._count)
27-
return self
2830
}
2931
}
3032

3133
@inlinable
32-
public func derive(_ x: consuming BufferView) -> dependsOn(x) BufferView {
34+
@lifetime(x)
35+
public func derive(_ x: consuming BufferView) -> BufferView {
3336
return BufferView(x._ptr, x._count)
3437
}
3538

3639
@inlinable
3740
public func use(_ x: consuming BufferView) {}
3841

3942
@inlinable
40-
public func consumeAndCreate(_ view: consuming BufferView) -> dependsOn(view) BufferView {
43+
@lifetime(view)
44+
public func consumeAndCreate(_ view: consuming BufferView) -> BufferView {
4145
return BufferView(view._ptr, view._count)
4246
}
4347

4448
@inlinable
45-
public func deriveThisOrThat(_ this: consuming BufferView, _ that: consuming BufferView) -> dependsOn(this, that) BufferView {
49+
@lifetime(this, that)
50+
public func deriveThisOrThat(_ this: consuming BufferView, _ that: consuming BufferView) -> BufferView {
4651
if (Int.random(in: 1..<100) == 0) {
4752
return BufferView(this._ptr, this._count)
4853
}

test/ModuleInterface/lifetime_dependence_test.swift

+10-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@
2121
// RUN: -enable-experimental-feature NonescapableTypes
2222

2323
import lifetime_dependence
24+
// CHECK: @lifetime(borrow a)
25+
// CHECK-NEXT: @inlinable internal init(_ ptr: Swift.UnsafeRawBufferPointer, _ a: borrowing Swift.Array<Swift.Int>) {
26+
// CHECK: @lifetime(a)
27+
// CHECK-NEXT: @inlinable internal init(_ ptr: Swift.UnsafeRawBufferPointer, _ a: consuming lifetime_dependence.AnotherView) {
2428

25-
// CHECK: @inlinable internal init(_ ptr: Swift.UnsafeRawBufferPointer, _ a: borrowing Swift.Array<Swift.Int>) -> dependsOn(a) Self {
26-
// CHECK: @inlinable internal init(_ ptr: Swift.UnsafeRawBufferPointer, _ a: consuming lifetime_dependence.AnotherView) -> dependsOn(a) Self {
29+
// CHECK: @lifetime(x)
30+
// CHECK-NEXT: @inlinable public func derive(_ x: consuming lifetime_dependence.BufferView) -> lifetime_dependence.BufferView {
2731

28-
// CHECK: @inlinable public func derive(_ x: consuming lifetime_dependence.BufferView) -> dependsOn(x) lifetime_dependence.BufferView {
32+
// CHECK: @lifetime(view)
33+
// CHECK-NEXT: @inlinable public func consumeAndCreate(_ view: consuming lifetime_dependence.BufferView) -> lifetime_dependence.BufferView {
2934

30-
// CHECK: @inlinable public func consumeAndCreate(_ view: consuming lifetime_dependence.BufferView) -> dependsOn(view) lifetime_dependence.BufferView {
31-
32-
// CHECK: @inlinable public func deriveThisOrThat(_ this: consuming lifetime_dependence.BufferView, _ that: consuming lifetime_dependence.BufferView) -> dependsOn(this) dependsOn(that) lifetime_dependence.BufferView {
35+
// CHECK: @lifetime(this, that)
36+
// CHECK-NEXT: @inlinable public func deriveThisOrThat(_ this: consuming lifetime_dependence.BufferView, _ that: consuming lifetime_dependence.BufferView) -> lifetime_dependence.BufferView {

test/ModuleInterface/nonescapable_types.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ public func derive<T : ~Escapable>(_ y: Y<T>) -> Y<T> {
7979
}
8080

8181
// CHECK: #if compiler(>=5.3) && $NonescapableTypes
82-
// CHECK: public func derive<T>(_ x: Test.X<T>) -> dependsOn(x) Test.X<T> where T : ~Escapable
82+
// CHECK: @lifetime(x)
83+
// CHECK: public func derive<T>(_ x: Test.X<T>) -> Test.X<T> where T : ~Escapable
8384
// CHECK: #else
8485
// CHECK: public func derive<T>(_ x: Test.X<T>) -> Test.X<T>
8586
// CHECK: #endif
86-
public func derive<T : ~Escapable>(_ x: X<T>) -> dependsOn(x) X<T> {
87+
@lifetime(x)
88+
public func derive<T : ~Escapable>(_ x: X<T>) -> X<T> {
8789
x
8890
}

test/Parse/explicit_lifetime_dependence_specifiers.swift

-167
This file was deleted.

test/SIL/Parser/lifetime_dependence.sil

+12-10
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import Swift
88

99
struct BufferView : ~Escapable {
1010
@_hasStorage let ptr: UnsafeRawBufferPointer { get }
11-
@inlinable init(_ ptr: UnsafeRawBufferPointer) -> _scope(ptr) Self
12-
init(_ ptr: UnsafeRawBufferPointer, _ a: borrowing Array<Int>) -> _scope(a) Self
11+
@lifetime(ptr) @inlinable init(_ ptr: UnsafeRawBufferPointer)
12+
@lifetime(borrow a) init(_ ptr: UnsafeRawBufferPointer, _ a: borrowing Array<Int>)
1313
}
1414

15-
func derive(_ x: borrowing BufferView) -> _scope(x) BufferView
15+
@lifetime(borrow x)
16+
func derive(_ x: borrowing BufferView) -> BufferView
1617

17-
func consumeAndCreate(_ x: consuming BufferView) -> _inherit(x) BufferView
18+
@lifetime(x)
19+
func consumeAndCreate(_ x: consuming BufferView) -> BufferView
1820

1921
sil hidden [unsafe_nonescapable_result] @bufferviewinit1 : $@convention(method) (UnsafeRawBufferPointer, @thin BufferView.Type) -> @owned BufferView {
2022
bb0(%0 : $UnsafeRawBufferPointer, %1 : $@thin BufferView.Type):
@@ -30,8 +32,8 @@ bb0(%0 : $UnsafeRawBufferPointer, %1 : $@thin BufferView.Type):
3032
return %8 : $BufferView
3133
}
3234

33-
// CHECK-LABEL: sil hidden @bufferviewtest2 : $@convention(method) (UnsafeRawBufferPointer, @guaranteed Array<Int>, @thin BufferView.Type) -> _scope(1) @owned BufferView {
34-
sil hidden @bufferviewtest2 : $@convention(method) (UnsafeRawBufferPointer, @guaranteed Array<Int>, @thin BufferView.Type) -> _scope(1) @owned BufferView {
35+
// CHECK-LABEL: sil hidden @bufferviewtest2 : $@convention(method) (UnsafeRawBufferPointer, @guaranteed Array<Int>, @thin BufferView.Type) -> @lifetime(borrow 1) @owned BufferView {
36+
sil hidden @bufferviewtest2 : $@convention(method) (UnsafeRawBufferPointer, @guaranteed Array<Int>, @thin BufferView.Type) -> @lifetime(borrow 1) @owned BufferView {
3537
bb0(%0 : $UnsafeRawBufferPointer, %1 : @noImplicitCopy $Array<Int>, %2 : $@thin BufferView.Type):
3638
%3 = alloc_stack [var_decl] $BufferView, var, name "self"
3739
%6 = begin_access [modify] [static] %3 : $*BufferView
@@ -44,8 +46,8 @@ bb0(%0 : $UnsafeRawBufferPointer, %1 : @noImplicitCopy $Array<Int>, %2 : $@thin
4446
return %10 : $BufferView
4547
}
4648

47-
// CHECK-LABEL: sil hidden @derive : $@convention(thin) (@guaranteed BufferView) -> _scope(0) @owned BufferView {
48-
sil hidden @derive : $@convention(thin) (@guaranteed BufferView) -> _scope(0) @owned BufferView {
49+
// CHECK-LABEL: sil hidden @derive : $@convention(thin) (@guaranteed BufferView) -> @lifetime(borrow 0) @owned BufferView {
50+
sil hidden @derive : $@convention(thin) (@guaranteed BufferView) -> @lifetime(borrow 0) @owned BufferView {
4951
bb0(%0 : @noImplicitCopy $BufferView):
5052
%2 = metatype $@thin BufferView.Type
5153
%3 = struct_extract %0 : $BufferView, #BufferView.ptr
@@ -54,8 +56,8 @@ bb0(%0 : @noImplicitCopy $BufferView):
5456
return %5 : $BufferView
5557
}
5658

57-
// CHECK-LABEL: sil hidden @consumeAndCreate : $@convention(thin) (@owned BufferView) -> _inherit(0) @owned BufferView {
58-
sil hidden @consumeAndCreate : $@convention(thin) (@owned BufferView) -> _inherit(0) @owned BufferView {
59+
// CHECK-LABEL: sil hidden @consumeAndCreate : $@convention(thin) (@owned BufferView) -> @lifetime(copy 0) @owned BufferView {
60+
sil hidden @consumeAndCreate : $@convention(thin) (@owned BufferView) -> @lifetime(copy 0) @owned BufferView {
5961
bb0(%0 : @noImplicitCopy @_eagerMove $BufferView):
6062
%1 = alloc_stack [var_decl] [moveable_value_debuginfo] $BufferView, var, name "x"
6163
%2 = struct_extract %0 : $BufferView, #BufferView.ptr

0 commit comments

Comments
 (0)