================ @@ -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); return false; } - const APSInt &LHS = APSInt(A.V, A.isSigned()); - const APSInt &RHS = APSInt(B.V, B.isSigned()); - - APSInt Value(LHS.extend(BitWidth) + RHS.extend(BitWidth), false); + auto SOp = Op<APSInt>(); + const APSInt &LHS = A.toAPSInt(); + const APSInt &RHS = B.toAPSInt(); + APSInt Value(SOp(LHS.extend(BitWidth), RHS.extend(BitWidth)), false); ---------------- AaronBallman wrote:
```suggestion const APSInt &LHS = A.toAPSInt(); const APSInt &RHS = B.toAPSInt(); APSInt Value(Op<APSInt>{}(LHS.extend(BitWidth), RHS.extend(BitWidth)), false); ``` https://github.com/llvm/llvm-project/pull/71648 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits