@@ -572,15 +572,16 @@ class SMTConv {
572572 // TODO: Refactor to put elsewhere
573573 static inline QualType getAPSIntType (ASTContext &Ctx,
574574 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;
576579 // If Ty is Null, could be because the original type was a _BitInt.
577580 // 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 ());
584585 return Ty;
585586 }
586587
@@ -594,15 +595,12 @@ class SMTConv {
594595 // FIXME: This should be a cast from a 1-bit integer type to a boolean type,
595596 // but the former is not available in Clang. Instead, extend the APSInt
596597 // 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};
606604 }
607605
608606 // Perform implicit type conversion on binary symbolic expressions.
0 commit comments