Skip to content

Commit 91f9f9d

Browse files
committed
[AST] NFC: Pack FuncDecl bits into intrusive bitfield
1 parent 9b9d173 commit 91f9f9d

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

include/swift/AST/Decl.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,21 @@ class alignas(1 << DeclAlignInBits) Decl {
364364
unsigned DefaultArgumentResilienceExpansion : 1;
365365
BITFIELD_END;
366366

367-
BITFIELD_START(FuncDecl, AbstractFunctionDecl, 3);
367+
BITFIELD_START(FuncDecl, AbstractFunctionDecl, 7);
368368
/// Whether this function is a 'static' method.
369369
unsigned IsStatic : 1;
370370

371371
/// \brief Whether 'static' or 'class' was used.
372372
unsigned StaticSpelling : 2;
373+
374+
/// Whether we are statically dispatched even if overridable
375+
unsigned ForcedStaticDispatch : 1;
376+
377+
/// Whether this function has a dynamic Self return type.
378+
unsigned HasDynamicSelf : 1;
379+
380+
/// Backing bits for 'self' access kind.
381+
unsigned SelfAccess : 2;
373382
BITFIELD_END;
374383

375384
BITFIELD_START(ConstructorDecl, AbstractFunctionDecl, 8);
@@ -5157,15 +5166,6 @@ class FuncDecl final : public AbstractFunctionDecl,
51575166

51585167
TypeLoc FnRetType;
51595168

5160-
/// Whether we are statically dispatched even if overridable
5161-
unsigned ForcedStaticDispatch : 1;
5162-
5163-
/// Whether this function has a dynamic Self return type.
5164-
unsigned HasDynamicSelf : 1;
5165-
5166-
/// Backing bits for 'self' access kind.
5167-
unsigned SelfAccess : 2;
5168-
51695169
/// \brief If this FuncDecl is an accessor for a property, this indicates
51705170
/// which property and what kind of accessor.
51715171
llvm::PointerIntPair<AbstractStorageDecl*, 3, AccessorKind> AccessorDecl;
@@ -5194,9 +5194,9 @@ class FuncDecl final : public AbstractFunctionDecl,
51945194
FuncDeclBits.StaticSpelling = static_cast<unsigned>(StaticSpelling);
51955195
assert(NumParameterLists > 0 && "Must have at least an empty tuple arg");
51965196

5197-
HasDynamicSelf = false;
5198-
ForcedStaticDispatch = false;
5199-
SelfAccess = static_cast<unsigned>(SelfAccessKind::NonMutating);
5197+
FuncDeclBits.HasDynamicSelf = false;
5198+
FuncDeclBits.ForcedStaticDispatch = false;
5199+
FuncDeclBits.SelfAccess = static_cast<unsigned>(SelfAccessKind::NonMutating);
52005200
}
52015201

52025202
static FuncDecl *createImpl(ASTContext &Context, SourceLoc StaticLoc,
@@ -5263,10 +5263,10 @@ class FuncDecl final : public AbstractFunctionDecl,
52635263
}
52645264

52655265
SelfAccessKind getSelfAccessKind() const {
5266-
return static_cast<SelfAccessKind>(SelfAccess);
5266+
return static_cast<SelfAccessKind>(FuncDeclBits.SelfAccess);
52675267
}
52685268
void setSelfAccessKind(SelfAccessKind mod) {
5269-
SelfAccess = static_cast<unsigned>(mod);
5269+
FuncDeclBits.SelfAccess = static_cast<unsigned>(mod);
52705270
}
52715271

52725272
/// \brief Returns the parameter lists(s) for the function definition.
@@ -5374,11 +5374,11 @@ class FuncDecl final : public AbstractFunctionDecl,
53745374

53755375
/// Determine whether this function has a dynamic \c Self return
53765376
/// type.
5377-
bool hasDynamicSelf() const { return HasDynamicSelf; }
5377+
bool hasDynamicSelf() const { return FuncDeclBits.HasDynamicSelf; }
53785378

53795379
/// Set whether this function has a dynamic \c Self return or not.
53805380
void setDynamicSelf(bool hasDynamicSelf) {
5381-
HasDynamicSelf = hasDynamicSelf;
5381+
FuncDeclBits.HasDynamicSelf = hasDynamicSelf;
53825382
}
53835383

53845384
void getLocalCaptures(SmallVectorImpl<CapturedValue> &Result) const {
@@ -5427,10 +5427,10 @@ class FuncDecl final : public AbstractFunctionDecl,
54275427

54285428
/// Returns true if the function is forced to be statically dispatched.
54295429
bool hasForcedStaticDispatch() const {
5430-
return ForcedStaticDispatch;
5430+
return FuncDeclBits.ForcedStaticDispatch;
54315431
}
54325432
void setForcedStaticDispatch(bool flag) {
5433-
ForcedStaticDispatch = flag;
5433+
FuncDeclBits.ForcedStaticDispatch = flag;
54345434
}
54355435

54365436
static bool classof(const Decl *D) { return D->getKind() == DeclKind::Func; }

0 commit comments

Comments
 (0)