]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Rename finalization scope masters into finalization masters
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 1 Feb 2024 14:30:28 +0000 (15:30 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 13 May 2024 08:03:34 +0000 (10:03 +0200)
Now that what was previously called "finalization master" has been renamed
into "finalization collection" in the front-end, we can also rename what was
initially called "finalization scope master" into "finalization master".

These entities indeed drive the finalization of all the objects that require
it, directly for (statically) declared objects or indirectly for dynamically
allocated objects (that is to say, through finalization collections).

gcc/ada/

* exp_ch7.adb: Adjust the description of finalization management.
(Build_Finalizer): Rename scope master into master throughout.
* rtsfind.ads (RE_Id): Replace RE_Finalization_Scope_Master with
RE_Finalization_Master.
(RE_Unit_Table): Replace entry for RE_Finalization_Scope_Master with
entry for RE_Finalization_Master.
* libgnat/s-finpri.ads (Finalization_Scope_Master): Rename into...
(Finalization_Master): ...this.
(Attach_Object_To_Master): Adjust to above renaming.
(Chain_Node_To_Master): Likewise.
(Finalize_Master): Likewise.
* libgnat/s-finpri.adb (Attach_Object_To_Master): Likewise.
(Chain_Node_To_Master): Likewise.
(Finalize_Master): Likewise.

gcc/ada/exp_ch7.adb
gcc/ada/libgnat/s-finpri.adb
gcc/ada/libgnat/s-finpri.ads
gcc/ada/rtsfind.ads

index 50d5359e04d641b39ba0ce11bcf4936769a5d581..a62c7441a488e0fce3eed920e2a1ee838b6f8904 100644 (file)
@@ -85,10 +85,9 @@ package body Exp_Ch7 is
 
    --  Initialize calls: they are generated for either declarations or dynamic
    --  allocations of controlled objects with no initial value. They are always
-   --  followed by an attachment to the current finalization chain. For the
-   --  dynamic allocation case, this is the chain attached to the scope of the
-   --  access type definition; otherwise, this is the chain of the current
-   --  scope.
+   --  followed by an attachment to some finalization chain. For the dynamic
+   --  dynamic allocation case, this is the collection attached to the access
+   --  type definition; otherwise, this is the master of the current scope.
 
    --  Adjust calls: they are generated on two occasions: (1) for declarations
    --  or dynamic allocations of controlled objects with an initial value (with
@@ -122,7 +121,7 @@ package body Exp_Ch7 is
    --  is expanded into:
    --
    --    declare
-   --       Mnn : System.Finalization_Primitives.Finalization_Scope_Master;
+   --       Mnn : System.Finalization_Primitives.Finalization_Master;
 
    --       XMN : aliased System.Finalization_Primitives.Master_Node;
    --       X : Ctrl;
@@ -203,8 +202,8 @@ package body Exp_Ch7 is
    --    at end
    --       _Finalizer;
 
-   --  In the case of a block containing a single controlled object, the scope
-   --  master degenerates into a single master node:
+   --  In the case of a block containing a single controlled object, the master
+   --  degenerates into a single master node:
 
    --    declare
    --       X : Ctrl := Init;
@@ -268,7 +267,7 @@ package body Exp_Ch7 is
 
    --  These direct actions must be signalled to the post-processing machinery
    --  and this is achieved through the handling of Master_Node objects, which
-   --  are the items actually chained in finalization chains of scope masters.
+   --  are the items actually chained in the finalization chains of masters.
    --  With the default processing, they are created by Build_Finalizer for the
    --  controlled objects spotted by Requires_Cleanup_Actions. But when direct
    --  actions are carried out, they are generated by these actions and later
@@ -1702,8 +1701,8 @@ package body Exp_Ch7 is
       Finalizer_Decls : List_Id := No_List;
       --  Local variable declarations
 
-      Finalization_Scope_Master : Entity_Id;
-      --  The Finalization Scope Master object
+      Finalization_Master : Entity_Id;
+      --  The Finalization Master object
 
       Finalizer_Stmts : List_Id := No_List;
       --  The statement list of the finalizer body
@@ -1774,33 +1773,33 @@ package body Exp_Ch7 is
       ----------------------
 
       procedure Build_Components is
-         Constraints       : List_Id;
-         Scope_Master_Decl : Node_Id;
-         Scope_Master_Name : Name_Id;
+         Constraints : List_Id;
+         Master_Decl : Node_Id;
+         Master_Name : Name_Id;
 
       begin
          pragma Assert (Present (Decls));
 
          --  If the context contains controlled objects, then we create the
-         --  finalization scope master, unless there is a single such object;
-         --  in this common case, we'll directly finalize the object.
+         --  finalization master, unless there is a single such object: in
+         --  this common case, we'll directly finalize the object.
 
          if Has_Ctrl_Objs then
             if Counter_Val > 1 then
                if For_Package_Spec then
-                  Scope_Master_Name :=
+                  Master_Name :=
                     New_External_Name (Name_uMaster, Suffix => "_spec");
                elsif For_Package_Body then
-                  Scope_Master_Name :=
+                  Master_Name :=
                     New_External_Name (Name_uMaster, Suffix => "_body");
                else
-                  Scope_Master_Name := New_Internal_Name ('M');
+                  Master_Name := New_Internal_Name ('M');
                end if;
 
-               Finalization_Scope_Master :=
-                 Make_Defining_Identifier (Loc, Scope_Master_Name);
+               Finalization_Master :=
+                 Make_Defining_Identifier (Loc, Master_Name);
 
-               --  The scope master is statically parameterized by the context
+               --  The master is statically parameterized by the context
 
                Constraints := New_List;
                Append_To (Constraints,
@@ -1811,20 +1810,20 @@ package body Exp_Ch7 is
                Append_To (Constraints,
                  New_Occurrence_Of (Boolean_Literals (For_Package), Loc));
 
-               Scope_Master_Decl :=
+               Master_Decl :=
                  Make_Object_Declaration (Loc,
-                   Defining_Identifier => Finalization_Scope_Master,
+                   Defining_Identifier => Finalization_Master,
                    Object_Definition   =>
                      Make_Subtype_Indication (Loc,
                        Subtype_Mark =>
                          New_Occurrence_Of
-                           (RTE (RE_Finalization_Scope_Master), Loc),
+                           (RTE (RE_Finalization_Master), Loc),
                        Constraint  =>
                          Make_Index_Or_Discriminant_Constraint (Loc,
                            Constraints => Constraints)));
 
-               Prepend_To (Decls, Scope_Master_Decl);
-               Analyze (Scope_Master_Decl, Suppress => All_Checks);
+               Prepend_To (Decls, Master_Decl);
+               Analyze (Master_Decl, Suppress => All_Checks);
             end if;
 
             if Exceptions_OK then
@@ -1976,8 +1975,7 @@ package body Exp_Ch7 is
                Name                   =>
                  New_Occurrence_Of (RTE (RE_Finalize_Master), Loc),
                  Parameter_Associations =>
-                   New_List
-                     (New_Occurrence_Of (Finalization_Scope_Master, Loc)));
+                   New_List (New_Occurrence_Of (Finalization_Master, Loc)));
 
             --  For CodePeer, the exception handlers normally generated here
             --  generate complex flowgraphs which result in capacity problems.
@@ -2895,11 +2893,11 @@ package body Exp_Ch7 is
          --  Create the declaration of the Master_Node for the object and
          --  insert it before the declaration of the object itself, except
          --  for the case where it is the only object because it will play
-         --  the role of a degenerated scope master and therefore needs to
-         --  be inserted at the same place the scope master would have been.
+         --  the role of a degenerated master and therefore needs to be
+         --  inserted at the same place the master would have been.
 
          else pragma Assert (No (Finalization_Master_Node (Obj_Id)));
-            --  For one object, use the Sloc the scope master would have had
+            --  For one object, use the Sloc the master would have had
 
             if Counter_Val = 1 then
                Master_Node_Loc := Sloc (N);
@@ -3157,7 +3155,7 @@ package body Exp_Ch7 is
                      Make_Attribute_Reference (Loc,
                        Prefix         => New_Occurrence_Of (Obj_Id, Loc),
                        Attribute_Name => Name_Unrestricted_Access),
-                     New_Occurrence_Of (Finalization_Scope_Master, Loc)));
+                     New_Occurrence_Of (Finalization_Master, Loc)));
 
             --  Finalize_Address is not generated in CodePeer mode because the
             --  body contains address arithmetic. So we don't want to generate
