Module Name: src Committed By: rillig Date: Fri Jun 30 19:43:01 UTC 2023
Modified Files: src/usr.bin/xlint/lint1: decl.c lex.c lint1.h Log Message: lint: replace macro for unique identifiers with function No functional change. To generate a diff of this commit: cvs rdiff -u -r1.327 -r1.328 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.162 -r1.163 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.171 -r1.172 src/usr.bin/xlint/lint1/lint1.h 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.327 src/usr.bin/xlint/lint1/decl.c:1.328 --- src/usr.bin/xlint/lint1/decl.c:1.327 Fri Jun 30 19:10:49 2023 +++ src/usr.bin/xlint/lint1/decl.c Fri Jun 30 19:43:00 2023 @@ -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. Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.162 src/usr.bin/xlint/lint1/lex.c:1.163 --- src/usr.bin/xlint/lint1/lex.c:1.162 Thu Jun 29 22:52:44 2023 +++ src/usr.bin/xlint/lint1/lex.c Fri Jun 30 19:43:00 2023 @@ -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; Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.171 src/usr.bin/xlint/lint1/lint1.h:1.172 --- src/usr.bin/xlint/lint1/lint1.h:1.171 Fri Jun 30 19:10:49 2023 +++ src/usr.bin/xlint/lint1/lint1.h Fri Jun 30 19:43:00 2023 @@ -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) {