Skip to content

Commit b6421e4

Browse files
committed
more minor SILGen notes / improvements
1 parent b6311db commit b6421e4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/SILGen/ManagedValue.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ void ManagedValue::copyInto(SILGenFunction &SGF, SILLocation loc,
123123
dest->finishInitialization(SGF);
124124
}
125125

126+
/// FIXME: There's no material difference between this anc ::copy, despite
127+
/// what this comment below says about ::copyUnmanaged!
128+
///
129+
/// Most users should always use ensurePlusOne instead!
130+
126131
/// This is the same operation as 'copy', but works on +0 values that don't
127132
/// have cleanups. It returns a +1 value with one.
128133
ManagedValue ManagedValue::copyUnmanaged(SILGenFunction &SGF, SILLocation loc) {

lib/SILGen/SILGenLValue.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3662,8 +3662,7 @@ RValue SILGenFunction::emitRValueForNonMemberVarDecl(SILLocation loc,
36623662
// If we have self, see if we are in an 'init' delegation sequence. If so,
36633663
// call out to the special delegation init routine. Otherwise, use the
36643664
// normal RValue emission logic.
3665-
if (var->getName() == getASTContext().Id_self &&
3666-
SelfInitDelegationState != NormalSelf) {
3665+
if (var->isSelfParameter() && SelfInitDelegationState != NormalSelf) {
36673666
auto rvalue =
36683667
emitRValueForSelfInDelegationInit(loc, formalRValueType, accessAddr, C);
36693668
return propagateRValuePastAccess(std::move(rvalue));
@@ -3717,7 +3716,7 @@ RValue SILGenFunction::emitRValueForNonMemberVarDecl(SILLocation loc,
37173716
// This is a 'let', so we can make guarantees.
37183717
return RValue(*this, loc, formalRValueType,
37193718
C.isGuaranteedPlusZeroOk()
3720-
? Result : Result.copyUnmanaged(*this, loc));
3719+
? Result : Result.ensurePlusOne(*this, loc));
37213720
}
37223721

37233722
LValue lv = emitLValueForNonMemberVarDecl(

0 commit comments

Comments
 (0)