]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
vec: use auto_vec in a few more places
authorJason Merrill <jason@redhat.com>
Tue, 13 Jul 2021 18:42:09 +0000 (14:42 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 14 Jul 2021 19:01:27 +0000 (15:01 -0400)
The uses of vec<T> in get_all_loop_exits and process_conditional were memory
leaks, as .release() was never called for them.  The other changes are some
cases that did have proper release handling, but it's simpler to leave
releasing to the auto_vec destructor.

gcc/ChangeLog:

* sel-sched-ir.h (get_all_loop_exits): Use auto_vec.

gcc/cp/ChangeLog:

* class.c (struct find_final_overrider_data): Use auto_vec.
(find_final_overrider): Remove explicit release.
* coroutines.cc (process_conditional): Use auto_vec.
* cp-gimplify.c (struct cp_genericize_data): Use auto_vec.
(cp_genericize_tree): Remove explicit release.
* parser.c (cp_parser_objc_at_property_declaration): Use
auto_delete_vec.
* semantics.c (omp_reduction_lookup): Use auto_vec.

gcc/cp/class.c
gcc/cp/coroutines.cc
gcc/cp/cp-gimplify.c
gcc/cp/parser.c
gcc/cp/semantics.c
gcc/sel-sched-ir.h

index 33093e1e1ef7e8fc60432d6a0814e85306ca1b20..14db06692dc90c68b06a5870b4afdc5e2420e596 100644 (file)
@@ -2391,7 +2391,7 @@ struct find_final_overrider_data {
   /* The candidate overriders.  */
   tree candidates;
   /* Path to most derived.  */
-  vec<tree> path;
+  auto_vec<tree> path;
 };
 
 /* Add the overrider along the current path to FFOD->CANDIDATES.
@@ -2504,8 +2504,6 @@ find_final_overrider (tree derived, tree binfo, tree fn)
   dfs_walk_all (derived, dfs_find_final_overrider_pre,
                dfs_find_final_overrider_post, &ffod);
 
-  ffod.path.release ();
-
   /* If there was no winner, issue an error message.  */
   if (!ffod.candidates || TREE_CHAIN (ffod.candidates))
     return error_mark_node;
index 54ffdc8d06211d41e8c2afcc57ebef56686cde19..712a5c0ab37ed6024638686af903944140fda5d6 100644 (file)
@@ -3081,7 +3081,7 @@ process_conditional (var_nest_node *n, tree& vlist)
 {
   tree init = n->init;
   hash_map<tree, tree> var_flags;
-  vec<tree> var_list = vNULL;
+  auto_vec<tree> var_list;
   tree new_then = push_stmt_list ();
   handle_nested_conditionals (n->then_cl, var_list, var_flags);
   new_then = pop_stmt_list (new_then);
index 00b7772fe0d2afbbeaf3adffa21608477a28ccc8..de37f2cdfdca79414a1816153de3cdde79286b28 100644 (file)
@@ -807,7 +807,7 @@ omp_cxx_notice_variable (struct cp_genericize_omp_taskreg *omp_ctx, tree decl)
 struct cp_genericize_data
 {
   hash_set<tree> *p_set;
-  vec<tree> bind_expr_stack;
+  auto_vec<tree> bind_expr_stack;
   struct cp_genericize_omp_taskreg *omp_ctx;
   tree try_block;
   bool no_sanitize_p;
@@ -1582,7 +1582,6 @@ cp_genericize_tree (tree* t_p, bool handle_invisiref_parm_p)
   wtd.handle_invisiref_parm_p = handle_invisiref_parm_p;
   cp_walk_tree (t_p, cp_genericize_r, &wtd, NULL);
   delete wtd.p_set;
-  wtd.bind_expr_stack.release ();
   if (sanitize_flags_p (SANITIZE_VPTR))
     cp_ubsan_instrument_member_accesses (t_p);
 }
index 93698aa14c9e40e04c2cf59a630924625e79a6da..821ce1771a400e46985eaa770bc264041c4cfce9 100644 (file)
@@ -35247,7 +35247,7 @@ cp_parser_objc_at_property_declaration (cp_parser *parser)
   /* Parse the optional attribute list.
 
      A list of parsed, but not verified, attributes.  */
-  vec<property_attribute_info *> prop_attr_list = vNULL;
+  auto_delete_vec<property_attribute_info> prop_attr_list;
   location_t loc = cp_lexer_peek_token (parser->lexer)->location;
 
   cp_lexer_consume_token (parser->lexer);  /* Eat '@property'.  */
@@ -35423,10 +35423,6 @@ cp_parser_objc_at_property_declaration (cp_parser *parser)
     }
 
   cp_parser_consume_semicolon_at_end_of_statement (parser);
-
-  while (!prop_attr_list.is_empty())
-    delete prop_attr_list.pop ();
-  prop_attr_list.release ();
 }
 
 /* Parse an Objective-C++ @synthesize declaration.  The syntax is:
index b080259083e476801d4469cddf14c091bdd90f61..b97dc1f6624f143c85c9090d692552e213419f91 100644 (file)
@@ -5774,7 +5774,7 @@ omp_reduction_lookup (location_t loc, tree id, tree type, tree *baselinkp,
 
   if (!id && CLASS_TYPE_P (type) && TYPE_BINFO (type))
     {
-      vec<tree> ambiguous = vNULL;
+      auto_vec<tree> ambiguous;
       tree binfo = TYPE_BINFO (type), base_binfo, ret = NULL_TREE;
       unsigned int ix;
       if (ambiguousp == NULL)
@@ -5811,7 +5811,6 @@ omp_reduction_lookup (location_t loc, tree id, tree type, tree *baselinkp,
              if (idx == 0)
                str = get_spaces (str);
            }
-         ambiguous.release ();
          ret = error_mark_node;
          baselink = NULL_TREE;
        }
index 78b2566ad3e9dae86752a56fad660977af01bef4..8ee0529d5a86ea5bb28ace56479006b392554cec 100644 (file)
@@ -1166,7 +1166,7 @@ get_all_loop_exits (basic_block bb)
             || (inner_loop_header_p (e->dest)))
            && loop_depth (e->dest->loop_father) >= this_depth)
          {
-           vec<edge> next_exits = get_all_loop_exits (e->dest);
+           auto_vec<edge> next_exits = get_all_loop_exits (e->dest);
 
            if (next_exits.exists ())
              {