diff mbox

Remove DEF_VECs from symtab.h

Message ID 20181017140411.4539-1-tom@tromey.com
State New
Headers show

Commit Message

Tom Tromey Oct. 17, 2018, 2:04 p.m. UTC
This removes a couple of DEF_VECs from symtab.h, replacing them with
std::vector at the points of use.

gdb/ChangeLog
2018-10-17  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    |  7 +++++++
 gdb/dwarf2read.c | 19 +++++++------------
 gdb/symtab.h     |  6 ------
 3 files changed, 14 insertions(+), 18 deletions(-)

Comments

Tom Tromey Oct. 26, 2018, 11:16 p.m. UTC | #1
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> This removes a couple of DEF_VECs from symtab.h, replacing them with
Tom> std::vector at the points of use.

I'm checking this in now.

Tom
diff mbox

Patch

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 2a1b805c9a..1b4f966cc3 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -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);
     }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 399666b473..b91ec12b29 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -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);
-
 
 
 /* The virtual function table is now an array of structures which have the