Skip to content

Commit e3009d5

Browse files
committed
[Swiftify] Make safe wrappers explicitly public
1 parent 83d4cc5 commit e3009d5

32 files changed

+68
-64
lines changed

lib/Macros/Sources/SwiftMacros/SwiftifyImportMacro.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,10 @@ func constructOverloadFunction(forDecl funcDecl: FunctionDeclSyntax,
14131413
atSign: .atSignToken(),
14141414
attributeName: IdentifierTypeSyntax(name: "_disfavoredOverload")))
14151415
] : [])
1416+
let hasVisibilityModifier = funcDecl.modifiers.contains { modifier in
1417+
let modName = modifier.name.trimmed.text
1418+
return modName == "public" || modName == "internal" || modName == "open" || modName == "private" || modName == "filePrivate"
1419+
}
14161420
let newFunc =
14171421
funcDecl
14181422
.with(\.signature, newSignature)
@@ -1435,6 +1439,7 @@ func constructOverloadFunction(forDecl funcDecl: FunctionDeclSyntax,
14351439
]
14361440
+ lifetimeAttrs
14371441
+ disfavoredOverload)
1442+
.with(\.modifiers, funcDecl.modifiers + (hasVisibilityModifier ? [] : [DeclModifierSyntax(name: .identifier("public"))]))
14381443
return DeclSyntax(newFunc)
14391444
}
14401445

test/Macros/SwiftifyImport/CountedBy/CountExpr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
func myFunc(_ ptr: UnsafePointer<CInt>, _ size: CInt, _ count: CInt) {
77
}
88

9-
// CHECK: @_alwaysEmitIntoClient
9+
// CHECK: @_alwaysEmitIntoClient public
1010
// CHECK-NEXT: func myFunc(_ ptr: UnsafeBufferPointer<CInt>, _ size: CInt, _ count: CInt) {
1111
// CHECK-NEXT: let _ptrCount: some BinaryInteger = size * count
1212
// CHECK-NEXT: if ptr.count < _ptrCount || _ptrCount < 0 {

test/Macros/SwiftifyImport/CountedBy/MultipleParams.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt, _ ptr2: UnsafePointer<CInt>, _ len2: CInt) {
77
}
88

9-
// CHECK: @_alwaysEmitIntoClient
9+
// CHECK: @_alwaysEmitIntoClient public
1010
// CHECK-NEXT: func myFunc(_ ptr: UnsafeBufferPointer<CInt>, _ ptr2: UnsafeBufferPointer<CInt>) {
1111
// CHECK-NEXT: return unsafe myFunc(ptr.baseAddress!, CInt(exactly: ptr.count)!, ptr2.baseAddress!, CInt(exactly: ptr2.count)!)
1212
// CHECK-NEXT: }

test/Macros/SwiftifyImport/CountedBy/Mutable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
func myFunc(_ ptr: UnsafeMutablePointer<CInt>, _ len: CInt) {
77
}
88

9-
// CHECK: @_alwaysEmitIntoClient
9+
// CHECK: @_alwaysEmitIntoClient public
1010
// CHECK-NEXT: func myFunc(_ ptr: UnsafeMutableBufferPointer<CInt>) {
1111
// CHECK-NEXT: return unsafe myFunc(ptr.baseAddress!, CInt(exactly: ptr.count)!)
1212
// CHECK-NEXT: }

test/Macros/SwiftifyImport/CountedBy/MutableSpan.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
func myFunc(_ ptr: UnsafeMutablePointer<CInt>, _ len: CInt) {
88
}
99

10-
// CHECK: @_alwaysEmitIntoClient @lifetime(ptr: copy ptr)
10+
// CHECK: @_alwaysEmitIntoClient @lifetime(ptr: copy ptr) public
1111
// CHECK-NEXT: func myFunc(_ ptr: inout MutableSpan<CInt>) {
1212
// CHECK-NEXT: return unsafe ptr.withUnsafeMutableBufferPointer { _ptrPtr in
1313
// CHECK-NEXT: return unsafe myFunc(_ptrPtr.baseAddress!, CInt(exactly: ptr.count)!)

