Fri Apr 2 10:13:03 2021 UTC ()
lint: name memory allocation functions consistently

No functional change.


(rillig)
diff -r1.208 -r1.209 src/usr.bin/xlint/lint1/cgram.y
diff -r1.167 -r1.168 src/usr.bin/xlint/lint1/decl.c
diff -r1.97 -r1.98 src/usr.bin/xlint/lint1/externs1.h
diff -r1.98 -r1.99 src/usr.bin/xlint/lint1/func.c
diff -r1.187 -r1.188 src/usr.bin/xlint/lint1/init.c
diff -r1.40 -r1.41 src/usr.bin/xlint/lint1/mem1.c
diff -r1.256 -r1.257 src/usr.bin/xlint/lint1/tree.c

cvs diff -r1.208 -r1.209 src/usr.bin/xlint/lint1/cgram.y (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/cgram.y 2021/04/02 09:52:36 1.208
+++ src/usr.bin/xlint/lint1/cgram.y 2021/04/02 10:13:03 1.209
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.208 2021/04/02 09:52:36 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.209 2021/04/02 10:13:03 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.208 2021/04/02 09:52:36 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.209 2021/04/02 10:13:03 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1878,7 +1878,7 @@
 		$$ = new_string_node($1);
 	  }
 	| T_CON {
-		$$ = new_constant_node(gettyp($1->v_tspec), $1);
+		$$ = expr_new_constant(gettyp($1->v_tspec), $1);
 	  }
 	| T_LPAREN expr T_RPAREN {
 		if ($2 != NULL)

cvs diff -r1.167 -r1.168 src/usr.bin/xlint/lint1/decl.c (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/decl.c 2021/03/30 14:25:28 1.167
+++ src/usr.bin/xlint/lint1/decl.c 2021/04/02 10:13:03 1.168
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.167 2021/03/30 14:25:28 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.168 2021/04/02 10:13:03 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.167 2021/03/30 14:25:28 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.168 2021/04/02 10:13:03 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -162,7 +162,7 @@
 {
 	type_t	*ntp;
 
-	ntp = tgetblk(sizeof *ntp);
+	ntp = expr_zalloc(sizeof *ntp);
 	*ntp = *tp;
 	return ntp;
 }
@@ -1015,9 +1015,9 @@
 				/* function returns illegal type */
 				error(15);
 				if (t == FUNC) {
-					*tpp = incref(*tpp, PTR);
+					*tpp = derive_type(*tpp, PTR);
 				} else {
-					*tpp = incref((*tpp)->t_subt, PTR);
+					*tpp = derive_type((*tpp)->t_subt, PTR);
 				}
 				return;
 			} else if (tp->t_const || tp->t_volatile) {
@@ -1183,7 +1183,7 @@
 	} else if (t == FUNC) {
 		/* function illegal in structure or union */
 		error(38);
-		dsym->s_type = tp = incref(tp, t = PTR);
+		dsym->s_type = tp = derive_type(tp, t = PTR);
 	}
 
 	/*
@@ -2416,12 +2416,12 @@
 	}
 
 	if ((t = sym->s_type->t_tspec) == ARRAY) {
-		sym->s_type = incref(sym->s_type->t_subt, PTR);
+		sym->s_type = derive_type(sym->s_type->t_subt, PTR);
 	} else if (t == FUNC) {
 		if (tflag)
 			/* a function is declared as an argument: %s */
 			warning(50, sym->s_name);
-		sym->s_type = incref(sym->s_type, PTR);
+		sym->s_type = derive_type(sym->s_type, PTR);
 	} else if (t == FLOAT) {
 		if (tflag)
 			sym->s_type = gettyp(DOUBLE);
@@ -3334,7 +3334,7 @@
 	 * will be used later to match types.
 	 */
 	if (tn->tn_op != CON && dcs->d_ctx != ABSTRACT)
-		tfreeblk();
+		expr_free_all();
 
 	if ((t = v->v_tspec) == FLOAT || t == DOUBLE || t == LDOUBLE) {
 		i = (int)v->v_ldbl;

cvs diff -r1.97 -r1.98 src/usr.bin/xlint/lint1/externs1.h (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/externs1.h 2021/04/02 09:52:36 1.97
+++ src/usr.bin/xlint/lint1/externs1.h 2021/04/02 10:13:03 1.98
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.97 2021/04/02 09:52:36 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.98 2021/04/02 10:13:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -105,11 +105,11 @@
 extern	void	freeblk(void);
 extern	void	freelblk(int);
 
-extern	void	*tgetblk(size_t);
+extern	void	*expr_zalloc(size_t);
 extern	tnode_t	*expr_zalloc_tnode(void);
-extern	void	tfreeblk(void);
-extern	struct	memory_block *tsave(void);
-extern	void	trestor(struct memory_block *);
+extern	void	expr_free_all(void);
+extern	struct	memory_block *expr_save_memory(void);
+extern	void	expr_restore_memory(struct memory_block *);
 
 /*
  * err.c
@@ -196,9 +196,9 @@
 /*
  * tree.c
  */
-extern	type_t	*incref(type_t *, tspec_t);
-extern	type_t	*tincref(type_t *, tspec_t);
-extern	tnode_t	*new_constant_node(type_t *, val_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	sym_t	*struct_or_union_member(tnode_t *, op_t, sym_t *);

cvs diff -r1.98 -r1.99 src/usr.bin/xlint/lint1/func.c (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/func.c 2021/03/26 20:31:07 1.98
+++ src/usr.bin/xlint/lint1/func.c 2021/04/02 10:13:03 1.99
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.98 2021/03/26 20:31:07 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.99 2021/04/02 10:13:03 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.98 2021/03/26 20:31:07 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.99 2021/04/02 10:13:03 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -541,7 +541,7 @@
 
 	check_case_label(tn, ci);
 
-	tfreeblk();
+	expr_free_all();
 
 	set_reached(true);
 }
@@ -883,7 +883,7 @@
 	 * Also remember this expression itself. We must check it at
 	 * the end of the loop to get "used but not set" warnings correct.
 	 */
-	cstmt->c_for_expr3_mem = tsave();
+	cstmt->c_for_expr3_mem = expr_save_memory();
 	cstmt->c_for_expr3 = tn3;
 	cstmt->c_for_expr3_pos = curr_pos;
 	cstmt->c_for_expr3_csrc_pos = csrc_pos;
@@ -920,7 +920,7 @@
 	cspos = csrc_pos;
 
 	/* Restore the tree memory for the reinitialization expression */
-	trestor(cstmt->c_for_expr3_mem);
+	expr_restore_memory(cstmt->c_for_expr3_mem);
 	tn3 = cstmt->c_for_expr3;
 	curr_pos = cstmt->c_for_expr3_pos;
 	csrc_pos = cstmt->c_for_expr3_csrc_pos;
@@ -935,7 +935,7 @@
 	if (tn3 != NULL) {
 		expr(tn3, false, false, true, false);
 	} else {
-		tfreeblk();
+		expr_free_all();
 	}
 
 	curr_pos = cpos;
@@ -1034,7 +1034,7 @@
 	if (tn != NULL && funcsym->s_type->t_subt->t_tspec == VOID) {
 		/* void function %s cannot return value */
 		error(213, funcsym->s_name);
-		tfreeblk();
+		expr_free_all();
 		tn = NULL;
 	} else if (tn == NULL && funcsym->s_type->t_subt->t_tspec != VOID) {
 		/*
@@ -1049,7 +1049,7 @@
 	if (tn != NULL) {
 
 		/* Create a temporary node for the left side */
-		ln = tgetblk(sizeof *ln);
+		ln = expr_zalloc(sizeof *ln);
 		ln->tn_op = NAME;
 		ln->tn_type = tduptyp(funcsym->s_type->t_subt);
 		ln->tn_type->t_const = false;

cvs diff -r1.187 -r1.188 src/usr.bin/xlint/lint1/init.c (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/init.c 2021/04/02 09:39:25 1.187
+++ src/usr.bin/xlint/lint1/init.c 2021/04/02 10:13:03 1.188
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.187 2021/04/02 09:39:25 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.188 2021/04/02 10:13:03 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.187 2021/04/02 09:39:25 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.188 2021/04/02 10:13:03 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -383,7 +383,7 @@
 	struct memory_block *tmem;
 
 	/* Create a temporary node for the left side. */
-	ln = tgetblk(sizeof *ln);
+	ln = expr_zalloc(sizeof *ln);
 	ln->tn_op = NAME;
 	ln->tn_type = tduptyp(tp);
 	ln->tn_type->t_const = false;
@@ -404,9 +404,9 @@
 	 * Preserve the tree memory. This is necessary because otherwise
 	 * expr() would free it.
 	 */
-	tmem = tsave();
+	tmem = expr_save_memory();
 	expr(tn, true, false, true, false);
-	trestor(tmem);
+	expr_restore_memory(tmem);
 
 	check_bit_field_init(ln, lt, rt);
 

cvs diff -r1.40 -r1.41 src/usr.bin/xlint/lint1/mem1.c (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/mem1.c 2021/04/02 09:52:36 1.40
+++ src/usr.bin/xlint/lint1/mem1.c 2021/04/02 10:13:03 1.41
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem1.c,v 1.40 2021/04/02 09:52:36 rillig Exp $	*/
+/*	$NetBSD: mem1.c,v 1.41 2021/04/02 10:13:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.40 2021/04/02 09:52:36 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.41 2021/04/02 10:13:03 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -336,24 +336,27 @@
  * expression.
  */
 void *
-tgetblk(size_t s)
+expr_zalloc(size_t s)
 {
 
 	return xgetblk(&tmblk, s);
 }
 
-/* Return a freshly allocated tree node. */
+/*
+ * Return a freshly allocated tree node that is freed at the end of the
+ * current expression.
+ */
 tnode_t *
 expr_zalloc_tnode(void)
 {
-	tnode_t *tn = tgetblk(sizeof *tn);
+	tnode_t *tn = expr_zalloc(sizeof *tn);
 	tn->tn_from_system_header = in_system_header;
 	return tn;
 }
 
 /* Free all memory which is allocated by the current expression. */
 void
-tfreeblk(void)
+expr_free_all(void)
 {
 
 	xfreeblk(&tmblk);
@@ -361,11 +364,11 @@
 
 /*
  * Save the memory which is used by the current expression. This memory
- * is not freed by the next tfreeblk() call. The pointer returned can be
+ * is not freed by the next expr_free_all() call. The pointer returned can be
  * used to restore the memory.
  */
 memory_block *
-tsave(void)
+expr_save_memory(void)
 {
 	memory_block	*tmem;
 
@@ -376,14 +379,14 @@
 
 /*
  * Free all memory used for the current expression and the memory used
- * be a previous expression and saved by tsave(). The next call to
- * tfreeblk() frees the restored memory.
+ * be a previous expression and saved by expr_save_memory(). The next call to
+ * expr_free_all() frees the restored memory.
  */
 void
-trestor(memory_block *tmem)
+expr_restore_memory(memory_block *tmem)
 {
 
-	tfreeblk();
+	expr_free_all();
 	if (tmblk != NULL) {
 		free(tmblk->blk);
 		free(tmblk);

cvs diff -r1.256 -r1.257 src/usr.bin/xlint/lint1/tree.c (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/tree.c 2021/04/02 09:52:36 1.256
+++ src/usr.bin/xlint/lint1/tree.c 2021/04/02 10:13:03 1.257
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.256 2021/04/02 09:52:36 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.257 2021/04/02 10:13:03 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.256 2021/04/02 09:52:36 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.257 2021/04/02 10:13:03 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -50,7 +50,7 @@
 #include "lint1.h"
 #include "cgram.h"
 
-static	tnode_t	*new_integer_constant_node(tspec_t, int64_t);
+static	tnode_t	*expr_new_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,
@@ -144,12 +144,9 @@
 }
 #endif
 
-/*
- * Increase degree of reference.
- * This is most often used to change type "T" in type "pointer to T".
- */
+/* Build 'pointer to tp', 'array of tp' or 'function returning tp'. */
 type_t *
-incref(type_t *tp, tspec_t t)
+derive_type(type_t *tp, tspec_t t)
 {
 	type_t	*tp2;
 
@@ -160,14 +157,15 @@
 }
 
 /*
- * same for use in expressions
+ * Build 'pointer to tp', 'array of tp' or 'function returning tp'.  The
+ * memory is freed at the end of the current expression.
  */
 type_t *
-tincref(type_t *tp, tspec_t t)
+expr_derive_type(type_t *tp, tspec_t t)
 {
 	type_t	*tp2;
 
-	tp2 = tgetblk(sizeof *tp2);
+	tp2 = expr_zalloc(sizeof *tp2);
 	tp2->t_tspec = t;
 	tp2->t_subt = tp;
 	return tp2;
@@ -177,14 +175,14 @@
  * Create a node for a constant.
  */
 tnode_t *
-new_constant_node(type_t *tp, val_t *v)
+expr_new_constant(type_t *tp, val_t *v)
 {
 	tnode_t	*n;
 
 	n = expr_zalloc_tnode();
 	n->tn_op = CON;
 	n->tn_type = tp;
-	n->tn_val = tgetblk(sizeof *n->tn_val);
+	n->tn_val = expr_zalloc(sizeof *n->tn_val);
 	n->tn_val->v_tspec = tp->t_tspec;
 	n->tn_val->v_ansiu = v->v_ansiu;
 	n->tn_val->v_u = v->v_u;
@@ -193,14 +191,14 @@
 }
 
 static tnode_t *
-new_integer_constant_node(tspec_t t, int64_t q)
+expr_new_integer_constant(tspec_t t, int64_t q)
 {
 	tnode_t	*n;
 
 	n = expr_zalloc_tnode();
 	n->tn_op = CON;
 	n->tn_type = gettyp(t);
-	n->tn_val = tgetblk(sizeof *n->tn_val);
+	n->tn_val = expr_zalloc(sizeof *n->tn_val);
 	n->tn_val->v_tspec = t;
 	n->tn_val->v_quad = q;
 	return n;
@@ -232,7 +230,7 @@
 			   strcmp(sym->s_name, "__PRETTY_FUNCTION__") == 0)) {
 		/* __FUNCTION__/__PRETTY_FUNCTION__ is a GCC extension */
 		gnuism(316);
-		sym->s_type = incref(gettyp(CHAR), PTR);
+		sym->s_type = derive_type(gettyp(CHAR), PTR);
 		sym->s_type->t_const = true;
 		return;
 	}
@@ -241,7 +239,7 @@
 		if (!Sflag)
 			/* __func__ is a C9X feature */
 			warning(317);
-		sym->s_type = incref(gettyp(CHAR), PTR);
+		sym->s_type = derive_type(gettyp(CHAR), PTR);
 		sym->s_type->t_const = true;
 		return;
 	}
@@ -271,7 +269,7 @@
 			 * XXX if tflag is set the symbol should be
 			 * exported to level 0
 			 */
-			sym->s_type = incref(sym->s_type, FUNC);
+			sym->s_type = derive_type(sym->s_type, FUNC);
 		} else {
 			fallback_symbol(sym);
 		}
@@ -288,7 +286,7 @@
 			n->tn_lvalue = true;
 	} else {
 		n->tn_op = CON;
-		n->tn_val = tgetblk(sizeof *n->tn_val);
+		n->tn_val = expr_zalloc(sizeof *n->tn_val);
 		*n->tn_val = sym->s_value;
 	}
 
@@ -306,21 +304,21 @@
 	n = expr_zalloc_tnode();
 
 	n->tn_op = STRING;
-	n->tn_type = tincref(gettyp(strg->st_tspec), ARRAY);
+	n->tn_type = expr_derive_type(gettyp(strg->st_tspec), ARRAY);
 	n->tn_type->t_dim = len + 1;
 	n->tn_lvalue = true;
 
-	n->tn_string = tgetblk(sizeof *n->tn_string);
+	n->tn_string = expr_zalloc(sizeof *n->tn_string);
 	n->tn_string->st_tspec = strg->st_tspec;
 	n->tn_string->st_len = len;
 
 	if (strg->st_tspec == CHAR) {
-		n->tn_string->st_cp = tgetblk(len + 1);
+		n->tn_string->st_cp = expr_zalloc(len + 1);
 		(void)memcpy(n->tn_string->st_cp, strg->st_cp, len + 1);
 		free(strg->st_cp);
 	} else {
 		size_t size = (len + 1) * sizeof *n->tn_string->st_wcp;
-		n->tn_string->st_wcp = tgetblk(size);
+		n->tn_string->st_wcp = expr_zalloc(size);
 		(void)memcpy(n->tn_string->st_wcp, strg->st_wcp, size);
 		free(strg->st_wcp);
 	}
@@ -352,8 +350,9 @@
 		rmsym(msym);
 		msym->s_kind = FMEMBER;
 		msym->s_scl = MOS;
-		msym->s_styp = tgetblk(sizeof *msym->s_styp);
-		msym->s_styp->sou_tag = tgetblk(sizeof *msym->s_styp->sou_tag);
+		msym->s_styp = expr_zalloc(sizeof *msym->s_styp);
+		msym->s_styp->sou_tag = expr_zalloc(
+		    sizeof *msym->s_styp->sou_tag);
 		msym->s_styp->sou_tag->s_name = unnamed;
 		msym->s_value.v_tspec = INT;
 		return msym;
@@ -698,8 +697,8 @@
 			/* %soperand of '%s' must be lvalue */
 			gnuism(114, "", modtab[ADDR].m_name);
 		}
-		tn = new_tnode(ADDR, tincref(tn->tn_type->t_subt, PTR),
-			     tn, NULL);
+		tn = new_tnode(ADDR,
+		    expr_derive_type(tn->tn_type->t_subt, PTR), tn, NULL);
 	}
 
 	/*
@@ -2066,7 +2065,7 @@
 		ntn->tn_left = tn;
 	} else {
 		ntn->tn_op = CON;
-		ntn->tn_val = tgetblk(sizeof *ntn->tn_val);
+		ntn->tn_val = expr_zalloc(sizeof *ntn->tn_val);
 		convert_constant(op, arg, ntn->tn_type, ntn->tn_val,
 		    tn->tn_val);
 	}
@@ -2684,13 +2683,13 @@
 	} else if (ln->tn_type->t_tspec != PTR) {
 		lint_assert(tflag);
 		lint_assert(is_integer(ln->tn_type->t_tspec));
-		ln = convert(NOOP, 0, tincref(gettyp(VOID), PTR), ln);
+		ln = convert(NOOP, 0, expr_derive_type(gettyp(VOID), PTR), ln);
 	}
 
-	ctn = new_integer_constant_node(PTRDIFF_TSPEC,
+	ctn = expr_new_integer_constant(PTRDIFF_TSPEC,
 	    rn->tn_sym->s_value.v_quad / CHAR_SIZE);
 
-	ntn = new_tnode(PLUS, tincref(rn->tn_type, PTR), ln, ctn);
+	ntn = new_tnode(PLUS, expr_derive_type(rn->tn_type, PTR), ln, ctn);
 	if (ln->tn_op == CON)
 		ntn = fold(ntn);
 
@@ -2719,7 +2718,7 @@
 	if (ln->tn_type->t_tspec == PTR) {
 		cn = plength(ln->tn_type);
 	} else {
-		cn = new_integer_constant_node(INT, (int64_t)1);
+		cn = expr_new_integer_constant(INT, (int64_t)1);
 	}
 	ntn = new_tnode(op, ln->tn_type, ln, cn);
 
@@ -2739,13 +2738,15 @@
 	switch (ln->tn_type->t_tspec) {
 	case LCOMPLEX:
 		/* XXX: integer and LDOUBLE don't match. */
-		cn = new_integer_constant_node(LDOUBLE, (int64_t)1);
+		cn = expr_new_integer_constant(LDOUBLE, (int64_t)1);
 		break;
 	case DCOMPLEX:
-		cn = new_integer_constant_node(DOUBLE, (int64_t)1);
+		/* XXX: integer and DOUBLE don't match. */
+		cn = expr_new_integer_constant(DOUBLE, (int64_t)1);
 		break;
 	case FCOMPLEX:
-		cn = new_integer_constant_node(FLOAT, (int64_t)1);
+		/* XXX: integer and FLOAT don't match. */
+		cn = expr_new_integer_constant(FLOAT, (int64_t)1);
 		break;
 	default:
 		/* __%s__ is illegal for type %s */
@@ -2780,7 +2781,7 @@
 		return tn->tn_left;
 	}
 
-	return new_tnode(ADDR, tincref(tn->tn_type, PTR), tn, NULL);
+	return new_tnode(ADDR, expr_derive_type(tn->tn_type, PTR), tn, NULL);
 }
 
 /*
@@ -3037,7 +3038,7 @@
 	if (elsz == 0)
 		elsz = CHAR_SIZE;
 
-	return new_integer_constant_node(PTRDIFF_TSPEC,
+	return expr_new_integer_constant(PTRDIFF_TSPEC,
 	    (int64_t)(elem * elsz / CHAR_SIZE));
 }
 
@@ -3187,7 +3188,7 @@
 
 	v->v_quad = xsign(q, t, -1);
 
-	cn = new_constant_node(tn->tn_type, v);
+	cn = expr_new_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)
@@ -3230,7 +3231,7 @@
 		lint_assert(/*CONSTCOND*/false);
 	}
 
-	return new_constant_node(tn->tn_type, v);
+	return expr_new_constant(tn->tn_type, v);
 }
 
 /*
@@ -3327,7 +3328,7 @@
 	    fpe = 0;
 	}
 
-	return new_constant_node(tn->tn_type, v);
+	return expr_new_constant(tn->tn_type, v);
 }
 
 
@@ -3338,7 +3339,7 @@
 build_sizeof(const type_t *tp)
 {
 	int64_t size_in_bytes = type_size_in_bits(tp) / CHAR_SIZE;
-	tnode_t *tn = new_integer_constant_node(SIZEOF_TSPEC, size_in_bytes);
+	tnode_t *tn = expr_new_integer_constant(SIZEOF_TSPEC, size_in_bytes);
 	tn->tn_system_dependent = true;
 	return tn;
 }
@@ -3356,7 +3357,7 @@
 
 	// XXX: wrong size, no checking for sym fixme
 	int64_t offset_in_bytes = type_size_in_bits(tp) / CHAR_SIZE;
-	tnode_t *tn = new_integer_constant_node(SIZEOF_TSPEC, offset_in_bytes);
+	tnode_t *tn = expr_new_integer_constant(SIZEOF_TSPEC, offset_in_bytes);
 	tn->tn_system_dependent = true;
 	return tn;
 }
@@ -3458,7 +3459,7 @@
 		break;
 	}
 
-	return new_integer_constant_node(SIZEOF_TSPEC,
+	return expr_new_integer_constant(SIZEOF_TSPEC,
 	    (int64_t)alignment_in_bits(tp) / CHAR_SIZE);
 }
 
@@ -3567,7 +3568,7 @@
 	 * will not change.
 	 */
 	if (arg == NULL)
-		arg = new_integer_constant_node(INT, (int64_t)0);
+		arg = expr_new_integer_constant(INT, 0);
 
 	ntn = new_tnode(PUSH, arg->tn_type, arg, args);
 
@@ -3789,7 +3790,7 @@
 	lint_assert(tn != NULL || nerr != 0);
 
 	if (tn == NULL) {
-		tfreeblk();
+		expr_free_all();
 		return;
 	}
 
@@ -3824,7 +3825,7 @@
 
 	/* free the tree memory */
 	if (dofreeblk)
-		tfreeblk();
+		expr_free_all();
 }
 
 static bool