Skip to content

Commit 3aa5ec5

Browse files
committed
more minor SILGen notes / improvements
1 parent bc4a83f commit 3aa5ec5

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
@@ -3660,8 +3660,7 @@ RValue SILGenFunction::emitRValueForNonMemberVarDecl(SILLocation loc,
36603660
// If we have self, see if we are in an 'init' delegation sequence. If so,
36613661
// call out to the special delegation init routine. Otherwise, use the
36623662
// normal RValue emission logic.
3663-
if (var->getName() == getASTContext().Id_self &&
3664-
SelfInitDelegationState != NormalSelf) {
3663+
if (var->isSelfParameter() && SelfInitDelegationState != NormalSelf) {
36653664
auto rvalue =
36663665
emitRValueForSelfInDelegationInit(loc, formalRValueType, accessAddr, C);
36673666
return propagateRValuePastAccess(std::move(rvalue));
@@ -3715,7 +3714,7 @@ RValue SILGenFunction::emitRValueForNonMemberVarDecl(SILLocation loc,
37153714
// This is a 'let', so we can make guarantees.
37163715
return RValue(*this, loc, formalRValueType,
37173716
C.isGuaranteedPlusZeroOk()
3718-
? Result : Result.copyUnmanaged(*this, loc));
3717+
? Result : Result.ensurePlusOne(*this, loc));
37193718
}
37203719

37213720
LValue lv = emitLValueForNonMemberVarDecl(

0 commit comments

Comments
 (0)