[clang] [clang][Interp] Implement inc/dec for IntegralAP (PR #69597)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 1 06:11:15 PDT 2023


================
@@ -167,17 +169,13 @@ template <bool Signed> class IntegralAP final {
   }
 
   static bool increment(IntegralAP A, IntegralAP *R) {
-    // FIXME: Implement.
-    assert(false);
-    *R = IntegralAP(A.V - 1);
-    return false;
+    IntegralAP<Signed> One(1, A.bitWidth());
+    return add(A, One, A.bitWidth() + 1, R);
   }
 
   static bool decrement(IntegralAP A, IntegralAP *R) {
-    // FIXME: Implement.
-    assert(false);
-    *R = IntegralAP(A.V - 1);
-    return false;
+    IntegralAP<Signed> One(1, A.bitWidth());
+    return sub(A, One, A.bitWidth() + 1, R);
----------------
AaronBallman wrote:

Why does this extend the bit width by 1?

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


More information about the cfe-commits mailing list