From: Lancelot Six <lancelot.six@amd.com>
To: <gdb-patches@sourceware.org>
Cc: Lancelot Six <lancelot.six@amd.com>
Subject: [PATCH 07/11] gdb: Remove uses of gdb::to_string (const std::string_view &)
Date: Fri, 13 Oct 2023 14:44:14 +0000 [thread overview]
Message-ID: <20231013144418.3180617-8-lancelot.six@amd.com> (raw)
In-Reply-To: <20231013144418.3180617-1-lancelot.six@amd.com>
This patch removes all uses of to_string(const std::string_view&) and
use the std::string ctor or implicit conversion from std::string_view to
std::string instead.
A later patch will remove this gdb::to_string while removing
gdbsupport/gdb_string_view.h.
Change-Id: I877cde557a0727be7b0435107e3c7a2aac165895
---
gdb/ada-lang.c | 20 +++++++++-----------
gdb/amdgpu-tdep.c | 18 +++++++++---------
gdb/debuginfod-support.c | 3 +--
gdb/dwarf2/read.c | 2 +-
gdb/solib-rocm.c | 8 ++++----
5 files changed, 24 insertions(+), 27 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3e394619399..ff7222c7eed 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -1040,7 +1040,7 @@ ada_fold_name (std::string_view name, bool throw_on_error = false)
static std::string fold_storage;
if (!name.empty () && name[0] == '\'')
- fold_storage = gdb::to_string (name.substr (1, name.size () - 2));
+ fold_storage = name.substr (1, name.size () - 2);
else
{
/* Why convert to UTF-32 and implement our own case-folding,
@@ -1081,12 +1081,12 @@ ada_fold_name (std::string_view name, bool throw_on_error = false)
warned = true;
warning (_("could not convert '%s' from the host encoding (%s) to UTF-32.\n"
"This normally should not happen, please file a bug report."),
- gdb::to_string (name).c_str (), host_charset ());
+ std::string (name).c_str (), host_charset ());
}
/* We don't try to recover from errors; just return the
original string. */
- fold_storage = gdb::to_string (name);
+ fold_storage = name;
return fold_storage.c_str ();
}
@@ -1135,12 +1135,12 @@ ada_fold_name (std::string_view name, bool throw_on_error = false)
warned = true;
warning (_("could not convert the lower-cased variant of '%s'\n"
"from UTF-32 to the host encoding (%s)."),
- gdb::to_string (name).c_str (), host_charset ());
+ std::string (name).c_str (), host_charset ());
}
/* We don't try to recover from errors; just return the
original string. */
- fold_storage = gdb::to_string (name);
+ fold_storage = name;
}
}
@@ -13255,11 +13255,9 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
if (!user_name.empty () && user_name[0] == '<')
{
if (user_name.back () == '>')
- m_encoded_name
- = gdb::to_string (user_name.substr (1, user_name.size () - 2));
+ m_encoded_name = user_name.substr (1, user_name.size () - 2);
else
- m_encoded_name
- = gdb::to_string (user_name.substr (1, user_name.size () - 1));
+ m_encoded_name = user_name.substr (1, user_name.size () - 1);
m_encoded_p = true;
m_verbatim_p = true;
m_wild_match_p = false;
@@ -13276,10 +13274,10 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
const char *folded = ada_fold_name (user_name);
m_encoded_name = ada_encode_1 (folded, false);
if (m_encoded_name.empty ())
- m_encoded_name = gdb::to_string (user_name);
+ m_encoded_name = user_name;
}
else
- m_encoded_name = gdb::to_string (user_name);
+ m_encoded_name = user_name;
/* Handle the 'package Standard' special case. See description
of m_standard_p. */
diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c
index 48dc8db6bcc..15f32885b07 100644
--- a/gdb/amdgpu-tdep.c
+++ b/gdb/amdgpu-tdep.c
@@ -401,7 +401,7 @@ parse_amd_dbgapi_register_type_enum_fields
if (value > std::numeric_limits<uint32_t>::max ())
enum_type.set_bit_size (64);
- enum_type.add_enumerator (gdb::to_string (name), value);
+ enum_type.add_enumerator (std::string (name), value);
fields = fields.substr (matches[0].rm_eo);
}
@@ -445,7 +445,7 @@ parse_amd_dbgapi_register_type_flags_fields
ULONGEST pos_begin = try_strtoulst (pos_begin_str);
if (field_type_str == "bool")
- flags_type.add_field (gdb::to_string (field_name), pos_begin, pos_begin,
+ flags_type.add_field (std::string (field_name), pos_begin, pos_begin,
nullptr);
else
{
@@ -456,7 +456,7 @@ parse_amd_dbgapi_register_type_flags_fields
ULONGEST pos_end = try_strtoulst (pos_end_str.substr (1));
const amd_dbgapi_register_type &field_type
= parse_amd_dbgapi_register_type (field_type_str, type_map);
- flags_type.add_field (gdb::to_string (field_name), pos_begin, pos_end,
+ flags_type.add_field (std::string (field_name), pos_begin, pos_end,
&field_type);
}
@@ -470,7 +470,7 @@ static const amd_dbgapi_register_type &
parse_amd_dbgapi_register_type_scalar (std::string_view name,
amd_dbgapi_register_type_map &type_map)
{
- std::string name_str = gdb::to_string (name);
+ std::string name_str (name);
auto it = type_map.find (name_str);
if (it != type_map.end ())
{
@@ -533,7 +533,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
std::string_view count_str_view
= type_str.substr (pos_open_bracket + 1,
pos_close_bracket - pos_open_bracket);
- std::string count_str = gdb::to_string (count_str_view);
+ std::string count_str (count_str_view);
unsigned int count = std::stoul (count_str);
std::string lookup_name
@@ -579,7 +579,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
/* No braces, lookup existing type. */
if (existing_type_it == type_map.end ())
error (_("reference to unknown type %s."),
- gdb::to_string (name).c_str ());
+ std::string (name).c_str ());
if (existing_type_it->second->kind ()
!= amd_dbgapi_register_type::kind::FLAGS)
@@ -592,7 +592,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
/* With braces, it's a definition. */
if (existing_type_it != type_map.end ())
error (_("re-definition of type %s."),
- gdb::to_string (name).c_str ());
+ std::string (name).c_str ());
amd_dbgapi_register_type_flags_up flags_type
(new amd_dbgapi_register_type_flags (bit_size, name));
@@ -631,7 +631,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
/* No braces, lookup existing type. */
if (existing_type_it == type_map.end ())
error (_("reference to unknown type %s"),
- gdb::to_string (name).c_str ());
+ std::string (name).c_str ());
if (existing_type_it->second->kind ()
!= amd_dbgapi_register_type::kind::ENUM)
@@ -644,7 +644,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
/* With braces, it's a definition. */
if (existing_type_it != type_map.end ())
error (_("re-definition of type %s"),
- gdb::to_string (name).c_str ());
+ std::string (name).c_str ());
amd_dbgapi_register_type_enum_up enum_type
(new amd_dbgapi_register_type_enum (name));
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 0e202ff5d96..eb88c406ad6 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -264,8 +264,7 @@ debuginfod_is_enabled ()
gdb_printf
(_(" <%ps>\n"),
styled_string (file_name_style.style (),
- gdb::to_string (url_view.substr (0,
- off)).c_str ()));
+ std::string (url_view.substr (0, off)).c_str ()));
if (off == std::string_view::npos)
break;
url_view = url_view.substr (off);
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 1846f7160cc..0973fb6fe13 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16886,7 +16886,7 @@ cooked_index_functions::expand_symtabs_matching
{
std::vector<std::string_view> name_vec
= lookup_name_without_params.split_name (lang);
- std::string last_name = gdb::to_string (name_vec.back ());
+ std::string last_name (name_vec.back ());
for (const cooked_index_entry *entry : table->find (last_name,
completing))
diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index 27cefb9604b..c39b5b8bdeb 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -454,7 +454,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
std::string_view uri (bfd_get_filename (abfd));
std::string_view protocol_delim = "://";
size_t protocol_end = uri.find (protocol_delim);
- std::string protocol = gdb::to_string (uri.substr (0, protocol_end));
+ std::string protocol (uri.substr (0, protocol_end));
protocol_end += protocol_delim.length ();
std::transform (protocol.begin (), protocol.end (), protocol.begin (),
@@ -477,7 +477,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
&& std::isxdigit (path[i + 2]))
{
std::string_view hex_digits = path.substr (i + 1, 2);
- decoded_path += std::stoi (gdb::to_string (hex_digits), 0, 16);
+ decoded_path += std::stoi (std::string (hex_digits), 0, 16);
i += 2;
}
else
@@ -563,7 +563,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
if (pid != inferior->pid)
{
warning (_("`%s': code object is from another inferior"),
- gdb::to_string (uri).c_str ());
+ std::string (uri).c_str ());
bfd_set_error (bfd_error_bad_value);
return nullptr;
}
@@ -580,7 +580,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
}
warning (_("`%s': protocol not supported: %s"),
- gdb::to_string (uri).c_str (), protocol.c_str ());
+ std::string (uri).c_str (), protocol.c_str ());
bfd_set_error (bfd_error_bad_value);
return nullptr;
}
--
2.34.1
next prev parent reply other threads:[~2023-10-13 14:45 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
2023-10-13 14:44 ` [PATCH 01/11] gdb/ax_cxx_compile_stdcxx.m4: upgrade Lancelot Six
2023-10-13 14:44 ` [PATCH 02/11] gdb/gdbsupport/gdbserver: Require c++17 Lancelot Six
2023-10-13 15:21 ` Eli Zaretskii
2023-10-16 21:50 ` Pedro Alves
2023-10-13 14:44 ` [PATCH 03/11] gdb: Use C++17's std::make_unique instead of gdb::make_unique Lancelot Six
2023-10-16 19:14 ` Tom Tromey
2023-10-17 14:02 ` Lancelot SIX
2023-10-13 14:44 ` [PATCH 04/11] gdb: Replace gdb::optional with std::optional Lancelot Six
2023-10-13 14:44 ` [PATCH 05/11] gdbsupport: remove gdb::optional Lancelot Six
2023-10-13 14:44 ` [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view Lancelot Six
2023-10-14 21:50 ` Tom Tromey
2023-10-14 23:58 ` Six, Lancelot
2023-10-16 15:06 ` Lancelot SIX
2023-10-16 19:35 ` Tom Tromey
2023-10-16 21:51 ` Pedro Alves
2023-10-17 14:13 ` Lancelot SIX
2023-10-17 14:20 ` Simon Marchi
2023-10-13 14:44 ` Lancelot Six [this message]
2023-10-13 14:44 ` [PATCH 08/11] gdbsupport: Remove gdb::string_view Lancelot Six
2023-10-16 19:38 ` Tom Tromey
2023-10-13 14:44 ` [PATCH 09/11] gdbsupport: Replace gdb::invoke_result with std::invoke_result Lancelot Six
2023-10-13 14:44 ` [PATCH 10/11] gdb/disasm.h: Mark callbacks noexcept unconditionally Lancelot Six
2023-10-16 21:51 ` Pedro Alves
2023-10-13 14:44 ` [PATCH 11/11] gdb: Use initializers in lambda captures unconditionally Lancelot Six
2023-10-16 19:43 ` [PATCH 00/11] GDB: Require C++17 Tom Tromey
2023-10-16 21:53 ` Pedro Alves
2023-10-23 13:42 ` Lancelot SIX
2023-10-28 20:48 ` Lancelot SIX
2023-11-21 12:04 ` [COMMITTED PATCH v2 0/9] " Lancelot Six
2023-11-21 12:04 ` [COMMITTED PATCH v2 1/9] gdb: Use C++17's std::make_unique instead of gdb::make_unique Lancelot Six
2023-11-21 12:04 ` [COMMITTED PATCH v2 2/9] gdb: Replace gdb::optional with std::optional Lancelot Six
2023-11-21 12:04 ` [COMMITTED PATCH v2 3/9] gdbsupport: remove gdb::optional Lancelot Six
2023-11-21 12:04 ` [COMMITTED PATCH v2 4/9] gdb: Use std::string_view instead of gdb::string_view Lancelot Six
2023-11-21 12:04 ` [COMMITTED PATCH v2 5/9] gdb: Remove uses of gdb::to_string (const std::string_view &) Lancelot Six
2023-11-21 12:04 ` [COMMITTED PATCH v2 6/9] gdbsupport: Remove gdb::string_view Lancelot Six
2023-11-21 12:04 ` [COMMITTED PATCH v2 7/9] gdbsupport: Replace gdb::invoke_result with std::invoke_result Lancelot Six
2023-11-21 12:04 ` [COMMITTED PATCH v2 8/9] gdb/disasm.h: Mark callbacks noexcept unconditionally Lancelot Six
2023-11-21 12:05 ` [COMMITTED PATCH v2 9/9] gdb: Use initializers in lambda captures unconditionally Lancelot Six
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=20231013144418.3180617-8-lancelot.six@amd.com \
--to=lancelot.six@amd.com \
--cc=gdb-patches@sourceware.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).