Swift SIL: add some APIs to Location

* `var description`
* `func ==`
* `func hasSameSourceLocation(as:)`
This commit is contained in:
Erik Eckstein
2023-01-16 15:40:51 +01:00
parent 8d90dafb22
commit d96ef3bedd
5 changed files with 73 additions and 8 deletions

View File

@@ -12,11 +12,24 @@
import SILBridging
public struct Location {
public struct Location: Equatable, CustomStringConvertible {
let bridged: swift.SILDebugLocation
public var description: String {
let stdString = SILLocation_debugDescription(bridged)
return String(_cxxString: stdString)
}
/// Keeps the debug scope but marks it as auto-generated.
public var autoGenerated: Location {
Location(bridged: SILLocation_getAutogeneratedLocation(bridged))
}
public static func ==(lhs: Location, rhs: Location) -> Bool {
SILLocation_equal(lhs.bridged, rhs.bridged)
}
public func hasSameSourceLocation(as other: Location) -> Bool {
SILLocation_hasSameSourceLocation(bridged, other.bridged)
}
}