Skip to content

Commit 80b1d92

Browse files
committed
Move @PointerBounds to stdlib core, support Implicitly Unwrapped types
1 parent ef164a8 commit 80b1d92

40 files changed

+37
-89
lines changed

lib/Macros/Sources/SwiftMacros/PointerBoundsMacro.swift

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ func transformType(_ prev: TypeSyntax, _ variant: Variant, _ isSizedBy: Bool) th
9797
if let optType = prev.as(OptionalTypeSyntax.self) {
9898
return TypeSyntax(optType.with(\.wrappedType, try transformType(optType.wrappedType, variant, isSizedBy)))
9999
}
100+
if let impOptType = prev.as(ImplicitlyUnwrappedOptionalTypeSyntax.self) {
101+
return try transformType(impOptType.wrappedType, variant, isSizedBy)
102+
}
100103
guard let idType = prev.as(IdentifierTypeSyntax.self) else {
101104
throw DiagnosticError("expected pointer type, got \(prev) with kind \(prev.kind)", node: prev)
102105
}

stdlib/private/StdlibUnittest/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ endif()
3232
if (SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING)
3333
list(APPEND swift_stdlib_unittest_modules "_StringProcessing")
3434
endif()
35-
if (SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS)
36-
list(APPEND swift_stdlib_unittest_modules "_PointerBounds")
37-
endif()
3835

3936
add_swift_target_library(swiftStdlibUnittest ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
4037
# This file should be listed the first. Module name is inferred from the

stdlib/public/CMakeLists.txt

-4
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,6 @@ if(SWIFT_BUILD_STDLIB)
279279
add_subdirectory(StringProcessing)
280280
add_subdirectory(RegexBuilder)
281281
endif()
282-
283-
if(SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS)
284-
add_subdirectory(PointerBounds)
285-
endif()
286282
endif()
287283

288284
if(SWIFT_BUILD_STDLIB AND NOT SWIFT_STDLIB_BUILD_ONLY_CORE_MODULES)

stdlib/public/PointerBounds/CMakeLists.txt

-13
This file was deleted.

stdlib/public/core/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ if(SWIFT_STDLIB_ENABLE_VECTOR_TYPES)
261261
list(APPEND SWIFTLIB_EMBEDDED_GYB_SOURCES SIMDConcreteOperations.swift.gyb SIMDVectorTypes.swift.gyb)
262262
endif()
263263

264+
if (SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS)
265+
list(APPEND SWIFTLIB_SOURCES PointerBounds.swift)
266+
list(APPEND SWIFTLIB_EMBEDDED_SOURCES PointerBounds.swift)
267+
endif()
268+
264269
# Freestanding and Linux/Android builds both have failures to resolve.
265270
if(NOT BOOTSTRAPPING_MODE STREQUAL "OFF" AND NOT SWIFT_FREESTANDING_FLAVOR AND NOT SWIFT_HOST_VARIANT_SDK STREQUAL "LINUX" AND NOT SWIFT_HOST_VARIANT_SDK STREQUAL "ANDROID")
266271
list(APPEND SWIFTLIB_SOURCES ObjectIdentifier+DebugDescription.swift)

stdlib/public/core/GroupInfo.json

+1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
],
191191
"Pointer": [
192192
"Pointer.swift",
193+
"PointerBounds.swift",
193194
"TemporaryAllocation.swift",
194195
"UnsafePointer.swift",
195196
"UnsafeRawPointer.swift",

stdlib/public/PointerBounds/PointerBounds.swift renamed to stdlib/public/core/PointerBounds.swift

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Swift
2-
31
/// Different ways to annotate pointer parameters using the `@PointerBounds` macro.
42
/// All indices into parameter lists start at 1. Indices __must__ be integer literals, and strings
53
/// __must__ be string literals, because their contents are parsed by the `@PointerBounds` macro.

test/Macros/PointerBounds/CountedBy/CountExpr.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.countedBy(pointer: 1, count: "size * count"))
97
func myFunc(_ ptr: UnsafePointer<CInt>, _ size: CInt, _ count: CInt) {
108
}

test/Macros/PointerBounds/CountedBy/MultipleParams.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.countedBy(pointer: 1, count: "len"), .countedBy(pointer: 3, count: "len2"))
97
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt, _ ptr2: UnsafePointer<CInt>, _ len2: CInt) {
108
}

test/Macros/PointerBounds/CountedBy/Mutable.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.countedBy(pointer: 1, count: "len"))
97
func myFunc(_ ptr: UnsafeMutablePointer<CInt>, _ len: CInt) {
108
}

test/Macros/PointerBounds/CountedBy/MutableSpan.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.countedBy(pointer: 1, count: "len"), .nonescaping(pointer: 1))
97
func myFunc(_ ptr: UnsafeMutablePointer<CInt>, _ len: CInt) {
108
}

