diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2022-01-20 18:05:39 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-05-10 08:19:28 +0000 |
commit | 45c4d9193dd33013522ff7e7f8f90f77d20cb7be (patch) | |
tree | 8223f62aacf8b603688862ab8c2366dd91740f3f /gcc/ada/sinfo-utils.adb | |
parent | ce63a97b518915b3b6c1221da60af719c7eccd5a (diff) | |
download | gcc-45c4d9193dd33013522ff7e7f8f90f77d20cb7be.zip gcc-45c4d9193dd33013522ff7e7f8f90f77d20cb7be.tar.gz gcc-45c4d9193dd33013522ff7e7f8f90f77d20cb7be.tar.bz2 |
[Ada] Remove repeated conversions between Source_Ptr and Int
Both Source_Ptr and Int are integer types (and even happen to have equal
ranges). Their values can be calculated without converting
back-and-forth, e.g.:
Int (Loc1) - Int (Loc2)
can be written simply as:
Int (Loc1 - Loc2)
Code cleanup related to handling of references to unset objects.
Offending occurrences found with various invocations of grep.
gcc/ada/
* par-ch10.adb, scng.adb, sem_res.adb, sinfo-utils.adb,
treepr.adb: Simplify calculations with Source_Ptr and Loc
values.
Diffstat (limited to 'gcc/ada/sinfo-utils.adb')
-rw-r--r-- | gcc/ada/sinfo-utils.adb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/ada/sinfo-utils.adb b/gcc/ada/sinfo-utils.adb index 121a039..3528891 100644 --- a/gcc/ada/sinfo-utils.adb +++ b/gcc/ada/sinfo-utils.adb @@ -191,7 +191,7 @@ package body Sinfo.Utils is function End_Location (N : Node_Id) return Source_Ptr is L : constant Valid_Uint := End_Span (N); begin - return Source_Ptr (Int (Sloc (N)) + UI_To_Int (L)); + return Sloc (N) + Source_Ptr (UI_To_Int (L)); end End_Location; -------------------- @@ -214,7 +214,7 @@ package body Sinfo.Utils is procedure Set_End_Location (N : Node_Id; S : Source_Ptr) is begin Set_End_Span (N, - UI_From_Int (Int (S) - Int (Sloc (N)))); + UI_From_Int (Int (S - Sloc (N)))); end Set_End_Location; -------------------------- |