Skip to content

Commit d4144a1

Browse files
committed
SC_Obligations: rework the scopes querying API
Exactly one set of subprograms of interest is ever used: the set for --subprograms command line arguments. Remove Is_Active's corresponding argument and always use the set at Switches.Subps_Of_Interest instead. This also opens the way to more efficient ways to check whether the current SCO is covered by a scope that matches --subprograms. Also rename Is_Active to avoid the confusion with the Active_Scopes/Active_Scope_Ent components (which can contain scopes that are *not* active according to --subprograms arguments).
1 parent d1ffb4f commit d4144a1

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

tools/gnatcov/annotations.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ package body Annotations is
426426
for SCO of LI.SCOs.all loop
427427
Traverse_SCO (ST, SCO);
428428
end loop;
429-
if not Is_Active (ST, Subps_Of_Interest) then
429+
if not In_Scope_Of_Interest (ST) then
430430
return;
431431
end if;
432432
end if;

tools/gnatcov/coverage-source.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ package body Coverage.Source is
20032003
is
20042004
begin
20052005
Traverse_SCO (ST, SCO);
2006-
if Is_Active (ST, Subps_Of_Interest) then
2006+
if In_Scope_Of_Interest (ST) then
20072007
Update_SCI (SCO, Tag, Process);
20082008
end if;
20092009
end Update_SCI_Wrapper;

tools/gnatcov/sc_obligations.adb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -757,18 +757,16 @@ package body SC_Obligations is
757757
ST.Next_Scope_Ent := ST.It.Next (Scope_Ent);
758758
end Set_Active_Scope_Ent;
759759

760-
---------------
761-
-- Is_Active --
762-
---------------
760+
--------------------------
761+
-- In_Scope_Of_Interest --
762+
--------------------------
763763

764-
function Is_Active
765-
(ST : Scope_Traversal_Type;
766-
Subps_Of_Interest : Scope_Id_Set) return Boolean is
764+
function In_Scope_Of_Interest (ST : Scope_Traversal_Type) return Boolean is
767765
begin
768766
return Subps_Of_Interest.Is_Empty
769767
or else not Scope_Id_Sets.Is_Empty
770768
(ST.Active_Scopes.Intersection (Subps_Of_Interest));
771-
end Is_Active;
769+
end In_Scope_Of_Interest;
772770

773771
-----------------
774772
-- Add_Address --

tools/gnatcov/sc_obligations.ads

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,11 @@ package SC_Obligations is
260260
-- Return the last SCO that was passed to Traverse_SCO, or No_SCO_Id if
261261
-- Traverse_SCO has not been called yet on ST.
262262

263-
function Is_Active
264-
(ST : Scope_Traversal_Type;
265-
Subps_Of_Interest : Scope_Id_Set) return Boolean;
266-
-- Return whether any of the scopes in Subps_Of_Interest is currently
267-
-- active. Return True if Subps_Of_Interest is empty (i.e. consider all
268-
-- subprograms of interest in that case).
263+
function In_Scope_Of_Interest (ST : Scope_Traversal_Type) return Boolean;
264+
-- Return whether at least one scope in Switches.Subps_Of_Interest contains
265+
-- Last_SCO (ST). Note that this also returns True if
266+
-- Switches.Subps_Of_Interest is empty (i.e. consider that all subprograms
267+
-- are of interest in that case).
269268

270269
No_Scope_Entity : constant Scope_Entity :=
271270
(From => No_SCO_Id,

0 commit comments

Comments
 (0)