Module Name: src
Committed By: rillig
Date: Fri Apr 2 11:53:25 UTC 2021
Modified Files:
src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h func.c init.c tree.c
Log Message:
lint: rename functions for duplicating types
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.209 -r1.210 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.168 -r1.169 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.188 -r1.189 src/usr.bin/xlint/lint1/init.c
cvs rdiff -u -r1.257 -r1.258 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.209 src/usr.bin/xlint/lint1/cgram.y:1.210
--- src/usr.bin/xlint/lint1/cgram.y:1.209 Fri Apr 2 10:13:03 2021
+++ src/usr.bin/xlint/lint1/cgram.y Fri Apr 2 11:53:25 2021
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.209 2021/04/02 10:13:03 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.210 2021/04/02 11:53:25 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.209 2021/04/02 10:13:03 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.210 2021/04/02 11:53:25 rillig Exp $");
#endif
#include <limits.h>
@@ -1889,7 +1889,7 @@ term:
expr_statement_list {
block_level--;
mem_block_level--;
- begin_initialization(mktempsym(duptyp($4->tn_type)));
+ begin_initialization(mktempsym(dup_type($4->tn_type)));
mem_block_level++;
block_level++;
/* ({ }) is a GCC extension */
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.168 src/usr.bin/xlint/lint1/decl.c:1.169
--- src/usr.bin/xlint/lint1/decl.c:1.168 Fri Apr 2 10:13:03 2021
+++ src/usr.bin/xlint/lint1/decl.c Fri Apr 2 11:53:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.168 2021/04/02 10:13:03 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.169 2021/04/02 11:53:25 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.168 2021/04/02 10:13:03 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.169 2021/04/02 11:53:25 rillig Exp $");
#endif
#include <sys/param.h>
@@ -133,8 +133,9 @@ initdecl(void)
/*
* Returns a shared type structure for arithmetic types and void.
*
- * It's important to duplicate this structure (using duptyp() or tduptyp())
- * if it is to be modified (adding qualifiers or anything else).
+ * It's important to duplicate this structure (using dup_type() or
+ * expr_dup_type()) if it is to be modified (adding qualifiers or anything
+ * else).
*/
type_t *
gettyp(tspec_t t)
@@ -144,7 +145,7 @@ gettyp(tspec_t t)
}
type_t *
-duptyp(const type_t *tp)
+dup_type(const type_t *tp)
{
type_t *ntp;
@@ -154,11 +155,11 @@ duptyp(const type_t *tp)
}
/*
- * Use tduptyp() instead of duptyp() inside expressions (if the
+ * Use expr_dup_type() instead of dup_type() inside expressions (if the
* allocated memory should be freed after the expr).
*/
type_t *
-tduptyp(const type_t *tp)
+expr_dup_type(const type_t *tp)
{
type_t *ntp;
@@ -394,7 +395,7 @@ tdeferr(type_t *td, tspec_t t)
if (!tflag)
/* modifying typedef with '%s'; only ... */
warning(5, ttab[t].tt_name);
- td = duptyp(gettyp(merge_type_specifiers(t2, t)));
+ td = dup_type(gettyp(merge_type_specifiers(t2, t)));
td->t_typedef = true;
return td;
}
@@ -403,7 +404,7 @@ tdeferr(type_t *td, tspec_t t)
if (t2 == INT || t2 == UINT) {
/* modifying typedef with '%s'; only qualifiers ... */
warning(5, "short");
- td = duptyp(gettyp(t2 == INT ? SHORT : USHORT));
+ td = dup_type(gettyp(t2 == INT ? SHORT : USHORT));
td->t_typedef = true;
return td;
}
@@ -428,7 +429,7 @@ tdeferr(type_t *td, tspec_t t)
} else if (t2 == DCOMPLEX) {
td = gettyp(LCOMPLEX);
}
- td = duptyp(td);
+ td = dup_type(td);
td->t_typedef = true;
return td;
}
@@ -857,7 +858,7 @@ deftyp(void)
}
if (dcs->d_const || dcs->d_volatile) {
- dcs->d_type = duptyp(dcs->d_type);
+ dcs->d_type = dup_type(dcs->d_type);
dcs->d_type->t_const |= dcs->d_const;
dcs->d_type->t_volatile |= dcs->d_volatile;
}
@@ -1123,7 +1124,7 @@ declare_bit_field(sym_t *dsym, tspec_t *
/* illegal bit-field type '%s' */
warning(35, type_name(tp));
int sz = tp->t_flen;
- dsym->s_type = tp = duptyp(gettyp(t = INT));
+ dsym->s_type = tp = dup_type(gettyp(t = INT));
if ((tp->t_flen = sz) > size_in_bits(t))
tp->t_flen = size_in_bits(t);
}
@@ -1267,7 +1268,7 @@ bitfield(sym_t *dsym, int len)
dsym->s_type = gettyp(UINT);
dsym->s_block_level = -1;
}
- dsym->s_type = duptyp(dsym->s_type);
+ dsym->s_type = dup_type(dsym->s_type);
dsym->s_type->t_bitfield = true;
dsym->s_type->t_flen = len;
dsym->s_bitfield = true;
@@ -2016,7 +2017,7 @@ declare_extern(sym_t *dsym, bool initflg
}
if (dsym->s_scl == TYPEDEF) {
- dsym->s_type = duptyp(dsym->s_type);
+ dsym->s_type = dup_type(dsym->s_type);
dsym->s_type->t_typedef = true;
settdsym(dsym->s_type, dsym);
}
@@ -2368,13 +2369,13 @@ complete_type(sym_t *dsym, sym_t *ssym)
lint_assert(dst->t_tspec == src->t_tspec);
if (dst->t_tspec == ARRAY) {
if (dst->t_dim == 0 && src->t_dim != 0) {
- *dstp = dst = duptyp(dst);
+ *dstp = dst = dup_type(dst);
dst->t_dim = src->t_dim;
setcomplete(dst, true);
}
} else if (dst->t_tspec == FUNC) {
if (!dst->t_proto && src->t_proto) {
- *dstp = dst = duptyp(dst);
+ *dstp = dst = dup_type(dst);
dst->t_proto = true;
dst->t_args = src->t_args;
}
@@ -2753,7 +2754,7 @@ declare_local(sym_t *dsym, bool initflg)
}
if (dsym->s_scl == TYPEDEF) {
- dsym->s_type = duptyp(dsym->s_type);
+ dsym->s_type = dup_type(dsym->s_type);
dsym->s_type->t_typedef = true;
settdsym(dsym->s_type, dsym);
}
Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.98 src/usr.bin/xlint/lint1/externs1.h:1.99
--- src/usr.bin/xlint/lint1/externs1.h:1.98 Fri Apr 2 10:13:03 2021
+++ src/usr.bin/xlint/lint1/externs1.h Fri Apr 2 11:53:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.98 2021/04/02 10:13:03 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.99 2021/04/02 11:53:25 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -138,8 +138,8 @@ extern int enumval;
extern void initdecl(void);
extern type_t *gettyp(tspec_t);
-extern type_t *duptyp(const type_t *);
-extern type_t *tduptyp(const type_t *);
+extern type_t *dup_type(const type_t *);
+extern type_t *expr_dup_type(const type_t *);
extern bool is_incomplete(const type_t *);
extern void setcomplete(type_t *, bool);
extern void add_storage_class(scl_t);
Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.99 src/usr.bin/xlint/lint1/func.c:1.100
--- src/usr.bin/xlint/lint1/func.c:1.99 Fri Apr 2 10:13:03 2021
+++ src/usr.bin/xlint/lint1/func.c Fri Apr 2 11:53:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.99 2021/04/02 10:13:03 rillig Exp $ */
+/* $NetBSD: func.c,v 1.100 2021/04/02 11:53:25 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.99 2021/04/02 10:13:03 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.100 2021/04/02 11:53:25 rillig Exp $");
#endif
#include <stdlib.h>
@@ -1051,7 +1051,7 @@ do_return(tnode_t *tn)
/* Create a temporary node for the left side */
ln = expr_zalloc(sizeof *ln);
ln->tn_op = NAME;
- ln->tn_type = tduptyp(funcsym->s_type->t_subt);
+ ln->tn_type = expr_dup_type(funcsym->s_type->t_subt);
ln->tn_type->t_const = false;
ln->tn_lvalue = true;
ln->tn_sym = funcsym; /* better than nothing */
Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.188 src/usr.bin/xlint/lint1/init.c:1.189
--- src/usr.bin/xlint/lint1/init.c:1.188 Fri Apr 2 10:13:03 2021
+++ src/usr.bin/xlint/lint1/init.c Fri Apr 2 11:53:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.188 2021/04/02 10:13:03 rillig Exp $ */
+/* $NetBSD: init.c,v 1.189 2021/04/02 11:53:25 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.188 2021/04/02 10:13:03 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.189 2021/04/02 11:53:25 rillig Exp $");
#endif
#include <stdlib.h>
@@ -321,7 +321,7 @@ update_type_of_array_of_unknown_size(sym
{
type_t *tp;
- tp = duptyp(sym->s_type);
+ tp = dup_type(sym->s_type);
tp->t_dim = (int)size;
tp->t_incomplete_array = false;
sym->s_type = tp;
@@ -385,7 +385,7 @@ check_init_expr(const type_t *tp, sym_t
/* Create a temporary node for the left side. */
ln = expr_zalloc(sizeof *ln);
ln->tn_op = NAME;
- ln->tn_type = tduptyp(tp);
+ ln->tn_type = expr_dup_type(tp);
ln->tn_type->t_const = false;
ln->tn_lvalue = true;
ln->tn_sym = sym;
@@ -880,7 +880,7 @@ initialization_expr_using_assign(struct
debug_step0("handing over to ASSIGN");
ln = new_name_node(in->in_sym, 0);
- ln->tn_type = tduptyp(ln->tn_type);
+ ln->tn_type = expr_dup_type(ln->tn_type);
ln->tn_type->t_const = false;
tn = build(ASSIGN, ln, rn);
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.257 src/usr.bin/xlint/lint1/tree.c:1.258
--- src/usr.bin/xlint/lint1/tree.c:1.257 Fri Apr 2 10:13:03 2021
+++ src/usr.bin/xlint/lint1/tree.c Fri Apr 2 11:53:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.257 2021/04/02 10:13:03 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.258 2021/04/02 11:53:25 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.257 2021/04/02 10:13:03 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.258 2021/04/02 11:53:25 rillig Exp $");
#endif
#include <float.h>
@@ -711,7 +711,7 @@ cconv(tnode_t *tn)
/* lvalue to rvalue */
if (tn->tn_lvalue) {
- tp = tduptyp(tn->tn_type);
+ tp = expr_dup_type(tn->tn_type);
tp->t_const = tp->t_volatile = false;
tn = new_tnode(LOAD, tp, tn, NULL);
}
@@ -1932,7 +1932,7 @@ promote(op_t op, bool farg, tnode_t *tn)
}
if (t != tn->tn_type->t_tspec) {
- ntp = tduptyp(tn->tn_type);
+ ntp = expr_dup_type(tn->tn_type);
ntp->t_tspec = t;
/*
* Keep t_is_enum so we are later able to check compatibility
@@ -2018,12 +2018,12 @@ balance(op_t op, tnode_t **lnp, tnode_t
}
if (t != lt) {
- ntp = tduptyp((*lnp)->tn_type);
+ ntp = expr_dup_type((*lnp)->tn_type);
ntp->t_tspec = t;
*lnp = convert(op, 0, ntp, *lnp);
}
if (t != rt) {
- ntp = tduptyp((*rnp)->tn_type);
+ ntp = expr_dup_type((*rnp)->tn_type);
ntp->t_tspec = t;
*rnp = convert(op, 0, ntp, *rnp);
}
@@ -2627,8 +2627,8 @@ merge_qualifiers(type_t **tpp, type_t *t
return;
}
- *tpp = tduptyp(*tpp);
- (*tpp)->t_subt = tduptyp((*tpp)->t_subt);
+ *tpp = expr_dup_type(*tpp);
+ (*tpp)->t_subt = expr_dup_type((*tpp)->t_subt);
(*tpp)->t_subt->t_const =
tp1->t_subt->t_const | tp2->t_subt->t_const;
(*tpp)->t_subt->t_volatile =
@@ -3703,7 +3703,7 @@ check_prototype_argument(
bool dowarn;
ln = xcalloc(1, sizeof *ln);
- ln->tn_type = tduptyp(tp);
+ ln->tn_type = expr_dup_type(tp);
ln->tn_type->t_const = false;
ln->tn_lvalue = true;
if (typeok(FARG, n, ln, tn)) {