Module Name: src Committed By: rillig Date: Tue Jul 20 19:44:36 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: cgram.y externs1.h init.c tree.c Log Message: lint: use consistent naming scheme for functions that build nodes No functional change. To generate a diff of this commit: cvs rdiff -u -r1.329 -r1.330 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.119 -r1.120 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.202 -r1.203 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.317 -r1.318 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/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.329 src/usr.bin/xlint/lint1/cgram.y:1.330 --- src/usr.bin/xlint/lint1/cgram.y:1.329 Tue Jul 20 19:35:53 2021 +++ src/usr.bin/xlint/lint1/cgram.y Tue Jul 20 19:44:36 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.329 2021/07/20 19:35:53 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.330 2021/07/20 19:44:36 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.329 2021/07/20 19:35:53 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.330 2021/07/20 19:44:36 rillig Exp $"); #endif #include <limits.h> @@ -412,13 +412,13 @@ primary_expression: /* XXX really necessary? */ if (yychar < 0) yychar = yylex(); - $$ = new_name_node(getsym($1), yychar); + $$ = build_name(getsym($1), yychar); } | T_CON { - $$ = expr_new_constant(gettyp($1->v_tspec), $1); + $$ = build_constant(gettyp($1->v_tspec), $1); } | string { - $$ = new_string_node($1); + $$ = build_string($1); } | T_LPAREN expression T_RPAREN { if ($2 != NULL) @@ -473,10 +473,10 @@ postfix_expression: $$ = build_unary(INDIR, build_binary($1, PLUS, $3)); } | postfix_expression T_LPAREN T_RPAREN { - $$ = new_function_call_node($1, NULL); + $$ = build_function_call($1, NULL); } | postfix_expression T_LPAREN argument_expression_list T_RPAREN { - $$ = new_function_call_node($1, $3); + $$ = build_function_call($1, $3); } | postfix_expression point_or_arrow T_NAME { $$ = build_member_access($1, $2, $3); @@ -492,7 +492,7 @@ postfix_expression: if (!Sflag) /* compound literals are a C9X/GCC extension */ gnuism(319); - $$ = new_name_node(*current_initsym(), 0); + $$ = build_name(*current_initsym(), 0); end_initialization(); } | T_LPAREN compound_statement_lbrace gcc_statement_expr_list { @@ -504,7 +504,7 @@ postfix_expression: /* ({ }) is a GCC extension */ gnuism(320); } compound_statement_rbrace T_RPAREN { - $$ = new_name_node(*current_initsym(), 0); + $$ = build_name(*current_initsym(), 0); end_initialization(); } ; @@ -564,10 +564,10 @@ point_or_arrow: /* helper for 'postfix /* K&R 7.1, C90 ???, C99 6.5.2, C11 6.5.2 */ argument_expression_list: assignment_expression { - $$ = new_function_argument_node(NULL, $1); + $$ = build_function_argument(NULL, $1); } | argument_expression_list T_COMMA assignment_expression { - $$ = new_function_argument_node($1, $3); + $$ = build_function_argument($1, $3); } ; Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.119 src/usr.bin/xlint/lint1/externs1.h:1.120 --- src/usr.bin/xlint/lint1/externs1.h:1.119 Tue Jul 20 19:35:53 2021 +++ src/usr.bin/xlint/lint1/externs1.h Tue Jul 20 19:44:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.119 2021/07/20 19:35:53 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.120 2021/07/20 19:44:36 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -204,9 +204,9 @@ extern int to_int_constant(tnode_t *, bo extern const tnode_t *before_conversion(const tnode_t *); extern type_t *derive_type(type_t *, tspec_t); extern type_t *expr_derive_type(type_t *, tspec_t); -extern tnode_t *expr_new_constant(type_t *, val_t *); -extern tnode_t *new_name_node(sym_t *, int); -extern tnode_t *new_string_node(strg_t *); +extern tnode_t *build_constant(type_t *, val_t *); +extern tnode_t *build_name(sym_t *, int); +extern tnode_t *build_string(strg_t *); extern sym_t *struct_or_union_member(tnode_t *, op_t, sym_t *); extern tnode_t *build_generic_selection(const tnode_t *, struct generic_association *); @@ -224,8 +224,8 @@ extern tnode_t *build_sizeof(const type_ extern tnode_t *build_offsetof(const type_t *, const sym_t *); extern tnode_t *build_alignof(const type_t *); extern tnode_t *cast(tnode_t *, type_t *); -extern tnode_t *new_function_argument_node(tnode_t *, tnode_t *); -extern tnode_t *new_function_call_node(tnode_t *, tnode_t *); +extern tnode_t *build_function_argument(tnode_t *, tnode_t *); +extern tnode_t *build_function_call(tnode_t *, tnode_t *); extern val_t *constant(tnode_t *, bool); extern void expr(tnode_t *, bool, bool, bool, bool); extern void check_expr_misc(const tnode_t *, bool, bool, bool, Index: src/usr.bin/xlint/lint1/init.c diff -u src/usr.bin/xlint/lint1/init.c:1.202 src/usr.bin/xlint/lint1/init.c:1.203 --- src/usr.bin/xlint/lint1/init.c:1.202 Tue Jul 20 19:35:53 2021 +++ src/usr.bin/xlint/lint1/init.c Tue Jul 20 19:44:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.202 2021/07/20 19:35:53 rillig Exp $ */ +/* $NetBSD: init.c,v 1.203 2021/07/20 19:44:36 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: init.c,v 1.202 2021/07/20 19:35:53 rillig Exp $"); +__RCSID("$NetBSD: init.c,v 1.203 2021/07/20 19:44:36 rillig Exp $"); #endif #include <stdlib.h> @@ -899,7 +899,7 @@ initialization_expr_using_assign(struct debug_step0("handing over to ASSIGN"); - ln = new_name_node(in->in_sym, 0); + ln = build_name(in->in_sym, 0); ln->tn_type = expr_dup_type(ln->tn_type); ln->tn_type->t_const = false; Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.317 src/usr.bin/xlint/lint1/tree.c:1.318 --- src/usr.bin/xlint/lint1/tree.c:1.317 Tue Jul 20 19:35:53 2021 +++ src/usr.bin/xlint/lint1/tree.c Tue Jul 20 19:44:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.317 2021/07/20 19:35:53 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.318 2021/07/20 19:44:36 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.317 2021/07/20 19:35:53 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.318 2021/07/20 19:44:36 rillig Exp $"); #endif #include <float.h> @@ -50,7 +50,7 @@ __RCSID("$NetBSD: tree.c,v 1.317 2021/07 #include "lint1.h" #include "cgram.h" -static tnode_t *expr_new_integer_constant(tspec_t, int64_t); +static tnode_t *build_integer_constant(tspec_t, int64_t); static void check_pointer_comparison(op_t, const tnode_t *, const tnode_t *); static bool check_assign_types_compatible(op_t, int, @@ -174,7 +174,7 @@ expr_derive_type(type_t *tp, tspec_t t) * Create a node for a constant. */ tnode_t * -expr_new_constant(type_t *tp, val_t *v) +build_constant(type_t *tp, val_t *v) { tnode_t *n; @@ -190,7 +190,7 @@ expr_new_constant(type_t *tp, val_t *v) } static tnode_t * -expr_new_integer_constant(tspec_t t, int64_t q) +build_integer_constant(tspec_t t, int64_t q) { tnode_t *n; @@ -245,7 +245,7 @@ is_gcc_builtin(const char *name) * follow_token is the token which follows the name. */ tnode_t * -new_name_node(sym_t *sym, int follow_token) +build_name(sym_t *sym, int follow_token) { tnode_t *n; @@ -295,7 +295,7 @@ new_name_node(sym_t *sym, int follow_tok } tnode_t * -new_string_node(strg_t *strg) +build_string(strg_t *strg) { size_t len; tnode_t *n; @@ -706,7 +706,7 @@ build_member_access(tnode_t *ln, op_t op ln = cconv(ln); } msym = struct_or_union_member(ln, op, getsym(member)); - return build_binary(ln, op, new_name_node(msym, 0)); + return build_binary(ln, op, build_name(msym, 0)); } /* @@ -2590,7 +2590,7 @@ build_struct_access(op_t op, tnode_t *ln ln = convert(NOOP, 0, expr_derive_type(gettyp(VOID), PTR), ln); } - ctn = expr_new_integer_constant(PTRDIFF_TSPEC, + ctn = build_integer_constant(PTRDIFF_TSPEC, rn->tn_sym->s_value.v_quad / CHAR_SIZE); ntn = new_tnode(PLUS, expr_derive_type(rn->tn_type, PTR), ln, ctn); @@ -2622,7 +2622,7 @@ build_prepost_incdec(op_t op, tnode_t *l if (ln->tn_type->t_tspec == PTR) { cn = plength(ln->tn_type); } else { - cn = expr_new_integer_constant(INT, (int64_t)1); + cn = build_integer_constant(INT, (int64_t)1); } ntn = new_tnode(op, ln->tn_type, ln, cn); @@ -2651,15 +2651,15 @@ build_real_imag(op_t op, tnode_t *ln) switch (ln->tn_type->t_tspec) { case LCOMPLEX: /* XXX: integer and LDOUBLE don't match. */ - cn = expr_new_integer_constant(LDOUBLE, (int64_t)1); + cn = build_integer_constant(LDOUBLE, (int64_t)1); break; case DCOMPLEX: /* XXX: integer and DOUBLE don't match. */ - cn = expr_new_integer_constant(DOUBLE, (int64_t)1); + cn = build_integer_constant(DOUBLE, (int64_t)1); break; case FCOMPLEX: /* XXX: integer and FLOAT don't match. */ - cn = expr_new_integer_constant(FLOAT, (int64_t)1); + cn = build_integer_constant(FLOAT, (int64_t)1); break; default: /* __%s__ is illegal for type %s */ @@ -2947,7 +2947,7 @@ plength(type_t *tp) if (elsz == 0) elsz = CHAR_SIZE; - return expr_new_integer_constant(PTRDIFF_TSPEC, + return build_integer_constant(PTRDIFF_TSPEC, (int64_t)(elem * elsz / CHAR_SIZE)); } @@ -3097,7 +3097,7 @@ fold(tnode_t *tn) v->v_quad = convert_integer(q, t, -1); - cn = expr_new_constant(tn->tn_type, v); + cn = build_constant(tn->tn_type, v); if (tn->tn_left->tn_system_dependent) cn->tn_system_dependent = true; if (modtab[tn->tn_op].m_binary && tn->tn_right->tn_system_dependent) @@ -3140,7 +3140,7 @@ fold_test(tnode_t *tn) lint_assert(/*CONSTCOND*/false); } - return expr_new_constant(tn->tn_type, v); + return build_constant(tn->tn_type, v); } /* @@ -3237,7 +3237,7 @@ fold_float(tnode_t *tn) fpe = 0; } - return expr_new_constant(tn->tn_type, v); + return build_constant(tn->tn_type, v); } @@ -3248,7 +3248,7 @@ tnode_t * build_sizeof(const type_t *tp) { int64_t size_in_bytes = type_size_in_bits(tp) / CHAR_SIZE; - tnode_t *tn = expr_new_integer_constant(SIZEOF_TSPEC, size_in_bytes); + tnode_t *tn = build_integer_constant(SIZEOF_TSPEC, size_in_bytes); tn->tn_system_dependent = true; return tn; } @@ -3266,7 +3266,7 @@ build_offsetof(const type_t *tp, const s // XXX: wrong size, no checking for sym fixme int64_t offset_in_bytes = type_size_in_bits(tp) / CHAR_SIZE; - tnode_t *tn = expr_new_integer_constant(SIZEOF_TSPEC, offset_in_bytes); + tnode_t *tn = build_integer_constant(SIZEOF_TSPEC, offset_in_bytes); tn->tn_system_dependent = true; return tn; } @@ -3368,7 +3368,7 @@ build_alignof(const type_t *tp) break; } - return expr_new_integer_constant(SIZEOF_TSPEC, + return build_integer_constant(SIZEOF_TSPEC, (int64_t)alignment_in_bits(tp) / CHAR_SIZE); } @@ -3463,11 +3463,11 @@ cast(tnode_t *tn, type_t *tp) /* * Create the node for a function argument. * All necessary conversions and type checks are done in - * new_function_call_node because new_function_argument_node has no + * build_function_call because build_function_argument has no * information about expected argument types. */ tnode_t * -new_function_argument_node(tnode_t *args, tnode_t *arg) +build_function_argument(tnode_t *args, tnode_t *arg) { tnode_t *ntn; @@ -3477,7 +3477,7 @@ new_function_argument_node(tnode_t *args * will not change. */ if (arg == NULL) - arg = expr_new_integer_constant(INT, 0); + arg = build_integer_constant(INT, 0); ntn = new_tnode(PUSH, arg->tn_type, arg, args); @@ -3489,7 +3489,7 @@ new_function_argument_node(tnode_t *args * function arguments and insert conversions, if necessary. */ tnode_t * -new_function_call_node(tnode_t *func, tnode_t *args) +build_function_call(tnode_t *func, tnode_t *args) { tnode_t *ntn; op_t fcop;