@@ -572,15 +572,16 @@ class SMTConv {
572
572
// TODO: Refactor to put elsewhere
573
573
static inline QualType getAPSIntType (ASTContext &Ctx,
574
574
const llvm::APSInt &Int) {
575
- QualType Ty = Ctx.getIntTypeForBitwidth (Int.getBitWidth (), Int.isSigned ());
575
+ QualType Ty;
576
+ if (!(Ty = Ctx.getIntTypeForBitwidth (Int.getBitWidth (), Int.isSigned ()))
577
+ .isNull ())
578
+ return Ty;
576
579
// If Ty is Null, could be because the original type was a _BitInt.
577
580
// Get the bit size and round up to next power of 2, max char size
578
- if (Ty.isNull ()) {
579
- unsigned CharTypeSize = Ctx.getTypeSize (Ctx.CharTy );
580
- unsigned Pow2DestWidth =
581
- std::max (llvm::bit_ceil (Int.getBitWidth ()), CharTypeSize);
582
- Ty = Ctx.getIntTypeForBitwidth (Pow2DestWidth, Int.isSigned ());
583
- }
581
+ unsigned CharTypeSize = Ctx.getTypeSize (Ctx.CharTy );
582
+ unsigned Pow2DestWidth =
583
+ std::max (llvm::bit_ceil (Int.getBitWidth ()), CharTypeSize);
584
+ Ty = Ctx.getIntTypeForBitwidth (Pow2DestWidth, Int.isSigned ());
584
585
return Ty;
585
586
}
586
587
@@ -594,15 +595,12 @@ class SMTConv {
594
595
// FIXME: This should be a cast from a 1-bit integer type to a boolean type,
595
596
// but the former is not available in Clang. Instead, extend the APSInt
596
597
// directly.
597
- if (APSIntBitwidth == 1 && Ty.isNull ()) {
598
- NewInt = Int.extend (Ctx.getTypeSize (Ctx.BoolTy ));
599
- Ty = getAPSIntType (Ctx, NewInt);
600
- } else if (!llvm::isPowerOf2_32 (APSIntBitwidth) && !Ty.isNull ()) {
601
- NewInt = Int.extend (Ctx.getTypeSize (Ty));
602
- } else
603
- NewInt = Int;
604
-
605
- return std::make_pair (NewInt, Ty);
598
+ if (APSIntBitwidth == 1 && Ty.isNull ())
599
+ return {Int.extend (Ctx.getTypeSize (Ctx.BoolTy )),
600
+ getAPSIntType (Ctx, NewInt)};
601
+ if (!llvm::isPowerOf2_32 (APSIntBitwidth) && !Ty.isNull ())
602
+ return {Int.extend (Ctx.getTypeSize (Ty)), Ty};
603
+ return {Int, Ty};
606
604
}
607
605
608
606
// Perform implicit type conversion on binary symbolic expressions.
0 commit comments