Skip to content

Commit 251282a

Browse files
authored
Merge pull request #13395 from davezarzycki/nfc_repack_AnyFunctionType_bits
[AST] NFC: Repack misc AnyFunctionType bits
2 parents e598ec4 + 4a28744 commit 251282a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

include/swift/AST/Types.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,10 @@ class alignas(1 << TypeAlignInBits) TypeBase {
301301
/// regparm and the calling convention.
302302
enum { NumExtInfoBits = 7 };
303303
unsigned ExtInfo : NumExtInfoBits;
304+
305+
unsigned NumParams : 10;
304306
};
305-
NUMBITS(AnyFunctionType, NumTypeBaseBits + 7);
307+
NUMBITS(AnyFunctionType, NumTypeBaseBits + 17);
306308

307309
struct ArchetypeTypeBitfields {
308310
unsigned : NumTypeBaseBits;
@@ -2397,7 +2399,6 @@ getSILFunctionLanguage(SILFunctionTypeRepresentation rep) {
23972399
class AnyFunctionType : public TypeBase {
23982400
const Type Input;
23992401
const Type Output;
2400-
const unsigned NumParams;
24012402

24022403
public:
24032404
using Representation = FunctionTypeRepresentation;
@@ -2609,9 +2610,10 @@ class AnyFunctionType : public TypeBase {
26092610
AnyFunctionType(TypeKind Kind, const ASTContext *CanTypeContext,
26102611
Type Input, Type Output, RecursiveTypeProperties properties,
26112612
unsigned NumParams, const ExtInfo &Info)
2612-
: TypeBase(Kind, CanTypeContext, properties), Input(Input), Output(Output),
2613-
NumParams(NumParams) {
2613+
: TypeBase(Kind, CanTypeContext, properties), Input(Input), Output(Output) {
26142614
AnyFunctionTypeBits.ExtInfo = Info.Bits;
2615+
AnyFunctionTypeBits.NumParams = NumParams;
2616+
assert(AnyFunctionTypeBits.NumParams == NumParams && "Params dropped!");
26152617
// The use of both assert() and static_assert() is intentional.
26162618
assert(AnyFunctionTypeBits.ExtInfo == Info.Bits && "Bits were dropped!");
26172619
static_assert(ExtInfo::NumMaskBits ==
@@ -2638,7 +2640,7 @@ class AnyFunctionType : public TypeBase {
26382640
Type getInput() const { return Input; }
26392641
Type getResult() const { return Output; }
26402642
ArrayRef<AnyFunctionType::Param> getParams() const;
2641-
unsigned getNumParams() const { return NumParams; }
2643+
unsigned getNumParams() const { return AnyFunctionTypeBits.NumParams; }
26422644

26432645
GenericSignature *getOptGenericSignature() const;
26442646

0 commit comments

Comments
 (0)