When .USEBEFORE was added in targ.c 1.22 from 2001-07-03, it was not
added to Targ_PrintType, probably because the PRINTBIT macro hid the
identifier OP_USE and only used USE.
The comment in ApplyDependencySourceOther repeated the code, its second
half didn't match any current code.
The comment above ParseDependencySourcesEmpty repeated the code.
No binary change, except for assertion line numbers.
Now that Enum_ToString is implemented for each type separately, it's
easy to convert them to bit-fields. This gets rid of the magic numbers
12 for CYCLE and 13 for DONECYCLE that left a suspicious gap in the
numbers. This gap was not needed since the code didn't make use of the
relative ordering of the enum constants.
The effects of this conversion are fewer capital letters in the code,
smaller scope for the GNode flags, and clearer code especially when
setting a flag back to false.
One strange thing is that GCC 10.3.0 doesn't optimize GNodeFlags_IsNone
to an single bitmasking instruction, at least on x86_64. Instead it
generates a testb instruction for each of the flags, even loading bit 8
separately from the others. Clang 12.0.1 knows this optimization
though and generates the obvious sequence of movzwl, testl, jz.
No functional change.
In strict bool mode, lint does not consider 'x & y' as having type bool,
if x and y have integer type, it only allows this for enums.
No functional change.
This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE were renamed.
Renaming the variable 'ctxt' was trivial since that word is used nowhere
else. In the comments though, each occurrence of the word 'context' had
to be checked individually since the word 'context' was not only used
for referring to a variable scope. It is also used to distinguish
different situations where characters are escaped in a certain way
('parsing context') and in a few other expressions.
The word "context" does not fit perfectly to the variables that are
associate with a GNode, as the context is usually something from the
outside and the variables are more like properties inherent to the
GNode.
The term "global context" fits even less. Since the thing where
variables are looked up is commonly named a scope, use that term
instead.
This commit only renames the global variables VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE, plus a few very closely related comments. These are:
GNode.vars (because of line breaks)
GNode_Free (dito)
varname-make_print_var_on_error.mk
varname-make_print_var_on_error-jobs.mk
The debug message in Var_Stats is left as-is since there is no unit test
for it yet.
The other renamings (variable names "context", "ctxt", as well as
further comments) will be done in a follow-up commit.
All callers with a variable name that is guaranteed to not contain a
dollar sign have been converted to call Global_Append instead of the
previous Global_AppendExpand. After that, Global_AppendExpand was
unused, therefore it was effectively just renamed.
There are many places where global variables are set or appended to. To
reduce clutter and code size, encode the VAR_GLOBAL in the function
name.
The word Expand in the function names says that the variable name is
expanded. In most of the cases, this is not necessary, but there are no
corresponding functions Global_Set or Global_Append yet.
Encoding the information whether the name is expanded or not in the
function name will make inconsistencies obvious in future manual code
reviews. Letting the compiler check this by using different types for
unexpanded and expanded variable names is probably not worth the effort.
There are still a few bugs to be fixed, such as in SetVar, which expands
the variable name twice in a row.
For printing the status of a GNode, there was already made_name (now
renamed to GNodeMade_Name), which prints user-friendly text instead of
the bare enum constant names.
To do this change confidently, I first had to demonstrate that the
output really affects something other than just the word "UNMADE". There
had not been a test for that case before, and the test immediately
discovered a bug in the -dg2 and -dg3 options. This bug is one of the
oldest in make, dating back to at least 1993.
The previous version of lint(1) from a few hours ago didn't catch all
occurrences. And even the current one doesn't catch everything.
Function arguments and return types still need some work. The "return
quietly" from shouldDieQuietly still implicitly converts from int to
_Bool.
No functional change.
Concatenating identifiers makes it difficult to spot them when searching
the code. This gets rid of the special case for OP_MEMBER and MEMBER.
The same pattern is applied in the DEBUG macro, by the way.
Especially in the variables module, the expression 'ctxt->context' looked
redundant. Having a GNode as a context sounds ok, but a context of a
context just doesn't make sense.
One notable thing is that there is no debug output when adding a
transformation rule like ".c.o", which means that these rules don't end
up in the global allTargets variable.
This may or may not be intentional. It seems not intentional since this
is one of the causes for the suff-rebuild test to behave unexpectedly.
It was unclear what the ellipsis referred to. It was meant to refer to
the function call Lst_Free, but that was not necessarily obvious to a
casual reader.
Initialization and destruction of the fields is independent from the
other fields. Therefore use declaration order, which allows to quickly
see whether a field was forgotten.
While here, add comments that in cleanup mode, not all memory is freed.
The variables of a node and the suffix survive right now.