Skip to content

Commit 7b1eea6

Browse files
committed
[silgenpattern] Gardening. Added some asserts, comments, reformulated some small control flow. NFC.
1 parent cf5d3fe commit 7b1eea6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/SILGen/SILGenPattern.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ class ArgUnforwarder {
888888
assert(operand.getFinalConsumption() !=
889889
CastConsumptionKind::TakeOnSuccess &&
890890
"When compiling with sil ownership take on success is disabled");
891-
// No unforwarding is needed, we always copy.
891+
// No unforwarding is needed, we always borrow/copy.
892892
return false;
893893
}
894894

@@ -1394,12 +1394,14 @@ static ConsumableManagedValue
13941394
getManagedSubobject(SILGenFunction &SGF, SILValue value,
13951395
const TypeLowering &valueTL,
13961396
CastConsumptionKind consumption) {
1397-
if (consumption != CastConsumptionKind::CopyOnSuccess) {
1398-
return {SGF.emitManagedRValueWithCleanup(value, valueTL),
1399-
consumption};
1400-
} else {
1397+
if (consumption == CastConsumptionKind::CopyOnSuccess) {
14011398
return {ManagedValue::forUnmanaged(value), consumption};
14021399
}
1400+
1401+
assert((!SGF.F.getModule().getOptions().EnableSILOwnership ||
1402+
consumption != CastConsumptionKind::TakeOnSuccess) &&
1403+
"TakeOnSuccess should never be used when sil ownership is enabled");
1404+
return {SGF.emitManagedRValueWithCleanup(value, valueTL), consumption};
14031405
}
14041406

14051407
static ConsumableManagedValue

0 commit comments

Comments
 (0)