Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint lint: rename type classification macros



details:   https://anonhg.NetBSD.org/src/rev/bd7d8d6adfb9
branches:  trunk
changeset: 949340:bd7d8d6adfb9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 10 00:05:45 2021 +0000

description:
lint: rename type classification macros

The previous names tspec_is_int and tspec_is_uint were confusing because
there are actually tspec_t constants called INT and UINT, these
classification macros return true for other integer types as well,
though.

While here, remove the prefix "tspec_" from these macros.  It wasn't as
helpful as intended, in many cases it was obviously redundant, when it
was called as tspec_is_integer(tn->tn_type->t_tspec).

No functional change.

diffstat:

 usr.bin/xlint/common/lint.h |   22 ++--
 usr.bin/xlint/lint1/cgram.y |    6 +-
 usr.bin/xlint/lint1/decl.c  |    6 +-
 usr.bin/xlint/lint1/emit1.c |    6 +-
 usr.bin/xlint/lint1/func.c  |   18 ++--
 usr.bin/xlint/lint1/init.c  |   21 ++---
 usr.bin/xlint/lint1/scan.l  |    8 +-
 usr.bin/xlint/lint1/tree.c  |  174 ++++++++++++++++++++-----------------------
 usr.bin/xlint/lint2/chk.c   |    8 +-
 9 files changed, 129 insertions(+), 140 deletions(-)

diffs (truncated from 994 to 300 lines):

diff -r c401e572293e -r bd7d8d6adfb9 usr.bin/xlint/common/lint.h
--- a/usr.bin/xlint/common/lint.h       Sat Jan 09 23:54:26 2021 +0000
+++ b/usr.bin/xlint/common/lint.h       Sun Jan 10 00:05:45 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lint.h,v 1.23 2021/01/04 01:12:20 rillig Exp $ */
+/*     $NetBSD: lint.h,v 1.24 2021/01/10 00:05:45 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -96,10 +96,10 @@
                                           if pflag is set */
        tspec_t tt_signed_counterpart;
        tspec_t tt_unsigned_counterpart;
-       bool    tt_is_int : 1;          /* integer type */
-       bool    tt_is_uint : 1;         /* unsigned integer type */
-       bool    tt_is_float : 1;        /* floating point type */
-       bool    tt_is_arith : 1;        /* arithmetic type */
+       bool    tt_is_integer : 1;      /* integer type */
+       bool    tt_is_uinteger : 1;     /* unsigned integer type */
+       bool    tt_is_floating : 1;     /* floating point type */
+       bool    tt_is_arithmetic : 1;   /* arithmetic type */
        bool    tt_is_scalar : 1;       /* scalar type */
        bool    tt_is_complex : 1;      /* complex type */
        const char *tt_name;            /* name of the type */
@@ -109,12 +109,12 @@
 #define psize(t)               (ttab[t].tt_psz)
 #define signed_type(t)         (ttab[t].tt_signed_counterpart)
 #define unsigned_type(t)       (ttab[t].tt_unsigned_counterpart)
-#define tspec_is_int(t)                (ttab[t].tt_is_int)
-#define tspec_is_uint(t)       (ttab[t].tt_is_uint)
-#define tspec_is_float(t)      (ttab[t].tt_is_float)
-#define tspec_is_arith(t)      (ttab[t].tt_is_arith)
-#define tspec_is_complex(t)    (ttab[t].tt_is_complex)
-#define tspec_is_scalar(t)     (ttab[t].tt_is_scalar)
+#define is_integer(t)          (ttab[t].tt_is_integer)
+#define is_uinteger(t)         (ttab[t].tt_is_uinteger)
+#define is_floating(t)         (ttab[t].tt_is_floating)
+#define is_arithmetic(t)       (ttab[t].tt_is_arithmetic)
+#define is_complex(t)          (ttab[t].tt_is_complex)
+#define is_scalar(t)           (ttab[t].tt_is_scalar)
 
 extern ttab_t  ttab[];
 
