Skip to content

Commit 17a2a41

Browse files
committed
Update tests
1 parent 55f0cec commit 17a2a41

File tree

8 files changed

+18
-140
lines changed

8 files changed

+18
-140
lines changed

test/Interop/C/swiftify-import/Inputs/counted-by-noescape.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,6 @@ void lenName(int lenName, int size, int * __counted_by(lenName * size) _Nullable
4343

4444
void func(int len, int * __counted_by(len) _Nullable func __noescape);
4545

46-
void *funcRenameKeyword(int len, int * __counted_by(len) _Nullable func __noescape,
47-
int extension __lifetimebound,
48-
int init,
49-
int open,
50-
int var,
51-
int is,
52-
int as,
53-
int in,
54-
int guard,
55-
int where) __attribute__((swift_name("funcRenamed(len:func:extension:init:open:var:is:as:in:guard:where:)")));
56-
57-
void *funcRenameKeywordAnonymous(int len, int * __counted_by(len) _Nullable __noescape,
58-
int __lifetimebound,
59-
int,
60-
int,
61-
int,
62-
int,
63-
int,
64-
int,
65-
int,
66-
int) __attribute__((swift_name("funcRenamedAnon(len:func:extension:init:open:var:is:as:in:guard:where:)")));
67-
6846
void funcRenameClash(int len, int * __counted_by(len) _Nullable func __noescape, int where)
6947
__attribute__((swift_name("clash(len:func:clash:)")));
7048

test/Interop/C/swiftify-import/counted-by-noescape.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ import CountedByNoEscapeClang
3636
// CHECK-NEXT: @_lifetime(_func_param1: copy _func_param1)
3737
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func `func`(_ _func_param1: inout MutableSpan<Int32>?)
3838

39-
// CHECK-NEXT: /// This is an auto-generated wrapper for safer interop
40-
// CHECK-NEXT: @available(visionOS 1.0, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *)
41-
// CHECK-NEXT: @_lifetime(borrow extension)
42-
// CHECK-NEXT: @_lifetime(func: copy func)
43-
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func funcRenamed(func: inout MutableSpan<Int32>?, extension: Int32, init: Int32, open: Int32, var: Int32, is: Int32, as: Int32, in: Int32, guard: Int32, where: Int32) -> UnsafeMutableRawPointer!
44-
45-
// CHECK-NEXT: /// This is an auto-generated wrapper for safer interop
46-
// CHECK-NEXT: @available(visionOS 1.0, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *)
47-
// CHECK-NEXT: @_lifetime(borrow _funcRenamedAnon_param2)
48-
// CHECK-NEXT: @_lifetime(_funcRenamedAnon_param1: copy _funcRenamedAnon_param1)
49-
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func funcRenamedAnon(func _funcRenamedAnon_param1: inout MutableSpan<Int32>?, extension _funcRenamedAnon_param2: Int32, init _funcRenamedAnon_param3: Int32, open _funcRenamedAnon_param4: Int32, var _funcRenamedAnon_param5: Int32, is _funcRenamedAnon_param6: Int32, as _funcRenamedAnon_param7: Int32, in _funcRenamedAnon_param8: Int32, guard _funcRenamedAnon_param9: Int32, where _funcRenamedAnon_param10: Int32) -> UnsafeMutableRawPointer!
50-
5139
// CHECK-NEXT: /// This is an auto-generated wrapper for safer interop
5240
// CHECK-NEXT: @available(visionOS 1.0, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *)
5341
// CHECK-NEXT: @_lifetime(_in_param1: copy _in_param1)
@@ -203,13 +191,6 @@ public func callFunc(_ p: inout MutableSpan<CInt>?) {
203191
`func`(&p)
204192
}
205193

206-
@available(visionOS 1.0, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *)
207-
@_lifetime(p: copy p)
208-
@inlinable
209-
public func callFuncRenameKeyword(_ p: inout MutableSpan<CInt>?) {
210-
let _ = funcRenamed(func: &p, extension: 1, init: 2, open: 3, var: 4, is: 5, as: 6, in: 7, guard: 8, where: 9)
211-
}
212-
213194
@available(visionOS 1.0, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *)
214195
@_lifetime(p: copy p)
215196
@inlinable

test/Macros/SwiftifyImport/CountedBy/ConstantCount.swift

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,6 @@ func mutReturn() -> UnsafeMutablePointer<CInt> {}
4040
@_SwiftifyImport(.countedBy(pointer: .return, count: "37"))
4141
func mutOptReturn() -> UnsafeMutablePointer<CInt>? {}
4242

43-
44-
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "37"), .lifetimeDependence(dependsOn: .param(1), pointer: .return, type: .copy))
45-
func noescape(_ ptr: UnsafePointer<CInt>) -> UnsafePointer<CInt> {}
46-
47-
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "37"), .lifetimeDependence(dependsOn: .param(1), pointer: .return, type: .copy))
48-
func noescapeOpt(_ ptr: UnsafePointer<CInt>?) -> UnsafePointer<CInt>? {}
49-
50-
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "37"), .lifetimeDependence(dependsOn: .param(1), pointer: .return, type: .copy))
51-
func noescapeMut(_ ptr: UnsafeMutablePointer<CInt>) -> UnsafeMutablePointer<CInt> {}
52-
53-
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "37"), .lifetimeDependence(dependsOn: .param(1), pointer: .return, type: .copy))
54-
func noescapeMutOpt(_ ptr: UnsafeMutablePointer<CInt>?) -> UnsafeMutablePointer<CInt>? {}
55-
5643
// CHECK: @_alwaysEmitIntoClient @_disfavoredOverload
5744
// CHECK-NEXT: func plain(_ ptr: UnsafeBufferPointer<CInt>) {
5845
// CHECK-NEXT: let _ptrCount = unsafe ptr.count
@@ -100,17 +87,6 @@ func noescapeMutOpt(_ ptr: UnsafeMutablePointer<CInt>?) -> UnsafeMutablePointer<
10087
// CHECK-NEXT: }
10188
// CHECK-NEXT: }
10289

