On Wed, 2023-08-09 at 18:14 -0400, Lewis Hyatt wrote:
> Previous patches in this series have laid the groundwork for supporting
> source code locations in memory ("generated data") rather than ordinary
> files. This patch completes the support by adding awareness of such
> locations to all places that need to support them. The main changes are to
> diagnostic-show-locus.cc; the others are primarily small tweaks such as
> changing from the FILE to the SRC member when inspecting an
> expanded_location.
> 
> gcc/c-family/ChangeLog:
> 
>         * c-format.cc (get_corrected_substring): Use the new overload of
>         location_get_source_line() to support generated data.
>         * c-indentation.cc (get_visual_column): Likewise.
>         (get_first_nws_vis_column): Change argument from a plain file name
>         to a source_id.
>         (detect_intervening_unindent): Likewise.
>         (should_warn_for_misleading_indentation): Pass
>         detect_intervening_unindent() the SRC field rather than the FILE
>         field from the expanded_location.
> 
> gcc/ChangeLog:
> 
>         * gcc-rich-location.cc (blank_line_before_p): Use the new overload
>         of location_get_source_line() to support generated data.
>         * input.cc (get_source_text_between): Likewise.
>         (get_substring_ranges_for_loc): Likewise.
>         (get_source_file_content): Change the argument from a plain filename
>         to a source_id.
>         (location_missing_trailing_newline): Likewise.
>         * input.h (get_source_file_content): Adjust prototype.
>         (location_missing_trailing_newline): Likewise.
>         * diagnostic-show-locus.cc (layout::calculate_x_offset_display): Use
>         the new overload of location_get_source_line() to support generated
>         data.
>         (layout::print_line): Likewise.
>         (class line_corrections): Change m_filename from a plain filename to
>         a source_id.
>         (source_line::source_line): Change argument from a plain filename to
>         a source_id.
>         (line_corrections::add_hint): Adapt to source_line change.
>         (layout::print_trailing_fixits): Adapt to line_corrections change.
>         (test_layout_x_offset_display_utf8): Test generated data too.
>         (test_layout_x_offset_display_tab): Likewise.
>         (test_diagnostic_show_locus_one_liner): Likewise.
>         (test_diagnostic_show_locus_one_liner_utf8): Likewise.
>         (test_add_location_if_nearby): Likewise.
>         (test_diagnostic_show_locus_fixit_lines): Likewise.
>         (test_fixit_consolidation): Likewise.
>         (test_overlapped_fixit_printing): Likewise.
>         (test_overlapped_fixit_printing_utf8): Likewise.
>         (test_overlapped_fixit_printing_2): Likewise.
>         (test_fixit_insert_containing_newline): Likewise.
>         (test_fixit_insert_containing_newline_2): Likewise.
>         (test_fixit_replace_containing_newline): Likewise.
>         (test_fixit_deletion_affecting_newline): Likewise.
>         (test_tab_expansion): Likewise.
>         (test_escaping_bytes_1): Likewise.
>         (test_escaping_bytes_2): Likewise.
>         (test_line_numbers_multiline_range): Likewise.
>         (diagnostic_show_locus_cc_tests): Likewise.
> ---
>  gcc/c-family/c-format.cc      |   2 +-
>  gcc/c-family/c-indentation.cc |   8 +-
>  gcc/diagnostic-show-locus.cc  | 227 ++++++++++++++++++----------------
>  gcc/gcc-rich-location.cc      |   2 +-
>  gcc/input.cc                  |  21 ++--
>  gcc/input.h                   |   6 +-
>  6 files changed, 136 insertions(+), 130 deletions(-)
> 

Looks OK for trunk as-is (assuming prerequisites, of course), but as I
think you noted elsewhere this probably needs revising if we're going
to reject applying fix-it-hints to locations in generated data buffers.

Thanks
Dave

Reply via email to