Module Name: src
Committed By: rillig
Date: Fri Jul 14 09:20:23 UTC 2023
Modified Files:
src/usr.bin/xlint/lint1: decl.c tree.c
Log Message:
lint: clean up redundant and verbose code
To generate a diff of this commit:
cvs rdiff -u -r1.355 -r1.356 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.565 -r1.566 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/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.355 src/usr.bin/xlint/lint1/decl.c:1.356
--- src/usr.bin/xlint/lint1/decl.c:1.355 Thu Jul 13 23:27:20 2023
+++ src/usr.bin/xlint/lint1/decl.c Fri Jul 14 09:20:23 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.355 2023/07/13 23:27:20 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.356 2023/07/14 09:20:23 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: decl.c,v 1.355 2023/07/13 23:27:20 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.356 2023/07/14 09:20:23 rillig Exp $");
#endif
#include <sys/param.h>
@@ -104,7 +104,6 @@ initdecl(void)
ttab[i].tt_rank_value =
ttab[i].tt_size_in_bits;
}
- ttab[BOOL].tt_rank_kind = RK_INTEGER;
ttab[BOOL].tt_rank_value = 1;
}
@@ -607,7 +606,7 @@ void
dcs_begin_type(void)
{
- debug_step("%s", __func__);
+ debug_enter();
dcs->d_abstract_type = NO_TSPEC;
dcs->d_complex_mod = NO_TSPEC;
dcs->d_sign_mod = NO_TSPEC;
@@ -711,7 +710,6 @@ void
dcs_end_type(void)
{
- debug_step("%s", __func__);
dcs_merge_declaration_specifiers();
if (dcs->d_multiple_storage_classes) {
@@ -743,6 +741,8 @@ dcs_end_type(void)
dcs->d_type->t_const |= dcs->d_qual.tq_const;
dcs->d_type->t_volatile |= dcs->d_qual.tq_volatile;
}
+
+ debug_leave();
}
/*
@@ -1148,10 +1148,10 @@ add_type_qualifiers(type_qualifiers *dst
/* duplicate '%s' */
warning(10, "volatile");
- dst->tq_const = dst->tq_const || src.tq_const;
- dst->tq_restrict = dst->tq_restrict || src.tq_restrict;
- dst->tq_volatile = dst->tq_volatile || src.tq_volatile;
- dst->tq_atomic = dst->tq_atomic || src.tq_atomic;
+ dst->tq_const = dst->tq_const | src.tq_const;
+ dst->tq_restrict = dst->tq_restrict | src.tq_restrict;
+ dst->tq_volatile = dst->tq_volatile | src.tq_volatile;
+ dst->tq_atomic = dst->tq_atomic | src.tq_atomic;
}
qual_ptr *
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.565 src/usr.bin/xlint/lint1/tree.c:1.566
--- src/usr.bin/xlint/lint1/tree.c:1.565 Fri Jul 14 09:04:08 2023
+++ src/usr.bin/xlint/lint1/tree.c Fri Jul 14 09:20:23 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.565 2023/07/14 09:04:08 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.566 2023/07/14 09:20:23 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.565 2023/07/14 09:04:08 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.566 2023/07/14 09:20:23 rillig Exp $");
#endif
#include <float.h>
@@ -358,8 +358,7 @@ build_op(op_t op, bool sys, type_t *type
if (op == INDIR || op == FSEL) {
lint_assert(ln->tn_type->t_tspec == PTR);
tspec_t t = ln->tn_type->t_subt->t_tspec;
- if (t != FUNC && t != VOID)
- ntn->tn_lvalue = true;
+ ntn->tn_lvalue = t != FUNC && t != VOID;
}
return ntn;
@@ -937,11 +936,7 @@ build_struct_access(op_t op, bool sys, t
lint_assert(rn->tn_op == NAME);
lint_assert(is_member(rn->tn_sym));
- /*
- * Remember if the left operand is an lvalue (structure members
- * are lvalues if and only if the structure itself is an lvalue).
- */
- bool nolval = op == POINT && !ln->tn_lvalue;
+ bool lvalue = op == ARROW || ln->tn_lvalue;
if (op == POINT) {
ln = build_address(sys, ln, true);
@@ -959,13 +954,9 @@ build_struct_access(op_t op, bool sys, t
if (ln->tn_op == CON)
ntn = fold(ntn);
- if (rn->tn_type->t_bitfield) {
- ntn = build_op(FSEL, sys, ntn->tn_type->t_subt, ntn, NULL);
- } else {
- ntn = build_op(INDIR, sys, ntn->tn_type->t_subt, ntn, NULL);
- }
-
- if (nolval)
+ op_t nop = rn->tn_type->t_bitfield ? FSEL : INDIR;
+ ntn = build_op(nop, sys, ntn->tn_type->t_subt, ntn, NULL);
+ if (!lvalue)
ntn->tn_lvalue = false;
return ntn;