get_scos.adb (Get_SCOs): Implement new form of CS entries (multiple entries per line...
authorRobert Dewar <dewar@adacore.com>
Tue, 26 Jan 2010 10:55:29 +0000 (10:55 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 26 Jan 2010 10:55:29 +0000 (11:55 +0100)
2010-01-26  Robert Dewar  <dewar@adacore.com>

* get_scos.adb (Get_SCOs): Implement new form of CS entries (multiple
entries per line, one for each statement in the sequence).
* par_sco.adb (Traverse_Declarations_Or_Statements): Increase array
size from 100 to 10_000 for SC_Array to avoid any real possibility of
overflow. Output decisions in for loops.
Exclude labels from CS lines.
* scos.ads: Clarify that label is not included in the entry point

From-SVN: r156243

gcc/ada/ChangeLog
gcc/ada/get_scos.adb
gcc/ada/par_sco.adb
gcc/ada/scos.ads

index 3914678a7e0b4c9dbd6160dc1a2ce2e0b437d1ad..f8261fbea7392dbe000fbaaabf1999598060ac42 100644 (file)
@@ -1,3 +1,13 @@
+2010-01-26  Robert Dewar  <dewar@adacore.com>
+
+       * get_scos.adb (Get_SCOs): Implement new form of CS entries (multiple
+       entries per line, one for each statement in the sequence).
+       * par_sco.adb (Traverse_Declarations_Or_Statements): Increase array
+       size from 100 to 10_000 for SC_Array to avoid any real possibility of
+       overflow. Output decisions in for loops.
+       Exclude labels from CS lines.
+       * scos.ads: Clarify that label is not included in the entry point
+
 2010-01-26  Robert Dewar  <dewar@adacore.com>
 
        * par_sco.adb (Traverse_Declarations_Or_Statments): Implement new
index 733263adb0ab5217c7a2c6538f2ceed62e713a68..5dd33f4bbf14a2cbc437b3bbde1afd0d4e1cd73f 100644 (file)
@@ -39,6 +39,11 @@ procedure Get_SCOs is
    use ASCII;
    --  For CR/LF
 
+   function At_EOL return Boolean;
+   --  Skips any spaces, then checks if we are the end of a line. If so,
+   --  returns True (but does not skip over the EOL sequence). If not,
+   --  then returns False.
+
    procedure Check (C : Character);
    --  Checks that file is positioned at given character, and if so skips past
    --  it, If not, raises Data_Error.
@@ -63,6 +68,16 @@ procedure Get_SCOs is
    --  Skips zero or more spaces at the current position, leaving the file
    --  positioned at the first non-blank character (or Types.EOF).
 
+   ------------
+   -- At_EOL --
+   ------------
+
+   function At_EOL return Boolean is
+   begin
+      Skip_Spaces;
+      return Nextc = CR or else Nextc = LF;
+   end At_EOL;
+
    -----------
    -- Check --
    -----------
@@ -236,8 +251,36 @@ begin
          --  Statement entry
 
          when 'S' =>
-            Get_Sloc_Range (Loc1, Loc2);
-            Add_SCO (C1 => 'S', From => Loc1, To => Loc2);
+            declare
+               Typ : Character;
+               Key : Character;
+
+            begin
+               Skip_Spaces;
+               Key := 'S';
+
+               loop
+                  Typ := Nextc;
+
+                  if Typ in '1' .. '9' then
+                     Typ := ' ';
+                  else
+                     Skipc;
+                  end if;
+
+                  Get_Sloc_Range (Loc1, Loc2);
+
+                  Add_SCO
+                    (C1   => Key,
+                     C2   => C,
+                     From => Loc1,
+                     To   => Loc2,
+                     Last => At_EOL);
+
+                  exit when At_EOL;
+                  Key := 's';
+               end loop;
+            end;
 
          --  Exit entry
 
index bee56cd540a5d4c0693df198868628f0a194f466..e0e9318076c1855dc530e9207025184f6dabfa72 100644 (file)
@@ -766,7 +766,7 @@ package body Par_SCO is
       end record;
       --  Used to store a single entry in the following array
 
-      SC_Array : array (Nat range 1 .. 100) of SC_Entry;
+      SC_Array : array (Nat range 1 .. 10_000) of SC_Entry;
       SC_Last  : Nat;
       --  Used to store statement components for a CS entry to be output
       --  as a result of the call to this procedure. SC_Last is the last
@@ -777,11 +777,12 @@ package body Par_SCO is
       --  the temporary caching of results in this array is that we want
       --  the SCO table entries for a given CS line to be contiguous, and
       --  the processing may output intermediate entries such as decision
-      --  entries. Note that the limit of 100 here is arbitrary, but does
-      --  not cause any trouble, if we encounter more than 100 statements
+      --  entries. Note that the limit of 10_000 here is arbitrary, but does
+      --  not cause any trouble, if we encounter more than 10_000 statements
       --  we simply break the current CS sequence at that point, which is
       --  harmless, since this is only used for back annotation and it is
-      --  not critical that back annotation always work in all cases.
+      --  not critical that back annotation always work in all cases. Anyway
+      --  exceeding 10,000 statements in a basic block is very unlikely.
 
       procedure Extend_Statement_Sequence (N : Node_Id; Typ : Character);
       --  Extend the current statement sequence to encompass the node N. Typ
@@ -941,15 +942,14 @@ package body Par_SCO is
                   Set_Statement_Entry;
                   Process_Decisions (Condition (N), 'E');
 
-               --  Label, which breaks the current statement sequence, and then
-               --  we include the label in the subsequent statement sequence.
+               --  Label, which breaks the current statement sequence, but the
+               --  label itself is not included in the next statement sequence,
+               --  since it generates no code.
 
                when N_Label =>
                   Set_Statement_Entry;
-                  Extend_Statement_Sequence (N, ' ');
 
-               --  Block statement, which breaks the current statement seqeunce
-               --  it probably does not need to, but for now it does.
+               --  Block statement, which breaks the current statement sequence
 
                when N_Block_Statement =>
                   Set_Statement_Entry;
@@ -1043,8 +1043,20 @@ package body Par_SCO is
 
                when N_Loop_Statement =>
                   if Present (Iteration_Scheme (N)) then
-                     Extend_Statement_Sequence (N, Iteration_Scheme (N), 'F');
-                     Process_Decisions (Condition (Iteration_Scheme (N)), 'W');
+                     declare
+                        ISC : constant Node_Id := Iteration_Scheme (N);
+
+                     begin
+                        Extend_Statement_Sequence (N, ISC, 'F');
+
+                        if Present (Condition (ISC)) then
+                           Process_Decisions
+                             (Condition (ISC), 'W');
+                        else
+                           Process_Decisions
+                             (Loop_Parameter_Specification (ISC), 'X');
+                        end if;
+                     end;
                   end if;
 
                   Set_Statement_Entry;
index e9c1d159215dd01be16443a4620250baeefc9634..b8dd08d0350305e84b41c24ad57d7e3be56035cb 100644 (file)
@@ -127,7 +127,8 @@ package SCOs is
    --        body or block statement that has a non-empty declarative part
    --      the first statement after a compound statement
    --      the first statement after an EXIT, RAISE or GOTO statement
-   --      any statement with a label
+   --      any statement with a label (the label itself is not part of the
+   --       entry point that is recorded).
 
    --    Each entry point must appear as the first entry on a CS line.
    --    The idea is that if any simple statement on a CS line is known to have