The NetBSD Project

CVS log for src/usr.bin/xlint/lint1/oper.c

[BACK] Up to [] / src / usr.bin / xlint / lint1

Request diff between arbitrary revisions

Default branch: MAIN

Revision 1.15 / (download) - annotate - [select for diffs], Mon Feb 5 23:11:22 2024 UTC (2 weeks, 6 days ago) by rillig
Branch: MAIN
Changes since 1.14: +3 -4 lines
Diff to previous 1.14 (colored)

lint: make function call arguments directly accessible

Previously, the arguments of a function call expression were arranged in
a linear tree structure, from right to left.  To allow easier access to
the arguments, store them in an array instead.

Revision 1.14 / (download) - annotate - [select for diffs], Thu Sep 14 22:20:08 2023 UTC (5 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.13: +1 -3 lines
Diff to previous 1.13 (colored)

lint: remove pseudo operators INC and DEC

These operators were not used in expressions, they were only used as
additional token info.  Use a plain bool instead.

No functional change.

Revision 1.13 / (download) - annotate - [select for diffs], Thu Sep 14 21:08:12 2023 UTC (5 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.12: +105 -27 lines
Diff to previous 1.12 (colored)

lint: remove preprocessor magic from definition of operators

No binary change.

Revision 1.12 / (download) - annotate - [select for diffs], Wed Sep 13 20:31:58 2023 UTC (5 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.11: +3 -2 lines
Diff to previous 1.11 (colored)

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.

Revision 1.11 / (download) - annotate - [select for diffs], Sat Apr 16 22:21:10 2022 UTC (22 months, 1 week ago) by rillig
Branch: MAIN
CVS Tags: netbsd-10-base, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10
Changes since 1.10: +3 -3 lines
Diff to previous 1.10 (colored)

lint: merge mod_t.m_test_context into m_requires_bool

These two flags mean exactly the same.

No functional change.

Revision 1.10 / (download) - annotate - [select for diffs], Mon Aug 2 20:58:39 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.9: +17 -11 lines
Diff to previous 1.9 (colored)

lint: expand abbreviations in definitions of operator properties

No functional change.

Revision 1.9 / (download) - annotate - [select for diffs], Sat Mar 20 20:56:58 2021 UTC (2 years, 11 months ago) by rillig
Branch: MAIN
CVS Tags: cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x
Changes since 1.8: +1 -7 lines
Diff to previous 1.8 (colored)

lint: move getopname over to tree.c

Except for the one use in print_tnode, the name of the operator is only
used in tree.c.

No functional change.

Revision 1.8 / (download) - annotate - [select for diffs], Sat Mar 20 20:39:35 2021 UTC (2 years, 11 months ago) by rillig
Branch: MAIN
Changes since 1.7: +6 -22 lines
Diff to previous 1.7 (colored)

lint: remove redundant operator properties table

It's enough to have modtab, which describes the properties of the
various operators.  There is no need to have a second table imods that
holds the same content.  Rather make modtab constant as well.

The only possible functional change is that the names of the internal
operators 'no-op', '++', '--', 'real', 'imag' and 'case' may appear in
diagnostics, where previously lint invoked undefined behavior by passing
a null pointer for a '%s' conversion specifier.

Revision 1.7 / (download) - annotate - [select for diffs], Sat Mar 20 20:15:37 2021 UTC (2 years, 11 months ago) by rillig
Branch: MAIN
Changes since 1.6: +13 -9 lines
Diff to previous 1.6 (colored)

lint: fix argument names and table headings for operator definitions

The abbreviations in the table of operator properties had been wrong
since ops.def 1.10 from 2021-01-12, when strict bool mode was added.  In
an earlier working draft, I had named that column 'takes_others' instead
of 'requires_bool', that's where the 'o' came from.

The names of the macro arguments had been wrong since op.h 1.11 from
2021-01-09, when the order of the columns changed and the macros were
not adjusted accordingly.  Since all the properties of the operator
table are uniform, this didn't result in any bugs, it was just confusing
for human readers.

Clang-tidy suggests to enclose the macro arguments in oper.c in
parentheses but that is not possible since the arguments are either
empty or 1, and the syntactical ambiguity of the '+ 0' being either a
unary or a binary operator is needed here.

No change to the resulting binary.

Revision 1.6 / (download) - annotate - [select for diffs], Sat Mar 20 19:33:25 2021 UTC (2 years, 11 months ago) by rillig
Branch: MAIN
Changes since 1.5: +9 -5 lines
Diff to previous 1.5 (colored)

lint: make lint's own code pass the strict bool mode

No functional change.

Revision 1.5 / (download) - annotate - [select for diffs], Mon Jan 18 20:02:34 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.4: +3 -2 lines
Diff to previous 1.4 (colored)

lint: clean up code (mostly comments)

Revision 1.4 / (download) - annotate - [select for diffs], Sat Jan 16 02:40:02 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored)

lint: replace 0 and 1 with false and true, where appropriate

Change in behavior: Passing the option -h exactly 4294967296 times or
any multiple thereof is no longer equivalent to passing it never at all,
it is now equivalent to passing it once.  See main2.c, hflag++ for the
actual change.

Other than that, no functional change intended.

A very large portion of the code already conformed to the requirements
of the strict bool mode.  The only missing thing was using the constant
literals false and true instead of 0 and 1.  For sure there are some
integer literals left that can be converted.  For now, all literals that
appeared in the form " = 0" or " = 1" have been replaced.

Revision 1.3 / (download) - annotate - [select for diffs], Tue Jan 12 20:42:01 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.2: +3 -3 lines
Diff to previous 1.2 (colored)

lint: add new check for strict bool mode

In strict bool mode, bool is considered incompatible with all other
scalar types, just as in Java, C#, Pascal.

The controlling expressions in if statements, while loops, for loops and
the '?:' operator must be of type bool.  The logical operators work on
bool instead of int, the bitwise operators accept both integer and bool.
The arithmetic operators don't accept bool.

Since <stdbool.h> implements bool using C preprocessor macros instead of
predefining the identifiers "true" and "false", the integer constants 0
and 1 may be used in all contexts that require a bool expression.
Except from these, no implicit conversion between bool and scalar types
is allowed.

See usr.bin/tests/xlint/lint1/d_c99_bool_strict.c for more details.

The command line option -T has been chosen because all obvious choices
(-b or -B for bool, -s or -S for strict) are already in use.  The -T may
stand for "types are checked strictly".

The default behavior of lint doesn't change.  The strict bool check is
purely optional.

An example program for strict bool mode is usr.bin/make, which has been
using explicit comparisons such as p != NULL, ch != '\0' or n > 0 in
most places for a long time now, even before the refactoring in 2020.

Revision 1.2 / (download) - annotate - [select for diffs], Sat Jan 9 22:19:11 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.1: +5 -3 lines
Diff to previous 1.1 (colored)

lint: make the table containing the operator properties more readable

The C preprocessor does not require its arguments to be expressions, an
empty string is valid as well.  This allows to replace the 0 in the
operator properties table with a space, making the 1 stick out.

Since the table is quite long, divide it into sections and add section

No change in the generated code.

Revision 1.1 / (download) - annotate - [select for diffs], Sat Jan 9 21:37:44 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN

lint: rename ops.c to oper.c

The file ops.c had previously been autogenerated.  This meant that in a
NetBSD build, it was generated in OBJDIR, and a build that had just
updated src/usr.bin would fail.  For a build that last ran on
2020-12-01, and again today, it looks like this:

	#      link  lint1/lint1
	cc ... -o lint1 cgram.lo ... ops.lo ... tyname.lo
	/usr/bin/ld: ops.lo: in function `initmtab':
	ops.c:(.text+0x63): undefined reference to `STRUCT_ASSIGN'

This is caused by ops.c existing in OBJDIR, so the new version in
NETBSDSRCDIR is not looked at.  To prevent this, use oper.c instead as
the filename, which has not been used before.

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

CVSweb <>