eopXD updated this revision to Diff 529634. eopXD added a comment. Address comment from Aaron.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152429/new/ https://reviews.llvm.org/D152429 Files: clang/include/clang/AST/Type.h Index: clang/include/clang/AST/Type.h =================================================================== --- clang/include/clang/AST/Type.h +++ clang/include/clang/AST/Type.h @@ -1649,7 +1649,8 @@ unsigned : NumTypeBits; /// The kind (BuiltinType::Kind) of builtin type this is. - unsigned Kind : 8; + static constexpr unsigned NumOfBuiltinTypeBits = 8; + unsigned Kind : NumOfBuiltinTypeBits; }; /// FunctionTypeBitfields store various bits belonging to FunctionProtoType. @@ -2677,6 +2678,10 @@ : Type(Builtin, QualType(), K == Dependent ? TypeDependence::DependentInstantiation : TypeDependence::None) { + static_assert(Kind::LastKind < + (1 << BuiltinTypeBitfields::NumOfBuiltinTypeBits) && + "Defined builtin type exceeds the allocated space for serial " + "numbering"); BuiltinTypeBits.Kind = K; }
Index: clang/include/clang/AST/Type.h =================================================================== --- clang/include/clang/AST/Type.h +++ clang/include/clang/AST/Type.h @@ -1649,7 +1649,8 @@ unsigned : NumTypeBits; /// The kind (BuiltinType::Kind) of builtin type this is. - unsigned Kind : 8; + static constexpr unsigned NumOfBuiltinTypeBits = 8; + unsigned Kind : NumOfBuiltinTypeBits; }; /// FunctionTypeBitfields store various bits belonging to FunctionProtoType. @@ -2677,6 +2678,10 @@ : Type(Builtin, QualType(), K == Dependent ? TypeDependence::DependentInstantiation : TypeDependence::None) { + static_assert(Kind::LastKind < + (1 << BuiltinTypeBitfields::NumOfBuiltinTypeBits) && + "Defined builtin type exceeds the allocated space for serial " + "numbering"); BuiltinTypeBits.Kind = K; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits