]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Flexible AST node structure
authorBob Duff <duff@adacore.com>
Tue, 14 Jul 2020 21:10:19 +0000 (17:10 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 20 Oct 2020 07:21:35 +0000 (03:21 -0400)
commit83dcc2bd35e5dc981a13959b9bb6750736cd6544
treeb2ecadbe1434218ceaec2b21a0539708482a3755
parent1b93e420fc10f0eaeb2b09d9b86c8defb5b459a4
[Ada] Flexible AST node structure

gcc/ada/

* atree.ads: Make Default_Node a constant.  Remove the
modification of Comes_From_Source, and use a separate flag for
that.  Change Sloc to 0; it always overwritten, and never left
as the No_Location value.
(Print_Statistics): Move to spec so we can call it from
gnat1drv.
(Num_Nodes): Rename to clarify that this is approximate.
Correct comment: nodes and entities are never deleted, the count
is never decremented, and this is not used by Xref.
(Initialize): Correct comment: Error_List is not created here.
Other minor naming and comment changes.
* atree.adb (Extend_Node, New_Copy, New_Entity, New_Node):
Streamline these. Simplify and improve efficiency.  Move code
from Allocate_Initialize_Node to these, where it can be executed
unconditionally.  Take advantage of automatic zeroing of the
Nodes table.
(Allocate_Initialize_Node): Remove this. It was an efficiency
bottleneck, and somewhat complicated, because it was called from
4 places, and had all sorts of conditionals to check where it
was called from. Better to move most of that code to the call
sites, where it can be executed (or not) unconditionally.
(Allocate_New_Node): New procedure to partly replace
Allocate_Initialize_Node (called from just 2 of those 4 places).
(Comes_From_Source_Default): New flag written/read by
Set_Comes_From_Source_Default/Get_Comes_From_Source_Default.
This allows us to make Default_Node into a constant with
all-zeros value.
(Set_Paren_Count_Of_Copy): New procedure to avoid duplicated
code.
(Report): New procedure to encapsulate the call to the reporting
procedure.
(Atree_Private_Part): We now need a body for this package, to
contain package body Nodes.
(Approx_Num_Nodes_And_Entities): Was Num_Nodes.  For efficiency,
compute the answer from Nodes.Last. That way we don't need to
increment a counter on every node creation. Other minor naming
and comment changes.
* gnat1drv.adb: Call Atree.Print_Statistics if -gnatd.A switch
was given.  Add comment documenting the new order dependency (we
must process the command line before calling Atree.Initialize).
* debug.adb: Document -gnatd.A.
* einfo.adb, sinfo.adb: Remove useless Style_Checks pragmas.
* nlists.ads (Allocate_List_Tables): Inline makes node creation
a little faster.
* nlists.adb (Initialize): Remove local constant E, which didn't
seem to add clarity.
* treepr.adb (Print_Init): Use renamed
Approx_Num_Nodes_And_Entities function.
* types.ads: Change the Low and High bounds as described above.
* types.h: Change Low and High bounds to match types.ads.
* sem_ch8.adb, namet.adb, namet.ads: Move the computation of
Last_Name_Id from sem_ch8 to namet, and correct it to not assume
Name_Ids are positive.
* ali.adb, ali-util.adb, bindo-writers.adb, exp_dist.adb,
fmap.adb, fname-uf.adb, osint.adb: Fix various hash functions to
avoid assuming the various ranges are positive. Note that "mod"
returns a nonnegative result when the second operand is
positive. "rem" can return negative values in that case (in
particular, if the first operand is negative, which it now is).
* switch-c.adb: Allow switch -gnaten to control the value of
Nodes_Size_In_Meg.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Remove traling whitespaces.
* opt.ads (Nodes_Size_In_Meg): New Variable.
24 files changed:
gcc/ada/ali-util.adb
gcc/ada/ali.adb
gcc/ada/atree.adb
gcc/ada/atree.ads
gcc/ada/bindo-writers.adb
gcc/ada/debug.adb
gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst
gcc/ada/einfo.adb
gcc/ada/exp_dist.adb
gcc/ada/fmap.adb
gcc/ada/fname-uf.adb
gcc/ada/gnat1drv.adb
gcc/ada/namet.adb
gcc/ada/namet.ads
gcc/ada/nlists.adb
gcc/ada/nlists.ads
gcc/ada/opt.ads
gcc/ada/osint.adb
gcc/ada/sem_ch8.adb
gcc/ada/sinfo.adb
gcc/ada/switch-c.adb
gcc/ada/treepr.adb
gcc/ada/types.ads
gcc/ada/types.h