Skip to content

Commit 27a29c0

Browse files
authored
[Swiftify][StrictMemorySafety] Test unsafe warnings in wrappers (NFC) (swiftlang#79719)
[Swiftify][StrictMemorySafety] Test `unsafe` warnings in wrappers (NFC) As _SwiftifyImport now emits the `unsafe` keyword to prevent warnings about unsafe code in the macro expansions, we should make sure that our tests do not emit any warnings. It turns out that calls to RawSpan::withUnsafeRawPointer are not recognised as unsafe, so we sometimes get warnings about using `unsafe` on a safe expression. This issue is tracked under rdar://145899513.
1 parent 297564f commit 27a29c0

29 files changed

+56
-25
lines changed

stdlib/public/core/Span/Span.swift

+10
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ extension Span where Element: ~Copyable {
9797
/// - buffer: an `UnsafeBufferPointer` to initialized elements.
9898
@_alwaysEmitIntoClient
9999
@lifetime(borrow buffer)
100+
@unsafe
100101
public init(
101102
_unsafeElements buffer: UnsafeBufferPointer<Element>
102103
) {
@@ -123,6 +124,7 @@ extension Span where Element: ~Copyable {
123124
/// - buffer: an `UnsafeMutableBufferPointer` to initialized elements.
124125
@_alwaysEmitIntoClient
125126
@lifetime(borrow buffer)
127+
@unsafe
126128
public init(
127129
_unsafeElements buffer: UnsafeMutableBufferPointer<Element>
128130
) {
@@ -145,6 +147,7 @@ extension Span where Element: ~Copyable {
145147
/// - count: the number of initialized elements in the span.
146148
@_alwaysEmitIntoClient
147149
@lifetime(borrow pointer)
150+
@unsafe
148151
public init(
149152
_unsafeStart pointer: UnsafePointer<Element>,
150153
count: Int
@@ -171,6 +174,7 @@ extension Span {
171174
/// - buffer: an `UnsafeBufferPointer` to initialized elements.
172175
@_alwaysEmitIntoClient
173176
@lifetime(borrow buffer)
177+
@unsafe
174178
public init(
175179
_unsafeElements buffer: borrowing Slice<UnsafeBufferPointer<Element>>
176180
) {
@@ -191,6 +195,7 @@ extension Span {
191195
/// - buffer: an `UnsafeMutableBufferPointer` to initialized elements.
192196
@_alwaysEmitIntoClient
193197
@lifetime(borrow buffer)
198+
@unsafe
194199
public init(
195200
_unsafeElements buffer: borrowing Slice<UnsafeMutableBufferPointer<Element>>
196201
) {
@@ -219,6 +224,7 @@ extension Span where Element: BitwiseCopyable {
219224
/// - buffer: a buffer to initialized elements.
220225
@_alwaysEmitIntoClient
221226
@lifetime(borrow buffer)
227+
@unsafe
222228
public init(
223229
_unsafeBytes buffer: UnsafeRawBufferPointer
224230
) {
@@ -254,6 +260,7 @@ extension Span where Element: BitwiseCopyable {
254260
/// - buffer: a buffer to initialized elements.
255261
@_alwaysEmitIntoClient
256262
@lifetime(borrow buffer)
263+
@unsafe
257264
public init(
258265
_unsafeBytes buffer: UnsafeMutableRawBufferPointer
259266
) {
@@ -280,6 +287,7 @@ extension Span where Element: BitwiseCopyable {
280287
/// - byteCount: the number of initialized elements in the span.
281288
@_alwaysEmitIntoClient
282289
@lifetime(borrow pointer)
290+
@unsafe
283291
public init(
284292
_unsafeStart pointer: UnsafeRawPointer,
285293
byteCount: Int
@@ -306,6 +314,7 @@ extension Span where Element: BitwiseCopyable {
306314
/// - buffer: a buffer to initialized elements.
307315
@_alwaysEmitIntoClient
308316
@lifetime(borrow buffer)
317+
@unsafe
309318
public init(
310319
_unsafeBytes buffer: borrowing Slice<UnsafeRawBufferPointer>
311320
) {
@@ -330,6 +339,7 @@ extension Span where Element: BitwiseCopyable {
330339
/// - buffer: a buffer to initialized elements.
331340
@_alwaysEmitIntoClient
332341
@lifetime(borrow buffer)
342+
@unsafe
333343
public init(
334344
_unsafeBytes buffer: borrowing Slice<UnsafeMutableRawBufferPointer>
335345
) {

test/Macros/SwiftifyImport/CountedBy/CountExpr.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "size * count"))
66
func myFunc(_ ptr: UnsafePointer<CInt>, _ size: CInt, _ count: CInt) {

test/Macros/SwiftifyImport/CountedBy/MultipleParams.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"), .countedBy(pointer: .param(3), count: "len2"))
66
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt, _ ptr2: UnsafePointer<CInt>, _ len2: CInt) {

test/Macros/SwiftifyImport/CountedBy/Mutable.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"))
66
func myFunc(_ ptr: UnsafeMutablePointer<CInt>, _ len: CInt) {

test/Macros/SwiftifyImport/CountedBy/MutableSpan.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions > %t.log 2>&1
3+
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions > %t.log 2>&1
44
// RUN: %FileCheck --match-full-lines %s < %t.log
55

66
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"), .nonescaping(pointer: .param(1)))

test/Macros/SwiftifyImport/CountedBy/NamedParams.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"))
66
func ptrNamed(ptr: UnsafePointer<CInt>, _ len: CInt) {

test/Macros/SwiftifyImport/CountedBy/Nullable.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"))
66
func myFunc(_ ptr: UnsafePointer<CInt>?, _ len: CInt) {

test/Macros/SwiftifyImport/CountedBy/PointerReturn.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// REQUIRES: swift_swift_parser
22
// REQUIRES: swift_feature_LifetimeDependence
33

4-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -enable-experimental-feature LifetimeDependence -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
4+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -enable-experimental-feature LifetimeDependence -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
55

66
@_SwiftifyImport(.countedBy(pointer: .return, count: "len"))
77
func myFunc(_ len: CInt) -> UnsafeMutablePointer<CInt> {

test/Macros/SwiftifyImport/CountedBy/QualifiedTypes.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"))
66
func foo(_ ptr: Swift.UnsafePointer<Swift.Int>, _ len: Swift.Int) -> Swift.Void {

test/Macros/SwiftifyImport/CountedBy/Return.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"))
66
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) -> CInt {

test/Macros/SwiftifyImport/CountedBy/SharedCount.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"), .countedBy(pointer: .param(2), count: "len"))
66
func myFunc(_ ptr: UnsafePointer<CInt>, _ ptr2: UnsafePointer<CInt>, _ len: CInt) {

test/Macros/SwiftifyImport/CountedBy/SimpleCount.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"))
66
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {

test/Macros/SwiftifyImport/CountedBy/SimpleSpan.swift

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

5+
// rdar://145899513 ([StrictMemorySafety] Call to RawSpan::withUnsafeBytes not recognized as unsafe, while call to Span::withUnsafeBufferPointer is)
6+
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors
7+
58
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"), .nonescaping(pointer: .param(1)))
69
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
710
}

test/Macros/SwiftifyImport/CountedBy/SimpleSpanWithReturn.swift

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

5+
// rdar://145899513 ([StrictMemorySafety] Call to RawSpan::withUnsafeBytes not recognized as unsafe, while call to Span::withUnsafeBufferPointer is)
6+
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors
7+
58
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"), .nonescaping(pointer: .param(1)))
69
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) -> CInt {
710
}

test/Macros/SwiftifyImport/CountedBy/SpanAndUnsafeBuffer.swift

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

5+
// rdar://145899513 ([StrictMemorySafety] Call to RawSpan::withUnsafeBytes not recognized as unsafe, while call to Span::withUnsafeBufferPointer is)
6+
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors
7+
58
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len1"), .countedBy(pointer: .param(3), count: "len2"), .nonescaping(pointer: .param(1)))
69
func myFunc(_ ptr1: UnsafePointer<CInt>, _ len1: CInt, _ ptr2: UnsafePointer<CInt>, _ len2: CInt) {
710
}

test/Macros/SwiftifyImport/CountedBy/Unwrapped.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"))
66
func myFunc(_ ptr: UnsafePointer<CInt>!, _ len: CInt) {

test/Macros/SwiftifyImport/CxxSpan/NoEscapeSpan.swift

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
// REQUIRES: swift_swift_parser
2+
// REQUIRES: swift_feature_LifetimeDependence
23

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
4+
// RUN: %target-swift-frontend %s -cxx-interoperability-mode=default -I %S/Inputs -Xcc -std=c++20 -swift-version 5 -module-name main -disable-availability-checking -typecheck -enable-experimental-feature LifetimeDependence -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
45

5-
public struct SpanOfInt {
6-
init(_ x: Span<CInt>) {}
7-
}
6+
// FIXME swift-ci linux tests do not support std::span
7+
// UNSUPPORTED: OS=linux-gnu
8+
9+
import CxxStdlib
10+
import StdSpan
811

912
@_SwiftifyImport(.nonescaping(pointer: .param(1)), typeMappings: ["SpanOfInt" : "std.span<CInt>"])
1013
func myFunc(_ span: SpanOfInt, _ secondSpan: SpanOfInt) {

test/Macros/SwiftifyImport/SizedBy/MultipleParams.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -strict-memory-safety -warnings-as-errors 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"), .sizedBy(pointer: .param(3), size: "size2"))
66
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt, _ ptr2: UnsafeRawPointer, _ size2: CInt) {

test/Macros/SwiftifyImport/SizedBy/Mutable.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"))
66
func myFunc(_ ptr: UnsafeMutableRawPointer, _ size: CInt) {

test/Macros/SwiftifyImport/SizedBy/MutableRawSpan.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions > %t.log 2>&1
3+
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions > %t.log 2>&1
44
// RUN: %FileCheck --match-full-lines %s < %t.log
55

66
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"), .nonescaping(pointer: .param(1)))

test/Macros/SwiftifyImport/SizedBy/Nullable.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"))
66
func myFunc(_ ptr: UnsafeRawPointer?, _ size: CInt) {

test/Macros/SwiftifyImport/SizedBy/Opaque.swift

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -verify 2>&1 | %FileCheck --match-full-lines %s
44

5+
// rdar://145899513 ([StrictMemorySafety] Call to RawSpan::withUnsafeBytes not recognized as unsafe, while call to Span::withUnsafeBufferPointer is)
6+
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors
7+
58
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"))
69
func nonnullUnsafeRawBufferPointer(_ ptr: OpaquePointer, _ size: CInt) {
710
}

test/Macros/SwiftifyImport/SizedBy/Return.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"))
66
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) -> CInt {

test/Macros/SwiftifyImport/SizedBy/SharedCount.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: swift_swift_parser
22

3-
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
3+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -strict-memory-safety -warnings-as-errors 2>&1 | %FileCheck --match-full-lines %s
44

55
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"), .sizedBy(pointer: .param(2), size: "size"))
66
func myFunc(_ ptr: UnsafeRawPointer, _ ptr2: UnsafeRawPointer, _ size: CInt) {

test/Macros/SwiftifyImport/SizedBy/SimpleRawSpan.swift

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

5+
// rdar://145899513 ([StrictMemorySafety] Call to RawSpan::withUnsafeBytes not recognized as unsafe, while call to Span::withUnsafeBufferPointer is)
6+
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors
7+
58
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"), .nonescaping(pointer: .param(1)))
69
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) {
710
}

test/Macros/SwiftifyImport/SizedBy/SimpleRawSpanWithReturn.swift

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s
44

5+
// rdar://145899513 ([StrictMemorySafety] Call to RawSpan::withUnsafeBytes not recognized as unsafe, while call to Span::withUnsafeBufferPointer is)
6+
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -strict-memory-safety -warnings-as-errors
7+
58
@_SwiftifyImport(.sizedBy(pointer: .param(1), size: "size"), .nonescaping(pointer: .param(1)))
69
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) -> CInt {
710
}

0 commit comments

Comments
 (0)