Skip to content

Commit bd233ea

Browse files
authored
[Swiftify] Don't use count from Span inside withUnsafeBufferPointer call (#81267)
1 parent a82f14b commit bd233ea

19 files changed

+257
-34
lines changed

lib/Macros/Sources/SwiftMacros/SwiftifyImportMacro.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ struct CxxSpanReturnThunkBuilder: SpanBoundsThunkBuilder {
545545
} else {
546546
"MutableSpan"
547547
}
548-
return "unsafe _cxxOverrideLifetime(\(raw: cast)(_unsafeCxxSpan: \(call)), copying: ())"
548+
return "unsafe _swiftifyOverrideLifetime(\(raw: cast)(_unsafeCxxSpan: \(call)), copying: ())"
549549
}
550550
}
551551

@@ -701,10 +701,15 @@ struct CountedOrSizedReturnPointerThunkBuilder: PointerBoundsThunkBuilder {
701701
}()
702702
"""
703703
}
704-
return
704+
var expr = ExprSyntax(
705705
"""
706-
unsafe \(raw: cast)(\(raw: startLabel): \(call), count: Int(\(countExpr)))
706+
\(raw: cast)(\(raw: startLabel): \(call), count: Int(\(countExpr)))
707707
"""
708+
)
709+
if generateSpan {
710+
expr = "_swiftifyOverrideLifetime(\(expr), copying: ())"
711+
}
712+
return "unsafe \(expr)"
708713
}
709714
}
710715

@@ -778,6 +783,13 @@ struct CountedOrSizedPointerThunkBuilder: ParamBoundsThunkBuilder, PointerBounds
778783
let argExpr = ExprSyntax("\(unwrappedName).baseAddress")
779784
assert(args[index] == nil)
780785
args[index] = try castPointerToOpaquePointer(unwrapIfNonnullable(argExpr))
786+
if skipTrivialCount {
787+
if let countVar = countExpr.as(DeclReferenceExprSyntax.self) {
788+
let i = try getParameterIndexForDeclRef(signature.parameterClause.parameters, countVar)
789+
args[i] = castIntToTargetType(
790+
expr: "\(unwrappedName).count", type: getParam(signature, i).type)
791+
}
792+
}
781793
let call = try base.buildFunctionCall(args)
782794
let ptrRef = unwrapIfNullable(ExprSyntax(DeclReferenceExprSyntax(baseName: name)))
783795

stdlib/public/core/SwiftifyImport.swift

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,43 @@ public enum _SwiftifyInfo {
6363
public macro _SwiftifyImport(_ paramInfo: _SwiftifyInfo..., typeMappings: [String: String] = [:]) =
6464
#externalMacro(module: "SwiftMacros", type: "SwiftifyImportMacro")
6565
#endif
66+
67+
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
68+
/// a value identical to `dependent` with a lifetime dependency on the caller's
69+
/// borrow scope of the `source` argument.
70+
///
71+
/// This mimics the stdlib definition. It is public for use with import macros.
72+
@unsafe
73+
@_unsafeNonescapableResult
74+
@_alwaysEmitIntoClient
75+
@_transparent
76+
@lifetime(borrow source)
77+
public func _swiftifyOverrideLifetime<
78+
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
79+
>(
80+
_ dependent: consuming T, borrowing source: borrowing U
81+
) -> T {
82+
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
83+
// should be expressed by a builtin that is hidden within the function body.
84+
dependent
85+
}
86+
87+
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
88+
/// a value identical to `dependent` that inherits all lifetime dependencies from
89+
/// the `source` argument.
90+
///
91+
/// This mimics the stdlib definition. It is public for use with import macros.
92+
@unsafe
93+
@_unsafeNonescapableResult
94+
@_alwaysEmitIntoClient
95+
@_transparent
96+
@lifetime(copy source)
97+
public func _swiftifyOverrideLifetime<
98+
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
99+
>(
100+
_ dependent: consuming T, copying source: borrowing U
101+
) -> T {
102+
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
103+
// should be expressed by a builtin that is hidden within the function body.
104+
dependent
105+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void nullUnspecified(int len, int * __counted_by(len) _Null_unspecified __noesca
1717

1818
void nonnull(int len, int * __counted_by(len) _Nonnull __noescape p);
1919

20-
//void nullable(int len, int * __counted_by(len) _Nullable p);
20+
void nullable(int len, int * __counted_by(len) _Nullable p __noescape);
2121

2222
int * __counted_by(len) __noescape returnPointer(int len);
2323

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ void nullUnspecified(int len, const void * __sized_by(len) __noescape _Null_unsp
1616

1717
void nonnull(int len, const void * __sized_by(len) __noescape _Nonnull p);
1818

19-
// Nullable ~Escapable types not supported yet
20-
//void nullable(int len, const void * __sized_by(len) __noescape _Nullable p);
19+
void nullable(int len, const void * __sized_by(len) __noescape _Nullable p);
2120

2221
const void * __sized_by(len) __noescape _Nonnull returnPointer(int len);
2322

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

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// swift-ide-test doesn't currently typecheck the macro expansions, so run the compiler as well
77
// RUN: %empty-directory(%t)
8-
// RUN: %target-swift-frontend -emit-module -plugin-path %swift-plugin-dir -o %t/CountedByNoEscape.swiftmodule -I %S/Inputs -enable-experimental-feature SafeInteropWrappers %s
8+
// RUN: %target-swift-frontend -emit-module -plugin-path %swift-plugin-dir -o %t/CountedByNoEscape.swiftmodule -I %S/Inputs -enable-experimental-feature SafeInteropWrappers -enable-experimental-feature LifetimeDependence %s
99

1010
// Check that ClangImporter correctly infers and expands @_SwiftifyImport macros for functions with __counted_by __noescape parameters.
1111

@@ -17,6 +17,8 @@ import CountedByNoEscapeClang
1717
// CHECK-NEXT: @_alwaysEmitIntoClient public func nonnull(_ p: inout MutableSpan<Int32>)
1818
// CHECK-NEXT: @lifetime(p: copy p)
1919
// CHECK-NEXT: @_alwaysEmitIntoClient public func nullUnspecified(_ p: inout MutableSpan<Int32>)
20+
// CHECK-NEXT: @lifetime(p: copy p)
21+
// CHECK-NEXT: @_alwaysEmitIntoClient public func nullable(_ p: inout MutableSpan<Int32>?)
2022
// CHECK-NEXT: @lifetime(copy p)
2123
// CHECK-NEXT: @lifetime(p: copy p)
2224
// CHECK-NEXT: @_alwaysEmitIntoClient public func returnLifetimeBound(_ len1: Int32, _ p: inout MutableSpan<Int32>) -> MutableSpan<Int32>
@@ -29,9 +31,57 @@ import CountedByNoEscapeClang
2931
// CHECK-NEXT: @lifetime(p: copy p)
3032
// CHECK-NEXT: @_alwaysEmitIntoClient public func swiftAttr(_ p: inout MutableSpan<Int32>)
3133

34+
@lifetime(p: copy p)
35+
@inlinable
36+
public func callComplexExpr(_ p: inout MutableSpan<CInt>) {
37+
complexExpr(CInt(p.count), 1, &p)
38+
}
39+
40+
@lifetime(p: copy p)
41+
@inlinable
42+
public func callNonnull(_ p: inout MutableSpan<CInt>) {
43+
nonnull(&p)
44+
}
45+
46+
@lifetime(p: copy p)
47+
@inlinable
48+
public func callNullUnspecified(_ p: inout MutableSpan<CInt>) {
49+
nullUnspecified(&p)
50+
}
51+
52+
@lifetime(p: copy p)
53+
@inlinable
54+
public func callNullable(_ p: inout MutableSpan<CInt>?) {
55+
nullable(&p)
56+
}
57+
58+
@lifetime(p: copy p)
59+
@inlinable
60+
public func callReturnLifetimeBound(_ p: inout MutableSpan<CInt>) {
61+
let a: MutableSpan<CInt> = returnLifetimeBound(2, &p)
62+
}
63+
3264
@inlinable
3365
public func callReturnPointer() {
3466
let a: UnsafeMutableBufferPointer<CInt>? = returnPointer(4) // call wrapper
3567
let b: UnsafeMutablePointer<CInt>? = returnPointer(4) // call unsafe interop
3668
}
3769

70+
@lifetime(p: copy p)
71+
@lifetime(p2: copy p2)
72+
@inlinable
73+
public func callShared(_ p: inout MutableSpan<CInt>, _ p2: inout MutableSpan<CInt>) {
74+
shared(CInt(p.count), &p, &p2)
75+
}
76+
77+
@lifetime(p: copy p)
78+
@inlinable
79+
public func callSimple(_ p: inout MutableSpan<CInt>) {
80+
simple(&p)
81+
}
82+
83+
@lifetime(p: copy p)
84+
@inlinable
85+
public func callSwiftAttr(_ p: inout MutableSpan<CInt>) {
86+
swiftAttr(&p)
87+
}

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,43 @@ import CountedByClang
1919
// CHECK-NEXT: @_alwaysEmitIntoClient public func simple(_ p: UnsafeMutableBufferPointer<Int{{.*}}>)
2020
// CHECK-NEXT: @_alwaysEmitIntoClient public func swiftAttr(_ p: UnsafeMutableBufferPointer<Int{{.*}}>)
2121

22+
@inlinable
23+
public func callComplexExpr(_ p: UnsafeMutableBufferPointer<CInt>) {
24+
complexExpr(CInt(p.count), 1, p)
25+
}
26+
27+
@inlinable
28+
public func callNonnull(_ p: UnsafeMutableBufferPointer<CInt>) {
29+
nonnull(p)
30+
}
31+
32+
@inlinable
33+
public func callNullUnspecified(_ p: UnsafeMutableBufferPointer<CInt>) {
34+
nullUnspecified(p)
35+
}
36+
37+
@inlinable
38+
public func callNullable(_ p: UnsafeMutableBufferPointer<CInt>?) {
39+
nullable(p)
40+
}
41+
2242
@inlinable
2343
public func callReturnPointer() {
2444
let a: UnsafeMutableBufferPointer<CInt>? = returnPointer(4) // call wrapper
2545
let b: UnsafeMutablePointer<CInt>? = returnPointer(4) // call unsafe interop
2646
}
47+
48+
@inlinable
49+
public func callShared(_ p: UnsafeMutableBufferPointer<CInt>, _ p2: UnsafeMutableBufferPointer<CInt>) {
50+
shared(CInt(p.count), p, p2)
51+
}
52+
53+
@inlinable
54+
public func callSimple(_ p: UnsafeMutableBufferPointer<CInt>) {
55+
simple(p)
56+
}
57+
58+
@inlinable
59+
public func callSwiftAttr(_ p: UnsafeMutableBufferPointer<CInt>) {
60+
swiftAttr(p)
61+
}

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,50 @@ import SizedByNoEscapeClang
1212
// CHECK: @_alwaysEmitIntoClient public func complexExpr(_ len: Int{{.*}}, _ offset: Int{{.*}}, _ p: RawSpan)
1313
// CHECK-NEXT: @_alwaysEmitIntoClient public func nonnull(_ p: RawSpan)
1414
// CHECK-NEXT: @_alwaysEmitIntoClient public func nullUnspecified(_ p: RawSpan)
15+
// CHECK-NEXT: @_alwaysEmitIntoClient public func nullable(_ p: RawSpan?)
1516
// CHECK-NEXT: @_alwaysEmitIntoClient public func opaque(_ p: RawSpan)
1617
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func returnPointer(_ len: Int{{.*}}) -> UnsafeRawBufferPointer
1718
// CHECK-NEXT: @_alwaysEmitIntoClient public func shared(_ len: Int{{.*}}, _ p1: RawSpan, _ p2: RawSpan)
1819
// CHECK-NEXT: @_alwaysEmitIntoClient public func simple(_ p: RawSpan)
1920
// CHECK-NEXT: @_alwaysEmitIntoClient public func swiftAttr(_ p: RawSpan)
21+
22+
@inlinable
23+
public func callComplexExpr(_ p: RawSpan) {
24+
complexExpr(CInt(p.byteCount), 1, p)
25+
}
26+
27+
@inlinable
28+
public func callNonnull(_ p: RawSpan) {
29+
nonnull(p)
30+
}
31+
32+
@inlinable
33+
public func callNullUnspecified(_ p: RawSpan) {
34+
nullUnspecified(p)
35+
}
36+
37+
@inlinable
38+
public func callNullable(_ p: RawSpan?) {
39+
nullable(p)
40+
}
41+
42+
@inlinable
43+
public func callReturnPointer() {
44+
let a: UnsafeRawBufferPointer? = returnPointer(4) // call wrapper
45+
let b: UnsafeRawPointer? = returnPointer(4) // call unsafe interop
46+
}
47+
48+
@inlinable
49+
public func callShared(_ p: RawSpan, _ p2: RawSpan) {
50+
shared(CInt(p.byteCount), p, p2)
51+
}
52+
53+
@inlinable
54+
public func callSimple(_ p: RawSpan) {
55+
simple(p)
56+
}
57+
58+
@inlinable
59+
public func callSwiftAttr(_ p: RawSpan) {
60+
swiftAttr(p)
61+
}

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,48 @@ import SizedByClang
1919
// CHECK-NEXT: @_alwaysEmitIntoClient public func simple(_ p: UnsafeMutableRawBufferPointer)
2020
// CHECK-NEXT: @_alwaysEmitIntoClient public func swiftAttr(_ p: UnsafeMutableRawBufferPointer)
2121

22+
@inlinable
23+
public func callComplexExpr(_ p: UnsafeMutableRawBufferPointer) {
24+
complexExpr(CInt(p.count), 1, p)
25+
}
26+
27+
@inlinable
28+
public func callNonnull(_ p: UnsafeMutableRawBufferPointer) {
29+
nonnull(p)
30+
}
31+
32+
@inlinable
33+
public func callNullUnspecified(_ p: UnsafeMutableRawBufferPointer) {
34+
nullUnspecified(p)
35+
}
36+
37+
@inlinable
38+
public func callNullable(_ p: UnsafeMutableRawBufferPointer?) {
39+
nullable(p)
40+
}
41+
42+
@inlinable
43+
public func callOpaque(_ p: UnsafeRawBufferPointer) {
44+
opaque(p)
45+
}
46+
47+
@inlinable
48+
public func callReturnPointer() {
49+
let a: UnsafeMutableRawBufferPointer? = returnPointer(4) // call wrapper
50+
let b: UnsafeMutableRawPointer? = returnPointer(4) // call unsafe interop
51+
}
52+
53+
@inlinable
54+
public func callShared(_ p: UnsafeMutableRawBufferPointer, _ p2: UnsafeMutableRawBufferPointer) {
55+
shared(CInt(p.count), p, p2)
56+
}
57+
58+
@inlinable
59+
public func callSimple(_ p: UnsafeMutableRawBufferPointer) {
60+
simple(p)
61+
}
62+
63+
@inlinable
64+
public func callSwiftAttr(_ p: UnsafeMutableRawBufferPointer) {
65+
swiftAttr(p)
66+
}

test/Macros/SwiftifyImport/CountedBy/MutableSpan.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ func myFunc(_ ptr: UnsafeMutablePointer<CInt>, _ len: CInt) {
1010
// CHECK: @_alwaysEmitIntoClient @lifetime(ptr: copy ptr)
1111
// CHECK-NEXT: func myFunc(_ ptr: inout MutableSpan<CInt>) {
1212
// CHECK-NEXT: return unsafe ptr.withUnsafeMutableBufferPointer { _ptrPtr in
13-
// CHECK-NEXT: return unsafe myFunc(_ptrPtr.baseAddress!, CInt(exactly: ptr.count)!)
13+
// CHECK-NEXT: return unsafe myFunc(_ptrPtr.baseAddress!, CInt(exactly: _ptrPtr.count)!)
1414
// CHECK-NEXT: }
1515
// CHECK-NEXT: }

test/Macros/SwiftifyImport/CountedBy/Nullable.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func myFunc4(_ ptr: UnsafeMutablePointer<CInt>?, _ len: CInt) -> UnsafeMutablePo
3030
// CHECK-NEXT: unsafe myFunc2(nil, CInt(exactly: ptr?.count ?? 0)!)
3131
// CHECK-NEXT: } else {
3232
// CHECK-NEXT: unsafe ptr!.withUnsafeMutableBufferPointer { _ptrPtr in
33-
// CHECK-NEXT: return unsafe myFunc2(_ptrPtr.baseAddress, CInt(exactly: ptr?.count ?? 0)!)
33+
// CHECK-NEXT: return unsafe myFunc2(_ptrPtr.baseAddress, CInt(exactly: _ptrPtr.count)!)
3434
// CHECK-NEXT: }
3535
// CHECK-NEXT: }
3636
// CHECK-NEXT: }()
@@ -45,18 +45,18 @@ func myFunc4(_ ptr: UnsafeMutablePointer<CInt>?, _ len: CInt) -> UnsafeMutablePo
4545
// CHECK-NEXT: unsafe myFunc3(nil, CInt(exactly: ptr?.count ?? 0)!, nil, CInt(exactly: ptr2?.count ?? 0)!)
4646
// CHECK-NEXT: } else {
4747
// CHECK-NEXT: unsafe ptr!.withUnsafeMutableBufferPointer { _ptrPtr in
48-
// CHECK-NEXT: return unsafe myFunc3(_ptrPtr.baseAddress, CInt(exactly: ptr?.count ?? 0)!, nil, CInt(exactly: ptr2?.count ?? 0)!)
48+
// CHECK-NEXT: return unsafe myFunc3(_ptrPtr.baseAddress, CInt(exactly: _ptrPtr.count)!, nil, CInt(exactly: ptr2?.count ?? 0)!)
4949
// CHECK-NEXT: }
5050
// CHECK-NEXT: }
5151
// CHECK-NEXT: }()
5252
// CHECK-NEXT: } else {
5353
// CHECK-NEXT: unsafe ptr2!.withUnsafeMutableBufferPointer { _ptr2Ptr in
5454
// CHECK-NEXT: return { () in
5555
// CHECK-NEXT: return if ptr == nil {
56-
// CHECK-NEXT: unsafe myFunc3(nil, CInt(exactly: ptr?.count ?? 0)!, _ptr2Ptr.baseAddress, CInt(exactly: ptr2?.count ?? 0)!)
56+
// CHECK-NEXT: unsafe myFunc3(nil, CInt(exactly: ptr?.count ?? 0)!, _ptr2Ptr.baseAddress, CInt(exactly: _ptr2Ptr.count)!)
5757
// CHECK-NEXT: } else {
5858
// CHECK-NEXT: unsafe ptr!.withUnsafeMutableBufferPointer { _ptrPtr in
59-
// CHECK-NEXT: return unsafe myFunc3(_ptrPtr.baseAddress, CInt(exactly: ptr?.count ?? 0)!, _ptr2Ptr.baseAddress, CInt(exactly: ptr2?.count ?? 0)!)
59+
// CHECK-NEXT: return unsafe myFunc3(_ptrPtr.baseAddress, CInt(exactly: _ptrPtr.count)!, _ptr2Ptr.baseAddress, CInt(exactly: _ptr2Ptr.count)!)
6060
// CHECK-NEXT: }
6161
// CHECK-NEXT: }
6262
// CHECK-NEXT: }()

test/Macros/SwiftifyImport/CountedBy/PointerReturn.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ func lifetimeDependentBorrow(_ p: borrowing UnsafePointer<CInt>, _ len1: CInt, _
3030

3131
// CHECK: @_alwaysEmitIntoClient @lifetime(copy p)
3232
// CHECK-NEXT: func lifetimeDependentCopy(_ p: Span<CInt>, _ len2: CInt) -> Span<CInt> {
33-
// CHECK-NEXT: return unsafe Span<CInt> (_unsafeStart: unsafe p.withUnsafeBufferPointer { _pPtr in
34-
// CHECK-NEXT: return unsafe lifetimeDependentCopy(_pPtr.baseAddress!, CInt(exactly: p.count)!, len2)
35-
// CHECK-NEXT: }, count: Int(len2))
33+
// CHECK-NEXT: return unsafe _swiftifyOverrideLifetime(Span<CInt> (_unsafeStart: unsafe p.withUnsafeBufferPointer { _pPtr in
34+
// CHECK-NEXT: return unsafe lifetimeDependentCopy(_pPtr.baseAddress!, CInt(exactly: _pPtr.count)!, len2)
35+
// CHECK-NEXT: }, count: Int(len2)), copying: ())
3636
// CHECK-NEXT: }
3737

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

test/Macros/SwiftifyImport/CountedBy/SimpleSpan.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
1010
// CHECK: @_alwaysEmitIntoClient
1111
// CHECK-NEXT: func myFunc(_ ptr: Span<CInt>) {
1212
// CHECK-NEXT: return unsafe ptr.withUnsafeBufferPointer { _ptrPtr in
13-
// CHECK-NEXT: return unsafe myFunc(_ptrPtr.baseAddress!, CInt(exactly: ptr.count)!)
13+
// CHECK-NEXT: return unsafe myFunc(_ptrPtr.baseAddress!, CInt(exactly: _ptrPtr.count)!)
1414
// CHECK-NEXT: }
1515
// CHECK-NEXT: }

test/Macros/SwiftifyImport/CountedBy/SimpleSpanWithReturn.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) -> CInt {
1010
// CHECK: @_alwaysEmitIntoClient
1111
// CHECK-NEXT: func myFunc(_ ptr: Span<CInt>) -> CInt {
1212
// CHECK-NEXT: return unsafe ptr.withUnsafeBufferPointer { _ptrPtr in
13-
// CHECK-NEXT: return unsafe myFunc(_ptrPtr.baseAddress!, CInt(exactly: ptr.count)!)
13+
// CHECK-NEXT: return unsafe myFunc(_ptrPtr.baseAddress!, CInt(exactly: _ptrPtr.count)!)
1414
// CHECK-NEXT: }
1515
// CHECK-NEXT: }

0 commit comments

Comments
 (0)