Home | History | Annotate | Download | only in lint1
History log of /src/usr.bin/xlint/lint1/op.h
RevisionDateAuthorComments
 1.28  31-Mar-2024  rillig lint: merge function call operators 'CALL' and 'ICALL'
 1.27  05-Feb-2024  rillig 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.
 1.26  03-Dec-2023  rillig lint: in declarations, replace tab with space

Previously, in some cases, the keywords 'const' or 'struct' were
followed by a tab, which doesn't make sense.

No functional change.
 1.25  14-Sep-2023  rillig lint: reduce pointer dereferences and relocations

No functional change.
 1.24  14-Sep-2023  rillig 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.
 1.23  14-Sep-2023  rillig lint: remove preprocessor magic from definition of operators

No binary change.
 1.22  13-Sep-2023  rillig 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.
 1.21  13-Jul-2023  rillig lint: indent copyright lines consistently
 1.20  15-Jun-2022  rillig lint: rename mod_t.m_requires_bool to m_compares_with_zero

The operators NOT, LOGAND, LOGOR and QUEST only require _Bool in strict
bool mode, in default mode they accept any scalar expression and compare
it with zero. The new names are more accurate.

No functional change.
 1.19  16-Apr-2022  rillig lint: merge mod_t.m_test_context into m_requires_bool

These two flags mean exactly the same.

No functional change.
 1.18  16-Apr-2022  rillig lint: rename members of tnode_t to more closely match reality

The flags do not describe the left operand of the node but both, as for
most operators, either none or both operands are in test context or in
value context.

The one exception is the operator '?' from the '?:' conditional, for
which the left operand is in test context and the right operand is in
value context.

No binary change.
 1.17  19-Aug-2021  rillig lint: un-abbreviate parameter names of macro
 1.16  20-Mar-2021  rillig 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.
 1.15  20-Mar-2021  rillig 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.
 1.14  20-Mar-2021  rillig 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.
 1.13  17-Jan-2021  rillig lint: rename mod_t members
 1.12  12-Jan-2021  rillig 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.
 1.11  09-Jan-2021  rillig lint: reorder table of operator properties

The 4 "requires" properties are now listed together, in descending
strictness.
 1.10  05-Jan-2021  rillig lint: clean up generation of the operator tables

Instead of running a shell program that runs an AWK program that
generates the two files ops.c and ops.h, just define the operator tables
once in ops.def and use these definitions flexibly in ops.c and op.h.
 1.9  04-Jan-2021  rillig lint: precedence confusion is only possible with binary operators

No functional change.

The operator table in ops.def states that every operator that has
possibly confusing precedence is also a binary operator, so assert that
instead of having two different code paths.
 1.8  02-Jan-2021  rillig lint: use bool instead of u_int:1 in structures

Better late than never.
 1.7  28-Dec-2020  rillig lint: rename fields in mod_t
 1.6  05-Feb-2011  christos as promised make the last ops table auto-generated.
 1.5  04-Feb-2011  christos generate ops table dynamically. Will move the other table from tree.c there
too.
 1.4  25-Apr-2008  christos branches: 1.4.18;
preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.
 1.3  27-Jul-1998  mycroft branches: 1.3.44;
Fix a recurring typo: comparision -> comparison.
 1.2  03-Jul-1995  cgd RCS id cleanup
 1.1  03-Jul-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1  03-Jul-1995  cgd lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar
reason to why 'install' is named 'xinstall'.
 1.3.44.1  18-May-2008  yamt sync with head.
 1.4.18.1  08-Feb-2011  bouyer Sync with HEAD

RSS XML Feed