Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: make the debug log for nodes more ...



details:   https://anonhg.NetBSD.org/src/rev/9f509af373ea
branches:  trunk
changeset: 953729:9f509af373ea
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Mar 18 22:05:33 2021 +0000

description:
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.

diffstat:

 usr.bin/xlint/lint1/tree.c |  23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diffs (53 lines):

diff -r 9067330d7eca -r 9f509af373ea usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Thu Mar 18 21:56:34 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Thu Mar 18 22:05:33 2021 +0000
@@ -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 @@
        }
 
        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");
 



Home | Main Index | Thread Index | Old Index