ada: Further cleanup in finalization machinery
commit39cb85867dee738bd3773b63c2b48d5d0731dea5
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 9 Nov 2023 14:00:56 +0000 (9 15:00 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 28 Nov 2023 09:35:48 +0000 (28 10:35 +0100)
tree1b82a51f2afb76185059e67a2759e6ffe9f1cc13
parent1954686718b97f927061a2840326734f0449adeb
ada: Further cleanup in finalization machinery

When transient scopes are being materialized, they can give rise to a block
created around the construct being wrapped or not, depending on the kind of
construct.  In both cases finalization actions for the transient objects of
the scope are generated the same way, with normal finalization done manually
immediately after the construct and exceptional finalization deferred to the
enclosing scope by means of a hooking mechanism.

Now when the block is generated, it becomes this enclosing scope, so the
normal finalization that comes with it would also be done immediately after
the construct, even without normal finalization generated manually.

Therefore this change gets rid of the manual finalization as well as of the
hooking in the cases where the block is generated, leading to a significant
streamlining of the expanded code in these cases.  This requires fixing a
small inaccuracy of the Within_Case_Or_If_Expression predicate, which must
only be concerned with the dependent expressions, since those are the only
ones to be treated specially by the finalization machinery.

It also contains a small cleanup for the description of the transient scope
management present at the beginning of the exp_ch7.adb file.

gcc/ada/

* exp_ch7.ads (Expand_Cleanup_Actions): Move declaration to the
Finalization Management section.
* exp_ch7.adb (Transient Scope Management): Move description down to
after that of the general finalization and make a few changes.
(Insert_Actions_In_Scope_Around): Call Process_Transients_In_Scope
only if cleanups are being handled.
(Process_Transients_In_Scope): Remove redundant test on Clean.
* exp_util.ads (Within_Case_Or_If_Expression): Adjust description.
* exp_util.adb (Within_Case_Or_If_Expression): Only return true if
within the dependent expressions of the conditional expressions.
gcc/ada/exp_ch7.adb
gcc/ada/exp_ch7.ads
gcc/ada/exp_util.adb
gcc/ada/exp_util.ads