[clang] [clang][Interp] Fix truncateCast() (PR #69911)

via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 25 00:48:25 PDT 2023


================
@@ -81,14 +89,20 @@ template <bool Signed> class IntegralAP final {
   }
 
   explicit operator bool() const { return !V.isZero(); }
-  explicit operator int8_t() const { return truncateCast<int8_t>(V); }
-  explicit operator uint8_t() const { return truncateCast<uint8_t>(V); }
-  explicit operator int16_t() const { return truncateCast<int16_t>(V); }
-  explicit operator uint16_t() const { return truncateCast<uint16_t>(V); }
-  explicit operator int32_t() const { return truncateCast<int32_t>(V); }
-  explicit operator uint32_t() const { return truncateCast<uint32_t>(V); }
-  explicit operator int64_t() const { return truncateCast<int64_t>(V); }
-  explicit operator uint64_t() const { return truncateCast<uint64_t>(V); }
+  explicit operator int8_t() const { return truncateCast<int8_t, Signed>(V); }
+  explicit operator uint8_t() const { return truncateCast<uint8_t, Signed>(V); }
+  explicit operator int16_t() const { return truncateCast<int16_t, Signed>(V); }
+  explicit operator uint16_t() const {
+    return truncateCast<uint16_t, Signed>(V);
+  }
+  explicit operator int32_t() const { return truncateCast<int32_t, Signed>(V); }
+  explicit operator uint32_t() const {
+    return truncateCast<uint32_t, Signed>(V);
+  }
+  explicit operator int64_t() const { return truncateCast<int64_t, Signed>(V); }
+  explicit operator uint64_t() const {
+    return truncateCast<uint64_t, Signed>(V);
+  }
----------------
cor3ntin wrote:

That sounds like a great idea

https://github.com/llvm/llvm-project/pull/69911


More information about the cfe-commits mailing list