Remove a VEC from aarch64-tdep.c
authorTom Tromey <tom@tromey.com>
Tue, 24 Jul 2018 01:51:58 +0000 (19:51 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 4 May 2019 20:40:55 +0000 (14:40 -0600)
This removes a VEC from aarch64-tdep.c, replacing it with a
std::vector.

gdb/ChangeLog
2019-05-04  Tom Tromey  <tom@tromey.com>

* aarch64-tdep.c (stack_item_t): Remove typedef and DEF_VEC.
(struct aarch64_call_info): Add initializers.
<si>: Now a std::vector.
(pass_on_stack, aarch64_push_dummy_call): Update.

gdb/ChangeLog
gdb/aarch64-tdep.c

index 5c6740a878ac1c22c1600a9019bbbd5fbfdad6ae..51aac88e8dc0c41a6650f3b543cf844f5a3e2d5e 100644 (file)
@@ -1,3 +1,10 @@
+2019-05-04  Tom Tromey  <tom@tromey.com>
+
+       * aarch64-tdep.c (stack_item_t): Remove typedef and DEF_VEC.
+       (struct aarch64_call_info): Add initializers.
+       <si>: Now a std::vector.
+       (pass_on_stack, aarch64_push_dummy_call): Update.
+
 2019-05-04  Simon Marchi  <simon.marchi@efficios.com>
            Tom Tromey  <tom@tromey.com>
 
index f8b4fa4c9743eda7a19e0e6b7dfb0090deb15e7a..2c8c6a1bdc32bb01894cc66efc0d8374d1245726 100644 (file)
@@ -1206,7 +1206,7 @@ aarch64_execute_dwarf_cfa_vendor_op (struct gdbarch *gdbarch, gdb_byte op,
 /* When arguments must be pushed onto the stack, they go on in reverse
    order.  The code below implements a FILO (stack) to do this.  */
 
-typedef struct
+struct stack_item_t
 {
   /* Value to pass on stack.  It can be NULL if this item is for stack
      padding.  */
@@ -1214,9 +1214,7 @@ typedef struct
 
   /* Size in bytes of value to pass on stack.  */
   int len;
-} stack_item_t;
-
-DEF_VEC_O (stack_item_t);
+};
 
 /* Implement the gdbarch type alignment method, overrides the generic
    alignment algorithm for anything that is aarch64 specific.  */
@@ -1392,22 +1390,22 @@ aapcs_is_vfp_call_or_return_candidate (struct type *type, int *count,
 struct aarch64_call_info
 {
   /* the current argument number.  */
-  unsigned argnum;
+  unsigned argnum = 0;
 
   /* The next general purpose register number, equivalent to NGRN as
      described in the AArch64 Procedure Call Standard.  */
-  unsigned ngrn;
+  unsigned ngrn = 0;
 
   /* The next SIMD and floating point register number, equivalent to
      NSRN as described in the AArch64 Procedure Call Standard.  */
-  unsigned nsrn;
+  unsigned nsrn = 0;
 
   /* The next stacked argument address, equivalent to NSAA as
      described in the AArch64 Procedure Call Standard.  */
-  unsigned nsaa;
+  unsigned nsaa = 0;
 
   /* Stack item vector.  */
-  VEC(stack_item_t) *si;
+  std::vector<stack_item_t> si;
 };
 
 /* Pass a value in a sequence of consecutive X registers.  The caller
@@ -1521,7 +1519,7 @@ pass_on_stack (struct aarch64_call_info *info, struct type *type,
 
   item.len = len;
   item.data = buf;
-  VEC_safe_push (stack_item_t, info->si, &item);
+  info->si.push_back (item);
 
   info->nsaa += len;
   if (info->nsaa & (align - 1))
@@ -1532,7 +1530,7 @@ pass_on_stack (struct aarch64_call_info *info, struct type *type,
       item.len = pad;
       item.data = NULL;
 
-      VEC_safe_push (stack_item_t, info->si, &item);
+      info->si.push_back (item);
       info->nsaa += pad;
     }
 }
@@ -1632,8 +1630,6 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   int argnum;
   struct aarch64_call_info info;
 
-  memset (&info, 0, sizeof (info));
-
   /* We need to know what the type of the called function is in order
      to determine the number of named/anonymous arguments for the
      actual argument placement, and the return type in order to handle
@@ -1762,18 +1758,16 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   if (info.nsaa & 15)
     sp -= 16 - (info.nsaa & 15);
 
-  while (!VEC_empty (stack_item_t, info.si))
+  while (!info.si.empty ())
     {
-      stack_item_t *si = VEC_last (stack_item_t, info.si);
+      const stack_item_t &si = info.si.back ();
 
-      sp -= si->len;
-      if (si->data != NULL)
-       write_memory (sp, si->data, si->len);
-      VEC_pop (stack_item_t, info.si);
+      sp -= si.len;
+      if (si.data != NULL)
+       write_memory (sp, si.data, si.len);
+      info.si.pop_back ();
     }
 
-  VEC_free (stack_item_t, info.si);
-
   /* Finally, update the SP register.  */
   regcache_cooked_write_unsigned (regcache, AARCH64_SP_REGNUM, sp);
 
This page took 0.041578 seconds and 4 git commands to generate.