public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/c++-contracts] input: rename get_source to get_source_text_between
Date: Thu,  3 Nov 2022 19:46:04 +0000 (GMT)	[thread overview]
Message-ID: <20221103194612.192CD3858417@sourceware.org> (raw)

https://gcc.gnu.org/g:7dbd1db4df283b73fe8e9c181d37a0754e429fac

commit 7dbd1db4df283b73fe8e9c181d37a0754e429fac
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Nov 3 15:44:25 2022 -0400

    input: rename get_source to get_source_text_between
    
    Let's use a more informative name.
    
    gcc/ChangeLog:
    
            * input.h:
            * input.cc (get_source):
            Rename to get_source_text_between.
    
    gcc/cp/ChangeLog:
    
            * contracts.cc (build_comment): Adjust.

Diff:
---
 gcc/input.h         | 2 +-
 gcc/cp/contracts.cc | 3 ++-
 gcc/input.cc        | 5 +++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gcc/input.h b/gcc/input.h
index c97768ad2f3..f18769950b5 100644
--- a/gcc/input.h
+++ b/gcc/input.h
@@ -111,7 +111,7 @@ class char_span
 };
 
 extern char_span location_get_source_line (const char *file_path, int line);
-extern char *get_source (location_t, location_t);
+extern char *get_source_text_between (location_t, location_t);
 
 extern bool location_missing_trailing_newline (const char *file_path);
 
diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
index 38eb4ad9bfe..79374344207 100644
--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -723,7 +723,8 @@ build_comment (cp_expr condition)
 {
   /* Try to get the actual source text for the condition; if that fails pretty
      print the resulting tree.  */
-  char *str = get_source (condition.get_start (), condition.get_finish ());
+  char *str = get_source_text_between (condition.get_start (),
+				       condition.get_finish ());
   if (!str)
     {
       /* FIXME cases where we end up here
diff --git a/gcc/input.cc b/gcc/input.cc
index 7166c810892..9b36356338a 100644
--- a/gcc/input.cc
+++ b/gcc/input.cc
@@ -949,10 +949,11 @@ location_get_source_line (const char *file_path, int line)
   return char_span (buffer, len);
 }
 
-/* Return the source text between two locations.  */
+/* Return a copy of the source text between two locations.  The caller is
+   responsible for freeing the return value.  */
 
 char *
-get_source (location_t start, location_t end)
+get_source_text_between (location_t start, location_t end)
 {
   expanded_location expstart =
     expand_location_to_spelling_point (start, LOCATION_ASPECT_START);

                 reply	other threads:[~2022-11-03 19:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221103194612.192CD3858417@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).