@@ -66,18 +66,20 @@ bool isOwnedForwardingInstruction(SILInstruction *inst);
66
66
// / previous terminator.
67
67
bool isOwnedForwardingValue (SILValue value);
68
68
69
- struct BorrowingOperandKind {
70
- enum Kind {
69
+ class BorrowingOperandKind {
70
+ public:
71
+ enum Kind : uint8_t {
71
72
BeginBorrow,
72
73
BeginApply,
73
74
Branch,
74
75
};
75
76
77
+ private:
76
78
Kind value;
77
79
80
+ public:
78
81
BorrowingOperandKind (Kind newValue) : value(newValue) {}
79
- BorrowingOperandKind (const BorrowingOperandKind &other)
80
- : value(other.value) {}
82
+
81
83
operator Kind () const { return value; }
82
84
83
85
static Optional<BorrowingOperandKind> get (SILInstructionKind kind) {
@@ -207,15 +209,20 @@ struct BorrowingOperand {
207
209
llvm::raw_ostream &operator <<(llvm::raw_ostream &os,
208
210
const BorrowingOperand &operand);
209
211
210
- struct BorrowedValueKind {
212
+ class BorrowedValueKind {
213
+ public:
211
214
// / Enum we use for exhaustive pattern matching over borrow scope introducers.
212
- enum Kind {
215
+ enum Kind : uint8_t {
213
216
LoadBorrow,
214
217
BeginBorrow,
215
218
SILFunctionArgument,
216
219
Phi,
217
220
};
218
221
222
+ private:
223
+ Kind value;
224
+
225
+ public:
219
226
static Optional<BorrowedValueKind> get (SILValue value) {
220
227
if (value.getOwnershipKind () != ValueOwnershipKind::Guaranteed)
221
228
return None;
@@ -240,10 +247,8 @@ struct BorrowedValueKind {
240
247
}
241
248
}
242
249
243
- Kind value;
244
-
245
250
BorrowedValueKind (Kind newValue) : value(newValue) {}
246
- BorrowedValueKind ( const BorrowedValueKind &other) : value(other.value) {}
251
+
247
252
operator Kind () const { return value; }
248
253
249
254
// / Is this a borrow scope that begins and ends within the same function and
@@ -383,18 +388,20 @@ bool getAllBorrowIntroducingValues(SILValue value,
383
388
// / introducer, then we return a .some(BorrowScopeIntroducingValue).
384
389
Optional<BorrowedValue> getSingleBorrowIntroducingValue (SILValue inputValue);
385
390
386
- struct InteriorPointerOperandKind {
391
+ class InteriorPointerOperandKind {
392
+ public:
387
393
enum Kind : uint8_t {
388
394
RefElementAddr,
389
395
RefTailAddr,
390
396
OpenExistentialBox,
391
397
};
392
398
399
+ private:
393
400
Kind value;
394
401
402
+ public:
395
403
InteriorPointerOperandKind (Kind newValue) : value(newValue) {}
396
- InteriorPointerOperandKind (const InteriorPointerOperandKind &other)
397
- : value(other.value) {}
404
+
398
405
operator Kind () const { return value; }
399
406
400
407
static Optional<InteriorPointerOperandKind> get (Operand *use) {
@@ -467,8 +474,9 @@ struct InteriorPointerOperand {
467
474
: operand(op), kind(kind) {}
468
475
};
469
476
470
- struct OwnedValueIntroducerKind {
471
- enum Kind {
477
+ class OwnedValueIntroducerKind {
478
+ public:
479
+ enum Kind : uint8_t {
472
480
// / An owned value that is a result of an Apply.
473
481
Apply,
474
482
@@ -519,6 +527,10 @@ struct OwnedValueIntroducerKind {
519
527
AllocRefInit,
520
528
};
521
529
530
+ private:
531
+ Kind value;
532
+
533
+ public:
522
534
static Optional<OwnedValueIntroducerKind> get (SILValue value) {
523
535
if (value.getOwnershipKind () != ValueOwnershipKind::Owned)
524
536
return None;
@@ -569,11 +581,8 @@ struct OwnedValueIntroducerKind {
569
581
llvm_unreachable (" Default should have caught this" );
570
582
}
571
583
572
- Kind value;
573
-
574
584
OwnedValueIntroducerKind (Kind newValue) : value(newValue) {}
575
- OwnedValueIntroducerKind (const OwnedValueIntroducerKind &other)
576
- : value(other.value) {}
585
+
577
586
operator Kind () const { return value; }
578
587
579
588
void print (llvm::raw_ostream &os) const ;
0 commit comments