Handle very long lines when printing fix-it hints
commit4df8da843601f869fe437d0cdd6cd513dd0fa066
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Nov 2017 21:45:56 +0000 (28 21:45 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Nov 2017 21:45:56 +0000 (28 21:45 +0000)
treeddb1c2a17409e23bb079ed3fde000da92cfa6021
parent3501ad333bbc74d4e3a6113670899e533fab78bc
Handle very long lines when printing fix-it hints

When fixing PR c/82050 I noticed a bug in how we print fix-it hints
for very long lines: we weren't taking into account the x-offset for
the line when printing the fix-it hint.

This could lead to output where instead of printing:

foo.c:14:3944: error: etc
  = foo.field
        ^~~~~
        replacement

where the lines have been offset to start printing at about column 3900,
the "replacement" line was erroneously *not* offset, and was thus
prefixed by thousands of spaces, leading to large whitespace gaps in
the output, and the replacement failing to line up with the source to be
replaced.

Fixed thusly.

gcc/ChangeLog:
* diagnostic-show-locus.c (layout::print_trailing_fixits): Handle
m_x_offset.
(layout::move_to_column): Likewise.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic-test-show-locus-bw.c
(test_very_wide_line): Update expected output to include a
fix-it hint.
* gcc.dg/plugin/diagnostic-test-show-locus-color.c
(test_very_wide_line): Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
(test_show_locus): Add a fix-it hint to "test_very_wide_line".

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255219 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/diagnostic-show-locus.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-bw.c
gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-color.c
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c