Module Name: src
Committed By: rillig
Date: Sat Apr 9 16:02:14 UTC 2022
Modified Files:
src/usr.bin/xlint/lint1: debug.c decl.c lint1.h tree.c
Log Message:
lint: extract is_member into separate function
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/lint1/debug.c
cvs rdiff -u -r1.273 -r1.274 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.147 -r1.148 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.422 -r1.423 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/debug.c
diff -u src/usr.bin/xlint/lint1/debug.c:1.14 src/usr.bin/xlint/lint1/debug.c:1.15
--- src/usr.bin/xlint/lint1/debug.c:1.14 Sat Apr 9 15:43:41 2022
+++ src/usr.bin/xlint/lint1/debug.c Sat Apr 9 16:02:14 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.14 2022/04/09 15:43:41 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.15 2022/04/09 16:02:14 rillig Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: debug.c,v 1.14 2022/04/09 15:43:41 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.15 2022/04/09 16:02:14 rillig Exp $");
#endif
#include <stdlib.h>
@@ -277,8 +277,7 @@ debug_sym(const char *prefix, const sym_
debug_printf(" value=%s",
sym->u.s_bool_constant ? "true" : "false");
- if ((sym->s_scl == MOS || sym->s_scl == MOU) &&
- sym->u.s_member.sm_sou_type != NULL) {
+ if (is_member(sym) && sym->u.s_member.sm_sou_type != NULL) {
struct_or_union *sou_type = sym->u.s_member.sm_sou_type;
const char *tag = sou_type->sou_tag->s_name;
const sym_t *def = sou_type->sou_first_typedef;
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.273 src/usr.bin/xlint/lint1/decl.c:1.274
--- src/usr.bin/xlint/lint1/decl.c:1.273 Sat Apr 9 15:43:41 2022
+++ src/usr.bin/xlint/lint1/decl.c Sat Apr 9 16:02:14 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.273 2022/04/09 15:43:41 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.274 2022/04/09 16:02:14 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.273 2022/04/09 15:43:41 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.274 2022/04/09 16:02:14 rillig Exp $");
#endif
#include <sys/param.h>
@@ -1123,12 +1123,10 @@ declarator_1_struct_union(sym_t *dsym)
int sz;
unsigned int o = 0; /* Appease GCC */
- lint_assert(dsym->s_scl == MOS || dsym->s_scl == MOU);
+ lint_assert(is_member(dsym));
if (dcs->d_redeclared_symbol != NULL) {
- /* should be ensured by storesym() */
- lint_assert(dcs->d_redeclared_symbol->s_scl == MOS ||
- dcs->d_redeclared_symbol->s_scl == MOU);
+ lint_assert(is_member(dcs->d_redeclared_symbol));
if (dsym->u.s_member.sm_sou_type ==
dcs->d_redeclared_symbol->u.s_member.sm_sou_type) {
Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.147 src/usr.bin/xlint/lint1/lint1.h:1.148
--- src/usr.bin/xlint/lint1/lint1.h:1.147 Sat Apr 9 15:43:41 2022
+++ src/usr.bin/xlint/lint1/lint1.h Sat Apr 9 16:02:14 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.147 2022/04/09 15:43:41 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.148 2022/04/09 16:02:14 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -582,3 +582,9 @@ is_struct_or_union(tspec_t t)
{
return t == STRUCT || t == UNION;
}
+
+static inline bool
+is_member(const sym_t *sym)
+{
+ return sym->s_scl == MOS || sym->s_scl == MOU;
+}
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.422 src/usr.bin/xlint/lint1/tree.c:1.423
--- src/usr.bin/xlint/lint1/tree.c:1.422 Sat Apr 9 15:43:41 2022
+++ src/usr.bin/xlint/lint1/tree.c Sat Apr 9 16:02:14 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.422 2022/04/09 15:43:41 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.423 2022/04/09 16:02:14 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.422 2022/04/09 15:43:41 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.423 2022/04/09 16:02:14 rillig Exp $");
#endif
#include <float.h>
@@ -386,7 +386,7 @@ struct_or_union_member(tnode_t *tn, op_t
*/
if (str != NULL) {
for (sym = msym; sym != NULL; sym = sym->s_symtab_next) {
- if (sym->s_scl != MOS && sym->s_scl != MOU)
+ if (!is_member(sym))
continue;
if (sym->u.s_member.sm_sou_type != str)
continue;
@@ -2776,7 +2776,7 @@ build_struct_access(op_t op, bool sys, t
bool nolval;
lint_assert(rn->tn_op == NAME);
- lint_assert(rn->tn_sym->s_scl == MOS || rn->tn_sym->s_scl == MOU);
+ lint_assert(is_member(rn->tn_sym));
/*
* Remember if the left operand is an lvalue (structure members