cp-tree.h (unemitted_tinfo_decls): Make a VEC(tree).
authorNathan Sidwell <nathan@codesourcery.com>
Wed, 22 Sep 2004 18:12:10 +0000 (18:12 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 22 Sep 2004 18:12:10 +0000 (18:12 +0000)
* cp-tree.h (unemitted_tinfo_decls): Make a VEC(tree).
* decl2.c (cp_finish_file): Adjust tinfo decl emission loop.
* rtti.c (unemitted_tinfo_decls): Make a VEC(tree).
(init_rtti_processing): Initialize it to something realistic.
(get_tinfo_decl): Adjust pushing the new decl.

From-SVN: r87872

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl2.c
gcc/cp/rtti.c

index f88f663fedf1a1ff03b313c3594f25c296ec4889..e91d4251d8df456ee3062bafecb6d5571e4261a9 100644 (file)
@@ -1,5 +1,11 @@
 2004-09-22  Nathan Sidwell  <nathan@codesourcery.com>
 
+       * cp-tree.h (unemitted_tinfo_decls): Make a VEC(tree).
+       * decl2.c (cp_finish_file): Adjust tinfo decl emission loop.
+       * rtti.c (unemitted_tinfo_decls): Make a VEC(tree).
+       (init_rtti_processing): Initialize it to something realistic.
+       (get_tinfo_decl): Adjust pushing the new decl.
+
        * cp-tree.h (struct lang_type_class): Remove marked flags, add
        diamond_shaped and repeated_base flags.  Reorder to keep 8-bit blocks.
        (TYPE_MARKED_P): New.
index 417d179ff0dd34f444b9dd1bc376efd5fd23e239..c439864c1b12b3db6259c9a88c1a2c83ed7658f4 100644 (file)
@@ -3967,8 +3967,8 @@ extern bool repo_export_class_p (tree);
 extern void finish_repo (void);
 
 /* in rtti.c */
-/* A varray of all tinfo decls that haven't been emitted yet.  */
-extern GTY(()) varray_type unemitted_tinfo_decls;
+/* A vector of all tinfo decls that haven't been emitted yet.  */
+extern GTY(()) VEC(tree) *unemitted_tinfo_decls;
 
 extern void init_rtti_processing (void);
 extern tree build_typeid (tree);
index 0c05a7ad160c6e39ef8ea2be11d1ed3750e133cd..8506ea3b3b8bb9bfd583fc6e01bc88b2f106cd42 100644 (file)
@@ -2780,7 +2780,6 @@ cp_finish_file (void)
   do 
     {
       tree t;
-      size_t n_old, n_new;
 
       reconsider = false;
 
@@ -2823,32 +2822,16 @@ cp_finish_file (void)
 
       /* Write out needed type info variables.  We have to be careful
         looping through unemitted decls, because emit_tinfo_decl may
-        cause other variables to be needed.  We stick new elements
-        (and old elements that we may need to reconsider) at the end
-        of the array, then shift them back to the beginning once we're
-        done.  */
-
-      n_old = VARRAY_ACTIVE_SIZE (unemitted_tinfo_decls);
-      for (i = 0; i < n_old; ++i)
-       {
-         tree tinfo_decl = VARRAY_TREE (unemitted_tinfo_decls, i);
-         if (emit_tinfo_decl (tinfo_decl))
-           reconsider = true;
-         else
-           VARRAY_PUSH_TREE (unemitted_tinfo_decls, tinfo_decl);
-       }
-  
-      /* The only elements we want to keep are the new ones.  Copy
-        them to the beginning of the array, then get rid of the
-        leftovers.  */
-      n_new = VARRAY_ACTIVE_SIZE (unemitted_tinfo_decls) - n_old;
-      if (n_new)
-       memmove (&VARRAY_TREE (unemitted_tinfo_decls, 0),
-                &VARRAY_TREE (unemitted_tinfo_decls, n_old),
-                n_new * sizeof (tree));
-      memset (&VARRAY_TREE (unemitted_tinfo_decls, n_new),
-             0, n_old * sizeof (tree));
-      VARRAY_ACTIVE_SIZE (unemitted_tinfo_decls) = n_new;
+        cause other variables to be needed. New elements will be
+        appended, and we remove from the vector those that actually
+        get emitted.  */
+      for (i = VEC_length (tree, unemitted_tinfo_decls);
+          VEC_iterate (tree, unemitted_tinfo_decls, --i, t);)
+       if (emit_tinfo_decl (t))
+         {
+           reconsider = true;
+           VEC_unordered_remove (tree, unemitted_tinfo_decls, i);
+         }
 
       /* The list of objects with static storage duration is built up
         in reverse order.  We clear STATIC_AGGREGATES so that any new
index 2dc05ad3cab8d87dc87127ed730073454e3fa36d..b995726e09b459909788c1466fa14459611869ec 100644 (file)
@@ -73,8 +73,8 @@ Boston, MA 02111-1307, USA.  */
 /* The IDENTIFIER_NODE naming the real class.  */
 #define TINFO_REAL_NAME(NODE) TREE_PURPOSE (NODE)
 
-/* A varray of all tinfo decls that haven't yet been emitted.  */
-varray_type unemitted_tinfo_decls;
+/* A vector of all tinfo decls that haven't yet been emitted.  */
+VEC (tree) *unemitted_tinfo_decls;
 
 static tree build_headof (tree);
 static tree ifnonnull (tree, tree);
@@ -120,8 +120,8 @@ init_rtti_processing (void)
   type_info_ptr_type = build_pointer_type (const_type_info_type);
   type_info_ref_type = build_reference_type (const_type_info_type);
 
-  VARRAY_TREE_INIT (unemitted_tinfo_decls, 10, "RTTI decls");
-
+  unemitted_tinfo_decls = VEC_alloc (tree, 124);
+  
   create_tinfo_types ();
 }
 
@@ -361,8 +361,7 @@ get_tinfo_decl (tree type)
       pushdecl_top_level_and_finish (d, NULL_TREE);
 
       /* Add decl to the global array of tinfo decls.  */
-      gcc_assert (unemitted_tinfo_decls != 0);
-      VARRAY_PUSH_TREE (unemitted_tinfo_decls, d);
+      VEC_safe_push (tree, unemitted_tinfo_decls, d);
     }
 
   return d;