diff options
Diffstat (limited to 'clang/lib/AST/Interp/IntegralAP.h')
-rw-r--r-- | clang/lib/AST/Interp/IntegralAP.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/AST/Interp/IntegralAP.h b/clang/lib/AST/Interp/IntegralAP.h index bd665959c..9019f32 100644 --- a/clang/lib/AST/Interp/IntegralAP.h +++ b/clang/lib/AST/Interp/IntegralAP.h @@ -102,7 +102,12 @@ public: template <bool InputSigned> static IntegralAP from(IntegralAP<InputSigned> V, unsigned NumBits = 0) { - return IntegralAP<Signed>(V.V); + if (NumBits == 0) + NumBits = V.bitWidth(); + + if constexpr (InputSigned) + return IntegralAP<Signed>(V.V.sextOrTrunc(NumBits)); + return IntegralAP<Signed>(V.V.zextOrTrunc(NumBits)); } template <unsigned Bits, bool InputSigned> |