Index: include/clang/AST/Type.h =================================================================== --- include/clang/AST/Type.h +++ include/clang/AST/Type.h @@ -1638,6 +1638,21 @@ unsigned NumArgs; }; + class PackExpansionTypeBitfields { + friend class PackExpansionType; + + unsigned : NumTypeBits; + + /// The number of expansions that this pack expansion will + /// generate when substituted (+1). + /// + /// This field will only have a non-zero value when some of the parameter + /// packs that occur within the pattern have been substituted but others + /// have not. Intentionally not a bitfield since we have plenty + /// of space left. + unsigned NumExpansions; + }; + union { TypeBitfields TypeBits; ArrayTypeBitfields ArrayTypeBits; @@ -1650,6 +1665,7 @@ TypeWithKeywordBitfields TypeWithKeywordBits; VectorTypeBitfields VectorTypeBits; TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits; + PackExpansionTypeBitfields PackExpansionTypeBits; static_assert(sizeof(TypeBitfields) <= 8, "TypeBitfields is larger than 8 bytes!"); @@ -1674,6 +1690,8 @@ static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8, "TemplateSpecializationTypeBitfields is larger" " than 8 bytes!"); + static_assert(sizeof(PackExpansionTypeBitfields) <= 8, + "PackExpansionTypeBitfields is larger than 8 bytes"); }; private: @@ -5189,22 +5207,16 @@ /// The pattern of the pack expansion. QualType Pattern; - /// The number of expansions that this pack expansion will - /// generate when substituted (+1), or indicates that - /// - /// This field will only have a non-zero value when some of the parameter - /// packs that occur within the pattern have been substituted but others have - /// not. - unsigned NumExpansions; - PackExpansionType(QualType Pattern, QualType Canon, Optional NumExpansions) : Type(PackExpansion, Canon, /*Dependent=*/Pattern->isDependentType(), /*InstantiationDependent=*/true, /*VariablyModified=*/Pattern->isVariablyModifiedType(), /*ContainsUnexpandedParameterPack=*/false), - Pattern(Pattern), - NumExpansions(NumExpansions ? *NumExpansions + 1 : 0) {} + Pattern(Pattern) { + PackExpansionTypeBits.NumExpansions = + NumExpansions ? *NumExpansions + 1 : 0; + } public: /// Retrieve the pattern of this pack expansion, which is the @@ -5215,9 +5227,8 @@ /// Retrieve the number of expansions that this pack expansion will /// generate, if known. Optional getNumExpansions() const { - if (NumExpansions) - return NumExpansions - 1; - + if (PackExpansionTypeBits.NumExpansions) + return PackExpansionTypeBits.NumExpansions - 1; return None; }