mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Standard library] Additional strict-memory-safety annotations
This commit is contained in:
@@ -163,7 +163,7 @@ internal func _assertionFailure(
|
|||||||
if _isDebugAssertConfiguration() {
|
if _isDebugAssertConfiguration() {
|
||||||
var message = message
|
var message = message
|
||||||
message.withUTF8 { (messageUTF8) -> Void in
|
message.withUTF8 { (messageUTF8) -> Void in
|
||||||
_embeddedReportFatalErrorInFile(prefix: prefix, message: messageUTF8, file: file, line: line)
|
unsafe _embeddedReportFatalErrorInFile(prefix: prefix, message: messageUTF8, file: file, line: line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ func print(_ buf: UnsafeBufferPointer<UInt8>, terminator: StaticString = "\n") {
|
|||||||
for c in buf {
|
for c in buf {
|
||||||
putchar(CInt(c))
|
putchar(CInt(c))
|
||||||
}
|
}
|
||||||
var p = terminator.utf8Start
|
var p = unsafe terminator.utf8Start
|
||||||
while p.pointee != 0 {
|
while unsafe p.pointee != 0 {
|
||||||
putchar(CInt(p.pointee))
|
unsafe putchar(CInt(p.pointee))
|
||||||
p += 1
|
p += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -551,5 +551,5 @@ func _embeddedReportFatalErrorInFile(prefix: StaticString, message: UnsafeBuffer
|
|||||||
print(line, terminator: ": ")
|
print(line, terminator: ": ")
|
||||||
print(prefix, terminator: "")
|
print(prefix, terminator: "")
|
||||||
if message.count > 0 { print(": ", terminator: "") }
|
if message.count > 0 { print(": ", terminator: "") }
|
||||||
print(message)
|
unsafe print(message)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ internal enum _PtrAuth {
|
|||||||
static func blend(pointer: UnsafeRawPointer,
|
static func blend(pointer: UnsafeRawPointer,
|
||||||
discriminator: UInt64) -> UInt64 {
|
discriminator: UInt64) -> UInt64 {
|
||||||
return UInt64(Builtin.int_ptrauth_blend(
|
return UInt64(Builtin.int_ptrauth_blend(
|
||||||
UInt64(unsafe UInt(bitPattern: pointer))._value,
|
UInt64(UInt(bitPattern: pointer))._value,
|
||||||
discriminator._value))
|
discriminator._value))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ internal enum _PtrAuth {
|
|||||||
key: Key,
|
key: Key,
|
||||||
discriminator: UInt64) -> UnsafeRawPointer {
|
discriminator: UInt64) -> UnsafeRawPointer {
|
||||||
let bitPattern = UInt64(Builtin.int_ptrauth_sign(
|
let bitPattern = UInt64(Builtin.int_ptrauth_sign(
|
||||||
UInt64(unsafe UInt(bitPattern: pointer))._value,
|
UInt64(UInt(bitPattern: pointer))._value,
|
||||||
key._value._value,
|
key._value._value,
|
||||||
discriminator._value))
|
discriminator._value))
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ internal enum _PtrAuth {
|
|||||||
newKey: Key,
|
newKey: Key,
|
||||||
newDiscriminator: UInt64) -> UnsafeRawPointer {
|
newDiscriminator: UInt64) -> UnsafeRawPointer {
|
||||||
let bitPattern = UInt64(Builtin.int_ptrauth_resign(
|
let bitPattern = UInt64(Builtin.int_ptrauth_resign(
|
||||||
UInt64(unsafe UInt(bitPattern: pointer))._value,
|
UInt64(UInt(bitPattern: pointer))._value,
|
||||||
oldKey._value._value,
|
oldKey._value._value,
|
||||||
oldDiscriminator._value,
|
oldDiscriminator._value,
|
||||||
newKey._value._value,
|
newKey._value._value,
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ extension RawSpan {
|
|||||||
public func _extracting(
|
public func _extracting(
|
||||||
unchecked bounds: ClosedRange<Int>
|
unchecked bounds: ClosedRange<Int>
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let range = Range(
|
let range = unsafe Range(
|
||||||
_uncheckedBounds: (bounds.lowerBound, bounds.upperBound + 1)
|
_uncheckedBounds: (bounds.lowerBound, bounds.upperBound + 1)
|
||||||
)
|
)
|
||||||
return unsafe _extracting(unchecked: range)
|
return unsafe _extracting(unchecked: range)
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ extension Span where Element: ~Copyable {
|
|||||||
public func _extracting(
|
public func _extracting(
|
||||||
unchecked bounds: ClosedRange<Index>
|
unchecked bounds: ClosedRange<Index>
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let range = Range(
|
let range = unsafe Range(
|
||||||
_uncheckedBounds: (bounds.lowerBound, bounds.upperBound + 1)
|
_uncheckedBounds: (bounds.lowerBound, bounds.upperBound + 1)
|
||||||
)
|
)
|
||||||
return unsafe _extracting(unchecked: range)
|
return unsafe _extracting(unchecked: range)
|
||||||
|
|||||||
@@ -447,10 +447,12 @@ extension Float80: CVarArg, _CVarArgAligned {
|
|||||||
// runtime.
|
// runtime.
|
||||||
@_fixed_layout
|
@_fixed_layout
|
||||||
@usableFromInline // c-abi
|
@usableFromInline // c-abi
|
||||||
|
@unsafe
|
||||||
final internal class __VaListBuilder {
|
final internal class __VaListBuilder {
|
||||||
#if arch(x86_64) || arch(s390x)
|
#if arch(x86_64) || arch(s390x)
|
||||||
@frozen // c-abi
|
@frozen // c-abi
|
||||||
@usableFromInline
|
@usableFromInline
|
||||||
|
@safe
|
||||||
internal struct Header {
|
internal struct Header {
|
||||||
@usableFromInline // c-abi
|
@usableFromInline // c-abi
|
||||||
internal var gp_offset = CUnsignedInt(0)
|
internal var gp_offset = CUnsignedInt(0)
|
||||||
@@ -468,21 +470,27 @@ final internal class __VaListBuilder {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
@usableFromInline // c-abi
|
@usableFromInline // c-abi
|
||||||
|
@safe
|
||||||
internal var gpRegistersUsed = 0
|
internal var gpRegistersUsed = 0
|
||||||
|
|
||||||
@usableFromInline // c-abi
|
@usableFromInline // c-abi
|
||||||
|
@safe
|
||||||
internal var fpRegistersUsed = 0
|
internal var fpRegistersUsed = 0
|
||||||
|
|
||||||
#if arch(x86_64) || arch(s390x)
|
#if arch(x86_64) || arch(s390x)
|
||||||
@usableFromInline // c-abi
|
@usableFromInline // c-abi
|
||||||
|
@safe
|
||||||
final // Property must be final since it is used by Builtin.addressof.
|
final // Property must be final since it is used by Builtin.addressof.
|
||||||
internal var header = Header()
|
internal var header = Header()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@usableFromInline // c-abi
|
@usableFromInline // c-abi
|
||||||
|
@safe
|
||||||
internal var storage: ContiguousArray<Int>
|
internal var storage: ContiguousArray<Int>
|
||||||
|
|
||||||
#if !_runtime(_ObjC)
|
#if !_runtime(_ObjC)
|
||||||
@usableFromInline // c-abi
|
@usableFromInline // c-abi
|
||||||
|
@safe
|
||||||
internal var retainer = [CVarArg]()
|
internal var retainer = [CVarArg]()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -560,9 +568,9 @@ final internal class __VaListBuilder {
|
|||||||
internal func va_list() -> CVaListPointer {
|
internal func va_list() -> CVaListPointer {
|
||||||
#if arch(x86_64) || arch(s390x)
|
#if arch(x86_64) || arch(s390x)
|
||||||
header.reg_save_area = storage._baseAddress
|
header.reg_save_area = storage._baseAddress
|
||||||
header.overflow_arg_area
|
unsafe header.overflow_arg_area
|
||||||
= storage._baseAddress + _registerSaveWords
|
= storage._baseAddress + _registerSaveWords
|
||||||
return CVaListPointer(
|
return unsafe CVaListPointer(
|
||||||
_fromUnsafeMutablePointer: UnsafeMutableRawPointer(
|
_fromUnsafeMutablePointer: UnsafeMutableRawPointer(
|
||||||
Builtin.addressof(&self.header)))
|
Builtin.addressof(&self.header)))
|
||||||
#elseif arch(arm64)
|
#elseif arch(arm64)
|
||||||
|
|||||||
Reference in New Issue
Block a user