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> 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 * par_sco.adb (Traverse_Declarations_Or_Statments): Implement new
format of statement sequence SCO entries (one location/statement). format of statement sequence SCO entries (one location/statement).
* put_scos.adb (Put_SCOs): Implement new format of CS lines * put_scos.adb (Put_SCOs): Implement new format of CS lines
......
...@@ -39,6 +39,11 @@ procedure Get_SCOs is ...@@ -39,6 +39,11 @@ procedure Get_SCOs is
use ASCII; use ASCII;
-- For CR/LF -- 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); procedure Check (C : Character);
-- Checks that file is positioned at given character, and if so skips past -- Checks that file is positioned at given character, and if so skips past
-- it, If not, raises Data_Error. -- it, If not, raises Data_Error.
...@@ -63,6 +68,16 @@ procedure Get_SCOs is ...@@ -63,6 +68,16 @@ procedure Get_SCOs is
-- Skips zero or more spaces at the current position, leaving the file -- Skips zero or more spaces at the current position, leaving the file
-- positioned at the first non-blank character (or Types.EOF). -- 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 -- -- Check --
----------- -----------
...@@ -236,8 +251,36 @@ begin ...@@ -236,8 +251,36 @@ begin
-- Statement entry -- Statement entry
when 'S' => when 'S' =>
Get_Sloc_Range (Loc1, Loc2); declare
Add_SCO (C1 => 'S', From => Loc1, To => Loc2); 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 -- Exit entry
......
...@@ -766,7 +766,7 @@ package body Par_SCO is ...@@ -766,7 +766,7 @@ package body Par_SCO is
end record; end record;
-- Used to store a single entry in the following array -- 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; SC_Last : Nat;
-- Used to store statement components for a CS entry to be output -- 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 -- as a result of the call to this procedure. SC_Last is the last
...@@ -777,11 +777,12 @@ package body Par_SCO is ...@@ -777,11 +777,12 @@ package body Par_SCO is
-- the temporary caching of results in this array is that we want -- 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 SCO table entries for a given CS line to be contiguous, and
-- the processing may output intermediate entries such as decision -- the processing may output intermediate entries such as decision
-- entries. Note that the limit of 100 here is arbitrary, but does -- entries. Note that the limit of 10_000 here is arbitrary, but does
-- not cause any trouble, if we encounter more than 100 statements -- not cause any trouble, if we encounter more than 10_000 statements
-- we simply break the current CS sequence at that point, which is -- we simply break the current CS sequence at that point, which is
-- harmless, since this is only used for back annotation and it 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); procedure Extend_Statement_Sequence (N : Node_Id; Typ : Character);
-- Extend the current statement sequence to encompass the node N. Typ -- Extend the current statement sequence to encompass the node N. Typ
...@@ -941,15 +942,14 @@ package body Par_SCO is ...@@ -941,15 +942,14 @@ package body Par_SCO is
Set_Statement_Entry; Set_Statement_Entry;
Process_Decisions (Condition (N), 'E'); Process_Decisions (Condition (N), 'E');
-- Label, which breaks the current statement sequence, and then -- Label, which breaks the current statement sequence, but the
-- we include the label in the subsequent statement sequence. -- label itself is not included in the next statement sequence,
-- since it generates no code.
when N_Label => when N_Label =>
Set_Statement_Entry; Set_Statement_Entry;
Extend_Statement_Sequence (N, ' ');
-- Block statement, which breaks the current statement seqeunce -- Block statement, which breaks the current statement sequence
-- it probably does not need to, but for now it does.
when N_Block_Statement => when N_Block_Statement =>
Set_Statement_Entry; Set_Statement_Entry;
...@@ -1043,8 +1043,20 @@ package body Par_SCO is ...@@ -1043,8 +1043,20 @@ package body Par_SCO is
when N_Loop_Statement => when N_Loop_Statement =>
if Present (Iteration_Scheme (N)) then if Present (Iteration_Scheme (N)) then
Extend_Statement_Sequence (N, Iteration_Scheme (N), 'F'); declare
Process_Decisions (Condition (Iteration_Scheme (N)), 'W'); 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; end if;
Set_Statement_Entry; Set_Statement_Entry;
......
...@@ -127,7 +127,8 @@ package SCOs is ...@@ -127,7 +127,8 @@ package SCOs is
-- body or block statement that has a non-empty declarative part -- body or block statement that has a non-empty declarative part
-- the first statement after a compound statement -- the first statement after a compound statement
-- the first statement after an EXIT, RAISE or GOTO 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. -- 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 -- 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