aboutsummaryrefslogtreecommitdiff
path: root/gdb/parse.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-01-02 19:12:32 -0700
committerTom Tromey <tom@tromey.com>2019-01-06 09:39:33 -0700
commit02e12e3806bc60f66e3c446c4dfa9c06a400e604 (patch)
tree480e7eca926f9945bcd9d7c199b7df57271ddde1 /gdb/parse.c
parentf097f5ad808bd535236a65077f40e9d082a4ec0b (diff)
downloadgdb-02e12e3806bc60f66e3c446c4dfa9c06a400e604.zip
gdb-02e12e3806bc60f66e3c446c4dfa9c06a400e604.tar.gz
gdb-02e12e3806bc60f66e3c446c4dfa9c06a400e604.tar.bz2
Use std::vector in type stacks
This removes the use of VEC from parse.c and, at the same time, removes some related cleanups from c-exp.y. gdb/ChangeLog 2019-01-06 Tom Tromey <tom@tromey.com> * parser-defs.h (type_ptr): Remove typedef. Don't declare VEC. (union type_stack_elt) <typelist_val>: Now a pointer to std::vector. (type_stack_cleanup): Don't declare. (push_typelist): Update. * parse.c (pop_typelist): Return a std::vector. (push_typelist): Take a std::vector. (follow_types): Update. Do not free args. (type_stack_cleanup): Remove. * c-exp.y (struct c_parse_state): New. (cpstate): New global. (type_aggregate_p, exp, ptr_operator, parameter_typelist) (nonempty_typelist): Update. (func_mod): Create a new vector. (c_parse): Create a c_parse_state. (check_parameter_typelist): Do not delete params. (function_method): Update. Do not delete type_list.
Diffstat (limited to 'gdb/parse.c')
-rw-r--r--gdb/parse.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/gdb/parse.c b/gdb/parse.c
index de2d53b..e7168ac 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -1457,7 +1457,7 @@ pop_type_int (void)
/* Pop a type list element from the global type stack. */
-static VEC (type_ptr) *
+static std::vector<struct type *> *
pop_typelist (void)
{
gdb_assert (!type_stack.elements.empty ());
@@ -1501,7 +1501,7 @@ push_type_stack (struct type_stack *stack)
/* Copy the global type stack into a newly allocated type stack and
return it. The global stack is cleared. The returned type stack
- must be freed with type_stack_cleanup. */
+ must be freed with delete. */
struct type_stack *
get_type_stack (void)
@@ -1511,22 +1511,12 @@ get_type_stack (void)
return result;
}
-/* A cleanup function that destroys a single type stack. */
-
-void
-type_stack_cleanup (void *arg)
-{
- struct type_stack *stack = (struct type_stack *) arg;
-
- delete stack;
-}
-
/* Push a function type with arguments onto the global type stack.
LIST holds the argument types. If the final item in LIST is NULL,
then the function will be varargs. */
void
-push_typelist (VEC (type_ptr) *list)
+push_typelist (std::vector<struct type *> *list)
{
type_stack_elt elt;
elt.typelist_val = list;
@@ -1655,14 +1645,12 @@ follow_types (struct type *follow_type)
case tp_function_with_arguments:
{
- VEC (type_ptr) *args = pop_typelist ();
+ std::vector<struct type *> *args = pop_typelist ();
follow_type
= lookup_function_type_with_arguments (follow_type,
- VEC_length (type_ptr, args),
- VEC_address (type_ptr,
- args));
- VEC_free (type_ptr, args);
+ args->size (),
+ args->data ());
}
break;