103-
// CHECK: @_alwaysEmitIntoClient @_lifetime(copy ptr) @_disfavoredOverload
104-
// CHECK-NEXT: func noescape(_ ptr: Span<CInt>) -> UnsafePointer<CInt> {
105-
// CHECK-NEXT: let _ptrCount = ptr.count
106-
// CHECK-NEXT: if _ptrCount != 37 {
107-
// CHECK-NEXT: fatalError("bounds check failure in noescape: expected \(37) but got \(_ptrCount)")
108-
// CHECK-NEXT: }
109-
// CHECK-NEXT: return unsafe ptr.withUnsafeBufferPointer { _ptrPtr in
110-
// CHECK-NEXT: return unsafe noescape(_ptrPtr.baseAddress!)
111-
// CHECK-NEXT: }
112-
// CHECK-NEXT: }
113-
11490
// CHECK: @_alwaysEmitIntoClient @_disfavoredOverload
11591
// CHECK-NEXT: func noescapeOpt(_ ptr: Span<CInt>?) {
11692
// CHECK-NEXT: let _ptrCount = ptr?.count ?? 0
@@ -128,23 +104,6 @@ func noescapeMutOpt(_ ptr: UnsafeMutablePointer<CInt>?) -> UnsafeMutablePointer<
128104
// CHECK-NEXT: }()
129105
// CHECK-NEXT: }
130106

