[clang] [clang][Interp] IntegralAP zero-init (PR #68081)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 13 06:11:54 PDT 2023


================
@@ -100,12 +100,13 @@ template <bool Signed> class IntegralAP final {
   }
   static IntegralAP from(const Boolean &B) {
     assert(false);
-    return IntegralAP::zero();
+    return IntegralAP::zero(1);
   }
 
-  static IntegralAP zero() {
-    assert(false);
-    return IntegralAP(0);
+  static IntegralAP zero(int32_t BitWidth) {
+    APSInt V =
+        APSInt(APInt(BitWidth, static_cast<int64_t>(0), Signed), !Signed);
----------------
AaronBallman wrote:

Oh wow, that's... neat. The explicit cast is also fine, but perhaps should be to `uint64_t` to remove one more implicit conversion step.

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


More information about the cfe-commits mailing list