mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[silgen] Add {ManagedValue,RValue}::ensurePlusOne(...).
This helper function returns *this if the value is already at +1. Otherwise, if the value is a +0 value, we copy the value. Since I am using this initially for some experiments, I am hiding it behind the enable guaranteed normal arguments flag. rdar://34222540
This commit is contained in:
@@ -698,6 +698,12 @@ RValue RValue::copy(SILGenFunction &SGF, SILLocation loc) const & {
|
||||
return RValue(SGF, std::move(copiedValues), type, elementsToBeAdded);
|
||||
}
|
||||
|
||||
RValue RValue::ensurePlusOne(SILGenFunction &SGF, SILLocation loc) && {
|
||||
if (SGF.getOptions().EnableGuaranteedNormalArguments && isPlusZero(SGF))
|
||||
return copy(SGF, loc);
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
RValue RValue::borrow(SILGenFunction &SGF, SILLocation loc) const & {
|
||||
assert((isComplete() || isInSpecialState()) &&
|
||||
"can't borrow incomplete rvalue");
|
||||
|
||||
Reference in New Issue
Block a user