From 894a38753e8c4cfef7a1dae17a76b405208b2708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 16 Nov 2023 18:04:15 +0100 Subject: [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. --- clang/lib/AST/Interp/IntegralAP.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'clang') 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 static IntegralAP from(IntegralAP V, unsigned NumBits = 0) { - return IntegralAP(V.V); + if (NumBits == 0) + NumBits = V.bitWidth(); + + if constexpr (InputSigned) + return IntegralAP(V.V.sextOrTrunc(NumBits)); + return IntegralAP(V.V.zextOrTrunc(NumBits)); } template -- cgit v1.1