Skip to content

Commit d34e086

Browse files
committed
Change return type of getEnumTag in value witness table
make it actually matches the description above
1 parent ff21023 commit d34e086

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

include/swift/ABI/ValueWitness.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ END_VALUE_WITNESS_RANGE(TypeLayoutWitness,
262262
/// [0..NumElements-1].
263263
FUNCTION_VALUE_WITNESS(getEnumTag,
264264
GetEnumTag,
265-
INT_TYPE,
265+
UINT_TYPE,
266266
(IMMUTABLE_VALUE_TYPE, TYPE_TYPE))
267267

268268
BEGIN_VALUE_WITNESS_RANGE(EnumValueWitness,

lib/PrintAsClang/PrintClangValueType.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ void ClangValueTypePrinter::printValueTypeDecl(
228228
"metadata._0);\n";
229229
os << " return _getOpaquePointer();\n";
230230
os << " }\n";
231-
// FIXME: (tongjie) return type should be unsigned
232-
os << " inline int _getEnumTag() const {\n";
231+
os << " inline unsigned _getEnumTag() const {\n";
233232
printEnumVWTableVariable();
234233
os << " return enumVWTable->getEnumTag(_getOpaquePointer(), "
235234
"metadata._0);\n";

test/Interop/SwiftToCxx/core/swift-impl-defs-in-cxx.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
// CHECK-NEXT: unsigned extraInhabitantCount;
5454
// CHECK-NEXT: };
5555
// CHECK-EMPTY:
56-
// CHECK-NEXT: using EnumValueWitnessGetEnumTagTy = int(* __ptrauth_swift_value_witness_function_pointer(41909))(const void * _Nonnull, void * _Nonnull) SWIFT_NOEXCEPT_FUNCTION_PTR;
56+
// CHECK-NEXT: using EnumValueWitnessGetEnumTagTy = unsigned(* __ptrauth_swift_value_witness_function_pointer(41909))(const void * _Nonnull, void * _Nonnull) SWIFT_NOEXCEPT_FUNCTION_PTR;
5757
// CHECK-NEXT: using EnumValueWitnessDestructiveProjectEnumDataTy = void(* __ptrauth_swift_value_witness_function_pointer(1053))(void * _Nonnull, void * _Nonnull) SWIFT_NOEXCEPT_FUNCTION_PTR;
5858
// CHECK-NEXT: using EnumValueWitnessDestructiveInjectEnumTagTy = void(* __ptrauth_swift_value_witness_function_pointer(45796))(void * _Nonnull, unsigned, void * _Nonnull) SWIFT_NOEXCEPT_FUNCTION_PTR;
5959
// CHECK-EMPTY:

test/Interop/SwiftToCxx/enums/swift-enum-case-functions.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public func checkIntDoubleOrBignum(_ x: IntDoubleOrBignum, tag: Int) -> Bool {
170170
// CHECK-NEXT: inline bool isThird() const {
171171
// CHECK-NEXT: return *this == cases::third;
172172
// CHECK-NEXT: }
173-
// CHECK: inline int _getEnumTag() const {
173+
// CHECK: inline unsigned _getEnumTag() const {
174174
// CHECK-NEXT: auto metadata = _impl::$s5Enums12BoolWithCaseOMa(0);
175175
// CHECK-NEXT: auto *vwTableAddr = reinterpret_cast<swift::_impl::ValueWitnessTable **>(metadata._0) - 1;
176176
// CHECK-NEXT: #ifdef __arm64e__
@@ -201,7 +201,7 @@ public func checkIntDoubleOrBignum(_ x: IntDoubleOrBignum, tag: Int) -> Bool {
201201
// CHECK: inline bool isThree() const {
202202
// CHECK-NEXT: return *this == cases::three;
203203
// CHECK-NEXT: }
204-
// CHECK: inline int _getEnumTag() const {
204+
// CHECK: inline unsigned _getEnumTag() const {
205205
// CHECK-NEXT: auto metadata = _impl::$s5Enums9CLikeEnumOMa(0);
206206
// CHECK-NEXT: auto *vwTableAddr = reinterpret_cast<swift::_impl::ValueWitnessTable **>(metadata._0) - 1;
207207
// CHECK-NEXT: #ifdef __arm64e__
@@ -224,7 +224,7 @@ public func checkIntDoubleOrBignum(_ x: IntDoubleOrBignum, tag: Int) -> Bool {
224224
// CHECK-NEXT: inline bool isOne() const {
225225
// CHECK-NEXT: return *this == cases::one;
226226
// CHECK-NEXT: }
227-
// CHECK: inline int _getEnumTag() const {
227+
// CHECK: inline unsigned _getEnumTag() const {
228228
// CHECK-NEXT: auto metadata = _impl::$s5Enums8DataCaseOMa(0);
229229
// CHECK-NEXT: auto *vwTableAddr = reinterpret_cast<swift::_impl::ValueWitnessTable **>(metadata._0) - 1;
230230
// CHECK-NEXT: #ifdef __arm64e__
@@ -255,7 +255,7 @@ public func checkIntDoubleOrBignum(_ x: IntDoubleOrBignum, tag: Int) -> Bool {
255255
// CHECK: inline bool isBignum() const {
256256
// CHECK-NEXT: return *this == cases::Bignum;
257257
// CHECK-NEXT: }
258-
// CHECK: inline int _getEnumTag() const {
258+
// CHECK: inline unsigned _getEnumTag() const {
259259
// CHECK-NEXT: auto metadata = _impl::$s5Enums17IntDoubleOrBignumOMa(0);
260260
// CHECK-NEXT: auto *vwTableAddr = reinterpret_cast<swift::_impl::ValueWitnessTable **>(metadata._0) - 1;
261261
// CHECK-NEXT: #ifdef __arm64e__
@@ -286,7 +286,7 @@ public func checkIntDoubleOrBignum(_ x: IntDoubleOrBignum, tag: Int) -> Bool {
286286
// CHECK: inline bool isPosInfinity() const {
287287
// CHECK-NEXT: return *this == cases::PosInfinity;
288288
// CHECK-NEXT: }
289-
// CHECK: inline int _getEnumTag() const {
289+
// CHECK: inline unsigned _getEnumTag() const {
290290
// CHECK-NEXT: auto metadata = _impl::$s5Enums13IntOrInfinityOMa(0);
291291
// CHECK-NEXT: auto *vwTableAddr = reinterpret_cast<swift::_impl::ValueWitnessTable **>(metadata._0) - 1;
292292
// CHECK-NEXT: #ifdef __arm64e__
@@ -321,7 +321,7 @@ public func checkIntDoubleOrBignum(_ x: IntDoubleOrBignum, tag: Int) -> Bool {
321321
// CHECK-NEXT: inline bool isFourth() const {
322322
// CHECK-NEXT: return *this == cases::fourth;
323323
// CHECK-NEXT: }
324-
// CHECK: inline int _getEnumTag() const {
324+
// CHECK: inline unsigned _getEnumTag() const {
325325
// CHECK-NEXT: auto metadata = _impl::$s5Enums20MultipleBoolWithCaseOMa(0);
326326
// CHECK-NEXT: auto *vwTableAddr = reinterpret_cast<swift::_impl::ValueWitnessTable **>(metadata._0) - 1;
327327
// CHECK-NEXT: #ifdef __arm64e__

0 commit comments

Comments
 (0)