Remove DEF_VECs from symtab.h
authorTom Tromey <tom@tromey.com>
Sun, 14 Oct 2018 18:18:21 +0000 (12:18 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 26 Oct 2018 23:15:10 +0000 (17:15 -0600)
This removes a couple of DEF_VECs from symtab.h, replacing them with
std::vector at the points of use.

gdb/ChangeLog
2018-10-26  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (recursively_compute_inclusions): Use std::vector.
(compute_compunit_symtab_includes): Update.
* symtab.h: (symtab_ptr): Remove typedef.  Don't define a VEC.
(compunit_symtab_ptr): Likewise.

gdb/ChangeLog
gdb/dwarf2read.c
gdb/symtab.h

index a8d15aa..1f8e958 100644 (file)
@@ -1,3 +1,10 @@
+2018-10-26  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2read.c (recursively_compute_inclusions): Use std::vector.
+       (compute_compunit_symtab_includes): Update.
+       * symtab.h: (symtab_ptr): Remove typedef.  Don't define a VEC.
+       (compunit_symtab_ptr): Likewise.
+
 2018-10-26  John Baldwin  <jhb@FreeBSD.org>
 
        * fbsd-tdep.c (fbsd_print_auxv_entry): Only use
index 2a1b805..1b4f966 100644 (file)
@@ -10210,7 +10210,7 @@ get_compunit_symtab (struct dwarf2_per_cu_data *per_cu)
    included by PER_CU.  */
 
 static void
-recursively_compute_inclusions (VEC (compunit_symtab_ptr) **result,
+recursively_compute_inclusions (std::vector<compunit_symtab *> *result,
                                htab_t all_children, htab_t all_type_symtabs,
                                struct dwarf2_per_cu_data *per_cu,
                                struct compunit_symtab *immediate_parent)
@@ -10240,14 +10240,14 @@ recursively_compute_inclusions (VEC (compunit_symtab_ptr) **result,
          if (*slot == NULL)
            {
              *slot = cust;
-             VEC_safe_push (compunit_symtab_ptr, *result, cust);
+             result->push_back (cust);
              if (cust->user == NULL)
                cust->user = immediate_parent;
            }
        }
       else
        {
-         VEC_safe_push (compunit_symtab_ptr, *result, cust);
+         result->push_back (cust);
          if (cust->user == NULL)
            cust->user = immediate_parent;
        }
@@ -10274,8 +10274,7 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu)
     {
       int ix, len;
       struct dwarf2_per_cu_data *per_cu_iter;
-      struct compunit_symtab *compunit_symtab_iter;
-      VEC (compunit_symtab_ptr) *result_symtabs = NULL;
+      std::vector<compunit_symtab *> result_symtabs;
       htab_t all_children, all_type_symtabs;
       struct compunit_symtab *cust = get_compunit_symtab (per_cu);
 
@@ -10299,18 +10298,14 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu)
        }
 
       /* Now we have a transitive closure of all the included symtabs.  */
-      len = VEC_length (compunit_symtab_ptr, result_symtabs);
+      len = result_symtabs.size ();
       cust->includes
        = XOBNEWVEC (&per_cu->dwarf2_per_objfile->objfile->objfile_obstack,
                     struct compunit_symtab *, len + 1);
-      for (ix = 0;
-          VEC_iterate (compunit_symtab_ptr, result_symtabs, ix,
-                       compunit_symtab_iter);
-          ++ix)
-       cust->includes[ix] = compunit_symtab_iter;
+      memcpy (cust->includes, result_symtabs.data (),
+             len * sizeof (compunit_symtab *));
       cust->includes[len] = NULL;
 
-      VEC_free (compunit_symtab_ptr, result_symtabs);
       htab_delete (all_children);
       htab_delete (all_type_symtabs);
     }
index 399666b..b91ec12 100644 (file)
@@ -1357,9 +1357,6 @@ struct symtab
 #define SYMTAB_DIRNAME(symtab) \
   COMPUNIT_DIRNAME (SYMTAB_COMPUNIT (symtab))
 
-typedef struct symtab *symtab_ptr;
-DEF_VEC_P (symtab_ptr);
-
 /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well
    as the list of all source files (what gdb has historically associated with
    the term "symtab").
@@ -1501,9 +1498,6 @@ extern struct symtab *
 
 extern enum language compunit_language (const struct compunit_symtab *cust);
 
-typedef struct compunit_symtab *compunit_symtab_ptr;
-DEF_VEC_P (compunit_symtab_ptr);
-
 \f
 
 /* The virtual function table is now an array of structures which have the