[clang] [compiler-rt] [ubsan] Display correct runtime messages for negative _BitInt (PR #96240)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 26 10:39:41 PDT 2024
================
@@ -125,6 +137,25 @@ class TypeDescriptor {
return 1 << (TypeInfo >> 1);
}
+ const char *getBitIntBitCountPointer() const {
+ DCHECK(isBitIntTy());
+ DCHECK(isSignedBitIntTy());
+ // Scan Name for zero and return the next address
+ const char *p = getTypeName();
+ while (*p != '\0')
+ ++p;
+ // Return the next address
+ return p + 1;
+ }
+
+ unsigned getIntegerBitCount() const {
+ DCHECK(isIntegerTy());
+ if (isSignedBitIntTy())
+ return *reinterpret_cast<const u32 *>(getBitIntBitCountPointer());
----------------
earnol wrote:
Well. I do agree with this statement, however do we have a way to know whether target has a strict alignment or not? Preferably on the define level or you would suggest use always use memcpy?
I considered this option, but was really reluctant to add memcpy dependency into libubsan.
So may be the better option is gather it byte by byte a strict alignment platform.
https://github.com/llvm/llvm-project/pull/96240
More information about the cfe-commits
mailing list