Skip to content

Commit 087c0e2

Browse files
committed
[LLVM] Fix compilation after changes in safety detection
This makes sure that the bindings can be built with a 5.9+ snapshot compiler. See swiftlang/swift#67296 (cherry picked from commit 470e7d8)
1 parent 2c4632d commit 087c0e2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/LLVM/LLVM_Utils.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@ extension StaticString {
3434
}
3535

3636
public func ==(lhs: llvm.StringRef, rhs: StaticString) -> Bool {
37+
#if $NewCxxMethodSafetyHeuristics
38+
let lhsBuffer = UnsafeBufferPointer<UInt8>(
39+
start: lhs.bytes_begin(),
40+
count: Int(lhs.bytes_end() - lhs.bytes_begin()))
41+
#else
3742
let lhsBuffer = UnsafeBufferPointer<UInt8>(
3843
start: lhs.__bytes_beginUnsafe(),
3944
count: Int(lhs.__bytes_endUnsafe() - lhs.__bytes_beginUnsafe()))
45+
#endif
4046
return rhs.withUTF8Buffer { (rhsBuffer: UnsafeBufferPointer<UInt8>) in
4147
if lhsBuffer.count != rhsBuffer.count { return false }
4248
return lhsBuffer.elementsEqual(rhsBuffer, by: ==)

0 commit comments

Comments
 (0)