Reimplement removal fix-it hints in terms of replace
commit73ffb7be5ef75c219a2e6c7f8116c21b7f07beaa
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Aug 2016 21:18:05 +0000 (19 21:18 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Aug 2016 21:18:05 +0000 (19 21:18 +0000)
tree783b8fccab5b0d0ff9313af8bdd05fec2a5ccdc7
parent270b838d816f8a2c372eac0121adcdf570feccfa
Reimplement removal fix-it hints in terms of replace

This patch eliminates class fixit_remove, reimplementing
rich_location::add_fixit_remove in terms of replacement with the
empty string.  Deleting the removal subclass simplifies
fixit-handling code, as we only have two concrete fixit_hint
subclasses to deal with, rather than three.

The patch also fixes some problems in diagnostic-show-locus.c for
situations where a replacement fix-it has a different range to the
range of the diagnostic, by unifying the drawing of the two kinds of
fixits.  For example, this:

  foo = bar.field;
      ^
            m_field

becomes:

  foo = bar.field;
      ^
            -----
            m_field

showing the range to be replaced.

gcc/ChangeLog:
* diagnostic-show-locus.c
(layout::annotation_line_showed_range_p): New method.
(layout::print_any_fixits): Remove case fixit_hint::REMOVE.
Reimplement case fixit_hint::REPLACE to cover removals, and
replacements where the range of the replacement isn't one
of the ranges in the rich_location.
(test_one_liner_fixit_replace): Likewise.
(selftest::test_one_liner_fixit_replace_non_equal_range): New
function.
(selftest::test_one_liner_fixit_replace_equal_secondary_range):
New function.
(selftest::test_diagnostic_show_locus_one_liner): Call the new
functions.
* diagnostic.c (print_parseable_fixits): Remove case
fixit_hint::REMOVE.

libcpp/ChangeLog:
* include/line-map.h (fixit_hint::kind): Delete REPLACE.
(class fixit_remove): Delete.
* line-map.c (rich_location::add_fixit_remove): Reimplement
by calling add_fixit_replace with an empty string.
(fixit_remove::fixit_remove): Delete.
(fixit_remove::affects_line_p): Delete.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239632 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/diagnostic-show-locus.c
gcc/diagnostic.c
libcpp/ChangeLog
libcpp/include/line-map.h
libcpp/line-map.c