[clang] [clang][Interp] Implement IntegralAP subtraction (PR #71648)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 8 06:12:28 PST 2023


================
@@ -256,28 +255,23 @@ template <bool Signed> class IntegralAP final {
   }
 
 private:
-  static bool CheckAddUB(const IntegralAP &A, const IntegralAP &B,
-                         unsigned BitWidth, IntegralAP *R) {
-    if (!A.isSigned()) {
-      R->V = A.V + B.V;
+  template <template <typename T> class Op>
+  static bool CheckAddSubUB(const IntegralAP &A, const IntegralAP &B,
+                            unsigned BitWidth, IntegralAP *R) {
+    if constexpr (!Signed) {
+      auto UOp = Op<APInt>();
+      R->V = UOp(A.V, B.V);
----------------
AaronBallman wrote:

```suggestion
      R->V = Op<APInt>{}(A.V, B.V);
```

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


More information about the cfe-commits mailing list