Skip to content

Commit 5f45e0f

Browse files
committed
[ownership] Move BorrowScopeOperand::visitEndScopeInstructions() from .h into .cpp.
1 parent 225b6e8 commit 5f45e0f

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

include/swift/SIL/OwnershipUtils.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -261,25 +261,7 @@ struct BorrowScopeOperand {
261261
return BorrowScopeOperand(*kind, op);
262262
}
263263

264-
void visitEndScopeInstructions(function_ref<void(Operand *)> func) const {
265-
switch (kind) {
266-
case BorrowScopeOperandKind::BeginBorrow:
267-
for (auto *use : cast<BeginBorrowInst>(op->getUser())->getUses()) {
268-
if (isa<EndBorrowInst>(use->getUser())) {
269-
func(use);
270-
}
271-
}
272-
return;
273-
case BorrowScopeOperandKind::BeginApply: {
274-
auto *user = cast<BeginApplyInst>(op->getUser());
275-
for (auto *use : user->getTokenResult()->getUses()) {
276-
func(use);
277-
}
278-
return;
279-
}
280-
}
281-
llvm_unreachable("Covered switch isn't covered");
282-
}
264+
void visitEndScopeInstructions(function_ref<void(Operand *)> func) const;
283265

284266
void print(llvm::raw_ostream &os) const;
285267
SWIFT_DEBUG_DUMP { print(llvm::dbgs()); }

lib/SIL/OwnershipUtils.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,27 @@ llvm::raw_ostream &swift::operator<<(llvm::raw_ostream &os,
122122
return os;
123123
}
124124

125+
void BorrowScopeOperand::visitEndScopeInstructions(
126+
function_ref<void(Operand *)> func) const {
127+
switch (kind) {
128+
case BorrowScopeOperandKind::BeginBorrow:
129+
for (auto *use : cast<BeginBorrowInst>(op->getUser())->getUses()) {
130+
if (isa<EndBorrowInst>(use->getUser())) {
131+
func(use);
132+
}
133+
}
134+
return;
135+
case BorrowScopeOperandKind::BeginApply: {
136+
auto *user = cast<BeginApplyInst>(op->getUser());
137+
for (auto *use : user->getTokenResult()->getUses()) {
138+
func(use);
139+
}
140+
return;
141+
}
142+
}
143+
llvm_unreachable("Covered switch isn't covered");
144+
}
145+
125146
//===----------------------------------------------------------------------===//
126147
// Borrow Introducers
127148
//===----------------------------------------------------------------------===//
@@ -141,6 +162,12 @@ void BorrowScopeIntroducingValueKind::print(llvm::raw_ostream &os) const {
141162
llvm_unreachable("Covered switch isn't covered?!");
142163
}
143164

165+
void BorrowScopeIntroducingValue::print(llvm::raw_ostream &os) const {
166+
os << "BorrowScopeIntroducingValue:\n"
167+
"Kind: " << kind << "\n"
168+
"Value: " << value;
169+
}
170+
144171
void BorrowScopeIntroducingValue::getLocalScopeEndingInstructions(
145172
SmallVectorImpl<SILInstruction *> &scopeEndingInsts) const {
146173
assert(isLocalScope() && "Should only call this given a local scope");

0 commit comments

Comments
 (0)