@@ -3179,7 +3177,7 @@ package body Exp_Ch7 is
                        Prefix         =>
                          New_Occurrence_Of (Master_Node_Id, Loc),
                        Attribute_Name => Name_Unrestricted_Access),
-                     New_Occurrence_Of (Finalization_Scope_Master, Loc)));
+                     New_Occurrence_Of (Finalization_Master, Loc)));
             end if;
          end if;
 
index 731c913b2e76e39a447647e0d8d5941450d1b17c..1fbd391c66c9b7a897c95a505d387512b6b7dfba 100644 (file)
@@ -75,7 +75,7 @@ package body System.Finalization_Primitives is
      (Object_Address   : System.Address;
       Finalize_Address : not null Finalize_Address_Ptr;
       Node             : not null Master_Node_Ptr;
-      Master           : in out Finalization_Scope_Master)
+      Master           : in out Finalization_Master)
    is
    begin
       Attach_Object_To_Node (Object_Address, Finalize_Address, Node.all);
@@ -105,7 +105,7 @@ package body System.Finalization_Primitives is
 
    procedure Chain_Node_To_Master
      (Node   : not null Master_Node_Ptr;
-      Master : in out Finalization_Scope_Master)
+      Master : in out Finalization_Master)
    is
    begin
       Node.Next   := Master.Head;
