Module Name:    src
Committed By:   rillig
Date:           Sat Apr 16 21:14:33 UTC 2022

Modified Files:
        src/usr.bin/xlint/lint1: op.h ops.def tree.c

Log Message:
lint: rename members of tnode_t to more closely match reality

The flags do not describe the left operand of the node but both, as for
most operators, either none or both operands are in test context or in
value context.

The one exception is the operator '?' from the '?:' conditional, for
which the left operand is in test context and the right operand is in
value context.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/xlint/lint1/op.h
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/xlint/lint1/ops.def
cvs rdiff -u -r1.431 -r1.432 src/usr.bin/xlint/lint1/tree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/op.h
diff -u src/usr.bin/xlint/lint1/op.h:1.17 src/usr.bin/xlint/lint1/op.h:1.18
--- src/usr.bin/xlint/lint1/op.h:1.17	Thu Aug 19 18:39:34 2021
+++ src/usr.bin/xlint/lint1/op.h	Sat Apr 16 21:14:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: op.h,v 1.17 2021/08/19 18:39:34 rillig Exp $	*/
+/*	$NetBSD: op.h,v 1.18 2022/04/16 21:14:33 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -46,8 +46,8 @@ typedef	struct {
 	bool	m_requires_arith: 1;
 	bool	m_requires_scalar: 1;
 	bool	m_fold_constant_operands: 1;
-	bool	m_left_value_context: 1;
-	bool	m_left_test_context: 1;
+	bool	m_value_context: 1;
+	bool	m_test_context: 1;
 	bool	m_balance_operands: 1;
 	bool	m_has_side_effect: 1;
 	bool	m_warn_if_left_unsigned_in_c90: 1;

Index: src/usr.bin/xlint/lint1/ops.def
diff -u src/usr.bin/xlint/lint1/ops.def:1.25 src/usr.bin/xlint/lint1/ops.def:1.26
--- src/usr.bin/xlint/lint1/ops.def:1.25	Fri Sep 10 20:02:50 2021
+++ src/usr.bin/xlint/lint1/ops.def	Sat Apr 16 21:14:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ops.def,v 1.25 2021/09/10 20:02:50 rillig Exp $ */
+/*	$NetBSD: ops.def,v 1.26 2022/04/16 21:14:33 rillig Exp $ */
 
 begin_ops()
 
@@ -14,8 +14,8 @@ begin_ops()
  *	warn if left operand unsigned			  x	|
  *	has side effects	- - - - - - - - - - - - x	|
  *	balance operands			      x	|	|
- *	left test context			    x	|	|
- *	left value context			  x	|	|
+ *	test context				    x	|	|
+ *	value context				  x	|	|
  *	fold constant operands	- - - - - - - - x	|	|
  *	requires scalar			      x	|	|	|
  *	requires arithmetic		    x	|	|	|

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.431 src/usr.bin/xlint/lint1/tree.c:1.432
--- src/usr.bin/xlint/lint1/tree.c:1.431	Sat Apr 16 20:57:10 2022
+++ src/usr.bin/xlint/lint1/tree.c	Sat Apr 16 21:14:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.431 2022/04/16 20:57:10 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.432 2022/04/16 21:14:33 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.431 2022/04/16 20:57:10 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.432 2022/04/16 21:14:33 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -536,7 +536,7 @@ build_binary(tnode_t *ln, op_t op, bool 
 	 * Apply class conversions to the left operand, but only if its
 	 * value is needed or it is compared with zero.
 	 */
-	if (mp->m_left_value_context || mp->m_left_test_context)
+	if (mp->m_value_context || mp->m_test_context)
 		ln = cconv(ln);
 	/*
 	 * The right operand is almost always in a test or value context,
@@ -555,7 +555,7 @@ build_binary(tnode_t *ln, op_t op, bool 
 	if (mp->m_comparison)
 		check_integer_comparison(op, ln, rn);
 
-	if (mp->m_left_value_context || mp->m_left_test_context)
+	if (mp->m_value_context || mp->m_test_context)
 		ln = promote(op, false, ln);
 	if (mp->m_binary && op != ARROW && op != POINT &&
 	    op != ASSIGN && op != RETURN && op != INIT) {
@@ -664,7 +664,7 @@ build_binary(tnode_t *ln, op_t op, bool 
 	 * it is compared with zero and if this operand is a constant.
 	 */
 	if (hflag && !constcond_flag &&
-	    mp->m_left_test_context &&
+	    mp->m_test_context &&
 	    (ln->tn_op == CON ||
 	     ((mp->m_binary && op != QUEST) && rn->tn_op == CON)) &&
 	    /* XXX: rn->tn_system_dependent should be checked as well */
@@ -676,7 +676,7 @@ build_binary(tnode_t *ln, op_t op, bool 
 	/* Fold if the operator requires it */
 	if (mp->m_fold_constant_operands) {
 		if (ln->tn_op == CON && (!mp->m_binary || rn->tn_op == CON)) {
-			if (mp->m_left_test_context) {
+			if (mp->m_test_context) {
 				ntn = fold_test(ntn);
 			} else if (is_floating(ntn->tn_type->t_tspec)) {
 				ntn = fold_float(ntn);
@@ -4172,8 +4172,8 @@ check_expr_misc(const tnode_t *tn, bool 
 	    szof, fcall, vctx, tctx, retval_discarded, eqwarn))
 		return;
 
-	cvctx = mp->m_left_value_context;
-	ctctx = mp->m_left_test_context;
+	cvctx = mp->m_value_context;
+	ctctx = mp->m_test_context;
 	eq = mp->m_warn_if_operand_eq &&
 	     !ln->tn_parenthesized &&
 	     rn != NULL && !rn->tn_parenthesized;

Reply via email to