131-
// CHECK: @_alwaysEmitIntoClient @_lifetime(copy ptr) @_disfavoredOverload
132-
// CHECK-NEXT: func noescapeOpt(_ ptr: Span<CInt>?) -> UnsafePointer<CInt>? {
133-
// CHECK-NEXT: let _ptrCount = ptr?.count ?? 0
134-
// CHECK-NEXT: if _ptrCount != 37 {
135-
// CHECK-NEXT: fatalError("bounds check failure in noescapeOpt: expected \(37) but got \(_ptrCount)")
136-
// CHECK-NEXT: }
137-
// CHECK-NEXT: return { () in
138-
// CHECK-NEXT: return if ptr == nil {
139-
// CHECK-NEXT: unsafe noescapeOpt(nil)
140-
// CHECK-NEXT: } else {
141-
// CHECK-NEXT: unsafe ptr!.withUnsafeBufferPointer { _ptrPtr in
142-
// CHECK-NEXT: return unsafe noescapeOpt(_ptrPtr.baseAddress)
143-
// CHECK-NEXT: }
144-
// CHECK-NEXT: }
145-
// CHECK-NEXT: }()
146-
// CHECK-NEXT: }
147-
148107
// CHECK: @_alwaysEmitIntoClient @_lifetime(ptr: copy ptr) @_disfavoredOverload
149108
// CHECK-NEXT: func noescapeMut(_ ptr: inout MutableSpan<CInt>) {
150109
// CHECK-NEXT: let _ptrCount = ptr.count
@@ -156,16 +115,6 @@ func noescapeMutOpt(_ ptr: UnsafeMutablePointer<CInt>?) -> UnsafeMutablePointer<
156115
// CHECK-NEXT: }
157116
// CHECK-NEXT: }
158117

159-
// CHECK: @_alwaysEmitIntoClient @_lifetime(copy ptr) @_lifetime(ptr: copy ptr) @_disfavoredOverload
160-
// CHECK-NEXT: func noescapeMut(_ ptr: inout MutableSpan<CInt>) -> UnsafeMutablePointer<CInt> {
161-
// CHECK-NEXT: let _ptrCount = ptr.count
162-
// CHECK-NEXT: if _ptrCount != 37 {
163-
// CHECK-NEXT: fatalError("bounds check failure in noescapeMut: expected \(37) but got \(_ptrCount)")
164-
// CHECK-NEXT: }
165-
// CHECK-NEXT: return unsafe ptr.withUnsafeMutableBufferPointer { _ptrPtr in
166-
// CHECK-NEXT: return unsafe noescapeMut(_ptrPtr.baseAddress!)
167-
// CHECK-NEXT: }
168-
// CHECK-NEXT: }
169118

170119
// CHECK: @_alwaysEmitIntoClient @_lifetime(ptr: copy ptr) @_disfavoredOverload
171120
// CHECK-NEXT: func noescapeMutOpt(_ ptr: inout MutableSpan<CInt>?) {
@@ -184,23 +133,6 @@ func noescapeMutOpt(_ ptr: UnsafeMutablePointer<CInt>?) -> UnsafeMutablePointer<
184133
// CHECK-NEXT: }()
185134
// CHECK-NEXT: }
186135

187-
// CHECK: @_alwaysEmitIntoClient @_lifetime(copy ptr) @_lifetime(ptr: copy ptr) @_disfavoredOverload
188-
// CHECK-NEXT: func noescapeMutOpt(_ ptr: inout MutableSpan<CInt>?) -> UnsafeMutablePointer<CInt>? {
189-
// CHECK-NEXT: let _ptrCount = ptr?.count ?? 0
190-
// CHECK-NEXT: if _ptrCount != 37 {
191-
// CHECK-NEXT: fatalError("bounds check failure in noescapeMutOpt: expected \(37) but got \(_ptrCount)")
192-
// CHECK-NEXT: }
193-
// CHECK-NEXT: return { () in
194-
// CHECK-NEXT: return if ptr == nil {
195-
// CHECK-NEXT: unsafe noescapeMutOpt(nil)
196-
// CHECK-NEXT: } else {
197-
// CHECK-NEXT: unsafe ptr!.withUnsafeMutableBufferPointer { _ptrPtr in
198-
// CHECK-NEXT: return unsafe noescapeMutOpt(_ptrPtr.baseAddress)
199-
// CHECK-NEXT: }
200-
// CHECK-NEXT: }
201-
// CHECK-NEXT: }()
202-
// CHECK-NEXT: }
203-
204136
// CHECK: @_alwaysEmitIntoClient @_disfavoredOverload
205137
// CHECK-NEXT: func plainReturn() -> UnsafeBufferPointer<CInt> {
206138
// CHECK-NEXT: return unsafe UnsafeBufferPointer<CInt> (start: unsafe plainReturn(), count: Int(37))

