@@ -2226,21 +2226,6 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
22262226 unsigned NumExpansions;
22272227 };
22282228
2229- class CountAttributedTypeBitfields {
2230- friend class CountAttributedType ;
2231-
2232- LLVM_PREFERRED_TYPE (TypeBitfields)
2233- unsigned : NumTypeBits;
2234-
2235- static constexpr unsigned NumCoupledDeclsBits = 4 ;
2236- unsigned NumCoupledDecls : NumCoupledDeclsBits;
2237- LLVM_PREFERRED_TYPE (bool )
2238- unsigned CountInBytes : 1 ;
2239- LLVM_PREFERRED_TYPE (bool )
2240- unsigned OrNull : 1 ;
2241- };
2242- static_assert (sizeof (CountAttributedTypeBitfields) <= sizeof (unsigned ));
2243-
22442229 union {
22452230 TypeBitfields TypeBits;
22462231 ArrayTypeBitfields ArrayTypeBits;
@@ -2263,7 +2248,6 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
22632248 DependentTemplateSpecializationTypeBitfields
22642249 DependentTemplateSpecializationTypeBits;
22652250 PackExpansionTypeBitfields PackExpansionTypeBits;
2266- CountAttributedTypeBitfields CountAttributedTypeBits;
22672251 };
22682252
22692253private:
@@ -3269,7 +3253,19 @@ class CountAttributedType final
32693253 TypeCoupledDeclRefInfo> {
32703254 friend class ASTContext ;
32713255
3256+ public:
3257+ enum DynamicCountPointerKind {
3258+ CountedBy = 0 ,
3259+ SizedBy,
3260+ CountedByOrNull,
3261+ SizedByOrNull,
3262+ };
3263+
3264+ private:
32723265 Expr *CountExpr;
3266+ LLVM_PREFERRED_TYPE (DynamicCountPointerKind)
3267+ unsigned Kind : 2 ;
3268+
32733269 // / \p CountExpr represents the argument of __counted_by or the likes. \p
32743270 // / CountInBytes indicates that \p CountExpr is a byte count (i.e.,
32753271 // / __sized_by(_or_null)) \p OrNull means it's an or_null variant (i.e.,
@@ -3281,29 +3277,20 @@ class CountAttributedType final
32813277 ArrayRef<TypeCoupledDeclRefInfo> CoupledDecls);
32823278
32833279 unsigned numTrailingObjects (OverloadToken<TypeCoupledDeclRefInfo>) const {
3284- return CountAttributedTypeBits. NumCoupledDecls ;
3280+ return Decls. size () ;
32853281 }
32863282
32873283public:
3288- enum DynamicCountPointerKind {
3289- CountedBy = 0 ,
3290- SizedBy,
3291- CountedByOrNull,
3292- SizedByOrNull,
3293- };
3294-
32953284 Expr *getCountExpr () const { return CountExpr; }
3296- bool isCountInBytes () const { return CountAttributedTypeBits. CountInBytes ; }
3297- bool isOrNull () const { return CountAttributedTypeBits. OrNull ; }
3285+ bool isCountInBytes () const { return static_cast < unsigned >( getKind ()) & 1 ; }
3286+ bool isOrNull () const { return static_cast < unsigned >( getKind ()) & 2 ; }
32983287
32993288 DynamicCountPointerKind getKind () const {
3300- if (isOrNull ())
3301- return isCountInBytes () ? SizedByOrNull : CountedByOrNull;
3302- return isCountInBytes () ? SizedBy : CountedBy;
3289+ return static_cast <DynamicCountPointerKind>(Kind);
33033290 }
33043291
33053292 void Profile (llvm::FoldingSetNodeID &ID ) {
3306- Profile (ID , desugar (), CountExpr , isCountInBytes (), isOrNull ());
3293+ Profile (ID , desugar (), getCountExpr () , isCountInBytes (), isOrNull ());
33073294 }
33083295
33093296 static void Profile (llvm::FoldingSetNodeID &ID , QualType WrappedTy,
0 commit comments