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