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: replace macro for unique identifie...
details: https://anonhg.NetBSD.org/src/rev/2a3a6a9c9ebe
branches: trunk
changeset: 377197:2a3a6a9c9ebe
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Jun 30 19:43:00 2023 +0000
description:
lint: replace macro for unique identifiers with function
No functional change.
diffstat:
usr.bin/xlint/lint1/decl.c | 10 +++++-----
usr.bin/xlint/lint1/lex.c | 8 ++++----
usr.bin/xlint/lint1/lint1.h | 22 ++++++++++++----------
3 files changed, 21 insertions(+), 19 deletions(-)
diffs (124 lines):
diff -r 545759e74808 -r 2a3a6a9c9ebe usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Fri Jun 30 19:10:49 2023 +0000
+++ b/usr.bin/xlint/lint1/decl.c Fri Jun 30 19:43:00 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.327 2023/06/30 19:10:49 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.328 2023/06/30 19:43:00 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.327 2023/06/30 19:10:49 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.328 2023/06/30 19:43:00 rillig Exp $");
#endif
#include <sys/param.h>
@@ -1579,7 +1579,7 @@ make_tag_type(sym_t *tag, tspec_t kind,
} else {
tag = block_zero_alloc(sizeof(*tag));
tag->s_name = unnamed;
- UNIQUE_CURR_POS(tag->s_def_pos);
+ tag->s_def_pos = unique_curr_pos();
tag->s_kind = FTAG;
tag->s_scl = scl;
tag->s_block_level = -1;
@@ -2834,7 +2834,7 @@ mark_as_set(sym_t *sym)
if (!sym->s_set) {
sym->s_set = true;
- UNIQUE_CURR_POS(sym->s_set_pos);
+ sym->s_set_pos = unique_curr_pos();
}
}
@@ -2845,7 +2845,7 @@ mark_as_used(sym_t *sym, bool fcall, boo
if (!sym->s_used) {
sym->s_used = true;
- UNIQUE_CURR_POS(sym->s_use_pos);
+ sym->s_use_pos = unique_curr_pos();
}
/*
* For function calls, another record is written.
diff -r 545759e74808 -r 2a3a6a9c9ebe usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Fri Jun 30 19:10:49 2023 +0000
+++ b/usr.bin/xlint/lint1/lex.c Fri Jun 30 19:43:00 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.162 2023/06/29 22:52:44 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.163 2023/06/30 19:43:00 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: lex.c,v 1.162 2023/06/29 22:52:44 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.163 2023/06/30 19:43:00 rillig Exp $");
#endif
#include <ctype.h>
@@ -1334,7 +1334,7 @@ getsym(sbuf_t *sb)
di = dcs;
}
- UNIQUE_CURR_POS(sym->s_def_pos);
+ sym->s_def_pos = unique_curr_pos();
if ((sym->s_kind = symtyp) != FLABEL)
sym->s_type = gettyp(INT);
@@ -1461,7 +1461,7 @@ pushdown(const sym_t *sym)
nsym = block_zero_alloc(sizeof(*nsym));
lint_assert(sym->s_block_level <= block_level);
nsym->s_name = sym->s_name;
- UNIQUE_CURR_POS(nsym->s_def_pos);
+ nsym->s_def_pos = unique_curr_pos();
nsym->s_kind = sym->s_kind;
nsym->s_block_level = block_level;
diff -r 545759e74808 -r 2a3a6a9c9ebe usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h Fri Jun 30 19:10:49 2023 +0000
+++ b/usr.bin/xlint/lint1/lint1.h Fri Jun 30 19:43:00 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.171 2023/06/30 19:10:49 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.172 2023/06/30 19:43:00 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -66,15 +66,6 @@ typedef struct {
int p_uniq; /* uniquifier */
} pos_t;
-/* Copies curr_pos, keeping things unique. */
-#define UNIQUE_CURR_POS(pos) \
- do { \
- (pos) = curr_pos; \
- curr_pos.p_uniq++; \
- if (curr_pos.p_file == csrc_pos.p_file) \
- csrc_pos.p_uniq++; \
- } while (false)
-
/*
* Strings cannot be referenced simply by a pointer to their first
* char. This is because strings can contain NUL characters other than the
@@ -519,6 +510,17 @@ check_printf(const char *fmt, ...)
} while (false)
#endif
+/* Copies curr_pos, keeping things unique. */
+static inline pos_t
+unique_curr_pos(void)
+{
+ pos_t curr = curr_pos;
+ curr_pos.p_uniq++;
+ if (curr_pos.p_file == csrc_pos.p_file)
+ csrc_pos.p_uniq++;
+ return curr;
+}
+
static inline bool
is_nonzero_val(const val_t *val)
{
Home |
Main Index |
Thread Index |
Old Index