@@ -58,7 +58,7 @@ typedef llvm::DenseMap<AssociatedTypeDecl *, TypeWitnessAndDecl>
5858enum class ProtocolConformanceKind {
5959 // / "Normal" conformance of a (possibly generic) nominal type, which
6060 // / contains complete mappings.
61- Normal,
61+ Normal = 0 ,
6262 // / Self-conformance of a protocol to itself.
6363 Self,
6464 // / Conformance for a specialization of a generic type, which projects the
@@ -69,7 +69,13 @@ enum class ProtocolConformanceKind {
6969 Inherited,
7070 // / Builtin conformances are special conformances that the runtime handles
7171 // / 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))
7379};
7480
7581// / Describes the state of a protocol conformance, which may be complete,
@@ -93,20 +99,35 @@ enum class ProtocolConformanceState {
9399// / for the various kinds of conformance (normal, specialized, inherited).
94100class alignas (1 << DeclAlignInBits) ProtocolConformance
95101 : public ASTAllocated<ProtocolConformance> {
96- // / The kind of protocol conformance.
97- ProtocolConformanceKind Kind;
98-
99102 // / The type that conforms to the protocol, in the context of the
100103 // / conformance definition.
101104 Type ConformingType;
102105
103106protected:
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+
104121 ProtocolConformance (ProtocolConformanceKind kind, Type conformingType)
105- : Kind (kind), ConformingType (conformingType) {}
122+ : ConformingType (conformingType) {
123+ Bits.ProtocolConformance .Kind = unsigned (kind);
124+ }
106125
107126public:
108127 // / 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+ }
110131
111132 // / Get the conforming type.
112133 Type getType () const { return ConformingType; }
0 commit comments