Skip to content

Commit af7d301

Browse files
committed
[sil] Make ValueOwnershipKind(unsigned) explicit to prevent implicit casts from ints/bools to ValueOwnershipKind.
I hit this problem while splitting classifying operand ownership from the ownership verifier itself. There is no reason to allow for this implicit conversion. Just makes updating code more error prone. rdar://44667493
1 parent 2cf1f63 commit af7d301

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

include/swift/SIL/SILInstruction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6094,7 +6094,8 @@ class UncheckedOwnershipConversionInst
60946094

60956095
public:
60966096
ValueOwnershipKind getConversionOwnershipKind() const {
6097-
return SILInstruction::Bits.UncheckedOwnershipConversionInst.Kind;
6097+
unsigned kind = SILInstruction::Bits.UncheckedOwnershipConversionInst.Kind;
6098+
return ValueOwnershipKind(kind);
60986099
}
60996100
};
61006101

include/swift/SIL/SILValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct ValueOwnershipKind {
123123
"ownership value?!");
124124

125125
ValueOwnershipKind(innerty NewValue) : Value(NewValue) {}
126-
ValueOwnershipKind(unsigned NewValue) : Value(innerty(NewValue)) {}
126+
explicit ValueOwnershipKind(unsigned NewValue) : Value(innerty(NewValue)) {}
127127
ValueOwnershipKind(SILModule &M, SILType Type,
128128
SILArgumentConvention Convention);
129129

0 commit comments

Comments
 (0)