Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ let package = Package(
swiftSettings: [
.enableExperimentalFeature("Lifetimes"),
.strictMemorySafety(),
.treatWarning("StrictMemorySafety", as: .error),
]
),
.macro(
Expand Down
2 changes: 1 addition & 1 deletion Sources/BinaryParsing/Parser Types/Slicing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ extension ParserSpan {
{
let rawSpan = try sliceSpan(byteCount: byteCount).bytes
do {
let span = Span<UInt8>(_bytes: rawSpan)
let span = unsafe Span<UInt8>(_bytes: rawSpan)
return try UTF8Span(validating: span)
} catch {
throw ParsingError(status: .userError, location: startPosition)
Expand Down
8 changes: 4 additions & 4 deletions Tests/BinaryParsingTests/OptimizationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ private let data: [UInt8] = [
struct OptimizationTests {
func precheckParseFour(parsing input: inout ParserSpan) throws -> Int {
try input._checkCount(minimum: 16)
let a = UInt32(_unchecked: (), parsingBigEndian: &input)
let b = UInt32(_unchecked: (), parsingBigEndian: &input)
let c = UInt32(_unchecked: (), parsingBigEndian: &input)
let d = UInt32(_unchecked: (), parsingBigEndian: &input)
let a = unsafe UInt32(_unchecked: (), parsingBigEndian: &input)
let b = unsafe UInt32(_unchecked: (), parsingBigEndian: &input)
let c = unsafe UInt32(_unchecked: (), parsingBigEndian: &input)
let d = unsafe UInt32(_unchecked: (), parsingBigEndian: &input)
return Int(a + b + c + d)
}

Expand Down
10 changes: 5 additions & 5 deletions Tests/BinaryParsingTests/TestingSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func === (lhs: borrowing ParserSpan, rhs: borrowing ParserSpan) -> Bool {
lhs.count == rhs.count
else { return false }

return lhs.withUnsafeBytes { lhs in
rhs.withUnsafeBytes { rhs in
(lhs.baseAddress, lhs.count) == (rhs.baseAddress, rhs.count)
return unsafe lhs.withUnsafeBytes { lhs in
unsafe rhs.withUnsafeBytes { rhs in
unsafe (lhs.baseAddress, lhs.count) == (rhs.baseAddress, rhs.count)
}
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ extension Array where Element == UInt8 {
if T.isSigned && value < 0 { 0xff } else { 0x00 }
}
self =
Array(repeating: paddingByte, count: paddingCount)
unsafe Array(repeating: paddingByte, count: paddingCount)
+ Swift.withUnsafeBytes(of: value.bigEndian, Array.init)
}

Expand All @@ -105,7 +105,7 @@ extension Array where Element == UInt8 {
if T.isSigned && value < 0 { 0xff } else { 0x00 }
}
self =
Swift.withUnsafeBytes(of: value.littleEndian, Array.init)
unsafe Swift.withUnsafeBytes(of: value.littleEndian, Array.init)
+ Array(repeating: paddingByte, count: paddingCount)
}

Expand Down
4 changes: 4 additions & 0 deletions Xcode/Shared.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ CODE_SIGN_IDENTITY[sdk=watchos*] = "iOS Developer"
CODE_SIGN_IDENTITY[sdk=appletvos*] = "iOS Developer"

SWIFT_VERSION = 6
SWIFT_STRICT_MEMORY_SAFETY = YES
SWIFT_WARNINGS_AS_ERRORS_GROUPS = StrictMemorySafety
SWIFT_STRICT_CONCURRENCY = complete

ONLY_ACTIVE_ARCH[config=Debug] = YES

SWIFT_COMPILATION_MODE[config=Release] = wholemodule
Expand Down
Loading