From patchwork Wed Apr 10 17:49:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 88310 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 13A853896C13 for ; Wed, 10 Apr 2024 17:50:24 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 7F9833858432 for ; Wed, 10 Apr 2024 17:49:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F9833858432 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7F9833858432 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::12b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712771401; cv=none; b=H4iVZ3TwCL9lLj51pbaizCB3FzFNIN/SMtwJgrEmhzne1j4mSYoj42oREnZYCuADBUlU+2XdGnnSLwQVPLTCjVM/LeiCXFdii1iFNTp9LQxWYPUmC5VIM8C7wU97apeVDSuPCwe+0aX8b3/EtN6B6CapeXhG+KpghUWmNXp1aCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712771401; c=relaxed/simple; bh=F3drJqptpo/Iz3pgzvEFjsZWftDW6/hW8AIfh0BPoco=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rsDgEUkULBShvu+RbjjUaxY6Xv9ka3hqqfyuwNfhyfuRBFbHvhE3oWduxIv9PRAXdCZJNEjwSF3keRbSP2S95DxCuSWUQREriqopbR/4/BmtnfRhLGjtJVJdC8A7ci2n9TaG1/UdA/OV//YY+Xo5qxNr9qKncr0CxmzBScqlchI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-36a06a409caso28891225ab.3 for ; Wed, 10 Apr 2024 10:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1712771389; x=1713376189; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ygHQCoZfe+IMzgVOvk++fzFAEKATpQuAj+Ci4M57zR0=; b=EmhVMxA4hYfqwKtyX76hzdXFn3fbusEiJk/jKDiwDWcce+otg1kHewDmH7S2nWwPl1 VqqINUp+6I59zuSKxao2BqML8gBGjyUUObqLQjC9MhHojyqLjEchjU1Wb3mlRaIugX72 OudFh14JusUUvWpAHJ1pyLWqCRHcP7sY1Sd5W6rRzIGZZL7WMEdRXYiBsBPa4m8FgsmO OM1xt6dLgebDYz38JFHfhoKu+HT+eWgCJzeKTheHU4c+zcm6yd4jbVhWZEQKB229/5mB SV+yilCODNZkbTs9TPxgRRQjEEGINkW2MmVKF0iZ09nOYW0p3coHnQ2HkvsHicn4O4IA EJZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712771389; x=1713376189; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ygHQCoZfe+IMzgVOvk++fzFAEKATpQuAj+Ci4M57zR0=; b=WVpBMNwb7khTI7DhggIa7z3OFNT3rw3gSbLY1S+SFD9tLnALnRdTU6OJEb2R/xtl/K gh6q0wdZFzQKXyqYtMkfo/Dj/8jB9sqjRJwiFT7xWmyXdAbnPhtvYIllXsFA1Q6t0YP/ PHXpz+8D1VpLA4mCNccAJ2eYgER3XXHt0rLJ1wI0IvYcZdkdTc/1CPROEnQzNERXI3Vp lmZ37jReIqrTs29+ZvvKZ0EsVHOf3iEky0r3j0wp+7gF1OQT+MTzYoFS/9ChyYuZ7xfV ZzyFgJ1n+/OY6Pty0xL4z5ECakhxCfrJt7ATWRJnHi6VXOwx1zG2JS5iC7Z8AHlF3B+y 6hLQ== X-Gm-Message-State: AOJu0Yz/7NyPbUDjrkJHMLYy5iT9txIcXYKK4sMJ6tgzenro/dIem+NE fVNI6BFeVF3Lbi0wUtyl6owQewS01q34P7bqxJgF23HdojEGLZ06rDpZfyebtGBFGRcG2iHjsw0 = X-Google-Smtp-Source: AGHT+IFDoFv3/9PG38cjqETHE87ibpqG0JxTvb8yHhwIMGLG1cbBSmcACTpF4BRNGMihEF0rWy6SVA== X-Received: by 2002:a92:ca45:0:b0:36a:3d4d:715e with SMTP id q5-20020a92ca45000000b0036a3d4d715emr2593424ilo.12.1712771388469; Wed, 10 Apr 2024 10:49:48 -0700 (PDT) Received: from localhost.localdomain (97-122-82-115.hlrn.qwest.net. [97.122.82.115]) by smtp.gmail.com with ESMTPSA id dv8-20020a056638608800b00482b63b6c45sm700978jab.14.2024.04.10.10.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 10:49:47 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Remove 'copy_names' parameter from add_using_directive Date: Wed, 10 Apr 2024 11:49:41 -0600 Message-ID: <20240410174941.2144268-1-tromey@adacore.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org 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. --- 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_compunit *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 = 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 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); } } 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. */ 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 &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 (), 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); #endif /* NAMESPACE_H */