[clang] [compiler-rt] [ubsan] Display correct runtime messages for negative _BitInt (PR #96240)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 23 06:38:10 PDT 2024
================
@@ -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 discussion of issue 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>()) {
----------------
earnol wrote:
The whole patch is limited to signed non-power-of-2 _BitInt only. Unsigned BitInts are not affected by the patch and did not have an issue to begin with. Please see the issue: https://github.com/llvm/llvm-project/issues/64100.
https://github.com/llvm/llvm-project/pull/96240
More information about the cfe-commits
mailing list