Module Name:    src
Committed By:   rillig
Date:           Thu Mar 18 22:05:33 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: make the debug log for nodes more readable

The operator NAME has the name 'name', therefore no special case is
needed.

Having the words 'with type' in the message makes the message easier to
find from the debug log.  Given that the operator name is used unquoted,
the log message 'name: int value=111' was nearly impossible to find in
the code.

Replace the '()' with an actual word, to avoid any confusion about
whether the type name might be a function type without prototype.

Reduce the amount of '=' signs, instead use commas to separate the
properties of the node.

No functional change outside debug mode.


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 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/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.234 src/usr.bin/xlint/lint1/tree.c:1.235
--- src/usr.bin/xlint/lint1/tree.c:1.234	Thu Mar 18 21:26:56 2021
+++ src/usr.bin/xlint/lint1/tree.c	Thu Mar 18 22:05:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.234 2021/03/18 21:26:56 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.235 2021/03/18 22:05: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.234 2021/03/18 21:26:56 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.235 2021/03/18 22:05:33 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -109,25 +109,24 @@ debug_node(const tnode_t *tn, int indent
 	}
 
 	op = tn->tn_op;
-	printf("%*s%s: %s%s%s",
+	printf("%*s%s with type '%s'%s%s",
 	    2 * indent, "",
-	    op == CVT && !tn->tn_cast ? "convert" :
-		op == NAME ? "name" : getopname(op),
-	    type_name(tn->tn_type), tn->tn_lvalue ? " lvalue" : "",
-	    tn->tn_parenthesized ? " ()" : "");
+	    op == CVT && !tn->tn_cast ? "convert" : getopname(op),
+	    type_name(tn->tn_type), tn->tn_lvalue ? ", lvalue" : "",
+	    tn->tn_parenthesized ? ", parenthesized" : "");
 
 	if (op == NAME)
 		printf(" %s\n", tn->tn_sym->s_name);
 	else if (op == CON && is_floating(tn->tn_type->t_tspec))
-		printf(" value=%Lg", tn->tn_val->v_ldbl);
+		printf(", value %Lg", tn->tn_val->v_ldbl);
 	else if (op == CON && is_uinteger(tn->tn_type->t_tspec))
-		printf(" value=%llu\n", (unsigned long long)tn->tn_val->v_quad);
+		printf(", value %llu\n", (unsigned long long)tn->tn_val->v_quad);
 	else if (op == CON && is_integer(tn->tn_type->t_tspec))
-		printf(" value=%lld\n", (long long)tn->tn_val->v_quad);
+		printf(", value %lld\n", (long long)tn->tn_val->v_quad);
 	else if (op == CON)
-		printf(" value=?\n");
+		printf(", unknown value\n");
 	else if (op == STRING)
-		printf(" length=%zu\n", tn->tn_string->st_len);
+		printf(", length %zu\n", tn->tn_string->st_len);
 	else {
 		printf("\n");
 

Reply via email to