================ @@ -3298,22 +3315,40 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) { /// { i16 TypeKind, i16 TypeInfo } /// \endcode /// -/// followed by an array of i8 containing the type name. TypeKind is 0 for an -/// integer, 1 for a floating point value, and -1 for anything else. +/// followed by an array of i8 containing the type name with extra information +/// for BitInt. TypeKind is TK_Integer(0) for an integer, TK_Float(1) for a +/// floating point value, TK_BitInt(2) for BitInt and TK_Unknown(0xFFFF) for +/// anything else. llvm::Constant *CodeGenFunction::EmitCheckTypeDescriptor(QualType T) { // Only emit each type's descriptor once. if (llvm::Constant *C = CGM.getTypeDescriptorFromMap(T)) return C; - uint16_t TypeKind = -1; + uint16_t TypeKind = TK_Unknown; uint16_t TypeInfo = 0; + bool IsBitInt = false; if (T->isIntegerType()) { - TypeKind = 0; + TypeKind = TK_Integer; TypeInfo = (llvm::Log2_32(getContext().getTypeSize(T)) << 1) | (T->isSignedIntegerType() ? 1 : 0); + // Follow suggestion from https://github.com/llvm/llvm-project/issues/64100 + // So we can write the exact amount of bits in TypeName after '\0' + // making it <diagnostic-like type name>.'\0'.<32-bit width>. + if (T->isSignedIntegerType() && T->getAs<BitIntType>()) { + // Do a sanity checks as we are using 32-bit type to store bit length. + assert((getContext().getTypeSize(T) > 0) && ---------------- MaskRay wrote:
The prevailing style uses `A > B && `, not `(A > B) && ` another choice is `assert(("xxxx", A > B))` https://github.com/llvm/llvm-project/pull/96240 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits