Skip to content

Commit be88e7c

Browse files
committed
[NFC] OSSACompleteLifetime: Tweak control flow.
Use a switch rather than several ifs.
1 parent 3192601 commit be88e7c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

include/swift/SIL/OSSALifetimeCompletion.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,24 @@ class OSSALifetimeCompletion {
9393
///
9494
/// TODO: We also need to complete scoped addresses (e.g. store_borrow)!
9595
LifetimeCompletion completeOSSALifetime(SILValue value, Boundary boundary) {
96-
if (value->getOwnershipKind() == OwnershipKind::None)
96+
switch (value->getOwnershipKind()) {
97+
case OwnershipKind::None:
9798
return LifetimeCompletion::NoLifetime;
98-
99-
if (value->getOwnershipKind() != OwnershipKind::Owned) {
99+
case OwnershipKind::Owned:
100+
break;
101+
case OwnershipKind::Any:
102+
llvm::report_fatal_error("value with any ownership kind!?");
103+
case OwnershipKind::Guaranteed:
104+
case OwnershipKind::Unowned: {
100105
BorrowedValue borrowedValue(value);
101106
if (!borrowedValue)
102107
return LifetimeCompletion::NoLifetime;
103108

104109
if (!borrowedValue.isLocalScope())
105110
return LifetimeCompletion::AlreadyComplete;
106111
}
112+
}
113+
107114
if (!completedValues.insert(value))
108115
return LifetimeCompletion::AlreadyComplete;
109116

0 commit comments

Comments
 (0)