@@ -224,6 +224,26 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, StaticSpellingKind SSK);
224
224
// / Diagnostic printing of \c ReferenceOwnership.
225
225
llvm::raw_ostream &operator <<(llvm::raw_ostream &OS, ReferenceOwnership RO);
226
226
227
+ enum class SelfAccessKind : uint8_t {
228
+ NonMutating,
229
+ Mutating,
230
+ LegacyConsuming,
231
+ Consuming,
232
+ Borrowing,
233
+ LastSelfAccessKind = Borrowing,
234
+ };
235
+ enum : unsigned {
236
+ NumSelfAccessKindBits =
237
+ countBitsUsed (static_cast <unsigned >(SelfAccessKind::LastSelfAccessKind))
238
+ };
239
+ static_assert (uint8_t (SelfAccessKind::LastSelfAccessKind) <
240
+ (NumSelfAccessKindBits << 1 ),
241
+ " Self Access Kind is too small to fit in SelfAccess kind bits. "
242
+ " Please expand " );
243
+
244
+ // / Diagnostic printing of \c SelfAccessKind.
245
+ llvm::raw_ostream &operator <<(llvm::raw_ostream &OS, SelfAccessKind SAK);
246
+
227
247
// / Encapsulation of the overload signature of a given declaration,
228
248
// / which is used to determine uniqueness of a declaration within a
229
249
// / given context.
@@ -315,6 +335,10 @@ enum class ArtificialMainKind : uint8_t {
315
335
// / Decl - Base class for all declarations in Swift.
316
336
class alignas (1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
317
337
protected:
338
+ // clang-format off
339
+ //
340
+ // We format these different than clang-format wishes us to... so turn if off
341
+ // for the inline bitfields.
318
342
union { uint64_t OpaqueBits;
319
343
320
344
SWIFT_INLINE_BITFIELD_BASE (Decl, bitmax (NumDeclKindBits,8 )+1 +1 +1 +1 +1 ,
@@ -456,7 +480,8 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
456
480
DistributedThunk: 1
457
481
);
458
482
459
- SWIFT_INLINE_BITFIELD (FuncDecl, AbstractFunctionDecl, 1 +1 +2 +1 +1 +2 +1 ,
483
+ SWIFT_INLINE_BITFIELD (FuncDecl, AbstractFunctionDecl,
484
+ 1 +1 +2 +1 +1 +NumSelfAccessKindBits+1 ,
460
485
// / Whether we've computed the 'static' flag yet.
461
486
IsStaticComputed : 1 ,
462
487
@@ -473,7 +498,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
473
498
SelfAccessComputed : 1 ,
474
499
475
500
// / Backing bits for 'self' access kind.
476
- SelfAccess : 2 ,
501
+ SelfAccess : NumSelfAccessKindBits ,
477
502
478
503
// / Whether this is a top-level function which should be treated
479
504
// / as if it were in local context for the purposes of capture
@@ -735,6 +760,8 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
735
760
);
736
761
737
762
} Bits;
763
+ // Turn back on clang-format now that we have defined our inline bitfields.
764
+ // clang-format on
738
765
739
766
// Storage for the declaration attributes.
740
767
DeclAttributes Attrs;
@@ -7234,17 +7261,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
7234
7261
7235
7262
class OperatorDecl ;
7236
7263
7237
- enum class SelfAccessKind : uint8_t {
7238
- NonMutating,
7239
- Mutating,
7240
- LegacyConsuming,
7241
- Consuming,
7242
- Borrowing,
7243
- };
7244
-
7245
- // / Diagnostic printing of \c SelfAccessKind.
7246
- llvm::raw_ostream &operator <<(llvm::raw_ostream &OS, SelfAccessKind SAK);
7247
-
7248
7264
// / FuncDecl - 'func' declaration.
7249
7265
class FuncDecl : public AbstractFunctionDecl {
7250
7266
friend class AbstractFunctionDecl ;
0 commit comments