]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Remove uses of gdb::to_string (const std::string_view &)
authorLancelot Six <lancelot.six@amd.com>
Fri, 13 Oct 2023 10:54:46 +0000 (10:54 +0000)
committerLancelot Six <lancelot.six@amd.com>
Fri, 13 Oct 2023 13:59:59 +0000 (13:59 +0000)
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
gdb/amdgpu-tdep.c
gdb/debuginfod-support.c
gdb/dwarf2/read.c
gdb/solib-rocm.c

index 3e394619399d2403ff4ea69170267824a3178123..ff7222c7eed0ea85de3e943c58983f4fbbe895b2 100644 (file)
@@ -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.  */
index 48dc8db6bccb9f04d5bb98262073fccd7745f14f..15f32885b07b76e19d3d6705f84b7fe2fa875b63 100644 (file)
@@ -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));
index 0e202ff5d96fdcb822a6eaac70d9d908c9f42fe4..eb88c406ad62444fc7ba20ee7d1a7b413918154f 100644 (file)
@@ -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);
index 1846f7160cc7a9bf8421af6c0331eb245871adcb..0973fb6fe1391f179163dd2736639aea5811d70c 100644 (file)
@@ -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))
index 27cefb9604bad557f5e00ec59af5cd0cb8e783c4..c39b5b8bdeb690b67ff46d301eb1d56eccab213d 100644 (file)
@@ -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;
     }