• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisióneb1e02fd05688c28686a02f197c5e7cb0a5d6a27 (tree)
Tiempo2017-09-10 05:10:51
AutorTom Tromey <tom@trom...>
CommiterTom Tromey

Log Message

Use std::vector in add_using_directive

This changes add_using_directive to accept a std::vector and then
changes the callers. This allows removing a cleanup.

ChangeLog
2017-09-09 Tom Tromey <tom@tromey.com>

* 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.

Cambiar Resumen

Diferencia incremental

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
11 2017-09-09 Tom Tromey <tom@tromey.com>
22
3+ * namespace.h (add_using_directive): Update.
4+ * namespace.c (add_using_directive): Change type of excludes to
5+ std::vector.
6+ * dwarf2read.c (read_import_statement): Use std::vector.
7+ (read_namespace): Update.
8+ * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
9+
10+2017-09-09 Tom Tromey <tom@tromey.com>
11+
312 * linespec.c (create_sals_line_offset): Use gdb::def_vector.
413
514 2017-09-09 Tom Tromey <tom@tromey.com>
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -93,8 +93,9 @@ cp_scan_for_anonymous_namespaces (const struct symbol *const symbol,
9393 anonymous namespace. So add symbols in it to the
9494 namespace given by the previous component if there is
9595 one, or to the global namespace if there isn't. */
96+ std::vector<const char *> excludes;
9697 add_using_directive (&local_using_directives,
97- dest, src, NULL, NULL, NULL, 1,
98+ dest, src, NULL, NULL, excludes, 1,
9899 &objfile->objfile_obstack);
99100 }
100101 /* The "+ 2" is for the "::". */
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9221,8 +9221,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
92219221 const char *import_alias;
92229222 const char *imported_declaration = NULL;
92239223 const char *import_prefix;
9224- VEC (const_char_ptr) *excludes = NULL;
9225- struct cleanup *cleanups;
9224+ std::vector<const char *> excludes;
92269225
92279226 import_attr = dwarf2_attr (die, DW_AT_import, cu);
92289227 if (import_attr == NULL)
@@ -9296,8 +9295,6 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
92969295 else
92979296 canonical_name = imported_name;
92989297
9299- cleanups = make_cleanup (VEC_cleanup (const_char_ptr), &excludes);
9300-
93019298 if (die->tag == DW_TAG_imported_module && cu->language == language_fortran)
93029299 for (child_die = die->child; child_die && child_die->tag;
93039300 child_die = sibling_die (child_die))
@@ -9337,7 +9334,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
93379334 continue;
93389335 }
93399336
9340- VEC_safe_push (const_char_ptr, excludes, imported_name);
9337+ excludes.push_back (imported_name);
93419338
93429339 process_die (child_die, cu);
93439340 }
@@ -9350,8 +9347,6 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
93509347 excludes,
93519348 0,
93529349 &objfile->objfile_obstack);
9353-
9354- do_cleanups (cleanups);
93559350 }
93569351
93579352 /* 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)
1461714612 {
1461814613 const char *previous_prefix = determine_prefix (die, cu);
1461914614
14615+ std::vector<const char *> excludes;
1462014616 add_using_directive (using_directives (cu->language),
1462114617 previous_prefix, TYPE_NAME (type), NULL,
14622- NULL, NULL, 0, &objfile->objfile_obstack);
14618+ NULL, excludes, 0, &objfile->objfile_obstack);
1462314619 }
1462414620 }
1462514621
--- a/gdb/namespace.c
+++ b/gdb/namespace.c
@@ -39,7 +39,7 @@ add_using_directive (struct using_direct **using_directives,
3939 const char *src,
4040 const char *alias,
4141 const char *declaration,
42- VEC (const_char_ptr) *excludes,
42+ const std::vector<const char *> &excludes,
4343 int copy_names,
4444 struct obstack *obstack)
4545 {
@@ -52,7 +52,6 @@ add_using_directive (struct using_direct **using_directives,
5252 for (current = *using_directives; current != NULL; current = current->next)
5353 {
5454 int ix;
55- const char *param;
5655
5756 if (strcmp (current->import_src, src) != 0)
5857 continue;
@@ -70,12 +69,11 @@ add_using_directive (struct using_direct **using_directives,
7069 continue;
7170
7271 /* Compare the contents of EXCLUDES. */
73- for (ix = 0; VEC_iterate (const_char_ptr, excludes, ix, param); ix++)
72+ for (ix = 0; ix < excludes.size (); ++ix)
7473 if (current->excludes[ix] == NULL
75- || strcmp (param, current->excludes[ix]) != 0)
74+ || strcmp (excludes[ix], current->excludes[ix]) != 0)
7675 break;
77- if (ix < VEC_length (const_char_ptr, excludes)
78- || current->excludes[ix] != NULL)
76+ if (ix < excludes.size () || current->excludes[ix] != NULL)
7977 continue;
8078
8179 /* Parameters exactly match CURRENT. */
@@ -83,8 +81,7 @@ add_using_directive (struct using_direct **using_directives,
8381 }
8482
8583 alloc_len = (sizeof(*newobj)
86- + (VEC_length (const_char_ptr, excludes)
87- * sizeof(*newobj->excludes)));
84+ + (excludes.size () * sizeof(*newobj->excludes)));
8885 newobj = (struct using_direct *) obstack_alloc (obstack, alloc_len);
8986 memset (newobj, 0, sizeof (*newobj));
9087
@@ -114,9 +111,9 @@ add_using_directive (struct using_direct **using_directives,
114111 else
115112 newobj->declaration = declaration;
116113
117- memcpy (newobj->excludes, VEC_address (const_char_ptr, excludes),
118- VEC_length (const_char_ptr, excludes) * sizeof (*newobj->excludes));
119- newobj->excludes[VEC_length (const_char_ptr, excludes)] = NULL;
114+ memcpy (newobj->excludes, excludes.data (),
115+ excludes.size () * sizeof (*newobj->excludes));
116+ newobj->excludes[excludes.size ()] = NULL;
120117
121118 newobj->next = *using_directives;
122119 *using_directives = newobj;
--- a/gdb/namespace.h
+++ b/gdb/namespace.h
@@ -111,7 +111,7 @@ extern void add_using_directive (struct using_direct **using_directives,
111111 const char *src,
112112 const char *alias,
113113 const char *declaration,
114- VEC (const_char_ptr) *excludes,
114+ const std::vector<const char *> &excludes,
115115 int copy_names,
116116 struct obstack *obstack);
117117