From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 4D56F3858D32; Mon, 15 Apr 2024 17:45:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D56F3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713203146; bh=BAjFHFUr8DPCuODAHE1mpgTYCXbrX8EJEJmk8wIFHDU=; h=From:To:Subject:Date:From; b=dg6ObhFSWyMDw2e0AUO/KrfC7wYAUp1GdGaIlgH7QNpA6mK4tTTYCy8NTsqwYEMAV DG05zEAS8z2hT6eMEfc0hNOVHJyoYx+wErAch2hdU0RAbseS+DrGAFv7AK6J+SO4qg TQbp4vaIdeMW+M0i49rYVYT/N8KFibRpiIzGaUQg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Remove 'copy_names' parameter from add_using_directive X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 35d691515799a8cf7b82a1cb934dadb6a85b022f X-Git-Newrev: 12406b2cdab40fd05df65c4fe4aabaf4882fcc8e Message-Id: <20240415174546.4D56F3858D32@sourceware.org> Date: Mon, 15 Apr 2024 17:45:46 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D12406b2cdab4= 0fd05df65c4fe4aabaf4882fcc8e commit 12406b2cdab40fd05df65c4fe4aabaf4882fcc8e Author: Tom Tromey Date: Wed Apr 10 11:48:13 2024 -0600 Remove 'copy_names' parameter from add_using_directive =20 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. =20 Approved-By: John Baldwin Diff: --- gdb/cp-namespace.c | 5 +++-- gdb/dwarf2/read.c | 3 +-- gdb/namespace.c | 36 +++++++++--------------------------- gdb/namespace.h | 1 - 4 files changed, 13 insertions(+), 32 deletions(-) diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index ec72d72b5a7..4434ddff79c 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -100,8 +100,9 @@ cp_scan_for_anonymous_namespaces (struct buildsym_compu= nit *compunit, to 0, this way it is always considered valid. */ std::vector 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 =3D next_component + 2; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 9e37011ddf0..b029c49a339 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -7248,7 +7248,6 @@ read_import_statement (struct die_info *die, struct d= warf2_cu *cu) imported_declaration, excludes, read_decl_line (die, cu), - 0, &objfile->objfile_obstack); } =20 @@ -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); } } =20 diff --git a/gdb/namespace.c b/gdb/namespace.c index 231c7bd4cb6..5a9a99d56de 100644 --- a/gdb/namespace.c +++ b/gdb/namespace.c @@ -27,12 +27,11 @@ 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. */ =20 void add_using_directive (struct using_direct **using_directives, @@ -42,7 +41,6 @@ add_using_directive (struct using_direct **using_directiv= es, const char *declaration, const std::vector &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_direct= ives, newobj =3D (struct using_direct *) obstack_alloc (obstack, alloc_len); memset (newobj, 0, sizeof (*newobj)); =20 - if (copy_names) - { - newobj->import_src =3D obstack_strdup (obstack, src); - newobj->import_dest =3D obstack_strdup (obstack, dest); - } - else - { - newobj->import_src =3D src; - newobj->import_dest =3D dest; - } - - if (alias !=3D NULL && copy_names) - newobj->alias =3D obstack_strdup (obstack, alias); - else - newobj->alias =3D alias; - - if (declaration !=3D NULL && copy_names) - newobj->declaration =3D obstack_strdup (obstack, declaration); - else - newobj->declaration =3D declaration; + newobj->import_src =3D src; + newobj->import_dest =3D dest; + newobj->alias =3D alias; + newobj->declaration =3D declaration; =20 if (!excludes.empty ()) memcpy (newobj->excludes, excludes.data (), diff --git a/gdb/namespace.h b/gdb/namespace.h index bc9dcf245ca..232dcc03bd8 100644 --- a/gdb/namespace.h +++ b/gdb/namespace.h @@ -125,7 +125,6 @@ extern void add_using_directive (struct using_direct **= using_directives, const char *declaration, const std::vector &excludes, const unsigned int decl_line, - int copy_names, struct obstack *obstack); =20 #endif /* NAMESPACE_H */