test/Macros/SwiftifyImport/CountedBy/NamedParams.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,32 @@ func allNamed(ptr: UnsafePointer<CInt>, len: CInt) {
2626
func allNamedOther(buf ptr: UnsafePointer<CInt>, count len: CInt) {
2727
}
2828

29-
// CHECK: @_alwaysEmitIntoClient
29+
// CHECK: @_alwaysEmitIntoClient public
3030
// CHECK-NEXT: func ptrNamed(ptr: UnsafeBufferPointer<CInt>) {
3131
// CHECK-NEXT: return unsafe ptrNamed(ptr: ptr.baseAddress!, CInt(exactly: ptr.count)!)
3232
// CHECK-NEXT: }
3333

34-
// CHECK: @_alwaysEmitIntoClient
34+
// CHECK: @_alwaysEmitIntoClient public
3535
// CHECK-NEXT: func ptrNamedOther(buf ptr: UnsafeBufferPointer<CInt>) {
3636
// CHECK-NEXT: return unsafe ptrNamedOther(buf: ptr.baseAddress!, CInt(exactly: ptr.count)!)
3737
// CHECK-NEXT: }
3838

39-
// CHECK: @_alwaysEmitIntoClient
39+
// CHECK: @_alwaysEmitIntoClient public
4040
// CHECK-NEXT: func lenNamed(_ ptr: UnsafeBufferPointer<CInt>) {
4141
// CHECK-NEXT: return unsafe lenNamed(ptr.baseAddress!, len: CInt(exactly: ptr.count)!)
4242
// CHECK-NEXT: }
4343

44-
// CHECK: @_alwaysEmitIntoClient
44+
// CHECK: @_alwaysEmitIntoClient public
4545
// CHECK-NEXT: func lenNamedOther(_ ptr: UnsafeBufferPointer<CInt>) {
4646
// CHECK-NEXT: return unsafe lenNamedOther(ptr.baseAddress!, count: CInt(exactly: ptr.count)!)
4747
// CHECK-NEXT: }
4848

49-
// CHECK: @_alwaysEmitIntoClient
49+
// CHECK: @_alwaysEmitIntoClient public
5050
// CHECK-NEXT: func allNamed(ptr: UnsafeBufferPointer<CInt>) {
5151
// CHECK-NEXT: return unsafe allNamed(ptr: ptr.baseAddress!, len: CInt(exactly: ptr.count)!)
5252
// CHECK-NEXT: }
5353

54-
// CHECK: @_alwaysEmitIntoClient
54+
// CHECK: @_alwaysEmitIntoClient public
5555
// CHECK-NEXT: func allNamedOther(buf ptr: UnsafeBufferPointer<CInt>) {
5656
// CHECK-NEXT: return unsafe allNamedOther(buf: ptr.baseAddress!, count: CInt(exactly: ptr.count)!)
5757
// CHECK-NEXT: }

test/Macros/SwiftifyImport/CountedBy/Nullable.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ func myFunc3(_ ptr: UnsafeMutablePointer<CInt>?, _ len: CInt, _ ptr2: UnsafeMuta
1818
func myFunc4(_ ptr: UnsafeMutablePointer<CInt>?, _ len: CInt) -> UnsafeMutablePointer<CInt>? {
1919
}
2020

21-
// CHECK: @_alwaysEmitIntoClient
21+
// CHECK: @_alwaysEmitIntoClient public
2222
// CHECK-NEXT: func myFunc(_ ptr: UnsafeBufferPointer<CInt>?) {
2323
// CHECK-NEXT: return unsafe myFunc(ptr?.baseAddress, CInt(exactly: ptr?.count ?? 0)!)
2424
// CHECK-NEXT: }
2525

26-
// CHECK: @_alwaysEmitIntoClient @lifetime(ptr: copy ptr)
26+
// CHECK: @_alwaysEmitIntoClient @lifetime(ptr: copy ptr) public
2727
// CHECK-NEXT: func myFunc2(_ ptr: inout MutableSpan<CInt>?) {
2828
// CHECK-NEXT: return { () in
2929
// CHECK-NEXT: return if ptr == nil {
@@ -36,7 +36,7 @@ func myFunc4(_ ptr: UnsafeMutablePointer<CInt>?, _ len: CInt) -> UnsafeMutablePo
3636
// CHECK-NEXT: }()
3737
// CHECK-NEXT: }
3838

39-
// CHECK: @_alwaysEmitIntoClient @lifetime(ptr: copy ptr) @lifetime(ptr2: copy ptr2)
39+
// CHECK: @_alwaysEmitIntoClient @lifetime(ptr: copy ptr) @lifetime(ptr2: copy ptr2) public
4040
// CHECK-NEXT: func myFunc3(_ ptr: inout MutableSpan<CInt>?, _ ptr2: inout MutableSpan<CInt>?) {
4141
// CHECK-NEXT: return { () in
4242
// CHECK-NEXT: return if ptr2 == nil {
@@ -65,7 +65,7 @@ func myFunc4(_ ptr: UnsafeMutablePointer<CInt>?, _ len: CInt) -> UnsafeMutablePo
6565
// CHECK-NEXT: }()
6666
// CHECK-NEXT: }
6767

68-
// CHECK: @_alwaysEmitIntoClient @lifetime(copy ptr) @lifetime(ptr: copy ptr)
68+
// CHECK: @_alwaysEmitIntoClient @lifetime(copy ptr) @lifetime(ptr: copy ptr) public
6969
// CHECK-NEXT: func myFunc4(_ ptr: inout MutableSpan<CInt>?, _ len: CInt) -> MutableSpan<CInt>? {
7070
// CHECK-NEXT: let _ptrCount: some BinaryInteger = len
7171
// CHECK-NEXT: if ptr?.count ?? 0 < _ptrCount || _ptrCount < 0 {

test/Macros/SwiftifyImport/CountedBy/PointerReturn.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ func lifetimeDependentCopy(_ p: UnsafePointer<CInt>, _ len1: CInt, _ len2: CInt)
1919
func lifetimeDependentBorrow(_ p: borrowing UnsafePointer<CInt>, _ len1: CInt, _ len2: CInt) -> UnsafePointer<CInt> {
2020
}
2121

22-
// CHECK: @_alwaysEmitIntoClient @_disfavoredOverload
22+
// CHECK: @_alwaysEmitIntoClient @_disfavoredOverload public
2323
// CHECK-NEXT: func myFunc(_ len: CInt) -> UnsafeMutableBufferPointer<CInt> {
2424
// CHECK-NEXT: return unsafe UnsafeMutableBufferPointer<CInt> (start: unsafe myFunc(len), count: Int(len))
2525
// CHECK-NEXT: }
2626

27-
// CHECK: @_alwaysEmitIntoClient @_disfavoredOverload
27+
// CHECK: @_alwaysEmitIntoClient @_disfavoredOverload public
2828
// CHECK-NEXT: func nonEscaping(_ len: CInt) -> UnsafeBufferPointer<CInt> {
2929
// CHECK-NEXT: return unsafe UnsafeBufferPointer<CInt> (start: unsafe nonEscaping(len), count: Int(len))
3030

31-
// CHECK: @_alwaysEmitIntoClient @lifetime(copy p)
31+
// CHECK: @_alwaysEmitIntoClient @lifetime(copy p) public
3232
// CHECK-NEXT: func lifetimeDependentCopy(_ p: Span<CInt>, _ len2: CInt) -> Span<CInt> {
3333
// CHECK-NEXT: return unsafe Span<CInt> (_unsafeStart: unsafe p.withUnsafeBufferPointer { _pPtr in
3434
// CHECK-NEXT: return unsafe lifetimeDependentCopy(_pPtr.baseAddress!, CInt(exactly: p.count)!, len2)
3535
// CHECK-NEXT: }, count: Int(len2))
3636
// CHECK-NEXT: }
3737

38-
// CHECK: @_alwaysEmitIntoClient @lifetime(borrow p)
38+
// CHECK: @_alwaysEmitIntoClient @lifetime(borrow p) public
3939
// CHECK-NEXT: func lifetimeDependentBorrow(_ p: borrowing UnsafeBufferPointer<CInt>, _ len2: CInt) -> Span<CInt> {
4040
// CHECK-NEXT: return unsafe Span<CInt> (_unsafeStart: unsafe lifetimeDependentBorrow(p.baseAddress!, CInt(exactly: p.count)!, len2), count: Int(len2))
4141
// CHECK-NEXT: }

test/Macros/SwiftifyImport/CountedBy/Protocol.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ protocol SimpleProtocol {
88
}
99

1010
// CHECK: extension SimpleProtocol {
11-
// CHECK-NEXT: @_alwaysEmitIntoClient
11+
// CHECK-NEXT: @_alwaysEmitIntoClient public
1212
// CHECK-NEXT: func myFunc(_ ptr: UnsafeBufferPointer<CInt>) {
1313
// CHECK-NEXT: return unsafe myFunc(ptr.baseAddress!, CInt(exactly: ptr.count)!)
1414
// CHECK-NEXT: }
@@ -22,14 +22,14 @@ protocol SpanProtocol {
2222
}
2323

2424
// CHECK: extension SpanProtocol {
25-
// CHECK-NEXT: @_alwaysEmitIntoClient
25+
// CHECK-NEXT: @_alwaysEmitIntoClient public
2626
// CHECK-NEXT: func foo(_ ptr: Span<CInt>) {
2727
// CHECK-NEXT: return unsafe ptr.withUnsafeBufferPointer { _ptrPtr in
2828
// CHECK-NEXT: return unsafe foo(_ptrPtr.baseAddress!, CInt(exactly: ptr.count)!)
2929
// CHECK-NEXT: }
3030
// CHECK-NEXT: }
3131

32-
// CHECK-NEXT: @_alwaysEmitIntoClient @lifetime(borrow self) @_disfavoredOverload
32+
// CHECK-NEXT: @_alwaysEmitIntoClient @lifetime(borrow self) @_disfavoredOverload public
3333
// CHECK-NEXT: func bar(_ len: CInt) -> Span<CInt> {
3434
// CHECK-NEXT: return unsafe Span<CInt>(_unsafeStart: unsafe bar(len), count: Int(len))
3535
// CHECK-NEXT: }
@@ -43,15 +43,14 @@ protocol MixedProtocol {
4343
}
4444

4545
// CHECK: extension MixedProtocol {
46-
// CHECK-NEXT: @_alwaysEmitIntoClient
46+
// CHECK-NEXT: @_alwaysEmitIntoClient public
4747
// CHECK-NEXT: func foo(_ ptr: Span<CInt>) {
4848
// CHECK-NEXT: return unsafe ptr.withUnsafeBufferPointer { _ptrPtr in
4949
// CHECK-NEXT: return unsafe foo(_ptrPtr.baseAddress!, CInt(exactly: ptr.count)!)
5050
// CHECK-NEXT: }
5151
// CHECK-NEXT: }
52-
// CHECK-NEXT: @_alwaysEmitIntoClient
52+
// CHECK-NEXT: @_alwaysEmitIntoClient public
5353
// CHECK-NEXT: func bar(_ ptr: UnsafeBufferPointer<CInt>) {
5454
// CHECK-NEXT: return unsafe bar(ptr.baseAddress!, CInt(exactly: ptr.count)!)
5555
// CHECK-NEXT: }
5656
// CHECK-NEXT: }
57-

test/Macros/SwiftifyImport/CountedBy/QualifiedTypes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ func foo(_ ptr: Swift.UnsafePointer<Swift.Int>, _ len: Swift.Int) -> Swift.Void
1010
func bar(_ ptr: Swift.UnsafePointer<Swift.CInt>, _ len: Swift.Int) -> () {
1111
}
1212

13-
// CHECK: @_alwaysEmitIntoClient
13+
// CHECK: @_alwaysEmitIntoClient public
1414
// CHECK-NEXT: func foo(_ ptr: Swift.UnsafeBufferPointer<Swift.Int>) -> Swift.Void {
1515
// CHECK-NEXT: return unsafe foo(ptr.baseAddress!, ptr.count)
1616
// CHECK-NEXT: }
1717

18-
// CHECK: @_alwaysEmitIntoClient
18+
// CHECK: @_alwaysEmitIntoClient public
1919
// CHECK-NEXT: func bar(_ ptr: Swift.UnsafeBufferPointer<Swift.CInt>) -> () {
2020
// CHECK-NEXT: return unsafe bar(ptr.baseAddress!, ptr.count)
2121
// CHECK-NEXT: }

test/Macros/SwiftifyImport/CountedBy/Return.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) -> CInt {
77
}
88

9-
// CHECK: @_alwaysEmitIntoClient
9+
// CHECK: @_alwaysEmitIntoClient public
1010
// CHECK-NEXT: func myFunc(_ ptr: UnsafeBufferPointer<CInt>) -> CInt {
1111
// CHECK-NEXT: return unsafe myFunc(ptr.baseAddress!, CInt(exactly: ptr.count)!)
1212
// CHECK-NEXT: }

test/Macros/SwiftifyImport/CountedBy/SharedCount.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
func myFunc(_ ptr: UnsafePointer<CInt>, _ ptr2: UnsafePointer<CInt>, _ len: CInt) {
77
}
88

9-
// CHECK: @_alwaysEmitIntoClient
9+
// CHECK: @_alwaysEmitIntoClient public
1010
// CHECK-NEXT: func myFunc(_ ptr: UnsafeBufferPointer<CInt>, _ ptr2: UnsafeBufferPointer<CInt>, _ len: CInt) {
1111
// CHECK-NEXT: let _ptrCount: some BinaryInteger = len
1212
// CHECK-NEXT: if ptr.count < _ptrCount || _ptrCount < 0 {

test/Macros/SwiftifyImport/CountedBy/SimpleCount.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
77
}
88

