compiler/error_spec.m:
Delete the function symbol of the error_msg_component type
that allowed the inclusion of help text *if* an option had a given value.
This functionality has been unused since we made all warning and
informational error_specs conditional on an option.
Delete the subtype whose only job was to rule out the now-deleted
function symbol.
Add a comment about a possible solution of a have-your-cake-AND-eat-it
problem.
compiler/error_sort.m:
compiler/error_util.m:
compiler/write_error_spec.m:
Conform to the change in error_spec.m.
This is another move towards making it impossible for the compiler
to stop due to the presence of an error *without* printing a diagnostic
about that error.
compiler/grab_modules.m:
Some of the errors that this module are intended to block the compiler
from continuing on to semantic analysis, and some are not. We used
to make the distinction by returning a flag saying "some of these
are blocking errors", but the list of diagnostics that contained
these blocking errors
- contained a list of error_specs reporting *both* kinds of errors, and
- was not returned alongside the flag, but instead hidden inside
the module baggage, making it hard to find, and easy to ignore.
Change this to computing two lists of error_specs: one for blocking errors,
and one for nonblocking ones. Return the former explicitly, keeping the
latter in the baggage. This design lets the code that stops execution
before semantic analysis to test for the list of blocking errors
being non-empty, which makes printing them the easy thing to do.
Delete the code that, with --very-verbose, wrote out any error_specs
we generated during the processing of a .opt or .trans_opt file
immediately after that processing. The reason is that
- if we print those error_specs out and then do not return them
to mercury_compile_make_hlds.m, then mercury_compile_make_hlds.m
will be making decisions on incomplete and therefore incorrect data,
while
- if we print those error_specs out and *also* return them, then
- either those diagnostics will be printed twice, or
- we need to implement a new system whereby write_error_spec.m
keeps a database of the diagnostics it has already printed,
and simply skips printing any repeats.
Neither of those alternative is palatable, and since in several
decades, I have never needed such immediate printing of diagnostics,
losing that capability is not really an issue.
Fix some relics of the era when the data structures that were
module_baggage's predecessors could not distinguish between fatal
and nonfatal errors.
compiler/mercury_compile_make_hlds.m:
For now, make the new code in grab_modules.m work with the existing
decision making code. Changing that is future work, since it requires
changes to other compiler components as well.
compiler/mercury_compile_args.m:
Instead of writing out any error messages (and setting the exit status)
in different ways in different circumstances, return all error messages
to our caller, as error_specs, and the option_table needed to print
those error_specs out.
Simplify the code that actually does the expansion of @file arguments,
both by invoking higher level primitives than were available when
the original code was written, and by avoiding repeatedly putting
arguments info ok/1 wrappers and taking them out again.
Change the argument list of setup_all_args to delete the ErrorStream
argument and pass only ProgressStream, because its only caller always
passes the *same* stream as both arguments.
compiler/mercury_compile_main.m:
Print the error messages that mercury_compile_args.m now returns.
Standardize on printing "mmc:" before those messages to identify
the program reporting those errors. (The old code could print any
one of "mercury_compile:", "mmc:", the name of the executable,
or nothing.)
compiler/file_util.m:
Add two utility functions for the new code in mercury_compile_args.m.
compiler/handle_options.m:
Add an XXX.
tests/invalid/invalid_mllibs.err_exp:
tests/invalid_make_int/bad_color.int_err_exp:
tests/invalid_options_file/inf_incl_direct.err_exp:
tests/invalid_options_file/inf_incl_indirect.err_exp:
tests/invalid_options_file/no_assign.err_exp:
tests/invalid_options_file/no_var.err_exp:
tests/invalid_options_file/nonexistent_file.err_exp:
tests/invalid_options_file/undefined_var.err_exp:
tests/invalid_options_file/unterminated_string.err_exp:
tests/invalid_options_file/unterminated_var.err_exp:
Consistently expect the "mmc:" prefix before the error messages
now printed by mercury_compile_main.m.
... by removing four more modules from that set.
compiler/make.module_dep_file.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_middle_passes.m:
Replace bespoke error reporting code with invocations of standardized
error reporting predicates.
compiler/source_file_map.m:
Delete an unused predicate.
... by removing globals.m, handle_options.m recompilation.used_file.m
from that set.
compiler/globals.m:
compiler/recompilation.used_file.m:
Replace bespoke error reporting code with invocations of standardized
error reporting predicates.
compiler/handle_options.m:
Generate error_specs instead of writing out warnings directly.
... by removing export.m and options_file.m from that set.
compiler/export.m:
compiler/options_file.m:
Replace bespoke error reporting code with invocations of standardized
error reporting predicates.
compiler/file_util.m:
Add versions of existing error reporting predicates and functions that
work without access to a globals structure, for use by options_file.m.
... by removing compiler_util.m from that set.
compiler/tupling.m:
Replace the only two calls to report_warning with code to return
error_specs.
compiler/mercury_compile_middle_passes.m:
Accumulate the resulting error_specs.
compiler/write_error_spec.m:
Inline the only call to record_warning_opt_table.
compiler/compiler_util.m:
Delete report_warning and record_warning_opt_table, which now have
no callers, and record_warning, which had no callers to begin with.
The crash that this diff fixes occurred when giving a command such as
"print Var^1" to mdb, where the first argument of Var is a direct arg.
runtime/mercury_ml_expand_body.h:
When deconstructing a term with a direct arg, return NULL
as the value of expand_info->chosen_arg_word_sized_ptr.
The crash occurred when we returned a non-null pointer,
which violated the expectations of trace/mercury_trace_vars.c
and its callers. (Not surprising, since those that function and
its callers were written long before the direct_arg optimization
was added to the system.)
runtime/mercury_deconstruct.h:
Document the rationale behind the above changes. (The contents of
mercury_ml_expand_body.h are #included in mercury_deconstruct.c.)
trace/mercury_trace_vars.c:
Add the debugging code I used to track down this issue, in disabled form.
Fix missing copyright year.
trace/mercury_trace_browse.c:
Delete obsolete comment.
Fix missing copyright years.
tests/debugger/direct_arg_test.{m,inp,exp}:
A test case for this bug.
tests/debugger/Mmakefile:
Enable the new test case.
compiler/hlds_out_type_table.m:
When dumping out the data constructors in the type table,
if a constructor has names for some of its fields,
put the name and the type of each field on different lines.
In the original test case for this bug, of which direct_arg_test.m
is an extreme simplification, pretty much every line overflows
without this.
Also, factor out some duplicated code, and replace bools with values
of a bespoke type.
configure.ac:
Require the installed compiler to support that option.
STANDARD_MCFLAGS:
Specify that option.
compiler/canonicalize_interface.m:
compiler/comp_unit_interface.m:
compiler/inst_user.m:
compiler/parse_module.m:
compiler/switch_util.m:
compiler/type_ctor_info.m:
deep_profiler/mdprof_dump.m:
library/digraph.m:
slice/mcov.m:
Delete unused equivalence types that were picked up by the option.
... in some contexts.
compiler/unused_types.m:
Implement the easy part of the above, the part that happens
*after* we collect the info about which equivalence types are used.
Document why we can report unused equivalence types only in some contexts.
compiler/prog_data_used_modules.m:
Define an extension of the used_modules type that also records
which equivalence types were expanded in the module.
Define the operations we need on this extended type.
compiler/equiv_type.m:
Invoke one of those operations to record the expansions of equivalence
types, if requested to do so.
Inline the predicate that used to do this at its only call site.
compiler/hlds_module.m:
Replace the used_module field in the module_info with a value of
the extended type that includes not just the old used_modules info,
but also the set of expanded equivalence types.
Delete a utility predicate on the old field. The last call to this
predicate was deleted on 2022 march 30.
compiler/equiv_type_parse_tree.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile_make_hlds.m:
compiler/unused_imports.m:
Conform to the changes above.
tests/warnings/warn_dead_procs.{m,err_exp}:
This test case already tests for warnings about unused du types.
Extend it to also test for unused eqv types.
library/int32.m:
Add these library operations.
NEWS.md:
Announce the new operations.
compiler/lookup_switch_util.m:
Use the checked operations added by this diff and other recent diffs
to replace unchecked casts.
Until now, the only integer type we generated dense switches
(including lookup switches) for was int itself; we did not do so
for any sized and/or unsigned integer types.
compiler/switch_util.m:
Simplify the representation of whether a switch is on an integer type.
The new version makes it impossible to make the mistake that caused
bug582 in the first place: not having a single representation for
for the switch being on *any* kind of integer type.
This fix requires solving a problem we never had to solve before:
representing information such as the min and max case values
in a way that works for every integer type, signed or unsigned,
sized or not. The solution that this diff adopts is to use int32s
to represent those limits, which implies that whatever the type
of the integer value being switched on, we will generate a dense
or a lookup switch for it only if all case values fit into an int32.
Since case values over two billion are vanishingly rare, this should be
an acceptable restriction.
Use uints instead of ints to represent counts of things.
Delete an unneeded pair of arguments.
compiler/lookup_switch_util.m:
Conform to the changes in switch_util.m. Use some of the new types
there to make arguments in arguments lists less confusable.
Provide some new utility operations.
Add XXXs where the basic operations we need seem not to exist.
compiler/dense_switch.m:
compiler/lookup_switch.m:
Use the new types in switch_util.m that can represent switches
on any integer type.
compiler/ml_lookup_switch.m:
compiler/ml_simplify_switch.m:
compiler/ml_string_switch.m:
compiler/ml_switch_gen.m:
compiler/switch_gen.m:
Conform to the changes above, and thereby gain the ability
to generate switches on integer types other than int itself.
library/int64.m:
Add a (commmented-out) declaration of an operation that could
help resolve one of the issues in new code in the modules above.
Similar operations would be needed in the modules of other
sized integer types as well.
library/library.m:
Fix a typo.
tests/hard_coded/bug582.{m,exp}:
Add a test case for this issue. Note that while we test whether
we get the expected output, there is no simple automatic way
to detect whether it was generated using a lookup table.
tests/hard_coded/Mmakefile:
Enable the new test case.
The old equiv_type.m's growth was organic, not planned. It mixed predicates
operating on different levels, and even predicates on the same level
were not always logically organized.
compiler/equiv_type_parse_tree.m:
This module contains the bulk of the old equiv_type.m, the part
concerned with processing parse tree items and their major components.
compiler/equiv_type.m:
The part of the old equiv_type.m that deals with expanding equivalences
inside basic parts of program representations.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new module.
compiler/decide_type_repn.m:
compiler/mercury_compile_make_hlds.m:
Conform to the changes above.
compiler/recompilation.record_uses.m:
Rename the eqv_expand_info type to item_recomp_deps to better document
its purpose (it is to record which equivalence expansions *an item
depends on*). Finish documenting the type itself.
Rename the predicates operating on values of that type accordingly,
together with the variables in their clauses.
Since the point of the type is to record info about an item,
make the main predicate that constructs values of this type
take *the id the actual item* as input. Previously, it was just
a sym_name that was part of the item id. We still need that version
in two places (where we don't know the final item id yet), but use it
only when we have to. In each case, document *why* we have to.
compiler/equiv_type.m:
compiler/equiv_type_hlds.m:
compiler/qual_info.m:
compiler/add_pragma_type_spec.m:
Conform to the changes above.
Use a consistent naming scheme for the variables of the renamed type.
In one case, stop using a "some [!StateVar]" scope that hurts
readability more than it helps.
compiler/unused_args_warn_pragma.m:
The existing code processed only the first procedure of each predicate,
skipping all the later procedures. It had a comment saying that it
warns about an unused arg only if it was unused in all modes,
but this claim was false.
Replace this old code with new code that
- gathers the set of unused args in each procedure, recording
which ones have mode "unused",
- considers all the procedures of a predicate together, and then
- generates either a single warning for the predicate as a whole,
or separate warnings for each procedure that has unused arguments.
We now generate a single warning for the predicate only if all the
procedures agree both on which arguments are unused, and on
which of those are *marked* by the mode as unused. Of course,
most of the time this will be the case simply because most predicates
have just one procedure.
Stop module qualifying predicate names in the warnings we generate,
since we do not generate warnings for imported predicates.
Color the unqualified name as the subject of the diagnostic.
When reporting unused args, list the arguments with "unused" modes
separately from the other arguments.
Simplify the interface with our caller in unused_args.m.
compiler/unused_args.m:
Conform to the simplified interface with unused_args_warn_pragma.m.
compiler/hlds_error_util.m:
Add a new version of an existing utility function.
tests/warnings/unused_args_some_modes.{m,err_exp}:
Add a test case for the new capability.
tests/warnings/Mmakefile:
Enable the new test case.
Stop mixing "VAR = VALUE" and "Var += VALUE" definitions
of make variables. Give some make variables better names.
Move some dependency definitions out of a block of rules.
tests/warnings/Mercury.options:
Enable --warn-unused-args for the new test case.
Delete some accidentally-duplicated entries.
tests/warnings/unused_args_test.err_exp:
Update the expected output.
After this, I think all modules in the check_hlds package belong there.
compiler/inst_match.m:
compiler/mode_test.m:
Move these modules from the check_hlds package to the hlds package
because most of their uses are outside the semantic analysis passes
that the check_hlds package is intended to contain.
compiler/inst_merge.m:
Move this module from the check_hlds package to the hlds package
because it is imported by only two modules, instmap.m and inst_match.m,
and after this diff, both are in the hlds package.
compiler/implementation_defined_literals.m:
Move this module from the check_hlds package to the hlds package
because it does a straightforward program transformation that
does not have anything to do with semantic analysis (though its
invocation does happen between semantic analysis passes).
compiler/notes/compiler_design.html:
Update the documentation of the goal_path.m module. (I checked the
documentation of the moved modules, which did not need updates,
and found the need for this instead.)
compiler/*.m:
Conform to the changes above. (For many modules, this deletes
their import of the check_hlds package itself.)
compiler/unused_args_analysis.m:
New module containing the parts of the old unused_args.m
that deal with the intermodule analysis framework.
compiler/unused_args_base_ops.m:
New module containing the parts of the old unused_args.m
that define and operate on the main data structure we use
to find out which variables are unused.
compiler/unused_args_optimize.m:
New module containing the parts of the old unused_args.m
that "optimize out" unused arguments.
compiler/unused_args_warn_pragma.m:
New module containing the parts of the old unused_args.m
that generate warnings about unused arguments, and that generate
unused_args pragmas for .opt files. The module contains both
because they share the same test for whether we want to ignore
any unused arguments in a predicate.
compiler/unused_args.m:
Delete the moved code.
compiler/transform_hlds.m:
compiler/notes/compiler_design.html:
Include and document the new modules.
compiler/mercury_compile_middle_passes.m:
compiler/mmc_analysis.m:
Conform to the changes above.
compiler/unused_args.m:
Rename the "usage_info" type to "required_by". Document the meaning
of its contents.
Rename the low-level predicates that operate on this data structure
accordingly. Make them fit consistently into the same pattern:
X_{is,are}_required_by_Y.
In the argument lists of these predicates, pass values of arg_var_in_proc
as a unit, instead of passing them as two separate components, one of which
was easily confusable with another argument that has the opposite role.
To make this possible *and* non-misleading, reorder arguments as needed.
In one case, replace a call to list.foldl with an explicit loop
to make the reordering possible.
Give the high-level predicates that operate on this data structure
more descriptive names as well. Document the logic behind the fixpoint
iteration.
compiler/unused_args.m:
Replace "fixup_x" naming scheme with "delete_unused_args_in_x".
Fix some misleading comments.
Add some comments on not-chosen alternative approaches.
Move a utility predicate to the end of the module,
and give it a simpler interface.