diff -r c401e572293e -r bd7d8d6adfb9 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sat Jan 09 23:54:26 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Jan 10 00:05:45 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.136 2021/01/09 14:10:15 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.137 2021/01/10 00:05:46 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.136 2021/01/09 14:10:15 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.137 2021/01/10 00:05:46 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -2112,7 +2112,7 @@
                error(55);
        } else {
                i = (int)v->v_quad;
-               if (tspec_is_uint(t)) {
+               if (is_uinteger(t)) {
                        if (uq_gt((uint64_t)v->v_quad,
                                  (uint64_t)TARG_INT_MAX)) {
                                /* integral constant too large */
diff -r c401e572293e -r bd7d8d6adfb9 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sat Jan 09 23:54:26 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sun Jan 10 00:05:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.113 2021/01/09 14:10:15 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.114 2021/01/10 00:05:46 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.113 2021/01/09 14:10:15 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.114 2021/01/10 00:05:46 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1127,7 +1127,7 @@
                         * Integer types not dealt with above are
                         * okay only if BITFIELDTYPE is in effect.
                         */
-                       if (!bitfieldtype_ok || !tspec_is_int(t)) {
+                       if (!bitfieldtype_ok || !is_integer(t)) {
                                /* illegal bit-field type */
                                warning(35);
                                sz = tp->t_flen;
diff -r c401e572293e -r bd7d8d6adfb9 usr.bin/xlint/lint1/emit1.c
--- a/usr.bin/xlint/lint1/emit1.c       Sat Jan 09 23:54:26 2021 +0000
+++ b/usr.bin/xlint/lint1/emit1.c       Sun Jan 10 00:05:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.34 2021/01/04 22:26:50 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.35 2021/01/10 00:05:46 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: emit1.c,v 1.34 2021/01/04 22:26:50 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.35 2021/01/10 00:05:46 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -442,7 +442,7 @@
                        continue;
                arg = arg->tn_left;
                if (arg->tn_op == CON) {
-                       if (tspec_is_int(t = arg->tn_type->t_tspec)) {
+                       if (is_integer(t = arg->tn_type->t_tspec)) {
                                /*
                                 * XXX it would probably be better to
                                 * explicitly test the sign
diff -r c401e572293e -r bd7d8d6adfb9 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Sat Jan 09 23:54:26 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c        Sun Jan 10 00:05:45 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.54 2021/01/09 03:08:54 rillig Exp $ */
+/*     $NetBSD: func.c,v 1.55 2021/01/10 00:05:46 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.54 2021/01/09 03:08:54 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.55 2021/01/10 00:05:46 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -437,7 +437,7 @@
                return;
        }
 
-       if (tn != NULL && !tspec_is_int(tn->tn_type->t_tspec)) {
+       if (tn != NULL && !is_integer(tn->tn_type->t_tspec)) {
                /* non-integral case expression */
                error(198);
                return;
@@ -473,7 +473,7 @@
                if (cl->cl_val.v_quad == nv.v_quad)
                        break;
        }
-       if (cl != NULL && tspec_is_uint(nv.v_tspec)) {
+       if (cl != NULL && is_uinteger(nv.v_tspec)) {
                /* duplicate case in switch: %lu */
                error(200, (u_long)nv.v_quad);
        } else if (cl != NULL) {
@@ -543,7 +543,7 @@
        if (tn != NULL)
                tn = promote(NOOP, 0, tn);
 
-       if (tn != NULL && !tspec_is_scalar(tn->tn_type->t_tspec)) {
+       if (tn != NULL && !is_scalar(tn->tn_type->t_tspec)) {
                /* C99 6.5.15p4 for the ?: operator; see typeok:QUEST */
                /* C99 6.8.4.1p1 for if statements */
                /* C99 6.8.5p2 for while, do and for loops */
@@ -610,7 +610,7 @@
                tn = cconv(tn);
        if (tn != NULL)
                tn = promote(NOOP, 0, tn);
-       if (tn != NULL && !tspec_is_int(tn->tn_type->t_tspec)) {
+       if (tn != NULL && !is_integer(tn->tn_type->t_tspec)) {
                /* switch expression must have integral type */
                error(205);
                tn = NULL;
@@ -720,7 +720,7 @@
        pushctrl(T_WHILE);
        cstmt->c_loop = 1;
        if (tn != NULL && tn->tn_op == CON) {
-               if (tspec_is_int(tn->tn_type->t_tspec)) {
+               if (is_integer(tn->tn_type->t_tspec)) {
                        cstmt->c_infinite = tn->tn_val->v_quad != 0;
                } else {
                        cstmt->c_infinite = tn->tn_val->v_ldbl != 0.0;
@@ -784,7 +784,7 @@
                tn = check_controlling_expression(tn);
 
        if (tn != NULL && tn->tn_op == CON) {
-               if (tspec_is_int(tn->tn_type->t_tspec)) {
+               if (is_integer(tn->tn_type->t_tspec)) {
                        cstmt->c_infinite = tn->tn_val->v_quad != 0;
                } else {
                        cstmt->c_infinite = tn->tn_val->v_ldbl != 0.0;
@@ -847,7 +847,7 @@
        if (tn2 == NULL) {
                cstmt->c_infinite = 1;
        } else if (tn2->tn_op == CON) {
-               if (tspec_is_int(tn2->tn_type->t_tspec)) {
+               if (is_integer(tn2->tn_type->t_tspec)) {
                        cstmt->c_infinite = tn2->tn_val->v_quad != 0;
                } else {
                        cstmt->c_infinite = tn2->tn_val->v_ldbl != 0.0;
diff -r c401e572293e -r bd7d8d6adfb9 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Sat Jan 09 23:54:26 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Sun Jan 10 00:05:45 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.60 2021/01/03 20:31:08 rillig Exp $ */
+/*     $NetBSD: init.c,v 1.61 2021/01/10 00:05:46 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.60 2021/01/03 20:31:08 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.61 2021/01/10 00:05:46 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -327,8 +327,7 @@
        }
 
        lint_assert(istk->i_remaining > 0);
-       lint_assert(istk->i_type == NULL ||
-           !tspec_is_scalar(istk->i_type->t_tspec));
+       lint_assert(istk->i_type == NULL || !is_scalar(istk->i_type->t_tspec));
 
        initstk = xcalloc(1, sizeof (istk_t));
        initstk->i_next = istk;
@@ -472,8 +471,7 @@
 {
 
        DPRINTF(("%s\n", __func__));
-       if (initstk->i_type != NULL &&
-           tspec_is_scalar(initstk->i_type->t_tspec)) {
+       if (initstk->i_type != NULL && is_scalar(initstk->i_type->t_tspec)) {
                /* invalid initializer type %s */
                error(176, type_name(initstk->i_type));
                initerr = 1;
@@ -494,8 +492,7 @@
 {
 
        DPRINTF(("%s\n", __func__));
-       if (initstk->i_type == NULL &&
-           !tspec_is_scalar(initstk->i_subt->t_tspec)) {
+       if (initstk->i_type == NULL && !is_scalar(initstk->i_subt->t_tspec)) {
                /* {}-enclosed initializer required */
                error(181);
        }
@@ -505,7 +502,7 @@
                initstack_check_too_many();
        while (!initerr) {
                if ((initstk->i_type != NULL &&
-                    tspec_is_scalar(initstk->i_type->t_tspec)))
+                    is_scalar(initstk->i_type->t_tspec)))
                        break;
                initstack_push();
        }
@@ -521,7 +518,7 @@
 
        if ((initsym->s_scl == AUTO || initsym->s_scl == REG) &&
            initstk->i_next == NULL) {
-               if (tflag && !tspec_is_scalar(initstk->i_subt->t_tspec))
+               if (tflag && !is_scalar(initstk->i_subt->t_tspec))
                        /* no automatic aggregate initialization in trad. C */
                        warning(188);
        }
@@ -620,7 +617,7 @@
        lt = ln->tn_type->t_tspec;
        rt = tn->tn_type->t_tspec;
 
-       lint_assert(tspec_is_scalar(lt));
+       lint_assert(is_scalar(lt));
 
        if (!typeok(INIT, 0, ln, tn))
                return;
@@ -633,7 +630,7 @@
        expr(tn, 1, 0, 1);
        trestor(tmem);
 
-       if (tspec_is_int(lt) && ln->tn_type->t_bitfield && !tspec_is_int(rt)) {
+       if (is_integer(lt) && ln->tn_type->t_bitfield && !is_integer(rt)) {
                /*
                 * Bit-fields can be initialized in trad. C only by integer
                 * constants.
diff -r c401e572293e -r bd7d8d6adfb9 usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Sat Jan 09 23:54:26 2021 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Sun Jan 10 00:05:45 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.115 2021/01/09 14:10:15 rillig Exp $ */
+/* $NetBSD: scan.l,v 1.116 2021/01/10 00:05:46 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.



Home | Main Index | Thread Index | Old Index