Skip to content

Commit 894a387

Browse files
committed
[clang][Interp][NFC] Properly implement IntegralAP::from(IntegralAP)
This used to just pass on the given parameter, but we need to respect the given bit width.
1 parent 865c1fd commit 894a387

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

clang/lib/AST/Interp/IntegralAP.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ template <bool Signed> class IntegralAP final {
102102

103103
template <bool InputSigned>
104104
static IntegralAP from(IntegralAP<InputSigned> V, unsigned NumBits = 0) {
105-
return IntegralAP<Signed>(V.V);
105+
if (NumBits == 0)
106+
NumBits = V.bitWidth();
107+
108+
if constexpr (InputSigned)
109+
return IntegralAP<Signed>(V.V.sextOrTrunc(NumBits));
110+
return IntegralAP<Signed>(V.V.zextOrTrunc(NumBits));
106111
}
107112

108113
template <unsigned Bits, bool InputSigned>

0 commit comments

Comments
 (0)