Skip to content

Commit 49bc96d

Browse files
committed
Revert "[silgen] Ensure that the outer cleanup is emitted along failure paths when initializing sub-tuple patterns"
This reverts commit be922b9. By adding some extra scopes here we are triggering some broken behavior in a bunch of projects. I am going to see if I can do another fix for this. That being said in the short term, we are reverting to unblock those projects. rdar://83770295
1 parent d6bc48a commit 49bc96d

File tree

2 files changed

+2
-31
lines changed

2 files changed

+2
-31
lines changed

lib/SILGen/SILGenDecl.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,9 @@ void TupleInitialization::copyOrInitValueInto(SILGenFunction &SGF,
6969
// In the address case, we forward the underlying value and store it
7070
// into memory and then create a +1 cleanup. since we assume here
7171
// that we have a +1 value since we are forwarding into memory.
72-
//
73-
// In order to ensure that we properly clean up along any failure paths, we
74-
// need to mark value as being persistently active. We then unforward it once
75-
// we are done.
7672
assert(value.isPlusOne(SGF) && "Can not store a +0 value into memory?!");
77-
CleanupStateRestorationScope valueScope(SGF.Cleanups);
78-
if (value.hasCleanup())
79-
valueScope.pushCleanupState(value.getCleanup(),
80-
CleanupState::PersistentlyActive);
81-
copyOrInitValueIntoHelper(
73+
value = ManagedValue::forUnmanaged(value.forward(SGF));
74+
return copyOrInitValueIntoHelper(
8275
SGF, loc, value, isInit, SubInitializations,
8376
[&](ManagedValue aggregate, unsigned i,
8477
SILType fieldType) -> ManagedValue {
@@ -90,8 +83,6 @@ void TupleInitialization::copyOrInitValueInto(SILGenFunction &SGF,
9083

9184
return SGF.emitManagedRValueWithCleanup(elt.getValue());
9285
});
93-
std::move(valueScope).pop();
94-
value.forward(SGF);
9586
}
9687

9788
void TupleInitialization::finishUninitialized(SILGenFunction &SGF) {

test/SILGen/enum.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -219,23 +219,3 @@ func sr7799_1(bar: SR7799??) {
219219
default: print("default")
220220
}
221221
}
222-
223-
// Make sure that we handle enum, tuple initialization composed
224-
// correctly. Previously, we leaked down a failure path due to us misusing
225-
// scopes.
226-
enum rdar81817725 {
227-
case localAddress
228-
case setOption(Int, Any)
229-
230-
static func takeAny(_:Any) -> Bool { return true }
231-
232-
static func testSwitchCleanup(syscall: rdar81817725, expectedLevel: Int,
233-
valueMatcher: (Any) -> Bool)
234-
throws -> Bool {
235-
if case .setOption(expectedLevel, let value) = syscall {
236-
return rdar81817725.takeAny(value)
237-
} else {
238-
return false
239-
}
240-
}
241-
}

0 commit comments

Comments
 (0)