[Ada] Use high-level Present instead of low-level equality test
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 29 Sep 2020 09:09:06 +0000 (11:09 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 24 Nov 2020 10:16:00 +0000 (05:16 -0500)
gcc/ada/

* lib-load.adb, lib-writ.adb, lib.adb, par-load.adb,
rtsfind.adb, sem_ch10.adb: Use Present where possible.

gcc/ada/lib-load.adb
gcc/ada/lib-writ.adb
gcc/ada/lib.adb
gcc/ada/par-load.adb
gcc/ada/rtsfind.adb
gcc/ada/sem_ch10.adb

index 2598285e1987baa3f0b1587e4f277640fe071f63..75226d35ffbd0c55763eb789b0cbea5feab52c80 100644 (file)
@@ -551,7 +551,7 @@ package body Lib.Load is
       --  Note: Unit_Name (Main_Unit) is not set if we are parsing gnat.adc.
 
       if Present (Error_Node)
-        and then Unit_Name (Main_Unit) /= No_Unit_Name
+        and then Present (Unit_Name (Main_Unit))
       then
          --  It seems like In_Extended_Main_Source_Unit (Error_Node) would
          --  do the trick here, but that's wrong, it is much too early to
index 6a63b8fb2b5ee1d806deac1f9f3f80712ae4e504..f17b46a8ba012812202065e1ee12b3b9c0895f3d 100644 (file)
@@ -837,7 +837,7 @@ package body Lib.Writ is
             --  preprocessing data and definition files, there is no Unit_Name,
             --  check for that first.
 
-            if Unit_Name (J) /= No_Unit_Name
+            if Present (Unit_Name (J))
               and then (With_Flags (J) or else Unit_Name (J) = Pname)
             then
                Num_Withs := Num_Withs + 1;
index 49a352a4e62e60fc3c8e2525dd629dcc62380a2a..d298267e875ae19155feb51681bb27a749246c41 100644 (file)
@@ -275,7 +275,7 @@ package body Lib is
    begin
       --  First unregister the old name, if any
 
-      if Old_N /= No_Unit_Name and then Unit_Names.Get (Old_N) = U then
+      if Present (Old_N) and then Unit_Names.Get (Old_N) = U then
          Unit_Names.Set (Old_N, No_Unit);
       end if;
 
index a1857dc5b57927302a4e4d5ace877a57d7668642..ecd54045e58865cfc59e94ef0734df2f632e49e4 100644 (file)
@@ -318,7 +318,7 @@ begin
 
       Spec_Name := Get_Parent_Spec_Name (Unit_Name (Cur_Unum));
 
-      if Spec_Name /= No_Unit_Name then
+      if Present (Spec_Name) then
          Unum :=
            Load_Unit
              (Load_Name  => Spec_Name,
index 872ce0165b9e62007c7b4b4e2e17ee2a94bfdfd2..6a0631fc3377a3a015285842b11b38e223b79e44 100644 (file)
@@ -423,7 +423,7 @@ package body Rtsfind is
                          (Unit_Name (Current_Sem_Unit));
 
                   begin
-                     if Parent_Name /= No_Unit_Name then
+                     if Present (Parent_Name) then
                         Get_Name_String (Parent_Name);
 
                         declare
index 0bad136d3f2e876612a3477d1af1f4e14e0d8c9d..aab186c7665371fbfce9c755966ef63c9c0548de 100644 (file)
@@ -768,7 +768,7 @@ package body Sem_Ch10 is
             Unum := Get_Cunit_Unit_Number (N);
             Par_Spec_Name := Get_Parent_Spec_Name (Unit_Name (Unum));
 
-            if Par_Spec_Name /= No_Unit_Name then
+            if Present (Par_Spec_Name) then
                Unum :=
                  Load_Unit
                    (Load_Name  => Par_Spec_Name,