test/Macros/PointerBounds/CountedBy/Nullable.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.countedBy(pointer: 1, count: "len"))
97
func myFunc(_ ptr: UnsafePointer<CInt>?, _ len: CInt) {
108
}

test/Macros/PointerBounds/CountedBy/Return.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.countedBy(pointer: 1, count: "len"))
97
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) -> CInt {
108
}

test/Macros/PointerBounds/CountedBy/SharedCount.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.countedBy(pointer: 1, count: "len"), .countedBy(pointer: 2, count: "len"))
97
func myFunc(_ ptr: UnsafePointer<CInt>, _ ptr2: UnsafePointer<CInt>, _ len: CInt) {
108
}

test/Macros/PointerBounds/CountedBy/SimpleCount.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.countedBy(pointer: 1, count: "len"))
97
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
108
}

test/Macros/PointerBounds/CountedBy/SimpleSpan.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.countedBy(pointer: 1, count: "len"), .nonescaping(pointer: 1))
97
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
108
}

test/Macros/PointerBounds/CountedBy/SimpleSpanWithReturn.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.countedBy(pointer: 1, count: "len"), .nonescaping(pointer: 1))
97
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) -> CInt {
108
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// REQUIRES: swift_swift_parser
2+
// REQUIRES: pointer_bounds
3+
4+
// 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 %s
5+
6+
@PointerBounds(.countedBy(pointer: 1, count: "len"))
7+
func myFunc(_ ptr: UnsafePointer<CInt>!, _ len: CInt) {
8+
}
9+
10+
// CHECK: @_alwaysEmitIntoClient
11+
// CHECK-NEXT: func myFunc(_ ptr: UnsafeBufferPointer<CInt>) {
12+
// CHECK-NEXT: myFunc(ptr.baseAddress!, CInt(exactly: ptr.count)!)
13+
// CHECK-NEXT: }
14+

test/Macros/PointerBounds/MacroErrors/ArrayType.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
55

6-
import _PointerBounds
7-
86
@PointerBounds(.countedBy(pointer: 1, count: "len"))
97
// expected-error@+1{{expected pointer type, got [CInt] with kind arrayType}}
108
func myFunc(_ ptr: [CInt], _ len: String) {

test/Macros/PointerBounds/MacroErrors/DynamicCountExpr.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
55

6-
import _PointerBounds
7-
86
let countString = "len"
97
// expected-error@+1{{expected string literal for 'count' parameter, got countString}}
108
@PointerBounds(.countedBy(pointer: 1, count: countString))

test/Macros/PointerBounds/MacroErrors/DynamicEnum.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
55

6-
import _PointerBounds
7-
86
let countedBy = PointerParam.countedBy(pointer: 1, count: "len")
97
// expected-error@+1{{expected PointerParam enum literal as argument, got 'countedBy'}}
108
@PointerBounds(countedBy)

test/Macros/PointerBounds/MacroErrors/DynamicPointerIndex.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
55

6-
import _PointerBounds
7-
86
let pointerIndex = 1
97
// expected-error@+1{{expected integer literal, got 'pointerIndex'}}
108
@PointerBounds(.countedBy(pointer: pointerIndex, count: "len"))

test/Macros/PointerBounds/MacroErrors/InvalidCount.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
55

6-
import _PointerBounds
7-
86
// expected-error@+1{{no parameter with name 'foo' in '_ ptr: UnsafePointer<CInt>, _ len: CInt'}}
97
@PointerBounds(.countedBy(pointer: 1, count: "foo"))
108
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {

test/Macros/PointerBounds/MacroErrors/PointerIndexOutOfBounds.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
55

6-
import _PointerBounds
7-
86
// expected-error@+1{{pointer index out of bounds}}
97
@PointerBounds(.countedBy(pointer: 3, count: "len"))
108
// expected-note@+1{{function myFunc has parameter indices 1..2}}

test/Macros/PointerBounds/MacroErrors/SamePointer.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir
55

6-
import _PointerBounds
7-
86
// expected-error@+1{{multiple PointerParams referring to parameter with index 1: .countedBy(pointer: 1, count: "dummy", nonescaping: false) and .countedBy(pointer: 1, count: "len", nonescaping: false)}}
97
@PointerBounds(.countedBy(pointer: 1, count: "len"), .countedBy(pointer: 1, count: "dummy"))
108
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt, _ dummy: CInt) {

test/Macros/PointerBounds/MacroErrors/UnexpectedCountExpr.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
55

6-
import _PointerBounds
7-
86
// expected-error@+1{{cannot convert value of type 'Int' to expected argument type 'String'}}
97
@PointerBounds(.countedBy(pointer: 1, count: 2))
108
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {

test/Macros/PointerBounds/MacroErrors/UnexpectedCountType.swift

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
// RUN: not %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 %s
77
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
88

9-
import _PointerBounds
10-
119
@PointerBounds(.countedBy(pointer: 1, count: "len"))
1210
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
1311
}

test/Macros/PointerBounds/MacroErrors/UnexpectedPointerType.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// RUN: %target-typecheck-verify-swift -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
55

6-
import _PointerBounds
7-
86
// expected-error@+2{{expected Unsafe[Mutable][Raw]Pointer type for type CInt - first type token is 'CInt'}}
97
@PointerBounds(.countedBy(pointer: 1, count: "len"))
108
func myFunc(_ ptr: CInt, _ len: CInt) {

test/Macros/PointerBounds/SizedBy/MultipleParams.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.sizedBy(pointer: 1, size: "size"), .sizedBy(pointer: 3, size: "size2"))
97
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt, _ ptr2: UnsafeRawPointer, _ size2: CInt) {
108
}

test/Macros/PointerBounds/SizedBy/Mutable.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.sizedBy(pointer: 1, size: "size"))
97
func myFunc(_ ptr: UnsafeMutableRawPointer, _ size: CInt) {
108
}

test/Macros/PointerBounds/SizedBy/MutableRawSpan.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.sizedBy(pointer: 1, size: "size"), .nonescaping(pointer: 1))
97
func myFunc(_ ptr: UnsafeMutableRawPointer, _ size: CInt) {
108
}

