Skip to content

Commit ab5faa7

Browse files
committed
Instrument.C: Remap_Scopes only once
The scope remapping was implemented in a loop over UIC.Instrumented_Entities, meaning that we were remapping them several time. One time is enough, so extract this code of the loop.
1 parent 5c838af commit ab5faa7

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

testsuite/tests/subp_of_interest_c/test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""
22
Check that the subprograms of interest mechanism works as expected on a C
3-
example.
3+
example. It also acts as a regression testcase as gnatcov used to crash when
4+
instrumenting a source including multiple headers, with at last one of them
5+
not having any coverage obligation.
46
"""
57

68
import os

tools/gnatcov/instrument-c.adb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,23 +3294,23 @@ package body Instrument.C is
32943294
-- Associate these bit maps to the corresponding CU
32953295

32963296
Set_Bit_Maps (UIC.CUs.Element (SFI), Bit_Maps);
3297+
end;
3298+
end loop;
32973299

3298-
-- Iterate through the package level body entities
3300+
-- Iterate through the package level body entities
32993301

3300-
Remap_Scopes (UIC.Scopes, SCO_Map);
3302+
Remap_Scopes (UIC.Scopes, SCO_Map);
33013303

3302-
for C in UIC.Scopes.Iterate loop
3303-
declare
3304-
CU : constant Created_Unit_Maps.Cursor :=
3305-
UIC.CUs.Find (Scopes_In_Files_Map.Key (C));
3306-
begin
3307-
if Created_Unit_Maps.Has_Element (CU) then
3308-
Set_Scope_Entities
3309-
(Created_Unit_Maps.Element (CU),
3310-
Scopes_In_Files_Map.Element (C).Scope_Entities);
3311-
end if;
3312-
end;
3313-
end loop;
3304+
for C in UIC.Scopes.Iterate loop
3305+
declare
3306+
CU : constant Created_Unit_Maps.Cursor :=
3307+
UIC.CUs.Find (Scopes_In_Files_Map.Key (C));
3308+
begin
3309+
if Created_Unit_Maps.Has_Element (CU) then
3310+
Set_Scope_Entities
3311+
(Created_Unit_Maps.Element (CU),
3312+
Scopes_In_Files_Map.Element (C).Scope_Entities);
3313+
end if;
33143314
end;
33153315
end loop;
33163316
end;

0 commit comments

Comments
 (0)