Skip to content

Commit b1352b4

Browse files
committed
Rename visitExtendedLocalScopeEndingUses
To visitExtendedScopeEndingUses. We need to talk about the "local" scope, which does not cross reborrows, in contrast to the extended scope. So the name was a contradiction that could cause confusion elsewhere.
1 parent ac2f7b7 commit b1352b4

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

include/swift/SIL/OwnershipUtils.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ bool findTransitiveGuaranteedUses(SILValue guaranteedValue,
150150
/// 1. If \p guaranteedValue introduces a borrow scope (begin_borrow,
151151
/// load_borrow, or phi), then its only use points are the extended scope-ending
152152
/// uses, and this function returns true. This is, in fact, equivalent to
153-
/// calling BorrowedValue::visitExtendedLocalScopeEndingUses().
153+
/// calling BorrowedValue::visitExtendedScopeEndingUses().
154154
///
155155
/// 2. If \p guaranteedValue does not introduce a borrow scope (it is not a
156156
/// valid BorrowedValue), then its uses are discovered transitively by looking
@@ -320,8 +320,6 @@ struct BorrowingOperand {
320320
/// BorrowingOperand.
321321
///
322322
/// Returns false and early exits if the visitor \p func returns false.
323-
///
324-
/// Note: this does not visit the intermediate reborrows.
325323
bool visitExtendedScopeEndingUses(function_ref<bool(Operand *)> func) const;
326324

327325
/// Returns true if this borrow scope operand consumes guaranteed
@@ -504,7 +502,7 @@ struct InteriorPointerOperand;
504502
/// jointly post-dominate this value (see visitLocalScopeEndingUses()). The
505503
/// extended scope, including reborrows has end points that are not dominated by
506504
/// this value but still jointly post-dominate (see
507-
/// visitExtendedLocalScopeEndingUses()).
505+
/// visitExtendedScopeEndingUses()).
508506
struct BorrowedValue {
509507
SILValue value;
510508
BorrowedValueKind kind = BorrowedValueKind::Invalid;
@@ -563,8 +561,8 @@ struct BorrowedValue {
563561
/// Given a local borrow scope introducer, visit all non-forwarding consuming
564562
/// users. This means that this looks through guaranteed block arguments. \p
565563
/// visitor is *not* called on Reborrows, only on final scope ending uses.
566-
bool visitExtendedLocalScopeEndingUses(
567-
function_ref<bool(Operand *)> visitor) const;
564+
bool
565+
visitExtendedScopeEndingUses(function_ref<bool(Operand *)> visitor) const;
568566

569567
void print(llvm::raw_ostream &os) const;
570568
SWIFT_DEBUG_DUMP { print(llvm::dbgs()); }

lib/SIL/Utils/OwnershipUtils.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ findInnerTransitiveGuaranteedUses(SILValue guaranteedValue,
244244
// Find all use points of \p guaranteedValue within its borrow scope. All use
245245
// points will be dominated by \p guaranteedValue.
246246
//
247-
// Record (non-nested) reborrows as uses and call \p visitReborrow.
247+
// Record (non-nested) reborrows as uses.
248248
//
249249
// BorrowedValues (which introduce a borrow scope) are fundamentally different
250250
// than "inner" guaranteed values. Their only use points are their scope-ending
@@ -418,14 +418,15 @@ bool BorrowingOperand::visitScopeEndingUses(
418418
}
419419

420420
bool BorrowingOperand::visitExtendedScopeEndingUses(
421-
function_ref<bool(Operand *)> func) const {
421+
function_ref<bool(Operand *)> visitor) const {
422+
422423
if (hasBorrowIntroducingUser()) {
423424
return visitBorrowIntroducingUserResults(
424-
[func](BorrowedValue borrowedValue) {
425-
return borrowedValue.visitExtendedLocalScopeEndingUses(func);
425+
[visitor](BorrowedValue borrowedValue) {
426+
return borrowedValue.visitExtendedScopeEndingUses(visitor);
426427
});
427428
}
428-
return visitScopeEndingUses(func);
429+
return visitScopeEndingUses(visitor);
429430
}
430431

431432
bool BorrowingOperand::visitBorrowIntroducingUserResults(
@@ -598,8 +599,8 @@ bool BorrowedValue::areUsesWithinLocalScope(
598599
}
599600

600601
// The visitor \p func is only called on final scope-ending uses, not reborrows.
601-
bool BorrowedValue::visitExtendedLocalScopeEndingUses(
602-
function_ref<bool(Operand *)> func) const {
602+
bool BorrowedValue::visitExtendedScopeEndingUses(
603+
function_ref<bool(Operand *)> visitor) const {
603604
assert(isLocalScope());
604605

605606
SmallPtrSetVector<SILValue, 4> reborrows;
@@ -613,7 +614,7 @@ bool BorrowedValue::visitExtendedLocalScopeEndingUses(
613614
});
614615
return true;
615616
}
616-
return func(scopeEndingUse);
617+
return visitor(scopeEndingUse);
617618
};
618619

619620
if (!visitLocalScopeEndingUses(visitEnd))

0 commit comments

Comments
 (0)