mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Rename pointer bounds (#78210)
* Make pointer bounds non-experimental * Rename @PointerBounds to @_SwiftifyImport * Rename filenames containing PointerBounds * Add _PointerParam exception to stdlib ABI test * Add _PointerParam to stdlib API changes * Rename _PointerParam to _SwiftifyInfo
This commit is contained in:
@@ -747,10 +747,6 @@ option(SWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION
|
|||||||
"Enable experimental SwiftParser validation by default"
|
"Enable experimental SwiftParser validation by default"
|
||||||
FALSE)
|
FALSE)
|
||||||
|
|
||||||
option(SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS
|
|
||||||
"Enable experimental safe wrappers around external functions"
|
|
||||||
FALSE)
|
|
||||||
|
|
||||||
cmake_dependent_option(SWIFT_BUILD_SOURCEKIT
|
cmake_dependent_option(SWIFT_BUILD_SOURCEKIT
|
||||||
"Build SourceKit" TRUE
|
"Build SourceKit" TRUE
|
||||||
"SWIFT_ENABLE_DISPATCH" FALSE)
|
"SWIFT_ENABLE_DISPATCH" FALSE)
|
||||||
@@ -1397,7 +1393,6 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
|
|||||||
message(STATUS "Observation Support: ${SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION}")
|
message(STATUS "Observation Support: ${SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION}")
|
||||||
message(STATUS "Synchronization Support: ${SWIFT_ENABLE_SYNCHRONIZATION}")
|
message(STATUS "Synchronization Support: ${SWIFT_ENABLE_SYNCHRONIZATION}")
|
||||||
message(STATUS "Volatile Support: ${SWIFT_ENABLE_VOLATILE}")
|
message(STATUS "Volatile Support: ${SWIFT_ENABLE_VOLATILE}")
|
||||||
message(STATUS "Pointer Bounds Support: ${SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS}")
|
|
||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
else()
|
else()
|
||||||
message(STATUS "Not building Swift standard library, SDK overlays, and runtime")
|
message(STATUS "Not building Swift standard library, SDK overlays, and runtime")
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
# Catalyst Support
|
# Catalyst Support
|
||||||
# -- Will need shadow invocations to generate swiftmodules for Swift parts
|
# -- Will need shadow invocations to generate swiftmodules for Swift parts
|
||||||
# Install *.abi.json, swiftdoc, and swiftsourceinfo
|
# Install *.abi.json, swiftdoc, and swiftsourceinfo
|
||||||
# Pointer bounds (SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS)
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.26...3.29)
|
cmake_minimum_required(VERSION 3.26...3.29)
|
||||||
|
|
||||||
|
|||||||
@@ -792,11 +792,6 @@ def enable_experimental_concise_pound_file : Flag<["-"],
|
|||||||
Flags<[FrontendOption, ModuleInterfaceOption]>,
|
Flags<[FrontendOption, ModuleInterfaceOption]>,
|
||||||
HelpText<"Enable experimental concise '#file' identifier">;
|
HelpText<"Enable experimental concise '#file' identifier">;
|
||||||
|
|
||||||
def enable_experimental_bounds_safety_interop :
|
|
||||||
Flag<["-"], "enable-experimental-bounds-safety-interop">,
|
|
||||||
Flags<[NoDriverOption, FrontendOption, HelpHidden, ModuleInterfaceOption]>,
|
|
||||||
HelpText<"Enable experimental C bounds safety interop code generation and config directives">;
|
|
||||||
|
|
||||||
def enable_experimental_cxx_interop :
|
def enable_experimental_cxx_interop :
|
||||||
Flag<["-"], "enable-experimental-cxx-interop">,
|
Flag<["-"], "enable-experimental-cxx-interop">,
|
||||||
Flags<[NoDriverOption, FrontendOption, HelpHidden]>,
|
Flags<[NoDriverOption, FrontendOption, HelpHidden]>,
|
||||||
|
|||||||
@@ -8673,16 +8673,16 @@ ClangImporter::Implementation::importSwiftAttrAttributes(Decl *MappedDecl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class PointerParamInfoPrinter {
|
class SwiftifyInfoPrinter {
|
||||||
public:
|
public:
|
||||||
clang::ASTContext &ctx;
|
clang::ASTContext &ctx;
|
||||||
llvm::raw_ostream &out;
|
llvm::raw_ostream &out;
|
||||||
bool firstParam = true;
|
bool firstParam = true;
|
||||||
PointerParamInfoPrinter(clang::ASTContext &ctx, llvm::raw_ostream &out)
|
SwiftifyInfoPrinter(clang::ASTContext &ctx, llvm::raw_ostream &out)
|
||||||
: ctx(ctx), out(out) {
|
: ctx(ctx), out(out) {
|
||||||
out << "@PointerBounds(";
|
out << "@_SwiftifyImport(";
|
||||||
}
|
}
|
||||||
~PointerParamInfoPrinter() { out << ")"; }
|
~SwiftifyInfoPrinter() { out << ")"; }
|
||||||
|
|
||||||
void printCountedBy(const clang::CountAttributedType *CAT,
|
void printCountedBy(const clang::CountAttributedType *CAT,
|
||||||
size_t pointerIndex) {
|
size_t pointerIndex) {
|
||||||
@@ -8725,7 +8725,7 @@ void ClangImporter::Implementation::importBoundsAttributes(
|
|||||||
{
|
{
|
||||||
llvm::raw_svector_ostream out(MacroString);
|
llvm::raw_svector_ostream out(MacroString);
|
||||||
|
|
||||||
PointerParamInfoPrinter printer(getClangASTContext(), out);
|
SwiftifyInfoPrinter printer(getClangASTContext(), out);
|
||||||
for (auto [index, param] : llvm::enumerate(ClangDecl->parameters())) {
|
for (auto [index, param] : llvm::enumerate(ClangDecl->parameters())) {
|
||||||
if (auto CAT = param->getType()->getAs<clang::CountAttributedType>()) {
|
if (auto CAT = param->getType()->getAs<clang::CountAttributedType>()) {
|
||||||
printer.printCountedBy(CAT, index);
|
printer.printCountedBy(CAT, index);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ add_swift_macro_library(SwiftMacros
|
|||||||
DistributedResolvableMacro.swift
|
DistributedResolvableMacro.swift
|
||||||
SyntaxExtensions.swift
|
SyntaxExtensions.swift
|
||||||
TaskLocalMacro.swift
|
TaskLocalMacro.swift
|
||||||
PointerBoundsMacro.swift
|
SwiftifyImportMacro.swift
|
||||||
SWIFT_DEPENDENCIES
|
SWIFT_DEPENDENCIES
|
||||||
SwiftDiagnostics
|
SwiftDiagnostics
|
||||||
SwiftSyntax
|
SwiftSyntax
|
||||||
|
|||||||
@@ -461,12 +461,12 @@ func getParameterIndexForDeclRef(
|
|||||||
/// Intended to map to C attributes like __counted_by, __ended_by and __no_escape,
|
/// Intended to map to C attributes like __counted_by, __ended_by and __no_escape,
|
||||||
/// for automatic application by ClangImporter when the C declaration is annotated
|
/// for automatic application by ClangImporter when the C declaration is annotated
|
||||||
/// appropriately.
|
/// appropriately.
|
||||||
public struct PointerBoundsMacro: PeerMacro {
|
public struct SwiftifyImportMacro: PeerMacro {
|
||||||
static func parseEnumName(_ enumConstructorExpr: FunctionCallExprSyntax) throws -> String {
|
static func parseEnumName(_ enumConstructorExpr: FunctionCallExprSyntax) throws -> String {
|
||||||
guard let calledExpr = enumConstructorExpr.calledExpression.as(MemberAccessExprSyntax.self)
|
guard let calledExpr = enumConstructorExpr.calledExpression.as(MemberAccessExprSyntax.self)
|
||||||
else {
|
else {
|
||||||
throw DiagnosticError(
|
throw DiagnosticError(
|
||||||
"expected PointerParam enum literal as argument, got '\(enumConstructorExpr)'",
|
"expected _SwiftifyInfo enum literal as argument, got '\(enumConstructorExpr)'",
|
||||||
node: enumConstructorExpr)
|
node: enumConstructorExpr)
|
||||||
}
|
}
|
||||||
return calledExpr.declName.baseName.text
|
return calledExpr.declName.baseName.text
|
||||||
@@ -564,7 +564,7 @@ public struct PointerBoundsMacro: PeerMacro {
|
|||||||
let paramExpr = paramAST.expression
|
let paramExpr = paramAST.expression
|
||||||
guard let enumConstructorExpr = paramExpr.as(FunctionCallExprSyntax.self) else {
|
guard let enumConstructorExpr = paramExpr.as(FunctionCallExprSyntax.self) else {
|
||||||
throw DiagnosticError(
|
throw DiagnosticError(
|
||||||
"expected PointerParam enum literal as argument, got '\(paramExpr)'", node: paramExpr)
|
"expected _SwiftifyInfo enum literal as argument, got '\(paramExpr)'", node: paramExpr)
|
||||||
}
|
}
|
||||||
let enumName = try parseEnumName(enumConstructorExpr)
|
let enumName = try parseEnumName(enumConstructorExpr)
|
||||||
switch enumName {
|
switch enumName {
|
||||||
@@ -627,7 +627,7 @@ public struct PointerBoundsMacro: PeerMacro {
|
|||||||
}
|
}
|
||||||
if argByIndex[i] != nil {
|
if argByIndex[i] != nil {
|
||||||
throw DiagnosticError(
|
throw DiagnosticError(
|
||||||
"multiple PointerParams referring to parameter with index "
|
"multiple _SwiftifyInfos referring to parameter with index "
|
||||||
+ "\(i): \(pointerArg) and \(argByIndex[i]!)", node: pointerArg.original)
|
+ "\(i): \(pointerArg) and \(argByIndex[i]!)", node: pointerArg.original)
|
||||||
}
|
}
|
||||||
argByIndex[i] = pointerArg
|
argByIndex[i] = pointerArg
|
||||||
@@ -647,7 +647,7 @@ public struct PointerBoundsMacro: PeerMacro {
|
|||||||
) throws -> [DeclSyntax] {
|
) throws -> [DeclSyntax] {
|
||||||
do {
|
do {
|
||||||
guard let funcDecl = declaration.as(FunctionDeclSyntax.self) else {
|
guard let funcDecl = declaration.as(FunctionDeclSyntax.self) else {
|
||||||
throw DiagnosticError("@PointerBounds only works on functions", node: declaration)
|
throw DiagnosticError("@_SwiftifyImport only works on functions", node: declaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
let argumentList = node.arguments!.as(LabeledExprListSyntax.self)!
|
let argumentList = node.arguments!.as(LabeledExprListSyntax.self)!
|
||||||
@@ -692,7 +692,7 @@ public struct PointerBoundsMacro: PeerMacro {
|
|||||||
case .attribute(let attr):
|
case .attribute(let attr):
|
||||||
// don't apply this macro recursively, and avoid dupe _alwaysEmitIntoClient
|
// don't apply this macro recursively, and avoid dupe _alwaysEmitIntoClient
|
||||||
let name = attr.attributeName.as(IdentifierTypeSyntax.self)?.name.text
|
let name = attr.attributeName.as(IdentifierTypeSyntax.self)?.name.text
|
||||||
return name == nil || (name != "PointerBounds" && name != "_alwaysEmitIntoClient")
|
return name == nil || (name != "_SwiftifyImport" && name != "_alwaysEmitIntoClient")
|
||||||
default: return true
|
default: return true
|
||||||
}
|
}
|
||||||
} + [
|
} + [
|
||||||
@@ -326,10 +326,6 @@ function(_add_target_variant_swift_compile_flags
|
|||||||
list(APPEND result "-D" "SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION")
|
list(APPEND result "-D" "SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS)
|
|
||||||
list(APPEND result "-D" "SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SWIFT_ENABLE_SYNCHRONIZATION)
|
if(SWIFT_ENABLE_SYNCHRONIZATION)
|
||||||
list(APPEND result "-D" "SWIFT_ENABLE_SYNCHRONIZATION")
|
list(APPEND result "-D" "SWIFT_ENABLE_SYNCHRONIZATION")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ split_embedded_sources(
|
|||||||
EMBEDDED Int128.swift
|
EMBEDDED Int128.swift
|
||||||
EMBEDDED Mirror.swift
|
EMBEDDED Mirror.swift
|
||||||
NORMAL PlaygroundDisplay.swift
|
NORMAL PlaygroundDisplay.swift
|
||||||
|
EMBEDDED SwiftifyImport.swift
|
||||||
NORMAL CommandLine.swift
|
NORMAL CommandLine.swift
|
||||||
EMBEDDED SliceBuffer.swift
|
EMBEDDED SliceBuffer.swift
|
||||||
EMBEDDED StaticBigInt.swift
|
EMBEDDED StaticBigInt.swift
|
||||||
@@ -263,11 +264,6 @@ if(SWIFT_STDLIB_ENABLE_VECTOR_TYPES)
|
|||||||
list(APPEND SWIFTLIB_EMBEDDED_GYB_SOURCES SIMDConcreteOperations.swift.gyb SIMDVectorTypes.swift.gyb)
|
list(APPEND SWIFTLIB_EMBEDDED_GYB_SOURCES SIMDConcreteOperations.swift.gyb SIMDVectorTypes.swift.gyb)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS)
|
|
||||||
list(APPEND SWIFTLIB_SOURCES PointerBounds.swift)
|
|
||||||
list(APPEND SWIFTLIB_EMBEDDED_SOURCES PointerBounds.swift)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Freestanding and Linux/Android builds both have failures to resolve.
|
# Freestanding and Linux/Android builds both have failures to resolve.
|
||||||
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")
|
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")
|
||||||
list(APPEND SWIFTLIB_SOURCES ObjectIdentifier+DebugDescription.swift)
|
list(APPEND SWIFTLIB_SOURCES ObjectIdentifier+DebugDescription.swift)
|
||||||
|
|||||||
@@ -190,7 +190,7 @@
|
|||||||
],
|
],
|
||||||
"Pointer": [
|
"Pointer": [
|
||||||
"Pointer.swift",
|
"Pointer.swift",
|
||||||
"PointerBounds.swift",
|
"SwiftifyImport.swift",
|
||||||
"TemporaryAllocation.swift",
|
"TemporaryAllocation.swift",
|
||||||
"UnsafePointer.swift",
|
"UnsafePointer.swift",
|
||||||
"UnsafeRawPointer.swift",
|
"UnsafeRawPointer.swift",
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
/// Different ways to annotate pointer parameters using the `@PointerBounds` macro.
|
/// Different ways to annotate pointer parameters using the `@_SwiftifyImport` macro.
|
||||||
/// All indices into parameter lists start at 1. Indices __must__ be integer literals, and strings
|
/// All indices into parameter lists start at 1. Indices __must__ be integer literals, and strings
|
||||||
/// __must__ be string literals, because their contents are parsed by the `@PointerBounds` macro.
|
/// __must__ be string literals, because their contents are parsed by the `@_SwiftifyImport` macro.
|
||||||
/// Only 1 instance of `countedBy`, `sizedBy` or `endedBy` can refer to each pointer index, however
|
/// Only 1 instance of `countedBy`, `sizedBy` or `endedBy` can refer to each pointer index, however
|
||||||
/// `nonescaping` is orthogonal to the rest and can (and should) overlap with other annotations.
|
/// `nonescaping` is orthogonal to the rest and can (and should) overlap with other annotations.
|
||||||
public enum PointerParam {
|
///
|
||||||
|
/// This is not marked @available, because _SwiftifyImport is available for any target. Instances
|
||||||
|
/// of _SwiftifyInfo should ONLY be passed as arguments directly to _SwiftifyImport, so they should
|
||||||
|
/// not affect linkage since there are never any instances at runtime.
|
||||||
|
public enum _SwiftifyInfo {
|
||||||
/// Corresponds to the C `__counted_by(count)` attribute.
|
/// Corresponds to the C `__counted_by(count)` attribute.
|
||||||
/// Parameter pointer: index of pointer in function parameter list. Must be of type
|
/// Parameter pointer: index of pointer in function parameter list. Must be of type
|
||||||
/// `Unsafe[Mutable]Pointer<T>[?]`, i.e. not an `UnsafeRawPointer`.
|
/// `Unsafe[Mutable]Pointer<T>[?]`, i.e. not an `UnsafeRawPointer`.
|
||||||
@@ -40,5 +44,5 @@ public enum PointerParam {
|
|||||||
/// Parameter paramInfo: information about how the function uses the pointer passed to it. The
|
/// Parameter paramInfo: information about how the function uses the pointer passed to it. The
|
||||||
/// safety of the generated wrapper function depends on this info being extensive and accurate.
|
/// safety of the generated wrapper function depends on this info being extensive and accurate.
|
||||||
@attached(peer, names: overloaded)
|
@attached(peer, names: overloaded)
|
||||||
public macro PointerBounds(_ paramInfo: PointerParam...) =
|
public macro _SwiftifyImport(_ paramInfo: _SwiftifyInfo...) =
|
||||||
#externalMacro(module: "SwiftMacros", type: "PointerBoundsMacro")
|
#externalMacro(module: "SwiftMacros", type: "SwiftifyImportMacro")
|
||||||
@@ -457,10 +457,6 @@ foreach(SDK ${SWIFT_SDKS})
|
|||||||
list(APPEND LIT_ARGS "--param" "string_processing")
|
list(APPEND LIT_ARGS "--param" "string_processing")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS)
|
|
||||||
list(APPEND LIT_ARGS "--param" "pointer_bounds")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SWIFT_ENABLE_BACKTRACING)
|
if(SWIFT_ENABLE_BACKTRACING)
|
||||||
list(APPEND LIT_ARGS "--param" "backtracing")
|
list(APPEND LIT_ARGS "--param" "backtracing")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
void simple(int len, int * __counted_by(len) p);
|
void simple(int len, int * __counted_by(len) p);
|
||||||
|
|
||||||
void swiftAttr(int len, int * p) __attribute__((swift_attr("@PointerBounds(.countedBy(pointer: 2, count: \"len\"))")));
|
void swiftAttr(int len, int *p) __attribute__((
|
||||||
|
swift_attr("@_SwiftifyImport(.countedBy(pointer: 2, count: \"len\"))")));
|
||||||
|
|
||||||
void shared(int len, int * __counted_by(len) p1, int * __counted_by(len) p2);
|
void shared(int len, int * __counted_by(len) p1, int * __counted_by(len) p2);
|
||||||
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
// REQUIRES: swift_feature_SafeInteropWrappers
|
// REQUIRES: swift_feature_SafeInteropWrappers
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// RUN: %empty-directory(%t)
|
// RUN: %empty-directory(%t)
|
||||||
// RUN: %target-swift-frontend -emit-module -disable-availability-checking -plugin-path %swift-plugin-dir -o %t/CountedBy.swiftmodule -I %S/Inputs -enable-experimental-feature SafeInteropWrappers %s
|
// RUN: %target-swift-frontend -emit-module -disable-availability-checking -plugin-path %swift-plugin-dir -o %t/CountedBy.swiftmodule -I %S/Inputs -enable-experimental-feature SafeInteropWrappers %s
|
||||||
|
|
||||||
// Check that ClangImporter correctly infers and expands @PointerBounds macros for functions with __counted_by parameters.
|
// Check that ClangImporter correctly infers and expands @_SwiftifyImport macros for functions with __counted_by parameters.
|
||||||
|
|
||||||
import CountedByClang
|
import CountedByClang
|
||||||
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir
|
|
||||||
|
|
||||||
// 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)}}
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"), .countedBy(pointer: 1, count: "dummy"))
|
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt, _ dummy: CInt) {
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "size * count"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "size * count"))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ size: CInt, _ count: CInt) {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ size: CInt, _ count: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"), .countedBy(pointer: 3, count: "len2"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"), .countedBy(pointer: 3, count: "len2"))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt, _ ptr2: UnsafePointer<CInt>, _ len2: CInt) {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt, _ ptr2: UnsafePointer<CInt>, _ len2: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"))
|
||||||
func myFunc(_ ptr: UnsafeMutablePointer<CInt>, _ len: CInt) {
|
func myFunc(_ ptr: UnsafeMutablePointer<CInt>, _ len: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
// REQUIRES: swift_feature_Span
|
// REQUIRES: swift_feature_Span
|
||||||
|
|
||||||
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span > %t.log 2>&1
|
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span > %t.log 2>&1
|
||||||
// RUN: %FileCheck --match-full-lines %s < %t.log
|
// RUN: %FileCheck --match-full-lines %s < %t.log
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"), .nonescaping(pointer: 1))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"), .nonescaping(pointer: 1))
|
||||||
func myFunc(_ ptr: UnsafeMutablePointer<CInt>, _ len: CInt) {
|
func myFunc(_ ptr: UnsafeMutablePointer<CInt>, _ len: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>?, _ len: CInt) {
|
func myFunc(_ ptr: UnsafePointer<CInt>?, _ len: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"))
|
||||||
func foo(_ ptr: Swift.UnsafePointer<Swift.Int>, _ len: Swift.Int) -> Swift.Void {
|
func foo(_ ptr: Swift.UnsafePointer<Swift.Int>, _ len: Swift.Int) -> Swift.Void {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"))
|
||||||
func bar(_ ptr: Swift.UnsafePointer<Swift.CInt>, _ len: Swift.Int) -> () {
|
func bar(_ ptr: Swift.UnsafePointer<Swift.CInt>, _ len: Swift.Int) -> () {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) -> CInt {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) -> CInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"), .countedBy(pointer: 2, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"), .countedBy(pointer: 2, count: "len"))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ ptr2: UnsafePointer<CInt>, _ len: CInt) {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ ptr2: UnsafePointer<CInt>, _ len: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
// REQUIRES: swift_feature_Span
|
// REQUIRES: swift_feature_Span
|
||||||
|
|
||||||
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
|
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"), .nonescaping(pointer: 1))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"), .nonescaping(pointer: 1))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
// REQUIRES: swift_feature_Span
|
// REQUIRES: swift_feature_Span
|
||||||
|
|
||||||
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
|
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"), .nonescaping(pointer: 1))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"), .nonescaping(pointer: 1))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) -> CInt {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) -> CInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>!, _ len: CInt) {
|
func myFunc(_ ptr: UnsafePointer<CInt>!, _ len: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"))
|
||||||
// expected-error@+1{{expected pointer type, got [CInt] with kind arrayType}}
|
// expected-error@+1{{expected pointer type, got [CInt] with kind arrayType}}
|
||||||
func myFunc(_ ptr: [CInt], _ len: String) {
|
func myFunc(_ ptr: [CInt], _ len: String) {
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
||||||
|
|
||||||
let countString = "len"
|
let countString = "len"
|
||||||
// expected-error@+1{{expected string literal for 'count' parameter, got countString}}
|
// expected-error@+1{{expected string literal for 'count' parameter, got countString}}
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: countString))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: countString))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
||||||
|
|
||||||
let countedBy = PointerParam.countedBy(pointer: 1, count: "len")
|
let countedBy = _SwiftifyInfo.countedBy(pointer: 1, count: "len")
|
||||||
// expected-error@+1{{expected PointerParam enum literal as argument, got 'countedBy'}}
|
// expected-error@+1{{expected _SwiftifyInfo enum literal as argument, got 'countedBy'}}
|
||||||
@PointerBounds(countedBy)
|
@_SwiftifyImport(countedBy)
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
||||||
|
|
||||||
let pointerIndex = 1
|
let pointerIndex = 1
|
||||||
// expected-error@+1{{expected integer literal, got 'pointerIndex'}}
|
// expected-error@+1{{expected integer literal, got 'pointerIndex'}}
|
||||||
@PointerBounds(.countedBy(pointer: pointerIndex, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: pointerIndex, count: "len"))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
||||||
|
|
||||||
// expected-error@+1{{no parameter with name 'foo' in '_ ptr: UnsafePointer<CInt>, _ len: CInt'}}
|
// expected-error@+1{{no parameter with name 'foo' in '_ ptr: UnsafePointer<CInt>, _ len: CInt'}}
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "foo"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "foo"))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,19 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
||||||
|
|
||||||
// expected-error@+1{{pointer index out of bounds}}
|
// expected-error@+1{{pointer index out of bounds}}
|
||||||
@PointerBounds(.countedBy(pointer: 3, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 3, count: "len"))
|
||||||
// expected-note@+1{{function myFunc has parameter indices 1..2}}
|
// expected-note@+1{{function myFunc has parameter indices 1..2}}
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
|
||||||
}
|
}
|
||||||
// expected-error@+1{{pointer index out of bounds}}
|
// expected-error@+1{{pointer index out of bounds}}
|
||||||
@PointerBounds(.countedBy(pointer: 0, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 0, count: "len"))
|
||||||
// expected-note@+1{{function myFunc2 has parameter indices 1..2}}
|
// expected-note@+1{{function myFunc2 has parameter indices 1..2}}
|
||||||
func myFunc2(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
|
func myFunc2(_ ptr: UnsafePointer<CInt>, _ len: CInt) {
|
||||||
}
|
}
|
||||||
// expected-error@+1{{pointer index out of bounds}}
|
// expected-error@+1{{pointer index out of bounds}}
|
||||||
@PointerBounds(.countedBy(pointer: 0, count: "1"))
|
@_SwiftifyImport(.countedBy(pointer: 0, count: "1"))
|
||||||
// expected-note@+1{{function myFunc3 has no parameters}}
|
// expected-note@+1{{function myFunc3 has no parameters}}
|
||||||
func myFunc3() {
|
func myFunc3() {
|
||||||
}
|
}
|
||||||
8
test/Macros/SwiftifyImport/MacroErrors/SamePointer.swift
Normal file
8
test/Macros/SwiftifyImport/MacroErrors/SamePointer.swift
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// REQUIRES: swift_swift_parser
|
||||||
|
|
||||||
|
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir
|
||||||
|
|
||||||
|
// expected-error@+1{{multiple _SwiftifyInfos referring to parameter with index 1: .countedBy(pointer: 1, count: "dummy", nonescaping: false) and .countedBy(pointer: 1, count: "len", nonescaping: false)}}
|
||||||
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"), .countedBy(pointer: 1, count: "dummy"))
|
||||||
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: CInt, _ dummy: CInt) {
|
||||||
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
||||||
|
|
||||||
// expected-error@+1{{cannot convert value of type 'Int' to expected argument type 'String'}}
|
// expected-error@+1{{cannot convert value of type 'Int' to expected argument type 'String'}}
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: 2))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: 2))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// XFAIL: *
|
// XFAIL: *
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
||||||
|
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"))
|
||||||
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
|
func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,4 +14,4 @@ func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
|
|||||||
// CHECK-NEXT: myFunc(ptr.baseAddress!, String(exactly: ptr.count)!)
|
// CHECK-NEXT: myFunc(ptr.baseAddress!, String(exactly: ptr.count)!)
|
||||||
// CHECK-NEXT: }
|
// CHECK-NEXT: }
|
||||||
|
|
||||||
// expected-error@PointerBounds:2{{no exact matches in call to initializer}}
|
// expected-error@_SwiftifyImport:2{{no exact matches in call to initializer}}
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// RUN: %target-typecheck-verify-swift -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
// RUN: %target-typecheck-verify-swift -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify
|
||||||
|
|
||||||
// expected-error@+2{{expected Unsafe[Mutable][Raw]Pointer type for type CInt - first type token is 'CInt'}}
|
// expected-error@+2{{expected Unsafe[Mutable][Raw]Pointer type for type CInt - first type token is 'CInt'}}
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"))
|
||||||
func myFunc(_ ptr: CInt, _ len: CInt) {
|
func myFunc(_ ptr: CInt, _ len: CInt) {
|
||||||
}
|
}
|
||||||
// expected-error@+2{{expected Unsafe[Mutable][Raw]Pointer type for type UnsafeBufferPointer<CInt> - first type token is 'UnsafeBufferPointer'}}
|
// expected-error@+2{{expected Unsafe[Mutable][Raw]Pointer type for type UnsafeBufferPointer<CInt> - first type token is 'UnsafeBufferPointer'}}
|
||||||
@PointerBounds(.countedBy(pointer: 1, count: "len"))
|
@_SwiftifyImport(.countedBy(pointer: 1, count: "len"))
|
||||||
func myFunc2(_ ptr: UnsafeBufferPointer<CInt>, _ len: CInt) {
|
func myFunc2(_ ptr: UnsafeBufferPointer<CInt>, _ len: CInt) {
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.sizedBy(pointer: 1, size: "size"), .sizedBy(pointer: 3, size: "size2"))
|
@_SwiftifyImport(.sizedBy(pointer: 1, size: "size"), .sizedBy(pointer: 3, size: "size2"))
|
||||||
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt, _ ptr2: UnsafeRawPointer, _ size2: CInt) {
|
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt, _ ptr2: UnsafeRawPointer, _ size2: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.sizedBy(pointer: 1, size: "size"))
|
@_SwiftifyImport(.sizedBy(pointer: 1, size: "size"))
|
||||||
func myFunc(_ ptr: UnsafeMutableRawPointer, _ size: CInt) {
|
func myFunc(_ ptr: UnsafeMutableRawPointer, _ size: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
// REQUIRES: swift_feature_Span
|
// REQUIRES: swift_feature_Span
|
||||||
|
|
||||||
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span > %t.log 2>&1
|
// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span > %t.log 2>&1
|
||||||
// RUN: %FileCheck --match-full-lines %s < %t.log
|
// RUN: %FileCheck --match-full-lines %s < %t.log
|
||||||
|
|
||||||
@PointerBounds(.sizedBy(pointer: 1, size: "size"), .nonescaping(pointer: 1))
|
@_SwiftifyImport(.sizedBy(pointer: 1, size: "size"), .nonescaping(pointer: 1))
|
||||||
func myFunc(_ ptr: UnsafeMutableRawPointer, _ size: CInt) {
|
func myFunc(_ ptr: UnsafeMutableRawPointer, _ size: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.sizedBy(pointer: 1, size: "size"))
|
@_SwiftifyImport(.sizedBy(pointer: 1, size: "size"))
|
||||||
func myFunc(_ ptr: UnsafeRawPointer?, _ size: CInt) {
|
func myFunc(_ ptr: UnsafeRawPointer?, _ size: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.sizedBy(pointer: 1, size: "size"))
|
@_SwiftifyImport(.sizedBy(pointer: 1, size: "size"))
|
||||||
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) -> CInt {
|
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) -> CInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.sizedBy(pointer: 1, size: "size"), .sizedBy(pointer: 2, size: "size"))
|
@_SwiftifyImport(.sizedBy(pointer: 1, size: "size"), .sizedBy(pointer: 2, size: "size"))
|
||||||
func myFunc(_ ptr: UnsafeRawPointer, _ ptr2: UnsafeRawPointer, _ size: CInt) {
|
func myFunc(_ ptr: UnsafeRawPointer, _ ptr2: UnsafeRawPointer, _ size: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
// REQUIRES: swift_feature_Span
|
// REQUIRES: swift_feature_Span
|
||||||
|
|
||||||
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
|
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.sizedBy(pointer: 1, size: "size"), .nonescaping(pointer: 1))
|
@_SwiftifyImport(.sizedBy(pointer: 1, size: "size"), .nonescaping(pointer: 1))
|
||||||
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) {
|
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
// REQUIRES: swift_feature_Span
|
// REQUIRES: swift_feature_Span
|
||||||
|
|
||||||
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
|
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -enable-experimental-feature Span 2>&1 | %FileCheck --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.sizedBy(pointer: 1, size: "size"), .nonescaping(pointer: 1))
|
@_SwiftifyImport(.sizedBy(pointer: 1, size: "size"), .nonescaping(pointer: 1))
|
||||||
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) -> CInt {
|
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) -> CInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.sizedBy(pointer: 1, size: "size"))
|
@_SwiftifyImport(.sizedBy(pointer: 1, size: "size"))
|
||||||
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) {
|
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.sizedBy(pointer: 1, size: "size * count"))
|
@_SwiftifyImport(.sizedBy(pointer: 1, size: "size * count"))
|
||||||
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt, _ count: CInt) {
|
func myFunc(_ ptr: UnsafeRawPointer, _ size: CInt, _ count: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
// REQUIRES: swift_swift_parser
|
// REQUIRES: swift_swift_parser
|
||||||
// REQUIRES: pointer_bounds
|
|
||||||
|
|
||||||
// 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 --match-full-lines %s
|
// 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 --match-full-lines %s
|
||||||
|
|
||||||
@PointerBounds(.sizedBy(pointer: 1, size: "len"))
|
@_SwiftifyImport(.sizedBy(pointer: 1, size: "len"))
|
||||||
func myFunc(_ ptr: UnsafeRawPointer!, _ len: CInt) {
|
func myFunc(_ ptr: UnsafeRawPointer!, _ len: CInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -797,3 +797,13 @@ Added: _$ss7RawSpanV9byteCountSivpMV
|
|||||||
Added: _$ss7RawSpanVMa
|
Added: _$ss7RawSpanVMa
|
||||||
Added: _$ss7RawSpanVMn
|
Added: _$ss7RawSpanVMn
|
||||||
Added: _$ss7RawSpanVN
|
Added: _$ss7RawSpanVN
|
||||||
|
|
||||||
|
// _SwiftifyInfo enum for _SwiftifyImports macro
|
||||||
|
Added: _$ss13_SwiftifyInfoO11nonescapingyABSi_tcABmFWC
|
||||||
|
Added: _$ss13_SwiftifyInfoO7endedByyABSi_SitcABmFWC
|
||||||
|
Added: _$ss13_SwiftifyInfoO7sizedByyABSi_SStcABmFWC
|
||||||
|
Added: _$ss13_SwiftifyInfoO9countedByyABSi_SStcABmFWC
|
||||||
|
Added: _$ss13_SwiftifyInfoOMa
|
||||||
|
Added: _$ss13_SwiftifyInfoOMn
|
||||||
|
Added: _$ss13_SwiftifyInfoON
|
||||||
|
|
||||||
|
|||||||
@@ -798,3 +798,13 @@ Added: _$ss7RawSpanV9byteCountSivpMV
|
|||||||
Added: _$ss7RawSpanVMa
|
Added: _$ss7RawSpanVMa
|
||||||
Added: _$ss7RawSpanVMn
|
Added: _$ss7RawSpanVMn
|
||||||
Added: _$ss7RawSpanVN
|
Added: _$ss7RawSpanVN
|
||||||
|
|
||||||
|
// _SwiftifyInfo enum for _SwiftifyImports macro
|
||||||
|
Added: _$ss13_SwiftifyInfoO11nonescapingyABSi_tcABmFWC
|
||||||
|
Added: _$ss13_SwiftifyInfoO7endedByyABSi_SitcABmFWC
|
||||||
|
Added: _$ss13_SwiftifyInfoO7sizedByyABSi_SStcABmFWC
|
||||||
|
Added: _$ss13_SwiftifyInfoO9countedByyABSi_SStcABmFWC
|
||||||
|
Added: _$ss13_SwiftifyInfoOMa
|
||||||
|
Added: _$ss13_SwiftifyInfoOMn
|
||||||
|
Added: _$ss13_SwiftifyInfoON
|
||||||
|
|
||||||
|
|||||||
@@ -822,4 +822,5 @@ Func _SliceBuffer.withUnsafeMutableBufferPointer(_:) has mangled name changing f
|
|||||||
|
|
||||||
Struct String.Index has added a conformance to an existing protocol CustomDebugStringConvertible
|
Struct String.Index has added a conformance to an existing protocol CustomDebugStringConvertible
|
||||||
|
|
||||||
|
Enum _SwiftifyInfo is a new API without @available attribute
|
||||||
// *** DO NOT DISABLE OR XFAIL THIS TEST. *** (See comment above.)
|
// *** DO NOT DISABLE OR XFAIL THIS TEST. *** (See comment above.)
|
||||||
|
|||||||
@@ -156,8 +156,6 @@ if "@SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING@" == "TRUE":
|
|||||||
config.available_features.add('string_processing')
|
config.available_features.add('string_processing')
|
||||||
if "@SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION@" == "TRUE":
|
if "@SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION@" == "TRUE":
|
||||||
config.available_features.add('observation')
|
config.available_features.add('observation')
|
||||||
if "@SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS@" == "TRUE":
|
|
||||||
config.available_features.add('pointer_bounds')
|
|
||||||
if "@SWIFT_STDLIB_ENABLE_DEBUG_PRECONDITIONS_IN_RELEASE@" == "TRUE":
|
if "@SWIFT_STDLIB_ENABLE_DEBUG_PRECONDITIONS_IN_RELEASE@" == "TRUE":
|
||||||
config.available_features.add('swift_stdlib_debug_preconditions_in_release')
|
config.available_features.add('swift_stdlib_debug_preconditions_in_release')
|
||||||
if "@SWIFT_ENABLE_VOLATILE@" == "TRUE":
|
if "@SWIFT_ENABLE_VOLATILE@" == "TRUE":
|
||||||
|
|||||||
@@ -2092,13 +2092,6 @@ for host in "${ALL_HOSTS[@]}"; do
|
|||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS}" ]] ; then
|
|
||||||
cmake_options=(
|
|
||||||
"${cmake_options[@]}"
|
|
||||||
-DSWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS:BOOL=$(true_false "${SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS}")
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# SWIFT_THREADING_PACKAGE can be:
|
# SWIFT_THREADING_PACKAGE can be:
|
||||||
#
|
#
|
||||||
# - Empty
|
# - Empty
|
||||||
|
|||||||
@@ -1524,7 +1524,6 @@ function Build-Compilers() {
|
|||||||
SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED = "YES";
|
SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED = "YES";
|
||||||
SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION = "YES";
|
SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION = "YES";
|
||||||
SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING = "YES";
|
SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING = "YES";
|
||||||
SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS = "YES";
|
|
||||||
SWIFT_ENABLE_SYNCHRONIZATION = "YES";
|
SWIFT_ENABLE_SYNCHRONIZATION = "YES";
|
||||||
SWIFT_ENABLE_VOLATILE = "YES";
|
SWIFT_ENABLE_VOLATILE = "YES";
|
||||||
SWIFT_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
|
SWIFT_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch";
|
||||||
@@ -1835,7 +1834,6 @@ function Build-Runtime([Platform]$Platform, $Arch) {
|
|||||||
SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED = "YES";
|
SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED = "YES";
|
||||||
SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION = "YES";
|
SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION = "YES";
|
||||||
SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING = "YES";
|
SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING = "YES";
|
||||||
SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS = "YES";
|
|
||||||
SWIFT_ENABLE_SYNCHRONIZATION = "YES";
|
SWIFT_ENABLE_SYNCHRONIZATION = "YES";
|
||||||
SWIFT_ENABLE_VOLATILE = "YES";
|
SWIFT_ENABLE_VOLATILE = "YES";
|
||||||
SWIFT_NATIVE_SWIFT_TOOLS_PATH = (Join-Path -Path $CompilersBinaryCache -ChildPath "bin");
|
SWIFT_NATIVE_SWIFT_TOOLS_PATH = (Join-Path -Path $CompilersBinaryCache -ChildPath "bin");
|
||||||
|
|||||||
@@ -1493,10 +1493,6 @@ def create_argument_parser():
|
|||||||
default=True,
|
default=True,
|
||||||
help='Enable experimental Swift Parser validation by default.')
|
help='Enable experimental Swift Parser validation by default.')
|
||||||
|
|
||||||
option('--enable-experimental-pointer-bounds', toggle_true,
|
|
||||||
default=False,
|
|
||||||
help='Enable experimental bounds safe C interop.')
|
|
||||||
|
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
in_group('Unsupported options')
|
in_group('Unsupported options')
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,6 @@ EXPECTED_DEFAULTS = {
|
|||||||
'enable_experimental_string_processing': True,
|
'enable_experimental_string_processing': True,
|
||||||
'enable_experimental_observation': True,
|
'enable_experimental_observation': True,
|
||||||
'enable_experimental_parser_validation': True,
|
'enable_experimental_parser_validation': True,
|
||||||
'enable_experimental_pointer_bounds': False,
|
|
||||||
'swift_enable_backtracing': True,
|
'swift_enable_backtracing': True,
|
||||||
'enable_synchronization': True,
|
'enable_synchronization': True,
|
||||||
'enable_volatile': True,
|
'enable_volatile': True,
|
||||||
@@ -628,7 +627,6 @@ EXPECTED_OPTIONS = [
|
|||||||
EnableOption('--enable-experimental-string-processing'),
|
EnableOption('--enable-experimental-string-processing'),
|
||||||
EnableOption('--enable-experimental-observation'),
|
EnableOption('--enable-experimental-observation'),
|
||||||
EnableOption('--enable-experimental-parser-validation'),
|
EnableOption('--enable-experimental-parser-validation'),
|
||||||
EnableOption('--enable-experimental-pointer-bounds'),
|
|
||||||
EnableOption('--enable-lsan'),
|
EnableOption('--enable-lsan'),
|
||||||
EnableOption('--enable-sanitize-coverage'),
|
EnableOption('--enable-sanitize-coverage'),
|
||||||
EnableOption('--enable-tsan'),
|
EnableOption('--enable-tsan'),
|
||||||
|
|||||||
@@ -104,8 +104,6 @@ class MinimalStdlib(cmake_product.CMakeProduct):
|
|||||||
'SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL', 'FALSE')
|
'SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL', 'FALSE')
|
||||||
self.cmake_options.define(
|
self.cmake_options.define(
|
||||||
'SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL', 'FALSE')
|
'SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL', 'FALSE')
|
||||||
self.cmake_options.define(
|
|
||||||
'SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS:BOOL', 'FALSE')
|
|
||||||
self.cmake_options.define('SWIFT_ENABLE_REFLECTION:BOOL', 'FALSE')
|
self.cmake_options.define('SWIFT_ENABLE_REFLECTION:BOOL', 'FALSE')
|
||||||
self.cmake_options.define(
|
self.cmake_options.define(
|
||||||
'SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS:BOOL', 'FALSE')
|
'SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS:BOOL', 'FALSE')
|
||||||
|
|||||||
@@ -57,9 +57,6 @@ class Swift(product.Product):
|
|||||||
self.cmake_options.extend(self._enable_experimental_cxx_interop)
|
self.cmake_options.extend(self._enable_experimental_cxx_interop)
|
||||||
self.cmake_options.extend(self._enable_cxx_interop_swift_bridging_header)
|
self.cmake_options.extend(self._enable_cxx_interop_swift_bridging_header)
|
||||||
|
|
||||||
# Add experimental c interop flag.
|
|
||||||
self.cmake_options.extend(self._enable_experimental_pointer_bounds)
|
|
||||||
|
|
||||||
# Add experimental distributed flag.
|
# Add experimental distributed flag.
|
||||||
self.cmake_options.extend(self._enable_experimental_distributed)
|
self.cmake_options.extend(self._enable_experimental_distributed)
|
||||||
|
|
||||||
@@ -218,11 +215,6 @@ updated without updating swift.py?")
|
|||||||
return [('SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL',
|
return [('SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL',
|
||||||
self.args.enable_experimental_observation)]
|
self.args.enable_experimental_observation)]
|
||||||
|
|
||||||
@property
|
|
||||||
def _enable_experimental_pointer_bounds(self):
|
|
||||||
return [('SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS:BOOL',
|
|
||||||
self.args.enable_experimental_pointer_bounds)]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _enable_synchronization(self):
|
def _enable_synchronization(self):
|
||||||
return [('SWIFT_ENABLE_SYNCHRONIZATION:BOOL',
|
return [('SWIFT_ENABLE_SYNCHRONIZATION:BOOL',
|
||||||
|
|||||||
@@ -164,8 +164,6 @@ class WasmStdlib(cmake_product.CMakeProduct):
|
|||||||
self.cmake_options.define('SWIFT_ENABLE_SYNCHRONIZATION:BOOL', 'TRUE')
|
self.cmake_options.define('SWIFT_ENABLE_SYNCHRONIZATION:BOOL', 'TRUE')
|
||||||
self.cmake_options.define('SWIFT_ENABLE_VOLATILE:BOOL', 'TRUE')
|
self.cmake_options.define('SWIFT_ENABLE_VOLATILE:BOOL', 'TRUE')
|
||||||
self.cmake_options.define('SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL', 'TRUE')
|
self.cmake_options.define('SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL', 'TRUE')
|
||||||
self.cmake_options.define('SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS:BOOL',
|
|
||||||
'TRUE')
|
|
||||||
|
|
||||||
self.add_extra_cmake_options()
|
self.add_extra_cmake_options()
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ class SwiftTestCase(unittest.TestCase):
|
|||||||
enable_experimental_distributed=False,
|
enable_experimental_distributed=False,
|
||||||
enable_experimental_observation=False,
|
enable_experimental_observation=False,
|
||||||
enable_experimental_parser_validation=False,
|
enable_experimental_parser_validation=False,
|
||||||
enable_experimental_pointer_bounds=False,
|
|
||||||
swift_enable_backtracing=False,
|
swift_enable_backtracing=False,
|
||||||
enable_synchronization=False,
|
enable_synchronization=False,
|
||||||
enable_volatile=False,
|
enable_volatile=False,
|
||||||
@@ -110,7 +109,6 @@ class SwiftTestCase(unittest.TestCase):
|
|||||||
'-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE',
|
'-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE',
|
||||||
'-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=FALSE',
|
'-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=FALSE',
|
||||||
'-DSWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION:BOOL=FALSE',
|
'-DSWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION:BOOL=FALSE',
|
||||||
'-DSWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS:BOOL=FALSE',
|
|
||||||
'-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE',
|
'-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE',
|
||||||
'-DSWIFT_ENABLE_SYNCHRONIZATION:BOOL=FALSE',
|
'-DSWIFT_ENABLE_SYNCHRONIZATION:BOOL=FALSE',
|
||||||
'-DSWIFT_ENABLE_VOLATILE:BOOL=FALSE',
|
'-DSWIFT_ENABLE_VOLATILE:BOOL=FALSE',
|
||||||
@@ -145,7 +143,6 @@ class SwiftTestCase(unittest.TestCase):
|
|||||||
'-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE',
|
'-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE',
|
||||||
'-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=FALSE',
|
'-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=FALSE',
|
||||||
'-DSWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION:BOOL=FALSE',
|
'-DSWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION:BOOL=FALSE',
|
||||||
'-DSWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS:BOOL=FALSE',
|
|
||||||
'-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE',
|
'-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE',
|
||||||
'-DSWIFT_ENABLE_SYNCHRONIZATION:BOOL=FALSE',
|
'-DSWIFT_ENABLE_SYNCHRONIZATION:BOOL=FALSE',
|
||||||
'-DSWIFT_ENABLE_VOLATILE:BOOL=FALSE',
|
'-DSWIFT_ENABLE_VOLATILE:BOOL=FALSE',
|
||||||
@@ -434,19 +431,6 @@ class SwiftTestCase(unittest.TestCase):
|
|||||||
[x for x in swift.cmake_options
|
[x for x in swift.cmake_options
|
||||||
if 'DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION' in x])
|
if 'DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION' in x])
|
||||||
|
|
||||||
def test_experimental_pointer_bounds_flags(self):
|
|
||||||
self.args.enable_experimental_pointer_bounds = True
|
|
||||||
swift = Swift(
|
|
||||||
args=self.args,
|
|
||||||
toolchain=self.toolchain,
|
|
||||||
source_dir='/path/to/src',
|
|
||||||
build_dir='/path/to/build')
|
|
||||||
self.assertEqual(
|
|
||||||
['-DSWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS:BOOL='
|
|
||||||
'TRUE'],
|
|
||||||
[x for x in swift.cmake_options
|
|
||||||
if 'DSWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS' in x])
|
|
||||||
|
|
||||||
def test_backtracing_flags(self):
|
def test_backtracing_flags(self):
|
||||||
self.args.swift_enable_backtracing = True
|
self.args.swift_enable_backtracing = True
|
||||||
swift = Swift(
|
swift = Swift(
|
||||||
|
|||||||
@@ -133,8 +133,6 @@ if "@SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED@" == "TRUE":
|
|||||||
config.available_features.add('distributed')
|
config.available_features.add('distributed')
|
||||||
if "@SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING@" == "TRUE":
|
if "@SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING@" == "TRUE":
|
||||||
config.available_features.add('string_processing')
|
config.available_features.add('string_processing')
|
||||||
if "@SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS@" == "TRUE":
|
|
||||||
config.available_features.add('pointer_bounds')
|
|
||||||
if "@SWIFT_STDLIB_ENABLE_DEBUG_PRECONDITIONS_IN_RELEASE@" == "TRUE":
|
if "@SWIFT_STDLIB_ENABLE_DEBUG_PRECONDITIONS_IN_RELEASE@" == "TRUE":
|
||||||
config.available_features.add('swift_stdlib_debug_preconditions_in_release')
|
config.available_features.add('swift_stdlib_debug_preconditions_in_release')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user