Skip to content

Commit a798f21

Browse files
committed
Introduce ResultConvention::Guaranteed and ResultConvention::GuaranteedAddress in SwiftCompilerSources
1 parent 1cff471 commit a798f21

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

SwiftCompilerSources/Sources/SIL/Argument.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ public enum ArgumentConvention : CustomStringConvertible {
488488
self = .directUnowned
489489
case .pack:
490490
self = .packOut
491+
case .guaranteed, .guaranteedAddress:
492+
fatalError("Result conventions @guaranteed and @guaranteed_addr are always returned directly")
491493
}
492494
}
493495

SwiftCompilerSources/Sources/SIL/FunctionConvention.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public struct ResultInfo : CustomStringConvertible {
133133
return hasLoweredAddresses || type.isExistentialArchetypeWithError()
134134
case .pack:
135135
return true
136-
case .owned, .unowned, .unownedInnerPointer, .autoreleased:
136+
case .owned, .unowned, .unownedInnerPointer, .autoreleased, .guaranteed, .guaranteedAddress:
137137
return false
138138
}
139139
}
@@ -358,6 +358,14 @@ public enum ResultConvention : CustomStringConvertible {
358358
/// The caller is responsible for destroying this return value. Its type is non-trivial.
359359
case owned
360360

361+
/// The caller is responsible for using the returned address within a valid
362+
/// scope. This is valid only for borrow and mutate accessors.
363+
case guaranteedAddress
364+
365+
/// The caller is responsible for using the returned value within a valid
366+
/// scope. This is valid only for borrow accessors.
367+
case guaranteed
368+
361369
/// The caller is not responsible for destroying this return value. Its type may be trivial, or it may simply be offered unsafely. It is valid at the instant of the return, but further operations may invalidate it.
362370
case unowned
363371

@@ -397,6 +405,10 @@ public enum ResultConvention : CustomStringConvertible {
397405
return "autoreleased"
398406
case .pack:
399407
return "pack"
408+
case .guaranteed:
409+
return "guaranteed"
410+
case .guaranteedAddress:
411+
return "guaranteedAddress"
400412
}
401413
}
402414
}
@@ -428,6 +440,8 @@ extension ResultConvention {
428440
case .UnownedInnerPointer: self = .unownedInnerPointer
429441
case .Autoreleased: self = .autoreleased
430442
case .Pack: self = .pack
443+
case .Guaranteed: self = .guaranteed
444+
case .GuaranteedAddress: self = .guaranteedAddress
431445
default:
432446
fatalError("unsupported result convention")
433447
}

include/swift/SIL/SILBridging.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ enum class BridgedResultConvention {
107107
Unowned,
108108
UnownedInnerPointer,
109109
Autoreleased,
110-
Pack
110+
Pack,
111+
GuaranteedAddress,
112+
Guaranteed,
111113
};
112114

113115
struct BridgedResultInfo {

0 commit comments

Comments
 (0)