Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint lint: rename functions to be clearer
details: https://anonhg.NetBSD.org/src/rev/988166e66ed5
branches: trunk
changeset: 369698:988166e66ed5
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Aug 28 10:43:18 2022 +0000
description:
lint: rename functions to be clearer
No need anymore to keep external identifiers at the "6 significant
initial characters" mandated by C90.
diffstat:
usr.bin/xlint/lint1/cgram.y | 36 ++++++++++----------
usr.bin/xlint/lint1/decl.c | 69 ++++++++++++++++++++---------------------
usr.bin/xlint/lint1/externs1.h | 10 +++---
usr.bin/xlint/lint1/tree.c | 6 +-
usr.bin/xlint/lint2/chk.c | 26 +++++++-------
5 files changed, 73 insertions(+), 74 deletions(-)
diffs (truncated from 536 to 300 lines):
diff -r 8fafa2896cf0 -r 988166e66ed5 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Sun Aug 28 10:26:37 2022 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Sun Aug 28 10:43:18 2022 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.422 2022/08/28 08:41:06 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.423 2022/08/28 10:43:18 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: cgram.y,v 1.422 2022/08/28 08:41:06 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.423 2022/08/28 10:43:18 rillig Exp $");
#endif
#include <limits.h>
@@ -872,15 +872,15 @@
* yychar is valid because otherwise the parser would not
* have been able to decide if it must shift or reduce
*/
- $$ = mktag($2, $1, false, yychar == T_SEMI);
+ $$ = make_tag_type($2, $1, false, yychar == T_SEMI);
}
| struct_or_union identifier_sym {
- dcs->d_tagtyp = mktag($2, $1, true, false);
+ dcs->d_tagtyp = make_tag_type($2, $1, true, false);
} braced_struct_declaration_list {
$$ = complete_tag_struct_or_union(dcs->d_tagtyp, $4);
}
| struct_or_union {
- dcs->d_tagtyp = mktag(NULL, $1, true, false);
+ dcs->d_tagtyp = make_tag_type(NULL, $1, true, false);
} braced_struct_declaration_list {
$$ = complete_tag_struct_or_union(dcs->d_tagtyp, $3);
}
@@ -924,7 +924,7 @@
struct_declaration_list: /* C99 6.7.2.1 */
struct_declaration
| struct_declaration_list struct_declaration {
- $$ = lnklst($1, $2);
+ $$ = concat_lists($1, $2);
}
;
@@ -980,7 +980,7 @@
| notype_struct_declarators {
symtyp = FMEMBER;
} T_COMMA type_struct_declarator {
- $$ = lnklst($1, declarator_1_struct_union($4));
+ $$ = concat_lists($1, declarator_1_struct_union($4));
}
;
@@ -991,46 +991,46 @@
| type_struct_declarators {
symtyp = FMEMBER;
} T_COMMA type_struct_declarator {
- $$ = lnklst($1, declarator_1_struct_union($4));
+ $$ = concat_lists($1, declarator_1_struct_union($4));
}
;
notype_struct_declarator:
notype_declarator
| notype_declarator T_COLON constant_expr { /* C99 6.7.2.1 */
- $$ = bitfield($1, to_int_constant($3, true));
+ $$ = set_bit_field_width($1, to_int_constant($3, true));
}
| {
symtyp = FVFT;
} T_COLON constant_expr { /* C99 6.7.2.1 */
- $$ = bitfield(NULL, to_int_constant($3, true));
+ $$ = set_bit_field_width(NULL, to_int_constant($3, true));
}
;
type_struct_declarator:
type_declarator
| type_declarator T_COLON constant_expr {
- $$ = bitfield($1, to_int_constant($3, true));
+ $$ = set_bit_field_width($1, to_int_constant($3, true));
}
| {
symtyp = FVFT;
} T_COLON constant_expr {
- $$ = bitfield(NULL, to_int_constant($3, true));
+ $$ = set_bit_field_width(NULL, to_int_constant($3, true));
}
;
/* K&R ---, C90 6.5.2.2, C99 6.7.2.2, C11 6.7.2.2 */
enum_specifier: /* C99 6.7.2.2 */
enum gcc_attribute_specifier_list_opt identifier_sym {
- $$ = mktag($3, ENUM, false, false);
+ $$ = make_tag_type($3, ENUM, false, false);
}
| enum gcc_attribute_specifier_list_opt identifier_sym {
- dcs->d_tagtyp = mktag($3, ENUM, true, false);
+ dcs->d_tagtyp = make_tag_type($3, ENUM, true, false);
} enum_declaration /*gcc_attribute_specifier_list_opt*/ {
$$ = complete_tag_enum(dcs->d_tagtyp, $5);
}
| enum gcc_attribute_specifier_list_opt {
- dcs->d_tagtyp = mktag(NULL, ENUM, true, false);
+ dcs->d_tagtyp = make_tag_type(NULL, ENUM, true, false);
} enum_declaration /*gcc_attribute_specifier_list_opt*/ {
$$ = complete_tag_enum(dcs->d_tagtyp, $4);
}
@@ -1077,7 +1077,7 @@
enumerator_list: /* C99 6.7.2.2 */
enumerator
| enumerator_list T_COMMA enumerator {
- $$ = lnklst($1, $3);
+ $$ = concat_lists($1, $3);
}
| error {
$$ = NULL;
@@ -1341,7 +1341,7 @@
$$ = old_style_function_name(getsym($1));
}
| identifier_list T_COMMA T_NAME {
- $$ = lnklst($1, old_style_function_name(getsym($3)));
+ $$ = concat_lists($1, old_style_function_name(getsym($3)));
}
| identifier_list error
;
@@ -1460,7 +1460,7 @@
parameter_type_list:
parameter_declaration
| parameter_type_list T_COMMA parameter_declaration {
- $$ = lnklst($1, $3);
+ $$ = concat_lists($1, $3);
}
;
diff -r 8fafa2896cf0 -r 988166e66ed5 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sun Aug 28 10:26:37 2022 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sun Aug 28 10:43:18 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.296 2022/08/28 08:41:06 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.297 2022/08/28 10:43:18 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.296 2022/08/28 08:41:06 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.297 2022/08/28 10:43:18 rillig Exp $");
#endif
#include <sys/param.h>
@@ -57,17 +57,17 @@
int enumval;
/*
- * pointer to top element of a stack which contains information local
+ * pointer to innermost element of a stack which contains information local
* to nested declarations
*/
dinfo_t *dcs;
-static type_t *tdeferr(type_t *, tspec_t);
-static void settdsym(type_t *, sym_t *);
+static type_t *typedef_error(type_t *, tspec_t);
+static void set_first_typedef(type_t *, sym_t *);
static void dcs_align(unsigned int, unsigned int);
-static sym_t *newtag(sym_t *, scl_t, bool, bool);
-static bool eqargs(const type_t *, const type_t *, bool *);
-static bool mnoarg(const type_t *, bool *);
+static sym_t *new_tag(sym_t *, scl_t, bool, bool);
+static bool eq_prototype_args(const type_t *, const type_t *, bool *);
+static bool matches_no_arg_function(const type_t *, bool *);
static bool check_old_style_definition(sym_t *, sym_t *);
static bool check_prototype_declaration(sym_t *, sym_t *);
static sym_t *new_style_function(sym_t *);
@@ -219,8 +219,7 @@
}
/*
- * Remember the storage class of the current declaration in dcs->d_scl
- * (the top element of the declaration stack) and detect multiple
+ * Remember the storage class of the current declaration and detect multiple
* storage classes.
*/
void
@@ -327,7 +326,7 @@
if (dcs->d_type != NULL && dcs->d_type->t_typedef) {
/* something like "typedef int a; a long ..." */
- dcs->d_type = tdeferr(dcs->d_type, t);
+ dcs->d_type = typedef_error(dcs->d_type, t);
return;
}
@@ -395,7 +394,7 @@
* and other specifiers (except struct, union, enum, typedef name)
*/
static type_t *
-tdeferr(type_t *td, tspec_t t)
+typedef_error(type_t *td, tspec_t t)
{
tspec_t t2;
@@ -460,7 +459,7 @@
* if the tag is unnamed.
*/
static void
-settdsym(type_t *tp, sym_t *sym)
+set_first_typedef(type_t *tp, sym_t *sym)
{
tspec_t t;
@@ -474,7 +473,7 @@
}
static unsigned int
-bitfieldsize(sym_t **mem)
+bit_field_size(sym_t **mem)
{
unsigned int len = (*mem)->s_type->t_flen;
while (*mem != NULL && (*mem)->s_type->t_bitfield) {
@@ -485,7 +484,7 @@
}
static void
-setpackedsize(type_t *tp)
+set_packed_size(type_t *tp)
{
struct_or_union *sp;
sym_t *mem;
@@ -500,7 +499,7 @@
unsigned int x;
if (mem->s_type->t_bitfield) {
- sp->sou_size_in_bits += bitfieldsize(&mem);
+ sp->sou_size_in_bits += bit_field_size(&mem);
if (mem == NULL)
break;
}
@@ -524,7 +523,7 @@
if (dcs->d_type == NULL)
dcs->d_packed = true;
else
- setpackedsize(dcs->d_type);
+ set_packed_size(dcs->d_type);
}
void
@@ -915,7 +914,7 @@
* struct/union/enum elements and parameters.
*/
sym_t *
-lnklst(sym_t *l1, sym_t *l2)
+concat_lists(sym_t *l1, sym_t *l2)
{
sym_t *l;
@@ -1219,7 +1218,7 @@
* Remember the width of the field in its type structure.
*/
sym_t *
-bitfield(sym_t *dsym, int len)
+set_bit_field_width(sym_t *dsym, int len)
{
if (dsym == NULL) {
@@ -1682,7 +1681,7 @@
* semi is true if the following token is T_SEMI
*/
type_t *
-mktag(sym_t *tag, tspec_t kind, bool decl, bool semi)
+make_tag_type(sym_t *tag, tspec_t kind, bool decl, bool semi)
{
scl_t scl;
type_t *tp;
@@ -1698,7 +1697,7 @@
if (tag != NULL) {
if (tag->s_scl != NOSCL) {
- tag = newtag(tag, scl, decl, semi);
+ tag = new_tag(tag, scl, decl, semi);
} else {
/* a new tag, no empty declaration */
dcs->d_enclosing->d_nonempty_decl = true;
@@ -1751,7 +1750,7 @@
* semi is true if T_SEMI follows
*/
static sym_t *
-newtag(sym_t *tag, scl_t scl, bool decl, bool semi)
+new_tag(sym_t *tag, scl_t scl, bool decl, bool semi)
{
if (tag->s_block_level < block_level) {
@@ -1848,7 +1847,7 @@
sp->sou_align_in_bits = dcs->d_sou_align_in_bits;
Home |
Main Index |
Thread Index |
Old Index