]> gcc.gnu.org Git - gcc.git/commit - gcc/ada/sem_ch8.adb
ada: Implement Aspects as fields under nodes
authorViljar Indus <indus@adacore.com>
Wed, 26 Jul 2023 10:29:14 +0000 (13:29 +0300)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 7 Nov 2023 09:15:04 +0000 (10:15 +0100)
commit76bf4321331b1d453555602407029344e1e1ee4a
treee3821e6f7bd7bf4dad7756bef8be642efbbfcafc
parentde4588f3680ccd0861e6b9a0a04e96d46fae178b
ada: Implement Aspects as fields under nodes

In the previous implementation Aspect Specifications were
stored in a separate table and not directly under each node.
This implementation included a lot of extra code that needed
to be maintained manually.

The new implementation stores Aspect_Specfications as a syntactic
field under each node. This removes the extra code that was needed
to store, traverse and clone aspects for nodes.

gcc/ada/

* aspects.adb (Exchange_Aspects): Removed. This method was
typically called after a Rewrite method. Now since the Rewrite
switches the aspects between the new and the old node it is no
longer needed.
(Has_Aspects): Converted to a utility method that performs the same
before as the previous Has_Aspects field did. Meaning it shows whether
a node actually has aspects or not.
(Copy_Aspects): New utility method that performs a deep copy of the
From nodes aspects.
(Aspect_Specfications): Removed. No longer needed. Replaced
by the primitive operation for the Aspect_Specification fields.
(Set_Aspect_Specifications): Likewise.
(Aspect_Specifications_Hash_Table): Remove the table and all the
utility methods for storing the old aspects.
* aspects.ads: Likewise.
* atree.adb (Copy_Separate_Tree): Remove custom code for aspects.
(New_Copy): Likewise.
(Replace): Likewise.
(Rewrite): Likewise.
* exp_ch3.adb (Expand_N_Object_Declaration): Keep the aspects from the old node.
* exp_ch6.adb (Validate_Subprogram_Calls): Previously aspects were ignored
because they were not on the tree. Explicitly ignore them here
when traversing the tree.
* exp_unst.adb (Build_Tables): Likewise
* gen_il-fields.ads: Remove Has_Aspects and add
Aspect_Specifications fields.
* gen_il-gen-gen_nodes.adb: Add Aspect_Specification fields
for all nodes that can have aspects. Additionally add
Expression_Copy for Aspect_Speficiations to avoid reusing
the Associated_Node for generic instantiation and aspect
analysis.
* ghost.adb (Remove_Ignored_Ghost_Node): Remove call to Remove_Aspects.
The rewritten node is a Null_Statement that cannot have aspects
and there is not anything to gain from removing them from the
Orignal_Node of N since it technically is not part of the active
tree.
* inline.adb (Process_Formals_In_Aspects): Simplify code for node traversal.
* par-ch13.adb: Avoid setting the parent explicitly for the
Aspect_Specifications list. This is done explicitly in the setter.
* par-ch6.adb: Likewise.
* par_sco.adb (Traverse_Aspects): Handle early return.
* sem_ch10.adb: Simplify code for Analyze_Aspect_Specifications.
* sem_ch11.adb: Likewise.
* sem_ch12.adb (Analyze_Formal_Derived_Interface_Type): Keep the aspects from
the orignal node after rewrite.
(Analyze_Formal_Derived_Type): Likewise.
(Analyze_Formal_Interface_Type): Likewise.
(Analyze_Formal_Object_Declaration): Simplify code for
Analyze_Aspect_Specifications.
(Analyze_Formal_Package_Declaration): Likewise.
(Analyze_Formal_Subprogram_Declaration): Likewise.
(Analyze_Formal_Type_Declaration): Likewise.
(Analyze_Generic_Package_Declaration): Remove Exchange_Aspects.
The new node already has the correct aspects after the rewrite.
Also simplify code for Analyze_Aspect_Specifications.
(Analyze_Generic_Subprogram_Declaration): Likewise.
(Analyze_Package_Instantiation): Simplify code for
Analyze_Aspect_Specifications.
(Build_Instance_Compilation_Unit_Nodes): Remove explicit copy of
aspects that is no longer needed.
(Save_References): Update the traversal code to handle
Aspect_Specifications in the tree.
(Copy_Generic_Node): Remove explicit copy for aspects. New_Copy
took care of that already.
* sem_ch13.adb (Analyze_Aspect_Specifications): Add early return to simplify
code for its calls. Avoid reusing the Entity(Associated_Node)
field for storing the original expression. Instead use the
new Expression_Copy field since Entity(Associated_Node) is
also used in generic instantiation.
(Analyze_Aspects_On_Subprogram_Body_Or_Stub): Simlify call
to Analyze_Aspect_Specifications.
(Check_Aspect_At_End_Of_Declarations): Use Expression_Copy
instead of Entity.
(Check_Aspect_At_Freeze_Point): Likewise.
* sem_ch3.adb: Simplify calls to Analyze_Aspect_Specifications.
* sem_ch6.adb (Analyze_Abstract_Subprogram_Declaration): Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Expression_Function): Keep the aspects from the
original node after a rewrite.
(Analyze_Generic_Subprogram_Body): Remove Exchange aspects
that is no longer needed. Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Null_Procedure): Keep the aspects from the
original node after a rewrite.
(Analyze_Subprogram_Body_Helper): Simplify calls to
Analyze_Aspect_Specifications.
(Analyze_Subprogram_Declaration): Likewise.
* sem_ch7.adb (Analyze_Package_Body_Helper): Remove Exchange aspects
that is no longer needed. Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Package_Declaration): Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Private_Type_Declaration): Likewise.
* sem_ch8.adb: Simplify calls to
Analyze_Aspect_Specifications.
* sem_ch9.adb (Analyze_Entry_Body): Simplify call to
Analyze_Aspects_On_Subprogram_Body_Or_Stub.
(Analyze_Entry_Declaration): Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Protected_Body): Likewise.
(Analyze_Protected_Type_Declaration): Likewise.
(Analyze_Single_Protected_Declaration): Keep the aspects from
the original node after a rewrite. Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Single_Task_Declaration): Likewise.
(Analyze_Task_Body): Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Task_Type_Declaration): Simplify calls to
Analyze_Aspect_Specifications.
* sem_dim.adb: Remove explicitly setting the parents
for the Aspect_Specification list.
* sem_disp.adb: Remove the with that is no longer
required since Aspect_Specifications is a node operation now.
* sem_util.adb (Copy_Node_With_Replacement): Remove explicit code for aspects.
* treepr.adb (Print_Field): Remove the version that was used for printing
aspects.
(Print_Node): Remove aspect specific code.
26 files changed:
gcc/ada/aspects.adb
gcc/ada/aspects.ads
gcc/ada/atree.adb
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch6.adb
gcc/ada/exp_unst.adb
gcc/ada/gen_il-fields.ads
gcc/ada/gen_il-gen-gen_nodes.adb
gcc/ada/ghost.adb
gcc/ada/inline.adb
gcc/ada/par-ch13.adb
gcc/ada/par-ch6.adb
gcc/ada/par_sco.adb
gcc/ada/sem_ch10.adb
gcc/ada/sem_ch11.adb
gcc/ada/sem_ch12.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_ch7.adb
gcc/ada/sem_ch8.adb
gcc/ada/sem_ch9.adb
gcc/ada/sem_dim.adb
gcc/ada/sem_disp.adb
gcc/ada/sem_util.adb
gcc/ada/treepr.adb
This page took 0.076813 seconds and 5 git commands to generate.