Skip to content

Commit 2ca9951

Browse files
committed
[NFC] LifetimeCompletion: Lift default a level.
1 parent 5383df7 commit 2ca9951

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

include/swift/SIL/OSSALifetimeCompletion.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class OSSALifetimeCompletion {
9797
/// TODO: We also need to complete scoped addresses (e.g. store_borrow)!
9898
LifetimeCompletion
9999
completeOSSALifetime(SILValue value,
100-
std::optional<Boundary> boundary = std::nullopt) {
100+
std::optional<Boundary> maybeBoundary = std::nullopt) {
101101
if (value->getOwnershipKind() == OwnershipKind::None)
102102
return LifetimeCompletion::NoLifetime;
103103

@@ -112,6 +112,9 @@ class OSSALifetimeCompletion {
112112
if (!completedValues.insert(value))
113113
return LifetimeCompletion::AlreadyComplete;
114114

115+
Boundary boundary = maybeBoundary.value_or(
116+
value->isLexical() ? Boundary::Availability : Boundary::Liveness);
117+
115118
return analyzeAndUpdateLifetime(value, boundary)
116119
? LifetimeCompletion::WasCompleted
117120
: LifetimeCompletion::AlreadyComplete;
@@ -122,8 +125,7 @@ class OSSALifetimeCompletion {
122125
llvm::function_ref<void(SILInstruction *)> visit);
123126

124127
protected:
125-
bool analyzeAndUpdateLifetime(SILValue value,
126-
std::optional<Boundary> boundary);
128+
bool analyzeAndUpdateLifetime(SILValue value, Boundary boundary);
127129
};
128130

129131
//===----------------------------------------------------------------------===//

lib/SIL/Utils/OSSALifetimeCompletion.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ endLifetimeAtAvailabilityBoundary(SILValue value,
338338
/// End the lifetime of \p value at unreachable instructions.
339339
///
340340
/// Returns true if any new instructions were created to complete the lifetime.
341-
bool OSSALifetimeCompletion::analyzeAndUpdateLifetime(
342-
SILValue value, std::optional<Boundary> maybeBoundary) {
341+
bool OSSALifetimeCompletion::analyzeAndUpdateLifetime(SILValue value,
342+
Boundary boundary) {
343343
// Called for inner borrows, inner adjacent reborrows, inner reborrows, and
344344
// scoped addresses.
345345
auto handleInnerScope = [this](SILValue innerBorrowedValue) {
@@ -348,9 +348,6 @@ bool OSSALifetimeCompletion::analyzeAndUpdateLifetime(
348348
InteriorLiveness liveness(value);
349349
liveness.compute(domInfo, handleInnerScope);
350350

351-
Boundary boundary = maybeBoundary.value_or(
352-
value->isLexical() ? Boundary::Availability : Boundary::Liveness);
353-
354351
bool changed = false;
355352
switch (boundary) {
356353
case Boundary::Availability:

0 commit comments

Comments
 (0)