aboutsummaryrefslogtreecommitdiff
path: root/libcpp/line-map.c
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-08-31 18:54:55 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-08-31 18:54:55 +0000
commit70017c995f095495d7190831446659b8fb794db2 (patch)
treee25a9f55c0d092448ebe2741c5ba533d8a45a34e /libcpp/line-map.c
parent68c215e47b73f5d64a51ba3b261fdc212dc8270d (diff)
diagnostic-show-locus.c: handle fixits on lines outside the regular ranges
The diagnostic_show_locus implementation determines the set of line spans that need printing based on the ranges within the rich_location (in layout::calculate_line_spans). Currently this doesn't take into account fix-it hints, and hence we fail to print fix-it hints that are on lines outside of those ranges. This patch updates the implementation to take fix-it hints into account when calculating the pertinent line spans, so that such fix-it hints do get printed. It also adds some validation, to ensure that we don't attempt to print fix-its hints affecting a different source file. gcc/ChangeLog: * diagnostic-show-locus.c (class layout): Add field m_fixit_hints. (layout_range::intersects_line_p): New method. (test_range_contains_point_for_single_point): Rename to... (test_layout_range_for_single_point): ...this, and add testing for layout_range::intersects_line_p. (test_range_contains_point_for_single_line): Rename to... (test_layout_range_for_single_line): ...this, and add testing for layout_range::intersects_line_p. (test_range_contains_point_for_multiple_lines): Rename to... (test_layout_range_for_multiple_lines): ...this, and add testing for layout_range::intersects_line_p. (layout::layout): Populate m_fixit_hints. (layout::get_expanded_location): Handle the case of a line-span for a fix-it hint. (layout::validate_fixit_hint_p): New method. (get_line_span_for_fixit_hint): New function. (layout::calculate_line_spans): Add spans for fixit-hints. (layout::should_print_annotation_line_p): New method. (layout::print_any_fixits): Drop param "richloc", instead using validated fixits in m_fixit_hints. Add "const" to hint pointers. (diagnostic_show_locus): Avoid printing blank annotation lines. (selftest::test_diagnostic_context::test_diagnostic_context): Initialize show_column and start_span. (selftest::test_diagnostic_context::start_span_cb): New static function. (selftest::test_diagnostic_show_locus_fixit_lines): New function. (selftest::diagnostic_show_locus_c_tests): Update for function renamings. Call test_diagnostic_show_locus_fixit_lines. libcpp/ChangeLog: * include/line-map.h (class fixit_remove): Remove stray decl. (fixit_hint::affects_line_p): Make const. (fixit_insert::affects_line_p): Likewise. (fixit_replace::affects_line_p): Likewise. * line-map.c (fixit_insert::affects_line_p): Likewise. (fixit_replace::affects_line_p): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239906 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/line-map.c')
-rw-r--r--libcpp/line-map.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index 72549ba0732..f69c60c7837 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -2314,7 +2314,7 @@ fixit_insert::~fixit_insert ()
/* Implementation of fixit_hint::affects_line_p for fixit_insert. */
bool
-fixit_insert::affects_line_p (const char *file, int line)
+fixit_insert::affects_line_p (const char *file, int line) const
{
expanded_location exploc
= linemap_client_expand_location_to_spelling_point (m_where);
@@ -2351,7 +2351,7 @@ fixit_replace::~fixit_replace ()
/* Implementation of fixit_hint::affects_line_p for fixit_replace. */
bool
-fixit_replace::affects_line_p (const char *file, int line)
+fixit_replace::affects_line_p (const char *file, int line) const
{
return m_src_range.intersects_line_p (file, line);
}