9-
// CHECK: @_alwaysEmitIntoClient
9+
// CHECK: @_alwaysEmitIntoClient public
1010
// CHECK-NEXT: func myFunc(_ ptr: UnsafeBufferPointer<CInt>) {
1111
// CHECK-NEXT: return unsafe myFunc(ptr.baseAddress!, CInt(exactly: ptr.count)!)
1212
// CHECK-NEXT: }

test/Macros/SwiftifyImport/CountedBy/SimpleSpan.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
88
}
99

10-
// CHECK: @_alwaysEmitIntoClient
10+
// CHECK: @_alwaysEmitIntoClient public
1111
// CHECK-NEXT: func myFunc(_ ptr: Span<CInt>) {
1212
// CHECK-NEXT: return unsafe ptr.withUnsafeBufferPointer { _ptrPtr in
1313
// CHECK-NEXT: return unsafe myFunc(_ptrPtr.baseAddress!, CInt(exactly: ptr.count)!)

test/Macros/SwiftifyImport/CountedBy/SimpleSpanWithReturn.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) -> CInt {
88
}
99

10-
// CHECK: @_alwaysEmitIntoClient
10+
// CHECK: @_alwaysEmitIntoClient public
1111
// CHECK-NEXT: func myFunc(_ ptr: Span<CInt>) -> CInt {
1212
// CHECK-NEXT: return unsafe ptr.withUnsafeBufferPointer { _ptrPtr in
1313
// CHECK-NEXT: return unsafe myFunc(_ptrPtr.baseAddress!, CInt(exactly: ptr.count)!)

