[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)
DonĂ¡t Nagy via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 10 07:50:43 PDT 2025
================
@@ -570,23 +572,42 @@ class SMTConv {
// TODO: Refactor to put elsewhere
static inline QualType getAPSIntType(ASTContext &Ctx,
const llvm::APSInt &Int) {
- return Ctx.getIntTypeForBitwidth(Int.getBitWidth(), Int.isSigned());
+ QualType Ty = Ctx.getIntTypeForBitwidth(Int.getBitWidth(), Int.isSigned());
+ // If Ty is Null, could be because the original type was a _BitInt.
+ // Get the bit size and round up to next power of 2, max char size
+ if (Ty.isNull()) {
+ unsigned CharTypeSize = Ctx.getTypeSize(Ctx.CharTy);
+ unsigned pow2DestWidth =
+ std::max(llvm::bit_ceil(Int.getBitWidth()), CharTypeSize);
+ Ty = Ctx.getIntTypeForBitwidth(pow2DestWidth, Int.isSigned());
----------------
NagyDonat wrote:
```suggestion
unsigned Pow2DestWidth =
std::max(llvm::bit_ceil(Int.getBitWidth()), CharTypeSize);
Ty = Ctx.getIntTypeForBitwidth(Pow2DestWidth, Int.isSigned());
```
Please follow the [LLVM Coding Standard](https://www.llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly).
https://github.com/llvm/llvm-project/pull/143310
More information about the cfe-commits
mailing list