mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SILGen: Manage retain/release properly for dynamic member lookups.
Introduce a proper cleanup for the Optional<T> value created by non-forced dynamic member lookups. Additionally, properly manage each reference to an OpaqueValue within an expression, and release the value when the RAII object goes out of scope. This is the conservative approach to be optimized soon. Swift SVN r8071
This commit is contained in:
@@ -1679,13 +1679,17 @@ RValue SILGenFunction::emitDynamicMemberRefExpr(DynamicMemberRefExpr *e,
|
||||
SILValue appliedMethod = B.createPartialApply(e, memberArg, operand,
|
||||
getLoweredType(methodTy));
|
||||
|
||||
// Package up the applied method in .Some().
|
||||
OpaqueValueRAII opaqueValue(*this, e->getOpaqueFn(), appliedMethod);
|
||||
SILValue optResult;
|
||||
|
||||
{
|
||||
// Package up the applied method in .Some().
|
||||
OpaqueValueRAII opaqueValue(*this, e->getOpaqueFn(), appliedMethod);
|
||||
|
||||
optResult = emitRValue(e->getCreateSome()).forwardAsSingleValue(*this, e);
|
||||
}
|
||||
|
||||
// Branch to the continuation block.
|
||||
B.createBranch(e, contBB,
|
||||
emitRValue(e->getCreateSome()).forwardAsSingleValue(*this,
|
||||
e));
|
||||
B.createBranch(e, contBB, optResult);
|
||||
}
|
||||
|
||||
// Create the no-member branch.
|
||||
@@ -1704,7 +1708,6 @@ RValue SILGenFunction::emitDynamicMemberRefExpr(DynamicMemberRefExpr *e,
|
||||
B.emitBlock(contBB);
|
||||
|
||||
// Package up the result.
|
||||
ManagedValue result(optMethodArg, existential.getCleanup());
|
||||
return RValue(*this, result, e);
|
||||
return RValue(*this, emitManagedRValueWithCleanup(optMethodArg), e);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user