On Wed, 2020-01-08 at 17:07 -0500, David Malcolm wrote:
> (replying to my own "[PATCH 05/41] Add -fdiagnostics-nn-line-numbers"
> with a followup that does it at the DejaGnu level rather than as a
> test-only option)
>
> On Wed, 2020-01-08 at 04:02 -0500, David Malcolm wrote:
> > I may be able to self-approve this. It's used by the diagnostic_path
> > patch, and by the analyzer test suite. Perhaps better to make
> > undocumeted, or do it via a DejaGnu pruning directive, but I wanted
> > to get v5 of the kit posted.
> >
> > This patch implements -fdiagnostics-nn-line-numbers, a new option
> > which makes diagnostic_show_locus print "NN" rather than specific
> > line numbers when printing the left margin.
> >
> > This is intended purely to make it easier to write certain kinds of
> > DejaGnu test; various integration tests for diagnostic paths later
> > in the patch kit make use of it.
> >
> > gcc/ChangeLog:
> > * common.opt (fdiagnostics-nn-line-numbers): New option.
> > * diagnostic-show-locus.c
> > (layout::m_use_nn_for_line_numbers_p):
> > New field.
> > (layout::layout): Initialize it.
> > (layout::calculate_linenum_width): Use it when computing
> > m_linenum_width.
> > (layout::print_source_line): Implement printing "NN" rather
> > than
> > the line number.
> > (selftest::test_line_numbers_multiline_range): Add a test of
> > "NN"
> > printing.
> > * diagnostic.c (diagnostic_initialize): Initialize
> > use_nn_for_line_numbers_p.
> > (num_digits): Add "use_nn_p" param.
> > (selftest::test_num_digits): Add a test for use_nn_p==true.
> > * diagnostic.h (diagnostic_context::use_nn_for_line_numbers_p):
> > New field.
> > (num_digits): Add optional "use_nn_p" param.
> > * doc/invoke.texi (-fdiagnostics-nn-line-numbers): New option.
> > * dwarf2out.c (gen_producer_string): Ignore
> > OPT_fdiagnostics_nn_line_numbers.
> > * lto-wrapper.c (merge_and_complain): Handle
> > OPT_fdiagnostics_nn_line_numbers.
> > (append_compiler_options): Likewise.
> > (append_diag_options): Likewise.
> > * opts.c (common_handle_option): Likewise.
> > * toplev.c (general_init): Initialize
> > global_dc->use_nn_for_line_numbers_p.
>
> Here's an alterative patch to the above that replaces the
> "-fdiagnostics-nn-line-numbers" option in earlier versions of the
> analyzer patch kit, by doing it at the DejaGnu level instead.
>
> This patch adds support for obscuring the line numbers printed in the
> left-hand margin when printing the source code, converting them to NN,
> e.g from:
>
> 7111 | if (!(flags & 0x0001)) {
> | ^
> | |
> | (1) following 'true' branch...
> 7112 |
>
> to:
>
> NN | if (!(flags & 0x0001)) {
> | ^
> | |
> | (1) following 'true' branch...
> NN |
>
> This is useful in followup patches e.g. when testing how interprocedural
> paths are printed using multiline.exp, to avoid depending on precise line
> numbers.
>
> I'm testing this now (but it seems to be a working, drop-in replacement
> for the option in the parts of the patch kit I've tested with it).
>
> Examples of use can be seen in the analyzer test suite:
> https://gcc.gnu.org/ml/gcc-patches/2020-01/msg00320.html
> (search for -fdiagnostics-nn-line-numbers and dg-begin-multiline-output
> there to get the idea)
>
> OK for trunk assuming the other testing looks good?
>
> gcc/testsuite/ChangeLog:
> * lib/gcc-dg.exp (cleanup-after-saved-dg-test): Reset global
> nn_line_numbers_enabled.
> * lib/nn-line-numbers.exp: New file.
> * lib/prune.exp: Load nn-line-numbers.exp.
> (prune_gcc_output): Call maybe-handle-nn-line-numbers.
OK
jeff
>