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