[Ada] Simplify Is_Loop_Pragma
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 7 Oct 2020 20:12:45 +0000 (22:12 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 24 Nov 2020 10:16:05 +0000 (05:16 -0500)
gcc/ada/

* sem_prag.adb (Is_Loop_Pragma): Avoid repeated calls to
Original_Node; remove unnecessary IF statement.

gcc/ada/sem_prag.adb

index b5212017146295d9eb3d19da5689e121a10cf4d1..590da5574e984ddc1c7915e17bf19f9dd33ce91b 100644 (file)
@@ -6194,17 +6194,15 @@ package body Sem_Prag is
          --------------------
 
          function Is_Loop_Pragma (Stmt : Node_Id) return Boolean is
+            Original_Stmt : constant Node_Id := Original_Node (Stmt);
+
          begin
             --  Inspect the original node as Loop_Invariant and Loop_Variant
             --  pragmas are rewritten to null when assertions are disabled.
 
-            if Nkind (Original_Node (Stmt)) = N_Pragma then
-               return
-                 Pragma_Name_Unmapped (Original_Node (Stmt))
+            return Nkind (Original_Stmt) = N_Pragma
+             and then Pragma_Name_Unmapped (Original_Stmt)
                    in Name_Loop_Invariant | Name_Loop_Variant;
-            else
-               return False;
-            end if;
          end Is_Loop_Pragma;
 
          ---------------------