Skip to content

Commit c3ae675

Browse files
committed
[AST] NFC: Repack misc ParenType bits
1 parent 4d56dfc commit c3ae675

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

include/swift/AST/Types.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,15 @@ class alignas(1 << TypeAlignInBits) TypeBase {
285285
};
286286
NUMBITS(ErrorType, NumTypeBaseBits + 1);
287287

288+
struct ParenTypeBitfields {
289+
unsigned : NumTypeBaseBits;
290+
291+
/// Whether there is an original type.
292+
enum { NumFlagBits = 5 };
293+
unsigned Flags : NumFlagBits;
294+
};
295+
NUMBITS(ParenType, NumTypeBaseBits + ParenTypeBitfields::NumFlagBits);
296+
288297
struct AnyFunctionTypeBitfields {
289298
unsigned : NumTypeBaseBits;
290299

@@ -353,6 +362,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
353362
union {
354363
TypeBaseBitfields TypeBaseBits;
355364
ErrorTypeBitfields ErrorTypeBits;
365+
ParenTypeBitfields ParenTypeBits;
356366
AnyFunctionTypeBitfields AnyFunctionTypeBits;
357367
TypeVariableTypeBitfields TypeVariableTypeBits;
358368
ArchetypeTypeBitfields ArchetypeTypeBits;
@@ -1415,6 +1425,9 @@ class ParameterTypeFlags {
14151425

14161426
public:
14171427
ParameterTypeFlags() = default;
1428+
static ParameterTypeFlags fromRaw(uint8_t raw) {
1429+
return ParameterTypeFlags(OptionSet<ParameterFlags>(raw));
1430+
}
14181431

14191432
ParameterTypeFlags(bool variadic, bool autoclosure, bool escaping, bool inOut, bool shared)
14201433
: value((variadic ? Variadic : 0) |
@@ -1465,7 +1478,6 @@ class ParameterTypeFlags {
14651478
/// ParenType - A paren type is a type that's been written in parentheses.
14661479
class ParenType : public TypeBase {
14671480
Type UnderlyingType;
1468-
ParameterTypeFlags parameterFlags;
14691481

14701482
friend class ASTContext;
14711483

@@ -1482,7 +1494,9 @@ class ParenType : public TypeBase {
14821494
TypeBase *getSinglyDesugaredType();
14831495

14841496
/// Get the parameter flags
1485-
ParameterTypeFlags getParameterFlags() const { return parameterFlags; }
1497+
ParameterTypeFlags getParameterFlags() const {
1498+
return ParameterTypeFlags::fromRaw(ParenTypeBits.Flags);
1499+
}
14861500

14871501
// Implement isa/cast/dyncast/etc.
14881502
static bool classof(const TypeBase *T) {

lib/AST/Type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,8 +1314,8 @@ ParenType::ParenType(Type baseType, RecursiveTypeProperties properties,
13141314
: TypeBase(TypeKind::Paren, nullptr, properties),
13151315
UnderlyingType(flags.isInOut()
13161316
? InOutType::get(baseType)
1317-
: baseType),
1318-
parameterFlags(flags) {
1317+
: baseType) {
1318+
ParenTypeBits.Flags = flags.toRaw();
13191319
if (flags.isInOut())
13201320
assert(!baseType->is<InOutType>() && "caller did not pass a base type");
13211321
if (baseType->is<InOutType>())

0 commit comments

Comments
 (0)