Skip to content

Commit 4a8743b

Browse files
authored
Merge pull request #752 from CodaFi/five-alarm-fire
2 parents 4f1286f + 0aec83a commit 4a8743b

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Sources/SwiftParser/CharacterInfo.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ extension Unicode.Scalar {
9393
}
9494
}
9595

96-
#if swift(<5.7)
9796
extension UnsafeRawBufferPointer {
9897
/// Returns a typed buffer to the memory referenced by this buffer,
9998
/// assuming that the memory is already bound to the specified type.
@@ -122,7 +121,6 @@ extension UnsafeRawBufferPointer {
122121
return .init(start: s.assumingMemoryBound(to: T.self), count: n)
123122
}
124123
}
125-
#endif
126124

127125
private var InfoTable: CharacterInfoTable = (
128126
// 0 NUL 1 SOH 2 STX 3 ETX

Sources/SwiftSyntax/BumpPtrAllocator.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ public class BumpPtrAllocator {
163163

164164
// MARK: Compatibilty Shims
165165

166-
#if swift(<5.7)
167166
extension UnsafeMutableRawPointer {
168167
/// Obtain the next pointer whose bit pattern is a multiple of alignment.
169168
///
@@ -181,4 +180,3 @@ extension UnsafeMutableRawPointer {
181180
return .init(bitPattern: bits)!
182181
}
183182
}
184-
#endif

Sources/SwiftSyntaxParser/SyntaxParser.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public enum SyntaxParser {
142142
let arena = SyntaxArena()
143143
let sourceBuffer = source.withUTF8 { arena.internSourceBuffer($0) }
144144

145+
#if compiler(>=5.7)
145146
if let languageVersion = languageVersion {
146147
languageVersion.withCString { languageVersionCString in
147148
swiftparse_parser_set_language_version(c_parser, languageVersionCString)
@@ -150,6 +151,7 @@ public enum SyntaxParser {
150151
if let enableBareSlashRegexLiteral = enableBareSlashRegexLiteral {
151152
swiftparse_parser_set_enable_bare_slash_regex_literal(c_parser, enableBareSlashRegexLiteral)
152153
}
154+
#endif
153155

154156
let nodeHandler = { (cnode: CSyntaxNodePtr!) -> UnsafeMutableRawPointer in
155157
RawSyntax.getOpaqueFromCNode(cnode, in: sourceBuffer, arena: arena)
@@ -205,7 +207,9 @@ public enum SyntaxParser {
205207
swiftparse_parser_set_diagnostic_handler(c_parser, diagHandler)
206208
}
207209

208-
let c_top = swiftparse_parse_string(c_parser, sourceBuffer.baseAddress, sourceBuffer.count)
210+
let c_top = sourceBuffer.withMemoryRebound(to: CChar.self) { sourceBuffer in
211+
return swiftparse_parse_string(c_parser, sourceBuffer.baseAddress, sourceBuffer.count)
212+
}
209213
let base = Syntax(raw: RawSyntax.fromOpaque(c_top!))
210214
guard let file = base.as(SourceFileSyntax.self) else {
211215
throw ParserError.invalidSyntaxData

0 commit comments

Comments
 (0)