Skip to content

Commit ef1b5a8

Browse files
authored
Merge pull request swiftlang#32405 from davezarzycki/pr32405
2 parents ba59ef5 + ced3b39 commit ef1b5a8

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

include/swift/SIL/OwnershipUtils.h

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

69-
struct BorrowingOperandKind {
70-
enum Kind {
69+
class BorrowingOperandKind {
70+
public:
71+
enum Kind : uint8_t {
7172
BeginBorrow,
7273
BeginApply,
7374
Branch,
7475
};
7576

77+
private:
7678
Kind value;
7779

80+
public:
7881
BorrowingOperandKind(Kind newValue) : value(newValue) {}
79-
BorrowingOperandKind(const BorrowingOperandKind &other)
80-
: value(other.value) {}
82+
8183
operator Kind() const { return value; }
8284

8385
static Optional<BorrowingOperandKind> get(SILInstructionKind kind) {
@@ -207,15 +209,20 @@ struct BorrowingOperand {
207209
llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
208210
const BorrowingOperand &operand);
209211

210-
struct BorrowedValueKind {
212+
class BorrowedValueKind {
213+
public:
211214
/// Enum we use for exhaustive pattern matching over borrow scope introducers.
212-
enum Kind {
215+
enum Kind : uint8_t {
213216
LoadBorrow,
214217
BeginBorrow,
215218
SILFunctionArgument,
216219
Phi,
217220
};
218221

222+
private:
223+
Kind value;
224+
225+
public:
219226
static Optional<BorrowedValueKind> get(SILValue value) {
220227
if (value.getOwnershipKind() != ValueOwnershipKind::Guaranteed)
221228
return None;
@@ -240,10 +247,8 @@ struct BorrowedValueKind {
240247
}
241248
}
242249

243-
Kind value;
244-
245250
BorrowedValueKind(Kind newValue) : value(newValue) {}
246-
BorrowedValueKind(const BorrowedValueKind &other) : value(other.value) {}
251+
247252
operator Kind() const { return value; }
248253

249254
/// Is this a borrow scope that begins and ends within the same function and
@@ -383,18 +388,20 @@ bool getAllBorrowIntroducingValues(SILValue value,
383388
/// introducer, then we return a .some(BorrowScopeIntroducingValue).
384389
Optional<BorrowedValue> getSingleBorrowIntroducingValue(SILValue inputValue);
385390

386-
struct InteriorPointerOperandKind {
391+
class InteriorPointerOperandKind {
392+
public:
387393
enum Kind : uint8_t {
388394
RefElementAddr,
389395
RefTailAddr,
390396
OpenExistentialBox,
391397
};
392398

399+
private:
393400
Kind value;
394401

402+
public:
395403
InteriorPointerOperandKind(Kind newValue) : value(newValue) {}
396-
InteriorPointerOperandKind(const InteriorPointerOperandKind &other)
397-
: value(other.value) {}
404+
398405
operator Kind() const { return value; }
399406

400407
static Optional<InteriorPointerOperandKind> get(Operand *use) {
@@ -467,8 +474,9 @@ struct InteriorPointerOperand {
467474
: operand(op), kind(kind) {}
468475
};
469476

470-
struct OwnedValueIntroducerKind {
471-
enum Kind {
477+
class OwnedValueIntroducerKind {
478+
public:
479+
enum Kind : uint8_t {
472480
/// An owned value that is a result of an Apply.
473481
Apply,
474482

@@ -519,6 +527,10 @@ struct OwnedValueIntroducerKind {
519527
AllocRefInit,
520528
};
521529

530+
private:
531+
Kind value;
532+
533+
public:
522534
static Optional<OwnedValueIntroducerKind> get(SILValue value) {
523535
if (value.getOwnershipKind() != ValueOwnershipKind::Owned)
524536
return None;
@@ -569,11 +581,8 @@ struct OwnedValueIntroducerKind {
569581
llvm_unreachable("Default should have caught this");
570582
}
571583

572-
Kind value;
573-
574584
OwnedValueIntroducerKind(Kind newValue) : value(newValue) {}
575-
OwnedValueIntroducerKind(const OwnedValueIntroducerKind &other)
576-
: value(other.value) {}
585+
577586
operator Kind() const { return value; }
578587

579588
void print(llvm::raw_ostream &os) const;

0 commit comments

Comments
 (0)