From patchwork Fri Jan 7 16:27:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 49711 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 988F43857C51 for ; Fri, 7 Jan 2022 16:44:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 988F43857C51 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641573872; bh=8Hpbef0PuvGtP71L9PfWOw44LQSoXtq1XMOt9auMXTs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=U9elKmW2lZp3Xh8o3DDXmrWH6pS5w+PxcGft9B3qc+bZGHOk2C0uSsifsBaSrUach DDUPEklv4uujC/jQdE+iRKNYCKvPS4WVZp0dPJOL5Dx1NZxEewOUU1Mo0wROBp+kDv W39xPzYXBkm1aLK22ZGn26lJxleh6X2FOBXpFcIg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 61A703857C69 for ; Fri, 7 Jan 2022 16:27:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 61A703857C69 Received: by mail-wm1-x32a.google.com with SMTP id d187-20020a1c1dc4000000b003474b4b7ebcso2540228wmd.5 for ; Fri, 07 Jan 2022 08:27:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=8Hpbef0PuvGtP71L9PfWOw44LQSoXtq1XMOt9auMXTs=; b=cuDjwRtlq7a6qXFQE/enJWsLmLPe0MW5vTcB5DM8wjnzeQJhUprRB2OX6wi4H14u/C hGz+SNHt/t0a+M68Nj+ha4wGMhpk77+aMY77UJGA+LIJgqAbEzDMpXmoAmq+/N56wYnc WD4Bc1agJ9uenDwYN88sR9It5wMOHdDUzmS6jDXSAqKJ9mbhhi6DSZiUeQDup7lUCvB0 AnyDJpyiC9rK5Luogu58yucTDusPnEKDIZcdcUNFsfCJ4EVPhg7Q5HYkRnHUEQVnXSx0 kC7KnAHlp5vy40wJKo6m078Yo9+p+JMoqh0XyZ4J8s2eIBh0cUKsF8xut2nU4QcivhEN bbTA== X-Gm-Message-State: AOAM531zILwNtvUEZCcERSDKN7+huG82c3sqCY+5JrcgXpICky0ItZB/ hBj9N4dEpVIiooiJ32nfIQySO3jX/fF10Q== X-Google-Smtp-Source: ABdhPJxAQo9FTA4NcHiRdKaUphdmvbpzUb8P3xQy+ZMsfFXlBCO6kaG+A6aNDyswt4mrXtabK1ptjg== X-Received: by 2002:a05:600c:2902:: with SMTP id i2mr11835460wmd.97.1641572834414; Fri, 07 Jan 2022 08:27:14 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id h14sm5024773wrz.31.2022.01.07.08.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 08:27:13 -0800 (PST) Date: Fri, 7 Jan 2022 16:27:13 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Simplify traversal in hooking of transient scopes Message-ID: <20220107162713.GA948565@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Subprogram calls can be detected with just Traverse_Func, we don't need a separate global variable or a Traverse_Proc (which is a wrapper for Traverse_Func with a yet another variable). Cleanup related to handling of transient scopes in various routines for (pre)analysis and resolution. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch7.adb (Process_Transients_In_Scope): Remove unnecessary initialization of Must_Hook; change Detect_Subprogram_Call from function to procedure; adapt caller. diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -6188,15 +6188,15 @@ package body Exp_Ch7 is Last_Object : Node_Id; Related_Node : Node_Id) is - Must_Hook : Boolean := False; + Must_Hook : Boolean; -- Flag denoting whether the context requires transient object -- export to the outer finalizer. function Is_Subprogram_Call (N : Node_Id) return Traverse_Result; - -- Determine whether an arbitrary node denotes a subprogram call + -- Return Abandon if arbitrary node denotes a subprogram call - procedure Detect_Subprogram_Call is - new Traverse_Proc (Is_Subprogram_Call); + function Has_Subprogram_Call is + new Traverse_Func (Is_Subprogram_Call); procedure Process_Transient_In_Scope (Obj_Decl : Node_Id; @@ -6216,7 +6216,6 @@ package body Exp_Ch7 is -- A regular procedure or function call if Nkind (N) in N_Subprogram_Call then - Must_Hook := True; return Abandon; -- Special cases @@ -6226,20 +6225,13 @@ package body Exp_Ch7 is -- of the call. elsif Is_Rewrite_Substitution (N) then - Detect_Subprogram_Call (Original_Node (N)); - - if Must_Hook then - return Abandon; - else - return OK; - end if; + return Has_Subprogram_Call (Original_Node (N)); -- Generalized indexing always involves a function call elsif Nkind (N) = N_Indexed_Component and then Present (Generalized_Indexing (N)) then - Must_Hook := True; return Abandon; -- Keep searching @@ -6476,8 +6468,8 @@ package body Exp_Ch7 is -- due to the possibility of abnormal call termination. else - Detect_Subprogram_Call (N); - Blk_Ins := Last_Object; + Must_Hook := Has_Subprogram_Call (N) = Abandon; + Blk_Ins := Last_Object; end if; if Clean then