Skip to content

Commit 67fc2ca

Browse files
committed
[ASTGen] Relax assertion on BridgedSourceLoc initializer
We do allow `SourceLoc` to point to the address right after the buffer ends to point to the end of a file. Fixes an issue found by the SourceKit stress tester.
1 parent 0a254b4 commit 67fc2ca

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/ASTGen/Sources/ASTGen/Misc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ extension BridgedSourceLoc {
6565
in buffer: UnsafeBufferPointer<UInt8>
6666
) {
6767
if let start = buffer.baseAddress,
68-
position.utf8Offset >= 0 && position.utf8Offset < buffer.count {
68+
position.utf8Offset >= 0 && position.utf8Offset <= buffer.count {
6969
self = SourceLoc_advanced(BridgedSourceLoc(raw: start), SwiftInt(position.utf8Offset))
7070
} else {
7171
self = nil
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %sourcekitd-test -req=cursor -pos=3:37 %s -- %s
2+
@freestanding(expression)
3+
macro powerAssert() = #externalMacro

0 commit comments

Comments
 (0)