test/Macros/PointerBounds/SizedBy/Nullable.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.sizedBy(pointer: 1, size: "size"))
97
func myFunc(_ ptr: UnsafeRawPointer?, _ size: CInt) {
108
}

test/Macros/PointerBounds/SizedBy/Return.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.sizedBy(pointer: 1, size: "size"))
97
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) -> CInt {
108
}

test/Macros/PointerBounds/SizedBy/SharedCount.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.sizedBy(pointer: 1, size: "size"), .sizedBy(pointer: 2, size: "size"))
97
func myFunc(_ ptr: UnsafeRawPointer, _ ptr2: UnsafeRawPointer, _ size: CInt) {
108
}

test/Macros/PointerBounds/SizedBy/SimpleRawSpan.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.sizedBy(pointer: 1, size: "size"), .nonescaping(pointer: 1))
97
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) {
108
}

test/Macros/PointerBounds/SizedBy/SimpleRawSpanWithReturn.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.sizedBy(pointer: 1, size: "size"), .nonescaping(pointer: 1))
97
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) -> CInt {
108
}

test/Macros/PointerBounds/SizedBy/SimpleSize.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.sizedBy(pointer: 1, size: "size"))
97
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) {
108
}

test/Macros/PointerBounds/SizedBy/SizeExpr.swift

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// 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 %s
55

6-
import _PointerBounds
7-
86
@PointerBounds(.sizedBy(pointer: 1, size: "size * count"))
97
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt, _ count: CInt) {
108
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// REQUIRES: swift_swift_parser
2+
// REQUIRES: pointer_bounds
3+
4+
// 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 %s
5+
6+
@PointerBounds(.sizedBy(pointer: 1, size: "len"))
7+
func myFunc(_ ptr: UnsafeRawPointer!, _ len: CInt) {
8+
}
9+
10+
// CHECK: @_alwaysEmitIntoClient
11+
// CHECK-NEXT: func myFunc(_ ptr: UnsafeRawBufferPointer) {
12+
// CHECK-NEXT: myFunc(ptr.baseAddress!, CInt(exactly: ptr.count)!)
13+
// CHECK-NEXT: }
14+

test/lit.cfg

-7
Original file line numberDiff line numberDiff line change
@@ -2107,13 +2107,6 @@ config.substitutions.append(('%string_processing_module', string_processing_modu
21072107
config.substitutions.append(('%/string_processing_module',
21082108
'/'.join(os.path.normpath(string_processing_module).split(os.sep))))
21092109

2110-
# Add 'pointer_bounds_module' as the path to the _PointerBounds .swiftmodule file
2111-
pointer_bounds_module = os.path.join(stdlib_dir, "_PointerBounds.swiftmodule",
2112-
target_specific_module_triple + ".swiftmodule")
2113-
config.substitutions.append(('%pointer_bounds_module', pointer_bounds_module))
2114-
config.substitutions.append(('%/pointer_bounds_module',
2115-
'/'.join(os.path.normpath(pointer_bounds_module).split(os.sep))))
2116-
21172110
back_deployment_runtime = lit_config.params.get('back_deployment_runtime', None)
21182111
if back_deployment_runtime is not None:
21192112
config.available_features.add('back_deployment_runtime')

0 commit comments

Comments
 (0)