mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SIL: Make drop_deinit a ForwardingInstruction.
drop_deinit forwards ownership while effectively stripping the deinitializer. It is similar to a type cast. Fixes rdar://125590074 ([NonescapableTypes] Nonescapable types cannot have deinits)
This commit is contained in:
@@ -8679,6 +8679,11 @@ class DestroyValueInst
|
||||
}
|
||||
|
||||
public:
|
||||
/// True if this destroy fully deinitializes the type by invoking the
|
||||
/// user-defined deinitializer if present. This returns false if a prior
|
||||
/// drop_deinit is present.
|
||||
bool isFullDeinitialization();
|
||||
|
||||
/// If true, then all references within the destroyed value will be
|
||||
/// overwritten with a sentinel. This is used in debug builds when shortening
|
||||
/// non-trivial value lifetimes to ensure the debugger cannot inspect invalid
|
||||
@@ -8749,11 +8754,12 @@ public:
|
||||
/// for details. See SILVerifier.cpp for constraints on valid uses.
|
||||
class DropDeinitInst
|
||||
: public UnaryInstructionBase<SILInstructionKind::DropDeinitInst,
|
||||
SingleValueInstruction> {
|
||||
OwnershipForwardingSingleValueInstruction> {
|
||||
friend class SILBuilder;
|
||||
|
||||
DropDeinitInst(SILDebugLocation DebugLoc, SILValue operand)
|
||||
: UnaryInstructionBase(DebugLoc, operand, operand->getType()) {}
|
||||
: UnaryInstructionBase(DebugLoc, operand, operand->getType(),
|
||||
OwnershipKind::Owned) {}
|
||||
};
|
||||
|
||||
/// Equivalent to a copy_addr to [init] except that it is used for diagnostics
|
||||
@@ -11134,6 +11140,7 @@ OwnershipForwardingSingleValueInstruction::classof(SILInstructionKind kind) {
|
||||
case SILInstructionKind::ThinToThickFunctionInst:
|
||||
case SILInstructionKind::UnconditionalCheckedCastInst:
|
||||
case SILInstructionKind::FunctionExtractIsolationInst:
|
||||
case SILInstructionKind::DropDeinitInst:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user