aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sinput.adb
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2021-03-03 11:45:41 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2021-06-16 04:43:04 -0400
commit207962b929cc771fd560c467f44efe8f9f679ac4 (patch)
tree29974c092086044df5fb3328cb06f8fb8ef96057 /gcc/ada/sinput.adb
parentcc9a7ae2299a530f087ee5dc83876fd44534104a (diff)
downloadgcc-207962b929cc771fd560c467f44efe8f9f679ac4.zip
gcc-207962b929cc771fd560c467f44efe8f9f679ac4.tar.gz
gcc-207962b929cc771fd560c467f44efe8f9f679ac4.tar.bz2
[Ada] Cleanup repeated calls in Sloc_Range
gcc/ada/ * sinput.adb (Sloc_Range): Refactor several repeated calls to Sloc and two comparisons with No_Location.
Diffstat (limited to 'gcc/ada/sinput.adb')
-rw-r--r--gcc/ada/sinput.adb21
1 files changed, 9 insertions, 12 deletions
diff --git a/gcc/ada/sinput.adb b/gcc/ada/sinput.adb
index df61856..e62bf45 100644
--- a/gcc/ada/sinput.adb
+++ b/gcc/ada/sinput.adb
@@ -933,7 +933,7 @@ package body Sinput is
procedure Sloc_Range (N : Node_Id; Min, Max : out Source_Ptr) is
- Indx : constant Source_File_Index := Get_Source_File_Index (Sloc (N));
+ Indx : constant Source_File_Index := Get_Source_File_Index (Sloc (N));
function Process (N : Node_Id) return Traverse_Result;
-- Process function for traversing the node tree
@@ -945,25 +945,22 @@ package body Sinput is
-------------
function Process (N : Node_Id) return Traverse_Result is
- Orig : constant Node_Id := Original_Node (N);
+ Loc : constant Source_Ptr := Sloc (Original_Node (N));
begin
-- Skip nodes that may have been added during expansion and
-- that originate in other units, such as code for contracts
-- in subprogram bodies.
- if Get_Source_File_Index (Sloc (Orig)) /= Indx then
+ if Get_Source_File_Index (Loc) /= Indx then
return Skip;
end if;
- if Sloc (Orig) < Min then
- if Sloc (Orig) > No_Location then
- Min := Sloc (Orig);
- end if;
-
- elsif Sloc (Orig) > Max then
- if Sloc (Orig) > No_Location then
- Max := Sloc (Orig);
+ if Loc > No_Location then
+ if Loc < Min then
+ Min := Loc;
+ elsif Loc > Max then
+ Max := Loc;
end if;
end if;
@@ -974,7 +971,7 @@ package body Sinput is
begin
Min := Sloc (N);
- Max := Sloc (N);
+ Max := Min;
Traverse (N);
end Sloc_Range;