diff mbox series

[Ada] Reuse Is_Rewrite_Substitution where possible

Message ID 20180530085952.GA21530@adacore.com
State New
Headers show
Series [Ada] Reuse Is_Rewrite_Substitution where possible | expand

Commit Message

Pierre-Marie de Rodat May 30, 2018, 8:59 a.m. UTC
Use a high-level Is_Rewrite_Substitution instead of a low-level inequality,
with the intention to improve the code easier to read. Semantics unaffected,
so no test provided.

Tested on x86_64-pc-linux-gnu, committed on trunk

2018-05-30  Piotr Trojanek  <trojanek@adacore.com>

gcc/ada/

	* errout.adb, exp_aggr.adb, exp_ch7.adb, exp_util.adb, lib.adb,
	sem_ch13.adb, sem_ch4.adb, sem_res.adb, sem_util.adb
	(Has_Original_Node): Refactor to use Is_Rewrite_Substitution.
diff mbox series

Patch

--- gcc/ada/errout.adb
+++ gcc/ada/errout.adb
@@ -2387,7 +2387,7 @@  package body Errout is
          end loop;
 
          if Nkind (N) = N_Raise_Constraint_Error
-           and then Original_Node (N) /= N
+           and then Is_Rewrite_Substitution (N)
            and then No (Condition (N))
          then
             --  Warnings may have been posted on subexpressions of the original

--- gcc/ada/exp_aggr.adb
+++ gcc/ada/exp_aggr.adb
@@ -6089,7 +6089,7 @@  package body Exp_Aggr is
       --  that Convert_To_Positional succeeded and reanalyzed the rewritten
       --  aggregate.
 
-      elsif Analyzed (N) and then N /= Original_Node (N) then
+      elsif Analyzed (N) and then Is_Rewrite_Substitution (N) then
          return;
       end if;
 

--- gcc/ada/exp_ch7.adb
+++ gcc/ada/exp_ch7.adb
@@ -5255,7 +5255,7 @@  package body Exp_Ch7 is
             --  node. Inspect the original node to detect the initial placement
             --  of the call.
 
-            elsif Original_Node (N) /= N then
+            elsif Is_Rewrite_Substitution (N) then
                Detect_Subprogram_Call (Original_Node (N));
 
                if Must_Hook then

--- gcc/ada/exp_util.adb
+++ gcc/ada/exp_util.adb
@@ -4826,7 +4826,7 @@  package body Exp_Util is
                while Present (E) loop
                   Force_Evaluation (E);
 
-                  if Original_Node (E) /= E then
+                  if Is_Rewrite_Substitution (E) then
                      Set_Do_Range_Check
                        (E, Do_Range_Check (Original_Node (E)));
                   end if;

--- gcc/ada/lib.adb
+++ gcc/ada/lib.adb
@@ -1326,7 +1326,7 @@  package body Lib is
       Write_Str ("=");
       Write_Str (Node_Kind'Image (Nkind (Item)));
 
-      if Item /= Original_Node (Item) then
+      if Is_Rewrite_Substitution (Item) then
          Write_Str (", orig = ");
          Write_Int (Int (Original_Node (Item)));
          Write_Str ("=");

--- gcc/ada/sem_ch13.adb
+++ gcc/ada/sem_ch13.adb
@@ -9643,7 +9643,7 @@  package body Sem_Ch13 is
                --  from the node, since we may have rewritten things and
                --  substituted an identifier representing the rewrite.
 
-               if Original_Node (Nod) /= Nod then
+               if Is_Rewrite_Substitution (Nod) then
                   Check_Expr_Constants (Original_Node (Nod));
 
                   --  If the node is an object declaration without initial

--- gcc/ada/sem_ch4.adb
+++ gcc/ada/sem_ch4.adb
@@ -1345,7 +1345,7 @@  package body Sem_Ch4 is
             --  parameter has been analyzed, but may need a subsequent
             --  dereference, so skip its analysis now.
 
-            if N /= Original_Node (N)
+            if Is_Rewrite_Substitution (N)
               and then Nkind (Original_Node (N)) = Nkind (N)
               and then Nkind (Name (N)) /= Nkind (Name (Original_Node (N)))
               and then Present (Parameter_Associations (N))

--- gcc/ada/sem_res.adb
+++ gcc/ada/sem_res.adb
@@ -12691,7 +12691,7 @@  package body Sem_Res is
 
             if Ada_Version >= Ada_2012
               and then not Comes_From_Source (N)
-              and then N /= Original_Node (N)
+              and then Is_Rewrite_Substitution (N)
               and then Ekind (Target_Type) = E_General_Access_Type
               and then Ekind (Opnd_Type) = E_Anonymous_Access_Type
             then

--- gcc/ada/sem_util.adb
+++ gcc/ada/sem_util.adb
@@ -15855,7 +15855,7 @@  package body Sem_Util is
       --  original node is a conversion, then Is_Variable will not be true
       --  but we still want to allow the conversion if it converts a variable).
 
-      elsif Original_Node (AV) /= AV then
+      elsif Is_Rewrite_Substitution (AV) then
 
          --  In Ada 2012, the explicit dereference may be a rewritten call to a
          --  Reference function.