lint: replace macro for unique identifiers with function

No functional change.
This commit is contained in:
rillig 2023-06-30 19:43:00 +00:00
parent f6c9a3ff5c
commit 54af47c51a
3 changed files with 21 additions and 19 deletions

View File

@ -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, bool decl, bool semi)
} 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, bool szof)
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.

View File

@ -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;

View File

@ -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)
{