]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove 'copy_names' parameter from add_using_directive
authorTom Tromey <tromey@adacore.com>
Wed, 10 Apr 2024 17:48:13 +0000 (11:48 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 15 Apr 2024 17:45:33 +0000 (11:45 -0600)
I noticed that add_using_directive's 'copy_names' parameter is only
used by a single caller.  This patch removes the parameter and changes
that caller to copy the names itself.  I chose to use intern here
since I suspect the names may well be repeated in a given objfile.

Approved-By: John Baldwin <jhb@FreeBSD.org>
gdb/cp-namespace.c
gdb/dwarf2/read.c
gdb/namespace.c
gdb/namespace.h

index ec72d72b5a787426007a8e05cb72ca7286a3d95c..4434ddff79cc59a83fd13b73353c865e0f53ab95 100644 (file)
@@ -100,8 +100,9 @@ cp_scan_for_anonymous_namespaces (struct buildsym_compunit *compunit,
                 to 0, this way it is always considered valid.  */
              std::vector<const char *> excludes;
              add_using_directive (compunit->get_local_using_directives (),
-                                  dest, src, NULL, NULL, excludes, 0,
-                                  1, &objfile->objfile_obstack);
+                                  objfile->intern (dest), objfile->intern (src),
+                                  nullptr, nullptr, excludes, 0,
+                                  &objfile->objfile_obstack);
            }
          /* The "+ 2" is for the "::".  */
          previous_component = next_component + 2;
index 9e37011ddf046ac7d1364e37139b491a2669f8af..b029c49a339988388936acdddf350cc118b4a5df 100644 (file)
@@ -7248,7 +7248,6 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
                       imported_declaration,
                       excludes,
                       read_decl_line (die, cu),
-                      0,
                       &objfile->objfile_obstack);
 }
 
@@ -14071,7 +14070,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu)
                               previous_prefix, type->name (), NULL,
                               NULL, excludes,
                               read_decl_line (die, cu),
-                              0, &objfile->objfile_obstack);
+                              &objfile->objfile_obstack);
        }
     }
 
index 231c7bd4cb662afb9cfce87e3062d2cc9c27658a..5a9a99d56dec9382c624c0a35580f98700481869 100644 (file)
    into the scope DEST.  ALIAS is the name of the imported namespace
    in the current scope.  If ALIAS is NULL then the namespace is known
    by its original name.  DECLARATION is the name if the imported
-   variable if this is a declaration import (Eg. using A::x), otherwise
-   it is NULL.  EXCLUDES is a list of names not to import from an
-   imported module or NULL.  If COPY_NAMES is non-zero, then the
-   arguments are copied into newly allocated memory so they can be
-   temporaries.  For EXCLUDES the contents of the vector are copied,
-   but the pointed to characters are not copied.  */
+   variable if this is a declaration import (Eg. using A::x),
+   otherwise it is NULL.  EXCLUDES is a list of names not to import
+   from an imported module or NULL.  For EXCLUDES the contents of the
+   vector are copied, but the pointed to characters are not
+   copied.  */
 
 void
 add_using_directive (struct using_direct **using_directives,
@@ -42,7 +41,6 @@ add_using_directive (struct using_direct **using_directives,
                     const char *declaration,
                     const std::vector<const char *> &excludes,
                     unsigned int decl_line,
-                    int copy_names,
                     struct obstack *obstack)
 {
   struct using_direct *current;
@@ -90,26 +88,10 @@ add_using_directive (struct using_direct **using_directives,
   newobj = (struct using_direct *) obstack_alloc (obstack, alloc_len);
   memset (newobj, 0, sizeof (*newobj));
 
-  if (copy_names)
-    {
-      newobj->import_src = obstack_strdup (obstack, src);
-      newobj->import_dest = obstack_strdup (obstack, dest);
-    }
-  else
-    {
-      newobj->import_src = src;
-      newobj->import_dest = dest;
-    }
-
-  if (alias != NULL && copy_names)
-    newobj->alias = obstack_strdup (obstack, alias);
-  else
-    newobj->alias = alias;
-
-  if (declaration != NULL && copy_names)
-    newobj->declaration = obstack_strdup (obstack, declaration);
-  else
-    newobj->declaration = declaration;
+  newobj->import_src = src;
+  newobj->import_dest = dest;
+  newobj->alias = alias;
+  newobj->declaration = declaration;
 
   if (!excludes.empty ())
     memcpy (newobj->excludes, excludes.data (),
index bc9dcf245ca69831b9fd8d7062b8c6d5bf16366d..232dcc03bd803d876e464b450419657763e5dfeb 100644 (file)
@@ -125,7 +125,6 @@ extern void add_using_directive (struct using_direct **using_directives,
                                 const char *declaration,
                                 const std::vector<const char *> &excludes,
                                 const unsigned int decl_line,
-                                int copy_names,
                                 struct obstack *obstack);
 
 #endif /* NAMESPACE_H */