public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Lewis Hyatt <lhyatt@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v4 6/8] diagnostics: Full support for generated data locations
Date: Tue, 15 Aug 2023 12:39:17 -0400	[thread overview]
Message-ID: <d1a57ed5d9cefcfe424ec5b74610645445265bff.camel@redhat.com> (raw)
In-Reply-To: <20230809221414.2849878-7-lhyatt@gmail.com>

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	other threads:[~2023-08-15 16:39 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 23:08 [PATCH v3 0/4] diagnostics: libcpp: Overhaul locations for _Pragma tokens Lewis Hyatt
2023-07-21 23:08 ` [PATCH v3 1/4] diagnostics: libcpp: Add LC_GEN linemaps to support in-memory buffers Lewis Hyatt
2023-07-28 22:58   ` David Malcolm
2023-07-31 22:39     ` Lewis Hyatt
2023-08-09 22:14       ` [PATCH v4 0/8] diagnostics: libcpp: Overhaul locations for _Pragma tokens Lewis Hyatt
2023-08-09 22:14         ` [PATCH v4 1/8] libcpp: Add LC_GEN linemaps to support in-memory buffers Lewis Hyatt
2023-08-11 22:45           ` David Malcolm
2023-08-13 20:18             ` Lewis Hyatt
2023-08-09 22:14         ` [PATCH v4 2/8] libcpp: diagnostics: Support generated data in expanded locations Lewis Hyatt
2023-08-11 23:02           ` David Malcolm
2023-08-14 21:41             ` Lewis Hyatt
2023-08-09 22:14         ` [PATCH v4 3/8] diagnostics: Refactor class file_cache_slot Lewis Hyatt
2023-08-15 15:43           ` David Malcolm
2023-08-15 17:58             ` Lewis Hyatt
2023-08-15 19:39               ` David Malcolm
2023-08-23 21:22                 ` Lewis Hyatt
2023-08-09 22:14         ` [PATCH v4 4/8] diagnostics: Support obtaining source code lines from generated data buffers Lewis Hyatt
2023-08-15 16:15           ` David Malcolm
2023-08-15 18:15             ` Lewis Hyatt
2023-08-15 19:46               ` David Malcolm
2023-08-15 20:08                 ` Lewis Hyatt
2023-08-23 19:41                   ` Lewis Hyatt
2023-08-09 22:14         ` [PATCH v4 5/8] diagnostics: Support testing generated data in input.cc selftests Lewis Hyatt
2023-08-15 16:27           ` David Malcolm
2023-08-09 22:14         ` [PATCH v4 6/8] diagnostics: Full support for generated data locations Lewis Hyatt
2023-08-15 16:39           ` David Malcolm [this message]
2023-08-09 22:14         ` [PATCH v4 7/8] diagnostics: libcpp: Assign real locations to the tokens inside _Pragma strings Lewis Hyatt
2023-08-09 22:14         ` [PATCH v4 8/8] diagnostics: Support generated data locations in SARIF output Lewis Hyatt
2023-08-15 17:04           ` David Malcolm
2023-08-15 17:51             ` Lewis Hyatt
2023-07-21 23:08 ` [PATCH v3 2/4] diagnostics: Handle generated data locations in edit_context Lewis Hyatt
2023-07-21 23:08 ` [PATCH v3 3/4] diagnostics: libcpp: Assign real locations to the tokens inside _Pragma strings Lewis Hyatt
2023-07-21 23:08 ` [PATCH v3 4/4] diagnostics: Support generated data locations in SARIF output Lewis Hyatt
2023-07-28 22:22 ` [PATCH v3 0/4] diagnostics: libcpp: Overhaul locations for _Pragma tokens David Malcolm
2023-07-29 14:27   ` Lewis Hyatt
2023-07-29 16:03     ` David Malcolm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d1a57ed5d9cefcfe424ec5b74610645445265bff.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=lhyatt@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).