From 55e6bd10fe49614cd54eb02dd44c50d0643804c3 Mon Sep 17 00:00:00 2001 From: Evan Haas Date: Sun, 18 Apr 2021 20:55:05 -0700 Subject: [PATCH] translate-c: use transCreateNodeInfixOp for pointer arithmetic --- src/translate_c.zig | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/translate_c.zig b/src/translate_c.zig index 8a2a1b6223..ac5c52ee0d 100644 --- a/src/translate_c.zig +++ b/src/translate_c.zig @@ -1353,10 +1353,14 @@ fn transCreatePointerArithmeticSignedOp( const bitcast_node = try usizeCastForWrappingPtrArithmetic(c.arena, rhs_node); - const arith_args = .{ .lhs = lhs_node, .rhs = bitcast_node }; - const arith_node = try if (is_add) Tag.add.create(c.arena, arith_args) else Tag.sub.create(c.arena, arith_args); - - return maybeSuppressResult(c, scope, result_used, arith_node); + return transCreateNodeInfixOp( + c, + scope, + if (is_add) .add else .sub, + lhs_node, + bitcast_node, + result_used, + ); } fn transBinaryOperator(