File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
SwiftCompilerSources/Sources/SIL Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,22 @@ public protocol ApplySite : Instruction {
122122 var unappliedArgumentCount : Int { get }
123123}
124124
125+ // lattice: no -> lifetime -> value
126+ public enum IsFullyAssigned {
127+ case no
128+ case lifetime
129+ case value
130+
131+ var reassignsLifetime : Bool {
132+ switch self {
133+ case . no:
134+ false
135+ case . lifetime, . value:
136+ true
137+ }
138+ }
139+ }
140+
125141extension ApplySite {
126142 public var callee : Value { operands [ ApplyOperandConventions . calleeIndex] . value }
127143
@@ -260,6 +276,26 @@ extension ApplySite {
260276 return operandConventions. parameterDependence ( targetOperandIndex: target. index, sourceOperandIndex: source. index)
261277 }
262278
279+ /// Returns .value if this apply fully assigns 'operand' (via @out).
280+ ///
281+ /// Returns .lifetime if this 'operand' is a non-Escapable inout argument and its lifetime is not propagated by the
282+ /// call ('@lifetime(param: copy param)' is not present).
283+ public func fullyAssigns( operand: Operand ) -> IsFullyAssigned {
284+ switch convention ( of: operand) {
285+ case . indirectOut:
286+ return . value
287+ case . indirectInout:
288+ if let argIdx = calleeArgumentIndex ( of: operand) ,
289+ calleeArgumentConventions. parameterDependence ( targetArgumentIndex: argIdx, sourceArgumentIndex: argIdx) == nil
290+ {
291+ return . lifetime
292+ }
293+ return . no
294+ default :
295+ return . no
296+ }
297+ }
298+
263299 public var yieldConventions : YieldConventions {
264300 YieldConventions ( convention: functionConvention)
265301 }
You can’t perform that action at this time.
0 commit comments