]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Avoid redundant checks for empty lists
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 6 Jan 2022 18:14:33 +0000 (19:14 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 11 Jan 2022 13:24:49 +0000 (13:24 +0000)
gcc/ada/

* exp_ch4.adb (Expand_N_Expression_With_Actions): Avoid
redundant check.
* exp_ch5.adb (Expand_N_If_Statement): Likewise.
* exp_ch7.adb (Process_Declarations): Likewise.
* sem_elab.adb (Freeze_Node_Location): Likewise.
* exp_util.adb (Insert_Actions): Likewise.
(Is_OK_PF_Pragma): Likewise.
(Requires_Cleanup_Actions): Remove early exit; ordinary
processing path will similarly do nothing.

gcc/ada/exp_ch4.adb
gcc/ada/exp_ch5.adb
gcc/ada/exp_ch7.adb
gcc/ada/exp_util.adb
gcc/ada/sem_elab.adb

index 18f0f746cae8238842de2931bc916db1d9321e40..c31f5bb36ba3f7707ff54aceea9305b856672096 100644 (file)
@@ -5697,7 +5697,7 @@ package body Exp_Ch4 is
       --  Do not evaluate the expression when there are no actions because the
       --  expression_with_actions node will be replaced by the expression.
 
-      elsif No (Acts) or else Is_Empty_List (Acts) then
+      elsif Is_Empty_List (Acts) then
          null;
 
       --  Force the evaluation of the expression by capturing its value in a
index daf865229662e9253666a5b43f6a295c6949c1ec..b38e3f54f679d275faac2385e3802148d77fe94e 100644 (file)
@@ -4475,9 +4475,7 @@ package body Exp_Ch5 is
             --  entire if statement by the sequence of else statements.
 
             if No (Elsif_Parts (N)) then
-               if No (Else_Statements (N))
-                 or else Is_Empty_List (Else_Statements (N))
-               then
+               if Is_Empty_List (Else_Statements (N)) then
                   Rewrite (N,
                     Make_Null_Statement (Sloc (N)));
                else
index 57b381c960a6cbcb9c704267e6ad75d7354a45b0..d7863c30b68f229422ed96579e0f2fbb021c704d 100644 (file)
@@ -2249,7 +2249,7 @@ package body Exp_Ch7 is
       --  Start of processing for Process_Declarations
 
       begin
-         if No (Decls) or else Is_Empty_List (Decls) then
+         if Is_Empty_List (Decls) then
             return;
          end if;
 
index e1b462ac05fbae592905deb8bbaf923e4139eb39..aa4707248151d6d1faaf3b5e396425e662bd3fd2 100644 (file)
@@ -7172,7 +7172,7 @@ package body Exp_Util is
       Wrapped_Node : Node_Id := Empty;
 
    begin
-      if No (Ins_Actions) or else Is_Empty_List (Ins_Actions) then
+      if Is_Empty_List (Ins_Actions) then
          return;
       end if;
 
@@ -9963,7 +9963,7 @@ package body Exp_Util is
             --  Nothing to do when the pragma lacks arguments, in which case it
             --  is illegal.
 
-            elsif No (Args) or else Is_Empty_List (Args) then
+            elsif Is_Empty_List (Args) then
                return False;
             end if;
 
@@ -12674,10 +12674,6 @@ package body Exp_Util is
       Typ     : Entity_Id;
 
    begin
-      if No (L) or else Is_Empty_List (L) then
-         return False;
-      end if;
-
       Decl := First (L);
       while Present (Decl) loop
 
index a4212786f68298f32d5e1d77f67e6452831a6628..8e38f8c1285e163ae55c94f1093dac72f0facef6 100644 (file)
@@ -15382,7 +15382,7 @@ package body Sem_Elab is
 
                elsif Present (Vis_Decls)
                  and then List_Containing (FNode) = Vis_Decls
-                 and then (No (Prv_Decls) or else Is_Empty_List (Prv_Decls))
+                 and then Is_Empty_List (Prv_Decls)
                then
                   null;