Skip to content

Commit bd3a755

Browse files
authored
Merge pull request #68643 from saehejkang/bridged-source-loc-assert-pos
[ASTGen]: Assert that the position is within buffer bounds for BridgedSourceLoc
2 parents d5005f8 + a3d59b3 commit bd3a755

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/ASTGen/Sources/ASTGen/Bridge.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ extension BridgedSourceLoc {
2020
at position: AbsolutePosition,
2121
in buffer: UnsafeBufferPointer<UInt8>
2222
) {
23-
if let start = buffer.baseAddress,
24-
position.utf8Offset >= 0 && position.utf8Offset < buffer.count {
25-
self = SourceLoc_advanced(BridgedSourceLoc(raw: start), SwiftInt(position.utf8Offset))
26-
} else {
27-
self = nil
28-
}
23+
precondition(position.utf8Offset >= 0 && position.utf8Offset < buffer.count)
24+
self = SourceLoc_advanced(BridgedSourceLoc(raw: buffer.baseAddress!), SwiftInt(position.utf8Offset))
2925
}
3026
}
3127

0 commit comments

Comments
 (0)