public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Jason Merrill <jason@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH RFA] input: add get_source_text_between
Date: Fri, 04 Nov 2022 11:16:14 -0400	[thread overview]
Message-ID: <41648997dfcb55920d54e93622501d4264068911.camel@redhat.com> (raw)
In-Reply-To: <22136833-3ba8-686b-4eae-a709f2c1780d@redhat.com>

On Fri, 2022-11-04 at 10:27 -0400, Jason Merrill wrote:
> On 11/3/22 19:06, David Malcolm wrote:
> > On Thu, 2022-11-03 at 15:59 -0400, Jason Merrill via Gcc-patches
> > wrote:

[...snip...]

> > 
> > 
> > Do you have test coverage for this from the DejaGnu side?  If not,
> > you
> > could add selftest coverage for this; see input.cc's
> > test_reading_source_line for something similar.
> 
> There is test coverage for the output of the the contract violation 
> handler, which involves printing the result of this function.

Thanks.   Is this test posted somwehere?  I was looking in:
 https://gcc.gnu.org/pipermail/gcc-patches/2022-November/604974.html
but I'm not seeing it.  Sorry if I'm missing something here.

Ideally we should have coverage for the three cases of:
(a) bails out and returns NULL
(b) single-line case
(c) multi-line case


> index a28abfac5ac..04d0809bfdf 100644
> --- a/gcc/input.cc
> +++ b/gcc/input.cc
> @@ -949,6 +949,97 @@ location_get_source_line (const char *file_path, int line)
>    return char_span (buffer, len);
>  }

Strings in input.cc are not always NUL-terminated, so...

>  
> +/* Return a copy of the source text between two locations.  The caller is
> +   responsible for freeing the return value.  */

...please note in the comment that if non-NULL, the copy is NUL-
terminated (I checked both exit paths that can return non-NULL, and
they do NUL-terminate their buffers).

OK with that nit fixed.

Thanks
Dave


  reply	other threads:[~2022-11-04 15:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03 19:59 Jason Merrill
2022-11-03 23:06 ` David Malcolm
2022-11-04 14:27   ` Jason Merrill
2022-11-04 15:16     ` David Malcolm [this message]
2022-11-04 17:06       ` Jason Merrill
2022-11-05  2:00         ` 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=41648997dfcb55920d54e93622501d4264068911.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.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).