Skip to content

Commit 62e7d46

Browse files
committed
Refactor logic when exceeding the path count limit
Return Path_Count_Limit + 1 rather than 0 as a special value to indicate that the number of paths in a decision binary diagram exceeds the path count limit, to be able to distinguish such cases from static decisions.
1 parent 6897c90 commit 62e7d46

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

tools/gnatcov/instrument-ada_unit.adb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8264,13 +8264,16 @@ package body Instrument.Ada_Unit is
82648264
Decision : constant SCO_Id :=
82658265
Enclosing_Decision (Condition);
82668266
begin
8267-
if Path_Count (Decision) /= 0
8268-
and then not SC.Decision_Static
8267+
-- If the number of paths in the decision binary diagram
8268+
-- exceeds the path count limit, we do not instrument it.
8269+
8270+
if Path_Count (Decision) > Get_Path_Count_Limit
8271+
and then not SC.Decision_Static
82698272
then
8273+
Set_Decision_SCO_Non_Instr_For_MCDC (Decision);
8274+
else
82708275
Insert_Condition_Witness
82718276
(UIC, SC, Offset_For_True (Condition));
8272-
else
8273-
Set_Decision_SCO_Non_Instr_For_MCDC (Decision);
82748277
end if;
82758278
end;
82768279
end loop;

tools/gnatcov/instrument-c.adb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3110,7 +3110,8 @@ package body Instrument.C is
31103110
Decision : constant SCO_Id :=
31113111
Enclosing_Decision (Condition);
31123112
begin
3113-
if Path_Count (Decision) = 0 then
3113+
if Path_Count (Decision) > Get_Path_Count_Limit
3114+
then
31143115
Set_Decision_SCO_Non_Instr_For_MCDC (Decision);
31153116
else
31163117
Insert_Condition_Witness

tools/gnatcov/instrument-common.adb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ package body Instrument.Common is
216216

217217
-- Warn if the number of paths exceeded the limit
218218

219-
if Path_Count = 0 and then Coverage.MCDC_Coverage_Enabled then
219+
if Path_Count > Get_Path_Count_Limit
220+
and then Coverage.MCDC_Coverage_Enabled
221+
then
220222
Diagnostics.Report
221223
(Decision_Sloc,
222224
"Number of distinct paths in the decision exceeds the limit"

tools/gnatcov/sc_obligations-bdd.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ package body SC_Obligations.BDD is
301301
BDD.Path_Count := Path_Count (BDD.Root_Condition);
302302
exception
303303
when Path_Limit_Error =>
304-
BDD.Path_Count := 0;
304+
BDD.Path_Count := Path_Count_Limit + 1;
305305
end Enumerate_Paths;
306306

307307
---------------

tools/gnatcov/sc_obligations.ads

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,7 @@ package SC_Obligations is
538538
function Path_Count (SCO : SCO_Id) return Natural;
539539
-- Return count of paths through decision's BDD from root condition to
540540
-- any outcome. This should be a positive number for any decision
541-
-- (at least 2, one for the True outcome, and one for the False outcome),
542-
-- but this function can also return 0 when the number of paths exceeds
543-
-- the limit set with Set_Path_Count_Limit.
541+
-- (at least 2, one for the True outcome, and one for the False outcome).
544542

545543
procedure Set_Path_Count_Limit (Limit : Natural);
546544
-- Set the path count limit beyond which BDD path enumeration is aborted

0 commit comments

Comments
 (0)