Skip to content

[ownership] Convert a few small visitor methods to be const. #30497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/swift/SIL/OwnershipUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ struct BorrowingOperand {

/// Visit all of the results of the operand's user instruction that are
/// consuming uses.
void visitUserResultConsumingUses(function_ref<void(Operand *)> visitor);
void visitUserResultConsumingUses(function_ref<void(Operand *)> visitor) const;

/// Visit all of the "results" of the user of this operand that are borrow
/// scope introducers for the specific scope that this borrow scope operand
/// summarizes.
void
visitBorrowIntroducingUserResults(function_ref<void(BorrowedValue)> visitor);
visitBorrowIntroducingUserResults(function_ref<void(BorrowedValue)> visitor) const;

/// Passes to visitor all of the consuming uses of this use's using
/// instruction.
Expand All @@ -193,7 +193,7 @@ struct BorrowingOperand {
/// guaranteed scope by using a worklist and checking if any of the operands
/// are BorrowScopeOperands.
void visitConsumingUsesOfBorrowIntroducingUserResults(
function_ref<void(Operand *)> visitor);
function_ref<void(Operand *)> visitor) const;

void print(llvm::raw_ostream &os) const;
SWIFT_DEBUG_DUMP { print(llvm::dbgs()); }
Expand Down
6 changes: 3 additions & 3 deletions lib/SIL/OwnershipUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void BorrowingOperand::visitEndScopeInstructions(
}

void BorrowingOperand::visitBorrowIntroducingUserResults(
function_ref<void(BorrowedValue)> visitor) {
function_ref<void(BorrowedValue)> visitor) const {
switch (kind) {
case BorrowScopeOperandKind::BeginApply:
llvm_unreachable("Never has borrow introducer results!");
Expand All @@ -212,7 +212,7 @@ void BorrowingOperand::visitBorrowIntroducingUserResults(
}

void BorrowingOperand::visitConsumingUsesOfBorrowIntroducingUserResults(
function_ref<void(Operand *)> func) {
function_ref<void(Operand *)> func) const {
// First visit all of the results of our user that are borrow introducing
// values.
visitBorrowIntroducingUserResults([&](BorrowedValue value) {
Expand All @@ -238,7 +238,7 @@ void BorrowingOperand::visitConsumingUsesOfBorrowIntroducingUserResults(
}

void BorrowingOperand::visitUserResultConsumingUses(
function_ref<void(Operand *)> visitor) {
function_ref<void(Operand *)> visitor) const {
auto *ti = dyn_cast<TermInst>(op->getUser());
if (!ti) {
for (SILValue result : op->getUser()->getResults()) {
Expand Down