test/Macros/SwiftifyImport/CountedBy/SpanAndUnsafeBuffer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
func myFunc(_ ptr1: UnsafePointer<CInt>, _ len1: CInt, _ ptr2: UnsafePointer<CInt>, _ len2: CInt) {
99
}
1010

11-
// CHECK: @_alwaysEmitIntoClient
11+
// CHECK: @_alwaysEmitIntoClient public
1212
// CHECK-NEXT: func myFunc(_ ptr1: Span<CInt>, _ ptr2: UnsafeBufferPointer<CInt>) {
1313
// CHECK-NEXT: return unsafe ptr1.withUnsafeBufferPointer { _ptr1Ptr in
1414
// CHECK-NEXT: return unsafe myFunc(_ptr1Ptr.baseAddress!, CInt(exactly: ptr1.count)!, ptr2.baseAddress!, CInt(exactly: ptr2.count)!)

test/Macros/SwiftifyImport/CountedBy/Unwrapped.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
func myFunc(_ ptr: UnsafePointer<CInt>!, _ len: CInt) {
77
}
88

9-
// CHECK: @_alwaysEmitIntoClient
9+
// CHECK: @_alwaysEmitIntoClient public
1010
// CHECK-NEXT: func myFunc(_ ptr: UnsafeBufferPointer<CInt>) {
1111
// CHECK-NEXT: return unsafe myFunc(ptr.baseAddress!, CInt(exactly: ptr.count)!)
1212
// CHECK-NEXT: }

