From d68f5d458d7df12b31d27094e8f7ed0208ccf693 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 10 Dec 2019 02:02:38 +0000 Subject: 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 --- gcc/gcc-rich-location.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/gcc-rich-location.h') diff --git a/gcc/gcc-rich-location.h b/gcc/gcc-rich-location.h index 3bee2e8..71f4f3d 100644 --- a/gcc/gcc-rich-location.h +++ b/gcc/gcc-rich-location.h @@ -111,7 +111,7 @@ class text_range_label : public range_label label_text get_text (unsigned /*range_idx*/) const FINAL OVERRIDE { - return label_text (const_cast (m_text), false); + return label_text::borrow (m_text); } private: -- cgit v1.1