Skip to content

Commit 8682002

Browse files
committed
[ownership] Rename BorrowScopeOperandKind -> BorrowingOperandKind.
I missed this when I was doing the original refactoring. This was again done using Xcode's refactoring functionality!
1 parent dbe0cfa commit 8682002

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

include/swift/SIL/OwnershipUtils.h

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bool isOwnedForwardingInstruction(SILInstruction *inst);
6666
/// previous terminator.
6767
bool isOwnedForwardingValue(SILValue value);
6868

69-
struct BorrowScopeOperandKind {
69+
struct BorrowingOperandKind {
7070
enum Kind {
7171
BeginBorrow,
7272
BeginApply,
@@ -75,30 +75,29 @@ struct BorrowScopeOperandKind {
7575

7676
Kind value;
7777

78-
BorrowScopeOperandKind(Kind newValue) : value(newValue) {}
79-
BorrowScopeOperandKind(const BorrowScopeOperandKind &other)
78+
BorrowingOperandKind(Kind newValue) : value(newValue) {}
79+
BorrowingOperandKind(const BorrowingOperandKind &other)
8080
: value(other.value) {}
8181
operator Kind() const { return value; }
8282

83-
static Optional<BorrowScopeOperandKind> get(SILInstructionKind kind) {
83+
static Optional<BorrowingOperandKind> get(SILInstructionKind kind) {
8484
switch (kind) {
8585
default:
8686
return None;
8787
case SILInstructionKind::BeginBorrowInst:
88-
return BorrowScopeOperandKind(BeginBorrow);
88+
return BorrowingOperandKind(BeginBorrow);
8989
case SILInstructionKind::BeginApplyInst:
90-
return BorrowScopeOperandKind(BeginApply);
90+
return BorrowingOperandKind(BeginApply);
9191
case SILInstructionKind::BranchInst:
92-
return BorrowScopeOperandKind(Branch);
92+
return BorrowingOperandKind(Branch);
9393
}
9494
}
9595

9696
void print(llvm::raw_ostream &os) const;
9797
SWIFT_DEBUG_DUMP { print(llvm::dbgs()); }
9898
};
9999

100-
llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
101-
BorrowScopeOperandKind kind);
100+
llvm::raw_ostream &operator<<(llvm::raw_ostream &os, BorrowingOperandKind kind);
102101

103102
struct BorrowedValue;
104103

@@ -111,11 +110,11 @@ struct BorrowedValue;
111110
/// guaranteed value in the same function: see begin_apply. In such cases, we
112111
/// require instead an end_* instruction to mark the end of the scope's region.
113112
struct BorrowingOperand {
114-
BorrowScopeOperandKind kind;
113+
BorrowingOperandKind kind;
115114
Operand *op;
116115

117116
BorrowingOperand(Operand *op)
118-
: kind(*BorrowScopeOperandKind::get(op->getUser()->getKind())), op(op) {}
117+
: kind(*BorrowingOperandKind::get(op->getUser()->getKind())), op(op) {}
119118
BorrowingOperand(const BorrowingOperand &other)
120119
: kind(other.kind), op(other.op) {}
121120
BorrowingOperand &operator=(const BorrowingOperand &other) {
@@ -127,7 +126,7 @@ struct BorrowingOperand {
127126
/// If value is a borrow introducer return it after doing some checks.
128127
static Optional<BorrowingOperand> get(Operand *op) {
129128
auto *user = op->getUser();
130-
auto kind = BorrowScopeOperandKind::get(user->getKind());
129+
auto kind = BorrowingOperandKind::get(user->getKind());
131130
if (!kind)
132131
return None;
133132
return BorrowingOperand(*kind, op);
@@ -139,10 +138,10 @@ struct BorrowingOperand {
139138
/// values and produces a new scope afterwards.
140139
bool consumesGuaranteedValues() const {
141140
switch (kind) {
142-
case BorrowScopeOperandKind::BeginBorrow:
143-
case BorrowScopeOperandKind::BeginApply:
141+
case BorrowingOperandKind::BeginBorrow:
142+
case BorrowingOperandKind::BeginApply:
144143
return false;
145-
case BorrowScopeOperandKind::Branch:
144+
case BorrowingOperandKind::Branch:
146145
return true;
147146
}
148147
llvm_unreachable("Covered switch isn't covered?!");
@@ -152,10 +151,10 @@ struct BorrowingOperand {
152151
/// for owned values.
153152
bool canAcceptOwnedValues() const {
154153
switch (kind) {
155-
case BorrowScopeOperandKind::BeginBorrow:
156-
case BorrowScopeOperandKind::BeginApply:
154+
case BorrowingOperandKind::BeginBorrow:
155+
case BorrowingOperandKind::BeginApply:
157156
return true;
158-
case BorrowScopeOperandKind::Branch:
157+
case BorrowingOperandKind::Branch:
159158
return false;
160159
}
161160
llvm_unreachable("Covered switch isn't covered?!");
@@ -167,10 +166,10 @@ struct BorrowingOperand {
167166
bool areAnyUserResultsBorrowIntroducers() const {
168167
// TODO: Can we derive this by running a borrow introducer check ourselves?
169168
switch (kind) {
170-
case BorrowScopeOperandKind::BeginBorrow:
171-
case BorrowScopeOperandKind::Branch:
169+
case BorrowingOperandKind::BeginBorrow:
170+
case BorrowingOperandKind::Branch:
172171
return true;
173-
case BorrowScopeOperandKind::BeginApply:
172+
case BorrowingOperandKind::BeginApply:
174173
return false;
175174
}
176175
llvm_unreachable("Covered switch isn't covered?!");
@@ -201,7 +200,7 @@ struct BorrowingOperand {
201200
private:
202201
/// Internal constructor for failable static constructor. Please do not expand
203202
/// its usage since it assumes the code passed in is well formed.
204-
BorrowingOperand(BorrowScopeOperandKind kind, Operand *op)
203+
BorrowingOperand(BorrowingOperandKind kind, Operand *op)
205204
: kind(kind), op(op) {}
206205
};
207206

lib/SIL/OwnershipUtils.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ bool swift::isOwnershipForwardingInst(SILInstruction *i) {
120120
}
121121

122122
//===----------------------------------------------------------------------===//
123-
// Borrow Scope Operand
123+
// Borrowing Operand
124124
//===----------------------------------------------------------------------===//
125125

126-
void BorrowScopeOperandKind::print(llvm::raw_ostream &os) const {
126+
void BorrowingOperandKind::print(llvm::raw_ostream &os) const {
127127
switch (value) {
128128
case Kind::BeginBorrow:
129129
os << "BeginBorrow";
@@ -139,7 +139,7 @@ void BorrowScopeOperandKind::print(llvm::raw_ostream &os) const {
139139
}
140140

141141
llvm::raw_ostream &swift::operator<<(llvm::raw_ostream &os,
142-
BorrowScopeOperandKind kind) {
142+
BorrowingOperandKind kind) {
143143
kind.print(os);
144144
return os;
145145
}
@@ -160,21 +160,21 @@ llvm::raw_ostream &swift::operator<<(llvm::raw_ostream &os,
160160
void BorrowingOperand::visitEndScopeInstructions(
161161
function_ref<void(Operand *)> func) const {
162162
switch (kind) {
163-
case BorrowScopeOperandKind::BeginBorrow:
163+
case BorrowingOperandKind::BeginBorrow:
164164
for (auto *use : cast<BeginBorrowInst>(op->getUser())->getUses()) {
165165
if (use->isConsumingUse()) {
166166
func(use);
167167
}
168168
}
169169
return;
170-
case BorrowScopeOperandKind::BeginApply: {
170+
case BorrowingOperandKind::BeginApply: {
171171
auto *user = cast<BeginApplyInst>(op->getUser());
172172
for (auto *use : user->getTokenResult()->getUses()) {
173173
func(use);
174174
}
175175
return;
176176
}
177-
case BorrowScopeOperandKind::Branch:
177+
case BorrowingOperandKind::Branch:
178178
for (auto *succBlock :
179179
cast<BranchInst>(op->getUser())->getSuccessorBlocks()) {
180180
auto *arg = succBlock->getArgument(op->getOperandNumber());
@@ -192,13 +192,13 @@ void BorrowingOperand::visitEndScopeInstructions(
192192
void BorrowingOperand::visitBorrowIntroducingUserResults(
193193
function_ref<void(BorrowedValue)> visitor) {
194194
switch (kind) {
195-
case BorrowScopeOperandKind::BeginApply:
195+
case BorrowingOperandKind::BeginApply:
196196
llvm_unreachable("Never has borrow introducer results!");
197-
case BorrowScopeOperandKind::BeginBorrow: {
197+
case BorrowingOperandKind::BeginBorrow: {
198198
auto value = *BorrowedValue::get(cast<BeginBorrowInst>(op->getUser()));
199199
return visitor(value);
200200
}
201-
case BorrowScopeOperandKind::Branch: {
201+
case BorrowingOperandKind::Branch: {
202202
auto *bi = cast<BranchInst>(op->getUser());
203203
for (auto *succBlock : bi->getSuccessorBlocks()) {
204204
auto value =

0 commit comments

Comments
 (0)