test/SILOptimizer/lifetime_dependence/semantics.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,6 @@ func test(arg: inout AddressableInt) -> Span<Int> {
627627
}
628628

629629
// unsafeAddress generates an addressable value with a local scope.
630-
@_lifetime(borrow arg)
631630
func testBorrowedAddressableInt(arg: Holder) -> Int {
632631
let span = arg.addressableInt.span()
633632
return span[0]

test/SILOptimizer/lifetime_dependence/verify_diagnostics.swift

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public struct NoncopyableImplicitAccessors : ~Copyable & ~Escapable {
169169
@_lifetime(borrow self)
170170
get { ne }
171171

172-
@_lifetime(&self)
172+
@_lifetime(self: copy newValue)
173173
set {
174174
ne = newValue
175175
}
@@ -315,14 +315,3 @@ func inoutToImmortal(_ s: inout RawSpan) {
315315
s = _overrideLifetime(tmp, borrowing: ())
316316
}
317317

318-
// =============================================================================
319-
// Dependence on non-Copyable values
320-
// =============================================================================
321-
322-
@_lifetime(immortal)
323-
func dependOnNonCopyable() -> NCBuffer {
324-
let buffer = NCBuffer()
325-
let count = buffer.bytes.count
326-
_ = count
327-
return buffer // expected-error {{noncopyable 'buffer' cannot be consumed when captured by an escaping closure or borrowed by a non-Escapable type}}
328-
}

test/SILOptimizer/lifetime_dependence/verify_library_diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public struct NoncopyableImplicitAccessors : ~Copyable & ~Escapable {
5050
@_lifetime(borrow self)
5151
get { ne }
5252

53-
@_lifetime(&self)
53+
@_lifetime(self: copy newValue)
5454
set {
5555
ne = newValue
5656
}

test/Sema/lifetime_depend_infer.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ struct TrivialAccessors {
331331
NEImmortal()
332332
}
333333

334-
@_lifetime(&self)
335334
set { // OK (no dependency)
336335
}
337336
}
@@ -385,7 +384,7 @@ struct NonescapableSelfAccessors: ~Escapable {
385384
ne
386385
}
387386
388-
@_lifetime(self) // expected-error{{cannot infer the lifetime dependence scope on a mutating method with a ~Escapable parameter, specify '@_lifetime(borrow self)' or '@_lifetime(copy self)'}}
387+
@_lifetime(self: newValue) // expected-error{{cannot infer the lifetime dependence scope on a mutating method with a ~Escapable parameter, specify '@_lifetime(borrow newValue)' or '@_lifetime(copy newValue)'}}
389388
set {
390389
ne = newValue
391390
}
@@ -409,7 +408,7 @@ struct NonescapableSelfAccessors: ~Escapable {
409408
ne
410409
}
411410
412-
@_lifetime(copy self)
411+
@_lifetime(self: copy newValue)
413412
set {
414413
ne = newValue
415414
}
@@ -433,7 +432,7 @@ struct NonescapableSelfAccessors: ~Escapable {
433432
ne
434433
}
435434
436-
@_lifetime(&self)
435+
@_lifetime(self: borrow newValue)
437436
set {
438437
ne = newValue
439438
}
@@ -482,7 +481,7 @@ struct NoncopyableSelfAccessors: ~Copyable & ~Escapable {
482481
ne
483482
}
484483
485-
@_lifetime(self) // expected-error{{cannot infer the lifetime dependence scope on a mutating method with a ~Escapable parameter, specify '@_lifetime(borrow self)' or '@_lifetime(copy self)'}}
484+
@_lifetime(self: newValue) // expected-error{{cannot infer the lifetime dependence scope on a mutating method with a ~Escapable parameter, specify '@_lifetime(borrow newValue)' or '@_lifetime(copy newValue)'}}
486485
set {
487486
ne = newValue
488487
}
@@ -506,7 +505,7 @@ struct NoncopyableSelfAccessors: ~Copyable & ~Escapable {
506505
ne
507506
}
508507
509-
@_lifetime(copy self)
508+
@_lifetime(self: copy newValue)
510509
set {
511510
ne = newValue
512511
}
@@ -530,7 +529,7 @@ struct NoncopyableSelfAccessors: ~Copyable & ~Escapable {
530529
ne
531530
}
532531
533-
@_lifetime(&self)
532+
@_lifetime(self: copy newValue)
534533
set {
535534
ne = newValue
536535
}
@@ -574,10 +573,10 @@ struct NonEscapableMutableSelf: ~Escapable {
574573
@_lifetime(self: self) // expected-error{{cannot infer the lifetime dependence scope on a mutating method with a ~Escapable parameter, specify '@_lifetime(borrow self)' or '@_lifetime(copy self)'}}
575574
mutating func mutatingMethodOneParamLifetime(_: NE) {}
576575
577-
@_lifetime(copy self) // OK
576+
@_lifetime(self: copy self) // OK
578577
mutating func mutatingMethodOneParamCopy(_: NE) {}
579578
580-
@_lifetime(&self)
579+
@_lifetime(self: copy self) // OK
581580
mutating func mutatingMethodOneParamBorrow(_: NE) {}
582581
}
583582

test/Sema/lifetime_depend_infer_lazy.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ struct NonescapableSelfAccessors: ~Escapable {
266266
ne
267267
}
268268

269-
@_lifetime(self) // OK
269+
@_lifetime(self: newValue) // OK
270270
set {
271271
ne = newValue
272272
}
@@ -290,7 +290,7 @@ struct NonescapableSelfAccessors: ~Escapable {
290290
ne
291291
}
292292

293-
@_lifetime(copy self)
293+
@_lifetime(self: copy newValue)
294294
set {
295295
ne = newValue
296296
}
@@ -314,7 +314,7 @@ struct NonescapableSelfAccessors: ~Escapable {
314314
ne
315315
}
316316

317-
@_lifetime(&self)
317+
@_lifetime(self: borrow newValue)
318318
set {
319319
ne = newValue
320320
}
@@ -363,7 +363,7 @@ struct NoncopyableSelfAccessors: ~Copyable & ~Escapable {
363363
ne
364364
}
365365

366-
@_lifetime(self) // OK
366+
@_lifetime(self: newValue) // OK
367367
set {
368368
ne = newValue
369369
}
@@ -387,7 +387,7 @@ struct NoncopyableSelfAccessors: ~Copyable & ~Escapable {
387387
ne
388388
}
389389

390-
@_lifetime(copy self)
390+
@_lifetime(self: copy self)
391391
set {
392392
ne = newValue
393393
}
@@ -411,7 +411,7 @@ struct NoncopyableSelfAccessors: ~Copyable & ~Escapable {
411411
ne
412412
}
413413

414-
@_lifetime(&self)
414+
@_lifetime(self: borrow newValue)
415415
set {
416416
ne = newValue
417417
}
@@ -446,9 +446,9 @@ struct NonEscapableMutableSelf: ~Escapable {
446446
@_lifetime(self: self) // OK
447447
mutating func mutatingMethodOneParamLifetime(_: NE) {}
448448

449-
@_lifetime(copy self) // OK
449+
@_lifetime(self: copy self) // OK
450450
mutating func mutatingMethodOneParamCopy(_: NE) {}
451451

452-
@_lifetime(&self)
452+
@_lifetime(self: copy self) // OK
453453
mutating func mutatingMethodOneParamBorrow(_: NE) {}
454454
}

0 commit comments

Comments
 (0)