[DI] Fix unfailable throw during super init.

When deallocating a partially allocated class in the trapping branch of
an unfailable cast, cast back down to the subclass which is being
partially deallocated before emitting the dealloc partial ref
instruction.
This commit is contained in:
Nate Chandler
2024-04-19 16:08:10 -07:00
parent 46ccdd6176
commit 5881ea43e7
3 changed files with 118 additions and 0 deletions

View File

@@ -2642,6 +2642,12 @@ void LifetimeChecker::processUninitializedRelease(SILInstruction *Release,
}
}
// Cast back down from an upcast.
if (auto *UI = dyn_cast<UpcastInst>(Pointer)) {
Pointer =
B.createUncheckedRefCast(Loc, Pointer, UI->getOperand()->getType());
}
// We've already destroyed any instance variables initialized by this
// constructor, now destroy instance variables initialized by subclass
// constructors that delegated to us, and finally free the memory.