aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2019-12-10 02:02:38 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2019-12-10 02:02:38 +0000
commitd68f5d458d7df12b31d27094e8f7ed0208ccf693 (patch)
treec30d686a52fa2b8eecdade9221ca87d28f6f4909 /gcc/cp
parentd3e28653fa2cd9ad8d5c6acb4bd182bd473c0995 (diff)
downloadgcc-d68f5d458d7df12b31d27094e8f7ed0208ccf693.zip
gcc-d68f5d458d7df12b31d27094e8f7ed0208ccf693.tar.gz
gcc-d68f5d458d7df12b31d27094e8f7ed0208ccf693.tar.bz2
Replace label_text ctor with "borrow" and "take"
libcpp's label_text class wraps a text buffer, along with a flag to determine if it "owns" the buffer. The existing ctor exposed this directly, but I found it difficult to remember the sense of flag, so this patch hides the ctor, in favor of static member functions "borrow" and "take", to make the effect on ownership explicit in the name. gcc/c-family/ChangeLog: * c-format.c (range_label_for_format_type_mismatch::get_text): Replace label_text ctor called with true with label_text::take. gcc/c/ChangeLog: * c-objc-common.c (range_label_for_type_mismatch::get_text): Replace label_text ctor calls. gcc/cp/ChangeLog: * error.c (range_label_for_type_mismatch::get_text): Replace label_text ctor calls with label_text::borrow. gcc/ChangeLog: * gcc-rich-location.c (maybe_range_label_for_tree_type_mismatch::get_text): Replace label_text ctor call with label_text::borrow. * gcc-rich-location.h (text_range_label::get_text): Replace label_text ctor called with false with label_text::borrow. libcpp/ChangeLog: * include/line-map.h (label_text::label_text): Make private. (label_text::borrow): New. (label_text::take): New. (label_text::take_or_copy): New. From-SVN: r279153
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/error.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b39a304..5140787 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-09 David Malcolm <dmalcolm@redhat.com>
+
+ * error.c (range_label_for_type_mismatch::get_text): Replace
+ label_text ctor calls with label_text::borrow.
+
2019-12-09 Paolo Carlini <paolo.carlini@oracle.com>
* typeck.c (check_for_casting_away_constness): Add location_t
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index a15230a..7c46c17 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -4528,7 +4528,7 @@ label_text
range_label_for_type_mismatch::get_text (unsigned /*range_idx*/) const
{
if (m_labelled_type == NULL_TREE)
- return label_text (NULL, false);
+ return label_text::borrow (NULL);
const bool verbose = false;
const bool show_color = false;
@@ -4543,5 +4543,5 @@ range_label_for_type_mismatch::get_text (unsigned /*range_idx*/) const
/* Both of the above return GC-allocated buffers, so the caller mustn't
free them. */
- return label_text (const_cast <char *> (result), false);
+ return label_text::borrow (result);
}