Skip to content

Commit 6a28b6a

Browse files
committed
Pass availability to _SwiftifyImport
This was only passed to _SwiftifyImportProtocol, now it is also passed to _SwiftifyImport. This results in @available being attached to generated overloads that use [Mutable][Raw]Span.
1 parent 1305b27 commit 6a28b6a

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9332,6 +9332,7 @@ void ClangImporter::Implementation::swiftify(
93329332
SwiftifyInfoPrinter printer(getClangASTContext(), SwiftContext, out);
93339333
if (!swiftifyImpl(printer, MappedDecl))
93349334
return;
9335+
printer.printAvailability();
93359336
printer.printTypeMapping();
93369337
}
93379338

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
void simple(int len, int * __counted_by(len) __noescape p);
88

99
void swiftAttr(int len, int *p) __attribute__((
10-
swift_attr("@_SwiftifyImport(.countedBy(pointer: .param(2), count: \"len\"), .nonescaping(pointer: .param(2)))")));
10+
swift_attr("@_SwiftifyImport(.countedBy(pointer: .param(2), count: \"len\"), .nonescaping(pointer: .param(2)), availability: [\"MutableSpan\": \"macOS 9999, *\"])")));
1111

1212
void shared(int len, int * __counted_by(len) __noescape p1, int * __counted_by(len) __noescape p2);
1313

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
void simple(int len, const void * __sized_by(len) __noescape p);
77

88
void swiftAttr(int len, const void *p) __attribute__((swift_attr(
9-
"@_SwiftifyImport(.sizedBy(pointer: .param(2), size: \"len\"), .nonescaping(pointer: .param(2)))")));
9+
"@_SwiftifyImport(.sizedBy(pointer: .param(2), size: \"len\"), .nonescaping(pointer: .param(2)), availability: [\"Span\": \"macOS 9999, *\"])")));
1010

1111
void shared(int len, const void * __sized_by(len) __noescape p1, const void * __sized_by(len) __noescape p2);
1212

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,28 @@
1111

1212
import CountedByNoEscapeClang
1313

14-
// CHECK: @lifetime(p: copy p)
14+
// CHECK: @available(macOS 9999, *)
15+
// CHECK-NEXT: @lifetime(p: copy p)
1516
// CHECK-NEXT: @_alwaysEmitIntoClient public func complexExpr(_ len: Int32, _ offset: Int32, _ p: inout MutableSpan<Int32>)
17+
// CHECK-NEXT: @available(macOS 9999, *)
1618
// CHECK-NEXT: @lifetime(p: copy p)
1719
// CHECK-NEXT: @_alwaysEmitIntoClient public func nonnull(_ p: inout MutableSpan<Int32>)
20+
// CHECK-NEXT: @available(macOS 9999, *)
1821
// CHECK-NEXT: @lifetime(p: copy p)
1922
// CHECK-NEXT: @_alwaysEmitIntoClient public func nullUnspecified(_ p: inout MutableSpan<Int32>)
23+
// CHECK-NEXT: @available(macOS 9999, *)
2024
// CHECK-NEXT: @lifetime(copy p)
2125
// CHECK-NEXT: @lifetime(p: copy p)
2226
// CHECK-NEXT: @_alwaysEmitIntoClient public func returnLifetimeBound(_ len1: Int32, _ p: inout MutableSpan<Int32>) -> MutableSpan<Int32>
2327
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func returnPointer(_ len: Int32) -> UnsafeMutableBufferPointer<Int32>
28+
// CHECK-NEXT: @available(macOS 9999, *)
2429
// CHECK-NEXT: @lifetime(p1: copy p1)
2530
// CHECK-NEXT: @lifetime(p2: copy p2)
2631
// CHECK-NEXT: @_alwaysEmitIntoClient public func shared(_ len: Int32, _ p1: inout MutableSpan<Int32>, _ p2: inout MutableSpan<Int32>)
32+
// CHECK-NEXT: @available(macOS 9999, *)
2733
// CHECK-NEXT: @lifetime(p: copy p)
2834
// CHECK-NEXT: @_alwaysEmitIntoClient public func simple(_ p: inout MutableSpan<Int32>)
35+
// CHECK-NEXT: @available(macOS 9999, *)
2936
// CHECK-NEXT: @lifetime(p: copy p)
3037
// CHECK-NEXT: @_alwaysEmitIntoClient public func swiftAttr(_ p: inout MutableSpan<Int32>)
3138

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@
99
// Check that ClangImporter correctly infers and expands @_SwiftifyImport macros for functions with __sized_by __noescape parameters.
1010
import SizedByNoEscapeClang
1111

12-
// CHECK: @_alwaysEmitIntoClient public func complexExpr(_ len: Int{{.*}}, _ offset: Int{{.*}}, _ p: RawSpan)
12+
// CHECK: @available(macOS 9999, *)
13+
// CHECK-NEXT: @_alwaysEmitIntoClient public func complexExpr(_ len: Int{{.*}}, _ offset: Int{{.*}}, _ p: RawSpan)
14+
// CHECK-NEXT: @available(macOS 9999, *)
1315
// CHECK-NEXT: @_alwaysEmitIntoClient public func nonnull(_ p: RawSpan)
16+
// CHECK-NEXT: @available(macOS 9999, *)
1417
// CHECK-NEXT: @_alwaysEmitIntoClient public func nullUnspecified(_ p: RawSpan)
18+
// CHECK-NEXT: @available(macOS 9999, *)
1519
// CHECK-NEXT: @_alwaysEmitIntoClient public func opaque(_ p: RawSpan)
1620
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func returnPointer(_ len: Int{{.*}}) -> UnsafeRawBufferPointer
21+
// CHECK-NEXT: @available(macOS 9999, *)
1722
// CHECK-NEXT: @_alwaysEmitIntoClient public func shared(_ len: Int{{.*}}, _ p1: RawSpan, _ p2: RawSpan)
23+
// CHECK-NEXT: @available(macOS 9999, *)
1824
// CHECK-NEXT: @_alwaysEmitIntoClient public func simple(_ p: RawSpan)
25+
// CHECK-NEXT: @available(macOS 9999, *)
1926
// CHECK-NEXT: @_alwaysEmitIntoClient public func swiftAttr(_ p: RawSpan)

0 commit comments

Comments
 (0)