From: Jason Merrill Date: Tue, 13 Jul 2021 18:42:09 +0000 (-0400) Subject: vec: use auto_vec in a few more places X-Git-Tag: basepoints/gcc-13~6005 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91bb571d200e551f427e337e00494e0b4f229876;p=thirdparty%2Fgcc.git vec: use auto_vec in a few more places The uses of vec 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. --- diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 33093e1e1ef7..14db06692dc9 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2391,7 +2391,7 @@ struct find_final_overrider_data { /* The candidate overriders. */ tree candidates; /* Path to most derived. */ - vec path; + auto_vec 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; diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 54ffdc8d0621..712a5c0ab37e 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -3081,7 +3081,7 @@ process_conditional (var_nest_node *n, tree& vlist) { tree init = n->init; hash_map var_flags; - vec var_list = vNULL; + auto_vec 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); diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 00b7772fe0d2..de37f2cdfdca 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -807,7 +807,7 @@ omp_cxx_notice_variable (struct cp_genericize_omp_taskreg *omp_ctx, tree decl) struct cp_genericize_data { hash_set *p_set; - vec bind_expr_stack; + auto_vec 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); } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 93698aa14c9e..821ce1771a40 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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 prop_attr_list = vNULL; + auto_delete_vec 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: diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b080259083e4..b97dc1f6624f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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 ambiguous = vNULL; + auto_vec 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; } diff --git a/gcc/sel-sched-ir.h b/gcc/sel-sched-ir.h index 78b2566ad3e9..8ee0529d5a86 100644 --- a/gcc/sel-sched-ir.h +++ b/gcc/sel-sched-ir.h @@ -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 next_exits = get_all_loop_exits (e->dest); + auto_vec next_exits = get_all_loop_exits (e->dest); if (next_exits.exists ()) {