@@ -78,7 +78,8 @@ template <bool Signed> class IntegralAP final {
7878
7979 template <typename T> static IntegralAP from (T Value, unsigned NumBits = 0 ) {
8080 assert (NumBits > 0 );
81- APSInt Copy = APSInt (APInt (NumBits, static_cast <int64_t >(Value), Signed), !Signed);
81+ APSInt Copy =
82+ APSInt (APInt (NumBits, static_cast <uint64_t >(Value), Signed), !Signed);
8283
8384 return IntegralAP<Signed>(Copy);
8485 }
@@ -97,16 +98,16 @@ template <bool Signed> class IntegralAP final {
9798 template <unsigned Bits, bool InputSigned>
9899 static IntegralAP from (Integral<Bits, InputSigned> I, unsigned BitWidth) {
99100 APSInt Copy =
100- APSInt (APInt (BitWidth, static_cast <int64_t >(I), InputSigned), !Signed);
101+ APSInt (APInt (BitWidth, static_cast <uint64_t >(I), InputSigned), !Signed);
101102 Copy.setIsSigned (Signed);
102103
103104 assert (Copy.isSigned () == Signed);
104105 return IntegralAP<Signed>(Copy);
105106 }
106107
107- static IntegralAP zero () {
108- assert ( false );
109- return IntegralAP (0 );
108+ static IntegralAP zero (int32_t BitWidth ) {
109+ APSInt V = APSInt ( APInt (BitWidth, 0LL , Signed), !Signed );
110+ return IntegralAP (V );
110111 }
111112
112113 constexpr unsigned bitWidth () const { return V.getBitWidth (); }
0 commit comments