From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 2D20A3857004 for ; Wed, 14 Jul 2021 19:10:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2D20A3857004 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-257-ShmOS6OBNLe_R063wSG1KA-1; Wed, 14 Jul 2021 15:10:42 -0400 X-MC-Unique: ShmOS6OBNLe_R063wSG1KA-1 Received: by mail-qk1-f200.google.com with SMTP id x2-20020ae9e6420000b02903b8853778c2so1946471qkl.18 for ; Wed, 14 Jul 2021 12:10:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=789JNOV1GeHy6grjaOuaP07qW1psZEjJmOoz1+O2YrE=; b=GicfBbrGAUvllJDbYtLkzSImtlNEYUFdo2vacPUYLVd8NBTN9UpdAYf76zmjC28lrn Ty2dLA8YAlXiZE8Hu2A2iZIvxSeep4HekJwzJ4kIF5FPwYqK8Ce6Wy0B5eYnG35HRvUB 7AUrXPeyNNweBcUpL+onnVc0n6lNquYc5RbCZhdQV1xeLWDehjrI1tdQXCDeCsOeppij jMuYeK5KaJB+Q5fxx05KL+pKbNyHZXqHU9I2NVNoBCA1gdq9qH3rx/A7x2DzxJewqlfZ HUAdLSOJcR15V5ofUxwIq9cy0N+c8DcN3qyCSqhAKkBRgNpkGaeGRwagMTkdgqVrtKbN JKAw== X-Gm-Message-State: AOAM531uRxuVZ9OQNZj+mCtYmg94iRC+SoVZsDzA663cN7nJh0X6Bo58 HE5PwwpnDOPky8pMgY7ZvQDIFYvz6HgcKVzbsmA8uNwPpy/cy8nEG2kZ+Gk2CjWYhPb+0oUoQiH rexFVAdikVun3nt87HD0320uH82VGcIH3tsM28eDXYlus9AmA0c+SRGA0hB8FIDL5WA== X-Received: by 2002:ae9:ea18:: with SMTP id f24mr11440547qkg.177.1626289841598; Wed, 14 Jul 2021 12:10:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/SHJAF2BFmlGHotOXuD7wvhi/fKgbjyTaQsx5hWaRFGftJKrSmBARFJhKV36o1rlQ9VjiAw== X-Received: by 2002:ae9:ea18:: with SMTP id f24mr11440524qkg.177.1626289841248; Wed, 14 Jul 2021 12:10:41 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s11817.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id y24sm1568451qkj.4.2021.07.14.12.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 12:10:40 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] vec: use auto_vec in a few more places Date: Wed, 14 Jul 2021 15:10:38 -0400 Message-Id: <20210714191038.352409-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jul 2021 19:10:47 -0000 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. Tested x86_64-pc-linux-gnu, applying to trunk. 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/sel-sched-ir.h | 2 +- gcc/cp/class.c | 4 +--- gcc/cp/coroutines.cc | 2 +- gcc/cp/cp-gimplify.c | 3 +-- gcc/cp/parser.c | 6 +----- gcc/cp/semantics.c | 3 +-- 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/gcc/sel-sched-ir.h b/gcc/sel-sched-ir.h index 78b2566ad3e..8ee0529d5a8 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 ()) { diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 33093e1e1ef..14db06692dc 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 54ffdc8d062..712a5c0ab37 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 00b7772fe0d..de37f2cdfdc 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 93698aa14c9..821ce1771a4 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 b080259083e..b97dc1f6624 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; } base-commit: b15e301748f0e042379909e32b3ade439dd8f8f9 -- 2.27.0