aboutsummaryrefslogtreecommitdiff
path: root/clang
diff options
context:
space:
mode:
authorTimm Bäder <tbaeder@redhat.com>2023-11-16 18:04:15 +0100
committerTimm Bäder <tbaeder@redhat.com>2023-11-17 08:04:30 +0100
commit894a38753e8c4cfef7a1dae17a76b405208b2708 (patch)
tree7856fd68b7deb7dc16b2b5108cafa2630bcdf476 /clang
parent865c1fda6f3e258b47a4f7992bb19ca2e9edcfa1 (diff)
downloadllvm-894a38753e8c4cfef7a1dae17a76b405208b2708.zip
llvm-894a38753e8c4cfef7a1dae17a76b405208b2708.tar.gz
llvm-894a38753e8c4cfef7a1dae17a76b405208b2708.tar.bz2
[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.
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/Interp/IntegralAP.h7
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>