@@ -234,7 +234,7 @@ package body System.Finalization_Primitives is
    -- Finalize_Master --
    ---------------------
 
-   procedure Finalize_Master (Master : in out Finalization_Scope_Master) is
+   procedure Finalize_Master (Master : in out Finalization_Master) is
       procedure Raise_From_Controlled_Operation (X : Exception_Occurrence);
       pragma Import (Ada, Raise_From_Controlled_Operation,
                                  "__gnat_raise_from_controlled_operation");
index 0632a72c1344a19396a042a81a7f9523de9737d5..9fe9ef47eb7618dc2cf0244f24d16df70c982569 100644 (file)
@@ -60,7 +60,7 @@ package System.Finalization_Primitives with Preelaborate is
    --  level of the program or associated with the declarative part of a
    --  subprogram or other closed scopes (block statements, for example).
 
-   type Finalization_Scope_Master
+   type Finalization_Master
      (Exceptions_OK : Boolean;
       Extra_Info    : Boolean;
       Library_Level : Boolean) is limited private;
@@ -71,7 +71,7 @@ package System.Finalization_Primitives with Preelaborate is
      (Object_Address   : System.Address;
       Finalize_Address : not null Finalize_Address_Ptr;
       Node             : not null Master_Node_Ptr;
-      Master           : in out Finalization_Scope_Master);
+      Master           : in out Finalization_Master);
    --  Associates a controlled object and its master node with a given master.
    --  Finalize_Address denotes the operation to be called to finalize the
    --  object (which could be a user-declared Finalize procedure or a procedure
@@ -89,12 +89,12 @@ package System.Finalization_Primitives with Preelaborate is
 
    procedure Chain_Node_To_Master
      (Node   : not null Master_Node_Ptr;
-      Master : in out Finalization_Scope_Master);
+      Master : in out Finalization_Master);
    --  Chain a master node to the given master. This is used to chain the node
    --  to the master of the enclosing scope for the objects that need special
    --  processing mentioned for Attach_Object_To_Node.
 
-   procedure Finalize_Master (Master : in out Finalization_Scope_Master);
+   procedure Finalize_Master (Master : in out Finalization_Master);
    --  Finalizes each of the controlled objects associated with Master, in the
    --  reverse of the order in which they were attached. Calls to the procedure
    --  with a Master that has already been finalized have no effects.
@@ -191,10 +191,10 @@ private
       Next             : Master_Node_Ptr      := null;
    end record;
 
-    --  Finalization scope master type structure. A unique master is associated
+    --  Finalization master type structure. A unique master is associated
     --  with each scope containing controlled objects.
 
-   type Finalization_Scope_Master
+   type Finalization_Master
      (Exceptions_OK : Boolean;
       Extra_Info    : Boolean;
       Library_Level : Boolean) is limited
index 266bdb471fe43f70bcc96f6a1295ad9614fca768..d67dc0e678370ef0953435bb1fbe228d4f47af22 100644 (file)
@@ -923,7 +923,7 @@ package Rtsfind is
      RE_Chain_Node_To_Master,            -- System.Finalization_Primitives
      RE_Finalization_Collection,         -- System.Finalization_Primitives
      RE_Finalization_Collection_Ptr,     -- System.Finalization_Primitives
-     RE_Finalization_Scope_Master,       -- System.Finalization_Primitives
+     RE_Finalization_Master,             -- System.Finalization_Primitives
      RE_Finalize_Master,                 -- System.Finalization_Primitives
      RE_Finalize_Object,                 -- System.Finalization_Primitives
      RE_Master_Node,                     -- System.Finalization_Primitives
@@ -2572,7 +2572,7 @@ package Rtsfind is
      RE_Chain_Node_To_Master             => System_Finalization_Primitives,
      RE_Finalization_Collection          => System_Finalization_Primitives,
      RE_Finalization_Collection_Ptr      => System_Finalization_Primitives,
-     RE_Finalization_Scope_Master        => System_Finalization_Primitives,
+     RE_Finalization_Master              => System_Finalization_Primitives,
      RE_Finalize_Master                  => System_Finalization_Primitives,
      RE_Finalize_Object                  => System_Finalization_Primitives,
      RE_Master_Node                      => System_Finalization_Primitives,