Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: split 'build' into build_binary an...
details: https://anonhg.NetBSD.org/src/rev/b7a86b6d6ba4
branches: trunk
changeset: 984738:b7a86b6d6ba4
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Jul 20 19:35:53 2021 +0000
description:
lint: split 'build' into build_binary and build_unary
No functional change.
diffstat:
usr.bin/xlint/lint1/cgram.y | 54 +++++++++++++++++++++---------------------
usr.bin/xlint/lint1/externs1.h | 5 ++-
usr.bin/xlint/lint1/func.c | 6 ++--
usr.bin/xlint/lint1/init.c | 6 ++--
usr.bin/xlint/lint1/tree.c | 20 ++++++++++-----
5 files changed, 49 insertions(+), 42 deletions(-)
diffs (289 lines):
diff -r d80fb68c7783 -r b7a86b6d6ba4 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Tue Jul 20 19:31:23 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Tue Jul 20 19:35:53 2021 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.328 2021/07/15 20:05:49 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.329 2021/07/20 19:35:53 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.328 2021/07/15 20:05:49 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.329 2021/07/20 19:35:53 rillig Exp $");
#endif
#include <limits.h>
@@ -470,7 +470,7 @@
postfix_expression:
primary_expression
| postfix_expression T_LBRACK expression T_RBRACK {
- $$ = build(INDIR, build(PLUS, $1, $3), NULL);
+ $$ = build_unary(INDIR, build_binary($1, PLUS, $3));
}
| postfix_expression T_LPAREN T_RPAREN {
$$ = new_function_call_node($1, NULL);
@@ -482,7 +482,7 @@
$$ = build_member_access($1, $2, $3);
}
| postfix_expression T_INCDEC {
- $$ = build($2 == INC ? INCAFT : DECAFT, $1, NULL);
+ $$ = build_unary($2 == INC ? INCAFT : DECAFT, $1);
}
| T_LPAREN type_name T_RPAREN { /* C99 6.5.2.5 "Compound literals" */
sym_t *tmp = mktempsym($2);
@@ -575,32 +575,32 @@
unary_expression:
postfix_expression
| T_INCDEC unary_expression {
- $$ = build($1 == INC ? INCBEF : DECBEF, $2, NULL);
+ $$ = build_unary($1 == INC ? INCBEF : DECBEF, $2);
}
| T_AMPER cast_expression {
- $$ = build(ADDR, $2, NULL);
+ $$ = build_unary(ADDR, $2);
}
| T_ASTERISK cast_expression {
- $$ = build(INDIR, $2, NULL);
+ $$ = build_unary(INDIR, $2);
}
| T_ADDITIVE cast_expression {
if (tflag && $1 == PLUS) {
/* unary + is illegal in traditional C */
warning(100);
}
- $$ = build($1 == PLUS ? UPLUS : UMINUS, $2, NULL);
+ $$ = build_unary($1 == PLUS ? UPLUS : UMINUS, $2);
}
| T_COMPLEMENT cast_expression {
- $$ = build(COMPL, $2, NULL);
+ $$ = build_unary(COMPL, $2);
}
| T_LOGNOT cast_expression {
- $$ = build(NOT, $2, NULL);
+ $$ = build_unary(NOT, $2);
}
| T_REAL cast_expression { /* GCC c_parser_unary_expression */
- $$ = build(REAL, $2, NULL);
+ $$ = build_unary(REAL, $2);
}
| T_IMAG cast_expression { /* GCC c_parser_unary_expression */
- $$ = build(IMAG, $2, NULL);
+ $$ = build_unary(IMAG, $2);
}
| T_EXTENSION cast_expression { /* GCC c_parser_unary_expression */
$$ = $2;
@@ -649,41 +649,41 @@
/* K&R ???, C90 ???, C99 6.5.5 to 6.5.15, C11 6.5.5 to 6.5.15 */
conditional_expression:
conditional_expression T_ASTERISK conditional_expression {
- $$ = build(MULT, $1, $3);
+ $$ = build_binary($1, MULT, $3);
}
| conditional_expression T_MULTIPLICATIVE conditional_expression {
- $$ = build($2, $1, $3);
+ $$ = build_binary($1, $2, $3);
}
| conditional_expression T_ADDITIVE conditional_expression {
- $$ = build($2, $1, $3);
+ $$ = build_binary($1, $2, $3);
}
| conditional_expression T_SHIFT conditional_expression {
- $$ = build($2, $1, $3);
+ $$ = build_binary($1, $2, $3);
}
| conditional_expression T_RELATIONAL conditional_expression {
- $$ = build($2, $1, $3);
+ $$ = build_binary($1, $2, $3);
}
| conditional_expression T_EQUALITY conditional_expression {
- $$ = build($2, $1, $3);
+ $$ = build_binary($1, $2, $3);
}
| conditional_expression T_AMPER conditional_expression {
- $$ = build(BITAND, $1, $3);
+ $$ = build_binary($1, BITAND, $3);
}
| conditional_expression T_BITXOR conditional_expression {
- $$ = build(BITXOR, $1, $3);
+ $$ = build_binary($1, BITXOR, $3);
}
| conditional_expression T_BITOR conditional_expression {
- $$ = build(BITOR, $1, $3);
+ $$ = build_binary($1, BITOR, $3);
}
| conditional_expression T_LOGAND conditional_expression {
- $$ = build(LOGAND, $1, $3);
+ $$ = build_binary($1, LOGAND, $3);
}
| conditional_expression T_LOGOR conditional_expression {
- $$ = build(LOGOR, $1, $3);
+ $$ = build_binary($1, LOGOR, $3);
}
| conditional_expression T_QUEST conditional_expression
T_COLON conditional_expression {
- $$ = build(QUEST, $1, build(COLON, $3, $5));
+ $$ = build_binary($1, QUEST, build_binary($3, COLON, $5));
}
| cast_expression;
@@ -691,10 +691,10 @@
assignment_expression:
conditional_expression
| assignment_expression T_ASSIGN conditional_expression {
- $$ = build(ASSIGN, $1, $3);
+ $$ = build_binary($1, ASSIGN, $3);
}
| assignment_expression T_OPASSIGN conditional_expression {
- $$ = build($2, $1, $3);
+ $$ = build_binary($1, $2, $3);
}
;
@@ -702,7 +702,7 @@
expression:
assignment_expression
| expression T_COMMA assignment_expression {
- $$ = build(COMMA, $1, $3);
+ $$ = build_binary($1, COMMA, $3);
}
;
diff -r d80fb68c7783 -r b7a86b6d6ba4 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h Tue Jul 20 19:31:23 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h Tue Jul 20 19:35:53 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.118 2021/07/15 17:03:50 rillig Exp $ */
+/* $NetBSD: externs1.h,v 1.119 2021/07/20 19:35:53 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -211,7 +211,8 @@
extern tnode_t *build_generic_selection(const tnode_t *,
struct generic_association *);
-extern tnode_t *build(op_t, tnode_t *, tnode_t *);
+extern tnode_t *build_binary(tnode_t *, op_t, tnode_t *);
+extern tnode_t *build_unary(op_t, tnode_t *);
extern tnode_t *build_member_access(tnode_t *, op_t, sbuf_t *);
extern tnode_t *cconv(tnode_t *);
extern bool is_typeok_bool_operand(const tnode_t *);
diff -r d80fb68c7783 -r b7a86b6d6ba4 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c Tue Jul 20 19:31:23 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c Tue Jul 20 19:35:53 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.113 2021/07/04 07:09:39 rillig Exp $ */
+/* $NetBSD: func.c,v 1.114 2021/07/20 19:35:53 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.113 2021/07/04 07:09:39 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.114 2021/07/20 19:35:53 rillig Exp $");
#endif
#include <stdlib.h>
@@ -1096,7 +1096,7 @@
ln->tn_lvalue = true;
ln->tn_sym = funcsym; /* better than nothing */
- tn = build(RETURN, ln, tn);
+ tn = build_binary(ln, RETURN, tn);
if (tn != NULL) {
rn = tn->tn_right;
diff -r d80fb68c7783 -r b7a86b6d6ba4 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c Tue Jul 20 19:31:23 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c Tue Jul 20 19:35:53 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.201 2021/07/02 22:46:43 rillig Exp $ */
+/* $NetBSD: init.c,v 1.202 2021/07/20 19:35:53 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.201 2021/07/02 22:46:43 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.202 2021/07/20 19:35:53 rillig Exp $");
#endif
#include <stdlib.h>
@@ -903,7 +903,7 @@
ln->tn_type = expr_dup_type(ln->tn_type);
ln->tn_type->t_const = false;
- tn = build(ASSIGN, ln, rn);
+ tn = build_binary(ln, ASSIGN, rn);
expr(tn, false, false, false, false);
return true;
diff -r d80fb68c7783 -r b7a86b6d6ba4 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Tue Jul 20 19:31:23 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Tue Jul 20 19:35:53 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.316 2021/07/15 21:22:19 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.317 2021/07/20 19:35:53 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.316 2021/07/15 21:22:19 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.317 2021/07/20 19:35:53 rillig Exp $");
#endif
#include <float.h>
@@ -509,7 +509,7 @@
* rn if not NULL, right operand
*/
tnode_t *
-build(op_t op, tnode_t *ln, tnode_t *rn)
+build_binary(tnode_t *ln, op_t op, tnode_t *rn)
{
const mod_t *mp;
tnode_t *ntn;
@@ -688,6 +688,12 @@
}
tnode_t *
+build_unary(op_t op, tnode_t *tn)
+{
+ return build_binary(tn, op, NULL);
+}
+
+tnode_t *
build_member_access(tnode_t *ln, op_t op, sbuf_t *member)
{
sym_t *msym;
@@ -700,7 +706,7 @@
ln = cconv(ln);
}
msym = struct_or_union_member(ln, op, getsym(member));
- return build(op, ln, new_name_node(msym, 0));
+ return build_binary(ln, op, new_name_node(msym, 0));
}
/*
@@ -3682,9 +3688,9 @@
}
/*
- * Perform some tests on expressions which can't be done in build() and
- * functions called by build(). These tests must be done here because
- * we need some information about the context in which the operations
+ * Perform some tests on expressions which can't be done in build_binary()
+ * and functions called by build_binary(). These tests must be done here
+ * because we need some information about the context in which the operations
* are performed.
* After all tests are performed and dofreeblk is true, expr() frees the
* memory which is used for the expression.
Home |
Main Index |
Thread Index |
Old Index