Skip to content

Commit 8dec9ad

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.
1 parent 62c4999 commit 8dec9ad

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/ASTGen/Sources/ASTGen/Bridge.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extension BridgedSourceLoc {
2020
at position: AbsolutePosition,
2121
in buffer: UnsafeBufferPointer<UInt8>
2222
) {
23-
precondition(position.utf8Offset >= 0 && position.utf8Offset < buffer.count)
23+
precondition(position.utf8Offset >= 0 && position.utf8Offset <= buffer.count)
2424
self = SourceLoc_advanced(BridgedSourceLoc(raw: buffer.baseAddress!), SwiftInt(position.utf8Offset))
2525
}
2626
}
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)