@@ -58,7 +58,7 @@ typedef llvm::DenseMap<AssociatedTypeDecl *, TypeWitnessAndDecl>
58
58
enum class ProtocolConformanceKind {
59
59
// / "Normal" conformance of a (possibly generic) nominal type, which
60
60
// / contains complete mappings.
61
- Normal,
61
+ Normal = 0 ,
62
62
// / Self-conformance of a protocol to itself.
63
63
Self,
64
64
// / Conformance for a specialization of a generic type, which projects the
@@ -69,7 +69,13 @@ enum class ProtocolConformanceKind {
69
69
Inherited,
70
70
// / Builtin conformances are special conformances that the runtime handles
71
71
// / and isn't implemented directly in Swift.
72
- Builtin
72
+ Builtin,
73
+
74
+ Last_Kind = Builtin
75
+ };
76
+ enum : unsigned {
77
+ NumProtocolConformanceKindBits =
78
+ countBitsUsed (static_cast <unsigned >(ProtocolConformanceKind::Last_Kind))
73
79
};
74
80
75
81
// / Describes the state of a protocol conformance, which may be complete,
@@ -93,20 +99,35 @@ enum class ProtocolConformanceState {
93
99
// / for the various kinds of conformance (normal, specialized, inherited).
94
100
class alignas (1 << DeclAlignInBits) ProtocolConformance
95
101
: public ASTAllocated<ProtocolConformance> {
96
- // / The kind of protocol conformance.
97
- ProtocolConformanceKind Kind;
98
-
99
102
// / The type that conforms to the protocol, in the context of the
100
103
// / conformance definition.
101
104
Type ConformingType;
102
105
103
106
protected:
107
+ // clang-format off
108
+ //
109
+ // We format these different than clang-format wishes us to... so turn if off
110
+ // for the inline bitfields.
111
+ union { uint64_t OpaqueBits;
112
+
113
+ SWIFT_INLINE_BITFIELD_BASE (ProtocolConformance,
114
+ bitmax (NumProtocolConformanceKindBits, 8 ),
115
+ // / The kind of protocol conformance.
116
+ Kind : bitmax (NumProtocolConformanceKindBits, 8 )
117
+ );
118
+ } Bits;
119
+ // clang-format on
120
+
104
121
ProtocolConformance (ProtocolConformanceKind kind, Type conformingType)
105
- : Kind (kind), ConformingType (conformingType) {}
122
+ : ConformingType (conformingType) {
123
+ Bits.ProtocolConformance .Kind = unsigned (kind);
124
+ }
106
125
107
126
public:
108
127
// / Determine the kind of protocol conformance.
109
- ProtocolConformanceKind getKind () const { return Kind; }
128
+ ProtocolConformanceKind getKind () const {
129
+ return static_cast <ProtocolConformanceKind>(Bits.ProtocolConformance .Kind );
130
+ }
110
131
111
132
// / Get the conforming type.
112
133
Type getType () const { return ConformingType; }
0 commit comments