Skip to content

Commit 7b8f433

Browse files
committed
EscapeUtils: add EscapeVisitorWithResult.cleanupOnAbort()
Useful to destroy the result if it's not returned
1 parent 877f8a7 commit 7b8f433

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/EscapeUtils.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ extension ProjectedValue {
104104
_ context: some Context) -> V.Result? {
105105
var walker = EscapeWalker(visitor: visitor, complexityBudget: complexityBudget, context)
106106
if walker.walkUp(addressOrValue: value, path: path.escapePath) == .abortWalk {
107+
walker.visitor.cleanupOnAbort()
107108
return nil
108109
}
109110
return walker.visitor.result
@@ -119,6 +120,7 @@ extension ProjectedValue {
119120
_ context: some Context) -> V.Result? {
120121
var walker = EscapeWalker(visitor: visitor, context)
121122
if walker.walkDown(addressOrValue: value, path: path.escapePath) == .abortWalk {
123+
walker.visitor.cleanupOnAbort()
122124
return nil
123125
}
124126
return walker.visitor.result
@@ -182,6 +184,12 @@ extension EscapeVisitor {
182184
protocol EscapeVisitorWithResult : EscapeVisitor {
183185
associatedtype Result
184186
var result: Result { get }
187+
188+
mutating func cleanupOnAbort()
189+
}
190+
191+
extension EscapeVisitorWithResult {
192+
mutating func cleanupOnAbort() {}
185193
}
186194

187195
// FIXME: This ought to be marked private, but that triggers a compiler bug

0 commit comments

Comments
 (0)