test/Macros/SwiftifyImport/CxxSpan/LifetimeboundSpan.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,32 @@ func myFunc8(_ ptr: UnsafeRawPointer, _ span: SpanOfInt, _ count: CInt, _ size:
5757
func myFunc9(_ span: MutableSpanOfInt) -> MutableSpanOfInt {
5858
}
5959

60-
// CHECK: @_alwaysEmitIntoClient @lifetime(copy span)
60+
// CHECK: @_alwaysEmitIntoClient @lifetime(copy span) public
6161
// CHECK-NEXT: func myFunc(_ span: Span<CInt>) -> Span<CInt> {
6262
// CHECK-NEXT: return unsafe _cxxOverrideLifetime(Span(_unsafeCxxSpan: unsafe myFunc(SpanOfInt(span))), copying: ())
6363
// CHECK-NEXT: }
6464

65-
// CHECK: @_alwaysEmitIntoClient @lifetime(borrow vec) @_disfavoredOverload
65+
// CHECK: @_alwaysEmitIntoClient @lifetime(borrow vec) @_disfavoredOverload public
6666
// CHECK-NEXT: func myFunc2(_ vec: borrowing VecOfInt) -> Span<CInt> {
6767
// CHECK-NEXT: return unsafe _cxxOverrideLifetime(Span(_unsafeCxxSpan: unsafe myFunc2(vec)), copying: ())
6868
// CHECK-NEXT: }
6969

70-
// CHECK: @_alwaysEmitIntoClient @lifetime(copy span1, copy span2)
70+
// CHECK: @_alwaysEmitIntoClient @lifetime(copy span1, copy span2) public
7171
// CHECK-NEXT: func myFunc3(_ span1: Span<CInt>, _ span2: Span<CInt>) -> Span<CInt> {
7272
// CHECK-NEXT: return unsafe _cxxOverrideLifetime(Span(_unsafeCxxSpan: unsafe myFunc3(SpanOfInt(span1), SpanOfInt(span2))), copying: ())
7373
// CHECK-NEXT: }
7474

75-
// CHECK: @_alwaysEmitIntoClient @lifetime(borrow vec, copy span)
75+
// CHECK: @_alwaysEmitIntoClient @lifetime(borrow vec, copy span) public
7676
// CHECK-NEXT: func myFunc4(_ vec: borrowing VecOfInt, _ span: Span<CInt>) -> Span<CInt> {
7777
// CHECK-NEXT: return unsafe _cxxOverrideLifetime(Span(_unsafeCxxSpan: unsafe myFunc4(vec, SpanOfInt(span))), copying: ())
7878
// CHECK-NEXT: }
7979

80-
// CHECK: @_alwaysEmitIntoClient @lifetime(borrow self) @_disfavoredOverload
80+
// CHECK: @_alwaysEmitIntoClient @lifetime(borrow self) @_disfavoredOverload public
8181
// CHECK-NEXT: func myFunc5() -> Span<CInt> {
8282
// CHECK-NEXT: return unsafe _cxxOverrideLifetime(Span(_unsafeCxxSpan: unsafe myFunc5()), copying: ())
8383
// CHECK-NEXT: }
8484

85-
// CHECK: @_alwaysEmitIntoClient @lifetime(copy span)
85+
// CHECK: @_alwaysEmitIntoClient @lifetime(copy span) public
8686
// CHECK-NEXT: func myFunc6(_ span: Span<CInt>, _ ptr: RawSpan, _ count: CInt, _ size: CInt) -> Span<CInt> {
8787
// CHECK-NEXT: let _ptrCount: some BinaryInteger = count * size
8888
// CHECK-NEXT: if ptr.byteCount < _ptrCount || _ptrCount < 0 {
@@ -93,7 +93,7 @@ func myFunc9(_ span: MutableSpanOfInt) -> MutableSpanOfInt {
9393
// CHECK-NEXT: }), copying: ())
9494
// CHECK-NEXT: }
9595

96-
// CHECK: @_alwaysEmitIntoClient @lifetime(copy span)
96+
// CHECK: @_alwaysEmitIntoClient @lifetime(copy span) public
9797
// CHECK-NEXT: func myFunc7(_ span: Span<CInt>, _ ptr: RawSpan, _ count: CInt, _ size: CInt) -> Span<CInt> {
9898
// CHECK-NEXT: let _ptrCount: some BinaryInteger = count * size
9999
// CHECK-NEXT: if ptr.byteCount < _ptrCount || _ptrCount < 0 {
@@ -104,7 +104,7 @@ func myFunc9(_ span: MutableSpanOfInt) -> MutableSpanOfInt {
104104
// CHECK-NEXT: }), copying: ())
105105
// CHECK-NEXT: }
106106

107-
// CHECK: @_alwaysEmitIntoClient @lifetime(copy span)
107+
// CHECK: @_alwaysEmitIntoClient @lifetime(copy span) public
108108
// CHECK-NEXT: func myFunc8(_ ptr: RawSpan, _ span: Span<CInt>, _ count: CInt, _ size: CInt) -> Span<CInt> {
109109
// CHECK-NEXT: let _ptrCount: some BinaryInteger = count * size
110110
// CHECK-NEXT: if ptr.byteCount < _ptrCount || _ptrCount < 0 {
@@ -115,7 +115,7 @@ func myFunc9(_ span: MutableSpanOfInt) -> MutableSpanOfInt {
115115
// CHECK-NEXT: }), copying: ())
116116
// CHECK-NEXT: }
117117

118-
// CHECK: @_alwaysEmitIntoClient @lifetime(copy span) @lifetime(span: copy span)
118+
// CHECK: @_alwaysEmitIntoClient @lifetime(copy span) @lifetime(span: copy span) public
119119
// CHECK-NEXT: func myFunc9(_ span: inout MutableSpan<CInt>) -> MutableSpan<CInt> {
120120
// CHECK-NEXT: return unsafe _cxxOverrideLifetime(MutableSpan(_unsafeCxxSpan: unsafe span.withUnsafeMutableBufferPointer { _spanPtr in
121121
// CHECK-NEXT: return unsafe myFunc9(MutableSpanOfInt(_spanPtr))

test/Macros/SwiftifyImport/CxxSpan/NoEscapeSpan.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,26 @@ func myFunc3(_ span: MutableSpanOfInt, _ secondSpan: SpanOfInt) {
2525
func myFunc4(_ span: MutableSpanOfInt, _ secondSpan: MutableSpanOfInt) {
2626
}
2727

28-
// CHECK: @_alwaysEmitIntoClient
28+
// CHECK: @_alwaysEmitIntoClient public
2929
// CHECK-NEXT: func myFunc(_ span: Span<CInt>, _ secondSpan: SpanOfInt) {
3030
// CHECK-NEXT: return unsafe myFunc(SpanOfInt(span), secondSpan)
3131
// CHECK-NEXT: }
3232

33-
// CHECK: @_alwaysEmitIntoClient @lifetime(span: copy span)
33+
// CHECK: @_alwaysEmitIntoClient @lifetime(span: copy span) public
3434
// CHECK-NEXT: func myFunc2(_ span: inout MutableSpan<CInt>, _ secondSpan: MutableSpanOfInt) {
3535
// CHECK-NEXT: return unsafe span.withUnsafeMutableBufferPointer { _spanPtr in
3636
// CHECK-NEXT: return unsafe myFunc2(MutableSpanOfInt(_spanPtr), secondSpan)
3737
// CHECK-NEXT: }
3838
// CHECK-NEXT: }
3939

40-
// CHECK: @_alwaysEmitIntoClient @lifetime(span: copy span)
40+
// CHECK: @_alwaysEmitIntoClient @lifetime(span: copy span) public
4141
// CHECK-NEXT: func myFunc3(_ span: inout MutableSpan<CInt>, _ secondSpan: Span<CInt>) {
4242
// CHECK-NEXT: return unsafe span.withUnsafeMutableBufferPointer { _spanPtr in
4343
// CHECK-NEXT: return unsafe myFunc3(MutableSpanOfInt(_spanPtr), SpanOfInt(secondSpan))
4444
// CHECK-NEXT: }
4545
// CHECK-NEXT: }
4646

47-
// CHECK: @_alwaysEmitIntoClient @lifetime(span: copy span) @lifetime(secondSpan: copy secondSpan)
47+
// CHECK: @_alwaysEmitIntoClient @lifetime(span: copy span) @lifetime(secondSpan: copy secondSpan) public
4848
// CHECK-NEXT: func myFunc4(_ span: inout MutableSpan<CInt>, _ secondSpan: inout MutableSpan<CInt>) {
4949
// CHECK-NEXT: return unsafe secondSpan.withUnsafeMutableBufferPointer { _secondSpanPtr in
5050
// CHECK-NEXT: return unsafe span.withUnsafeMutableBufferPointer { _spanPtr in

test/Macros/SwiftifyImport/MacroErrors/UnexpectedCountType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
1010
}
1111

12-
// CHECK: @_alwaysEmitIntoClient
12+
// CHECK: @_alwaysEmitIntoClient public
1313
// CHECK-NEXT: func myFunc(_ ptr: UnsafeBufferPointer<CInt>) {
1414
// CHECK-NEXT: myFunc(ptr.baseAddress!, String(exactly: ptr.count)!)
1515
// CHECK-NEXT: }

test/Macros/SwiftifyImport/SizedBy/MultipleParams.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt, _ ptr2: UnsafeRawPointer, _ size2: CInt) {
77
}
88

9-
// CHECK: @_alwaysEmitIntoClient
9+
// CHECK: @_alwaysEmitIntoClient public
1010
// CHECK-NEXT: func myFunc(_ ptr: UnsafeRawBufferPointer, _ ptr2: UnsafeRawBufferPointer) {
1111
// CHECK-NEXT: return unsafe myFunc(ptr.baseAddress!, CInt(exactly: ptr.count)!, ptr2.baseAddress!, CInt(exactly: ptr2.count)!)
1212
// CHECK-NEXT: }

0 commit comments

Comments
 (0)