GNU Binutils with patches for OS216
Revisión | eb1e02fd05688c28686a02f197c5e7cb0a5d6a27 (tree) |
---|---|
Tiempo | 2017-09-10 05:10:51 |
Autor | Tom Tromey <tom@trom...> |
Commiter | Tom Tromey |
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.
@@ -1,5 +1,14 @@ | ||
1 | 1 | 2017-09-09 Tom Tromey <tom@tromey.com> |
2 | 2 | |
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 | + | |
3 | 12 | * linespec.c (create_sals_line_offset): Use gdb::def_vector. |
4 | 13 | |
5 | 14 | 2017-09-09 Tom Tromey <tom@tromey.com> |
@@ -93,8 +93,9 @@ cp_scan_for_anonymous_namespaces (const struct symbol *const symbol, | ||
93 | 93 | anonymous namespace. So add symbols in it to the |
94 | 94 | namespace given by the previous component if there is |
95 | 95 | one, or to the global namespace if there isn't. */ |
96 | + std::vector<const char *> excludes; | |
96 | 97 | add_using_directive (&local_using_directives, |
97 | - dest, src, NULL, NULL, NULL, 1, | |
98 | + dest, src, NULL, NULL, excludes, 1, | |
98 | 99 | &objfile->objfile_obstack); |
99 | 100 | } |
100 | 101 | /* The "+ 2" is for the "::". */ |
@@ -9221,8 +9221,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) | ||
9221 | 9221 | const char *import_alias; |
9222 | 9222 | const char *imported_declaration = NULL; |
9223 | 9223 | const char *import_prefix; |
9224 | - VEC (const_char_ptr) *excludes = NULL; | |
9225 | - struct cleanup *cleanups; | |
9224 | + std::vector<const char *> excludes; | |
9226 | 9225 | |
9227 | 9226 | import_attr = dwarf2_attr (die, DW_AT_import, cu); |
9228 | 9227 | if (import_attr == NULL) |
@@ -9296,8 +9295,6 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) | ||
9296 | 9295 | else |
9297 | 9296 | canonical_name = imported_name; |
9298 | 9297 | |
9299 | - cleanups = make_cleanup (VEC_cleanup (const_char_ptr), &excludes); | |
9300 | - | |
9301 | 9298 | if (die->tag == DW_TAG_imported_module && cu->language == language_fortran) |
9302 | 9299 | for (child_die = die->child; child_die && child_die->tag; |
9303 | 9300 | child_die = sibling_die (child_die)) |
@@ -9337,7 +9334,7 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) | ||
9337 | 9334 | continue; |
9338 | 9335 | } |
9339 | 9336 | |
9340 | - VEC_safe_push (const_char_ptr, excludes, imported_name); | |
9337 | + excludes.push_back (imported_name); | |
9341 | 9338 | |
9342 | 9339 | process_die (child_die, cu); |
9343 | 9340 | } |
@@ -9350,8 +9347,6 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) | ||
9350 | 9347 | excludes, |
9351 | 9348 | 0, |
9352 | 9349 | &objfile->objfile_obstack); |
9353 | - | |
9354 | - do_cleanups (cleanups); | |
9355 | 9350 | } |
9356 | 9351 | |
9357 | 9352 | /* 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) | ||
14617 | 14612 | { |
14618 | 14613 | const char *previous_prefix = determine_prefix (die, cu); |
14619 | 14614 | |
14615 | + std::vector<const char *> excludes; | |
14620 | 14616 | add_using_directive (using_directives (cu->language), |
14621 | 14617 | previous_prefix, TYPE_NAME (type), NULL, |
14622 | - NULL, NULL, 0, &objfile->objfile_obstack); | |
14618 | + NULL, excludes, 0, &objfile->objfile_obstack); | |
14623 | 14619 | } |
14624 | 14620 | } |
14625 | 14621 |
@@ -39,7 +39,7 @@ add_using_directive (struct using_direct **using_directives, | ||
39 | 39 | const char *src, |
40 | 40 | const char *alias, |
41 | 41 | const char *declaration, |
42 | - VEC (const_char_ptr) *excludes, | |
42 | + const std::vector<const char *> &excludes, | |
43 | 43 | int copy_names, |
44 | 44 | struct obstack *obstack) |
45 | 45 | { |
@@ -52,7 +52,6 @@ add_using_directive (struct using_direct **using_directives, | ||
52 | 52 | for (current = *using_directives; current != NULL; current = current->next) |
53 | 53 | { |
54 | 54 | int ix; |
55 | - const char *param; | |
56 | 55 | |
57 | 56 | if (strcmp (current->import_src, src) != 0) |
58 | 57 | continue; |
@@ -70,12 +69,11 @@ add_using_directive (struct using_direct **using_directives, | ||
70 | 69 | continue; |
71 | 70 | |
72 | 71 | /* 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) | |
74 | 73 | if (current->excludes[ix] == NULL |
75 | - || strcmp (param, current->excludes[ix]) != 0) | |
74 | + || strcmp (excludes[ix], current->excludes[ix]) != 0) | |
76 | 75 | break; |
77 | - if (ix < VEC_length (const_char_ptr, excludes) | |
78 | - || current->excludes[ix] != NULL) | |
76 | + if (ix < excludes.size () || current->excludes[ix] != NULL) | |
79 | 77 | continue; |
80 | 78 | |
81 | 79 | /* Parameters exactly match CURRENT. */ |
@@ -83,8 +81,7 @@ add_using_directive (struct using_direct **using_directives, | ||
83 | 81 | } |
84 | 82 | |
85 | 83 | alloc_len = (sizeof(*newobj) |
86 | - + (VEC_length (const_char_ptr, excludes) | |
87 | - * sizeof(*newobj->excludes))); | |
84 | + + (excludes.size () * sizeof(*newobj->excludes))); | |
88 | 85 | newobj = (struct using_direct *) obstack_alloc (obstack, alloc_len); |
89 | 86 | memset (newobj, 0, sizeof (*newobj)); |
90 | 87 |
@@ -114,9 +111,9 @@ add_using_directive (struct using_direct **using_directives, | ||
114 | 111 | else |
115 | 112 | newobj->declaration = declaration; |
116 | 113 | |
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; | |
120 | 117 | |
121 | 118 | newobj->next = *using_directives; |
122 | 119 | *using_directives = newobj; |
@@ -111,7 +111,7 @@ extern void add_using_directive (struct using_direct **using_directives, | ||
111 | 111 | const char *src, |
112 | 112 | const char *alias, |
113 | 113 | const char *declaration, |
114 | - VEC (const_char_ptr) *excludes, | |
114 | + const std::vector<const char *> &excludes, | |
115 | 115 | int copy_names, |
116 | 116 | struct obstack *obstack); |
117 | 117 |