Skip to content

Commit 114a1a9

Browse files
committed
address review comments
1 parent 1773ea0 commit 114a1a9

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9145,7 +9145,8 @@ struct CountedByExpressionValidator
91459145
};
91469146
} // namespace
91479147

9148-
// don't try to transform any Swift types that _SwiftifyImport doesn't know how to handle
9148+
// Don't try to transform any Swift types that _SwiftifyImport doesn't know how
9149+
// to handle.
91499150
static bool SwiftifiableCountedByPointerType(Type swiftType) {
91509151
Type nonnullType = swiftType->lookThroughSingleOptionalType();
91519152
PointerTypeKind PTK;

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
#include <stdint.h>
44

5+
#ifndef __sized_by
56
#define __sized_by(x) __attribute__((__sized_by__(x)))
7+
#endif
68

79
void simple(int len, void * __sized_by(len) p);
810

@@ -24,8 +26,14 @@ void * __sized_by(len) returnPointer(int len);
2426
typedef struct foo opaque_t;
2527
void opaque(int len, opaque_t * __sized_by(len) p);
2628

29+
typedef opaque_t *opaqueptr_t;
30+
void opaqueptr(int len, opaqueptr_t __sized_by(len) p);
31+
2732
void charsized(char *__sized_by(size), int size);
2833

2934
uint8_t *__sized_by(size) bytesized(int size);
3035

31-
void doublebytesized(uint16_t *__sized_by(size), int size);
36+
void doublebytesized(uint16_t *__sized_by(size), int size);
37+
38+
typedef uint8_t * bytesizedptr_t;
39+
void aliasedBytesized(bytesizedptr_t __sized_by(size) p, int size);

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import SizedByClang
1010

1111

1212
// CHECK: /// This is an auto-generated wrapper for safer interop
13+
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func aliasedBytesized(_ p: UnsafeMutableRawBufferPointer)
14+
15+
// CHECK-NEXT: /// This is an auto-generated wrapper for safer interop
1316
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func bytesized(_ size: Int{{.*}}) -> UnsafeMutableRawBufferPointer
1417

1518
// CHECK-NEXT: /// This is an auto-generated wrapper for safer interop
@@ -30,6 +33,9 @@ import SizedByClang
3033
// CHECK-NEXT: /// This is an auto-generated wrapper for safer interop
3134
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func opaque(_ p: UnsafeRawBufferPointer)
3235

36+
// CHECK-NEXT: /// This is an auto-generated wrapper for safer interop
37+
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func opaqueptr(_ p: UnsafeRawBufferPointer)
38+
3339
// CHECK-NEXT: /// This is an auto-generated wrapper for safer interop
3440
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func returnPointer(_ len: Int{{.*}}) -> UnsafeMutableRawBufferPointer
3541

@@ -67,6 +73,11 @@ public func callOpaque(_ p: UnsafeRawBufferPointer) {
6773
unsafe opaque(p)
6874
}
6975

76+
@inlinable
77+
public func callOpaqueptr(_ p: UnsafeRawBufferPointer) {
78+
unsafe opaqueptr(p)
79+
}
80+
7081
@inlinable
7182
public func callReturnPointer() {
7283
let _: UnsafeMutableRawBufferPointer? = returnPointer(4) // call wrapper
@@ -97,3 +108,8 @@ public func callCharsized(_ p: UnsafeMutableRawBufferPointer) {
97108
public func callBytesized() {
98109
let _: UnsafeMutableRawBufferPointer = bytesized(37)
99110
}
111+
112+
@inlinable
113+
public func callAliasedBytesized(_ p: UnsafeMutableRawBufferPointer) {
114+
unsafe aliasedBytesized(p)
115+
}

0 commit comments

Comments
 (0)