Commit ec80da28 by Robert Dewar Committed by Arnaud Charlet

get_scos.adb (Get_SCOs): Implement new form of CS entries (multiple entries per line...

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
parent 9dbf1c3e
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
format of statement sequence SCO entries (one location/statement).
* put_scos.adb (Put_SCOs): Implement new format of CS lines
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment