From patchwork Sat Sep 9 00:41:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 22776 Received: (qmail 14667 invoked by alias); 9 Sep 2017 01:06:06 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14655 invoked by uid 89); 9 Sep 2017 01:06:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=EXCLUDES, CURRENT X-HELO: outbound-ss-1812.hostmonster.com Received: from gproxy1-pub.mail.unifiedlayer.com (HELO outbound-ss-1812.hostmonster.com) (69.89.25.95) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Sep 2017 01:06:03 +0000 Received: from cmgw2 (cmgw3 [10.0.90.83]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id 19CE7175ABA for ; Fri, 8 Sep 2017 18:41:40 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id 7Chd1w00X2f2jeq01ChgVL; Fri, 08 Sep 2017 18:41:40 -0600 X-Authority-Analysis: v=2.2 cv=dZfw5Tfe c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=zstS-IiYAAAA:8 a=kODBykl2ehbrxv8HKTsA:9 a=hd8gOgDqxbAYfnPe:21 a=ncb8o-ZelWjMlYBn:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-76-94.hlrn.qwest.net ([75.166.76.94]:58538 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dqTq4-000TWc-S3; Fri, 08 Sep 2017 18:41:36 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 4/4] Use std::vector in add_using_directive Date: Fri, 8 Sep 2017 18:41:29 -0600 Message-Id: <20170909004129.28782-5-tom@tromey.com> In-Reply-To: <20170909004129.28782-1-tom@tromey.com> References: <20170909004129.28782-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dqTq4-000TWc-S3 X-Source-Sender: 75-166-76-94.hlrn.qwest.net (bapiya.Home) [75.166.76.94]:58538 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This changes add_using_directive to accept a std::vector and then changes the callers. This allows removing a cleanup. gdb/ChangeLog 2017-09-08 Tom Tromey * namespace.h (add_using_directive): Update. * namespace.c (add_using_directive): Change type of excludes to std::vector. * dwarf2read.c (read_import_statement): Use std::vector. (read_namespace): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. --- gdb/ChangeLog | 9 +++++++++ gdb/cp-namespace.c | 3 ++- gdb/dwarf2read.c | 12 ++++-------- gdb/namespace.c | 19 ++++++++----------- gdb/namespace.h | 2 +- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4f4b543..1e486d6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2017-09-08 Tom Tromey + * namespace.h (add_using_directive): Update. + * namespace.c (add_using_directive): Change type of excludes to + std::vector. + * dwarf2read.c (read_import_statement): Use std::vector. + (read_namespace): Update. + * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update. + +2017-09-08 Tom Tromey + * linespec.c (create_sals_line_offset): Use gdb::def_vector. 2017-09-08 Tom Tromey diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index c7b5aa8..6a0266e 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -93,8 +93,9 @@ cp_scan_for_anonymous_namespaces (const struct symbol *const symbol, anonymous namespace. So add symbols in it to the namespace given by the previous component if there is one, or to the global namespace if there isn't. */ + std::vector excludes; add_using_directive (&local_using_directives, - dest, src, NULL, NULL, NULL, 1, + dest, src, NULL, NULL, excludes, 1, &objfile->objfile_obstack); } /* The "+ 2" is for the "::". */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 201a857..8e65492 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -9221,8 +9221,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) const char *import_alias; const char *imported_declaration = NULL; const char *import_prefix; - VEC (const_char_ptr) *excludes = NULL; - struct cleanup *cleanups; + std::vector excludes; import_attr = dwarf2_attr (die, DW_AT_import, cu); if (import_attr == NULL) @@ -9296,8 +9295,6 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) else canonical_name = imported_name; - cleanups = make_cleanup (VEC_cleanup (const_char_ptr), &excludes); - if (die->tag == DW_TAG_imported_module && cu->language == language_fortran) for (child_die = die->child; child_die && child_die->tag; child_die = sibling_die (child_die)) @@ -9337,7 +9334,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) continue; } - VEC_safe_push (const_char_ptr, excludes, imported_name); + excludes.push_back (imported_name); process_die (child_die, cu); } @@ -9350,8 +9347,6 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) excludes, 0, &objfile->objfile_obstack); - - do_cleanups (cleanups); } /* Check for possibly missing DW_AT_comp_dir with relative .debug_line @@ -14617,9 +14612,10 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) { const char *previous_prefix = determine_prefix (die, cu); + std::vector excludes; add_using_directive (using_directives (cu->language), previous_prefix, TYPE_NAME (type), NULL, - NULL, NULL, 0, &objfile->objfile_obstack); + NULL, excludes, 0, &objfile->objfile_obstack); } } diff --git a/gdb/namespace.c b/gdb/namespace.c index 5ada813..a851ce9 100644 --- a/gdb/namespace.c +++ b/gdb/namespace.c @@ -39,7 +39,7 @@ add_using_directive (struct using_direct **using_directives, const char *src, const char *alias, const char *declaration, - VEC (const_char_ptr) *excludes, + const std::vector &excludes, int copy_names, struct obstack *obstack) { @@ -52,7 +52,6 @@ add_using_directive (struct using_direct **using_directives, for (current = *using_directives; current != NULL; current = current->next) { int ix; - const char *param; if (strcmp (current->import_src, src) != 0) continue; @@ -70,12 +69,11 @@ add_using_directive (struct using_direct **using_directives, continue; /* Compare the contents of EXCLUDES. */ - for (ix = 0; VEC_iterate (const_char_ptr, excludes, ix, param); ix++) + for (ix = 0; ix < excludes.size (); ++ix) if (current->excludes[ix] == NULL - || strcmp (param, current->excludes[ix]) != 0) + || strcmp (excludes[ix], current->excludes[ix]) != 0) break; - if (ix < VEC_length (const_char_ptr, excludes) - || current->excludes[ix] != NULL) + if (ix < excludes.size () || current->excludes[ix] != NULL) continue; /* Parameters exactly match CURRENT. */ @@ -83,8 +81,7 @@ add_using_directive (struct using_direct **using_directives, } alloc_len = (sizeof(*newobj) - + (VEC_length (const_char_ptr, excludes) - * sizeof(*newobj->excludes))); + + (excludes.size () * sizeof(*newobj->excludes))); newobj = (struct using_direct *) obstack_alloc (obstack, alloc_len); memset (newobj, 0, sizeof (*newobj)); @@ -114,9 +111,9 @@ add_using_directive (struct using_direct **using_directives, else newobj->declaration = declaration; - memcpy (newobj->excludes, VEC_address (const_char_ptr, excludes), - VEC_length (const_char_ptr, excludes) * sizeof (*newobj->excludes)); - newobj->excludes[VEC_length (const_char_ptr, excludes)] = NULL; + memcpy (newobj->excludes, excludes.data (), + excludes.size () * sizeof (*newobj->excludes)); + newobj->excludes[excludes.size ()] = NULL; newobj->next = *using_directives; *using_directives = newobj; diff --git a/gdb/namespace.h b/gdb/namespace.h index 75ae030..6804582 100644 --- a/gdb/namespace.h +++ b/gdb/namespace.h @@ -111,7 +111,7 @@ extern void add_using_directive (struct using_direct **using_directives, const char *src, const char *alias, const char *declaration, - VEC (const_char_ptr) *excludes, + const std::vector &excludes, int copy_names, struct obstack *obstack);