[clang] [compiler-rt] [ubsan] Display correct runtime messages for negative _BitInt (PR #93612)

Aaron Ballman via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 17 09:49:21 PDT 2024


================
@@ -3318,6 +3353,20 @@ llvm::Constant *CodeGenFunction::EmitCheckTypeDescriptor(QualType T) {
       DiagnosticsEngine::ak_qualtype, (intptr_t)T.getAsOpaquePtr(), StringRef(),
       StringRef(), std::nullopt, Buffer, std::nullopt);
 
+  if (IsBitInt) {
+    // The Structure is: 0 to end the string, 32 bit unsigned integer in target
+    // endianness, zero.
+    char s[6] = {'\0', '\0', '\0', '\0', '\0', '\0'};
+    const auto *EIT = T->getAs<BitIntType>();
----------------
AaronBallman wrote:

```suggestion
    const auto *EIT = T->castAs<BitIntType>();
```
We don't expect it to ever return a null pointer, so we might as well cast instead.

https://github.com/llvm/llvm-project/pull/93612


More information about the llvm-commits mailing list