Skip to content

Commit ec63dd9

Browse files
committed
Minor refactorings/reformattings/typo fixes
1 parent e520096 commit ec63dd9

File tree

6 files changed

+69
-53
lines changed

6 files changed

+69
-53
lines changed

testsuite/tests/subp_of_interest/test.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
if thistest.options.trace_mode == "bin":
4848
thistest.fail_if_no_match(
4949
"gnatcov coverage output",
50-
"warning: Ignoring --subprograms switches as this is not supported with"
51-
" binary traces.",
50+
"warning: Ignoring --subprograms switches as this is not supported"
51+
" with binary traces.",
5252
contents_of("coverage.log"),
5353
)
5454
else:
@@ -61,9 +61,9 @@
6161
"xcov_subp",
6262
)
6363

64-
# Then check that the checkpoint contains only coverage data for the specific
65-
# subprogram. To do this, produce a new coverage report from the checkpoint
66-
# without using the --subprograms switch.
64+
# Then check that the checkpoint contains only coverage data for the
65+
# specific subprogram. To do this, produce a new coverage report from the
66+
# checkpoint without using the --subprograms switch.
6767
xcov(
6868
cov_args[:-1]
6969
+ ["--checkpoint", "trace.ckpt", "--output-dir=xcov_no_subp"]
@@ -90,10 +90,12 @@
9090
regexp=r".*Wrong argument passed to --subprograms: .*",
9191
actual=contents_of("xcov-wrong1.txt"),
9292
)
93-
93+
9494
# Case 2: line number is not a number
9595
xcov(
96-
cov_args + ["--subprograms", f"{os.path.join('..', 'src', 'pkg.ads')}:b",],
96+
cov_args + [
97+
"--subprograms", f"{os.path.join('..', 'src', 'pkg.ads')}:b",
98+
],
9799
out="xcov-wrong2.txt",
98100
register_failure=False,
99101
)
@@ -102,7 +104,7 @@
102104
regexp=r".*Wrong argument passed to --subprograms: .*",
103105
actual=contents_of("xcov-wrong2.txt"),
104106
)
105-
107+
106108
# Case 3: file does not exist
107109
xcov(
108110
cov_args + ["--subprograms", "dumb-file-name:4"],
@@ -111,11 +113,12 @@
111113
)
112114
thistest.fail_if_no_match(
113115
what="unexpected coverage output",
114-
regexp=r".*Error when parsing --subprograms argument dumb-file-name:4:"
115-
r".*dumb-file-name does not exist",
116+
regexp=(
117+
r".*Error when parsing --subprograms argument dumb-file-name:4:"
118+
r".*dumb-file-name does not exist"
119+
),
116120
actual=contents_of("xcov-wrong3.txt"),
117121
)
118122

119123

120-
121124
thistest.result()

testsuite/tests/subp_of_interest_c/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
from SCOV.minicheck import build_run_and_coverage, check_xcov_reports
1212
from SUITE.context import thistest
13-
from SUITE.cutils import contents_of, Wdir
14-
from SUITE.tutils import gprfor, xcov
13+
from SUITE.cutils import Wdir
14+
from SUITE.tutils import gprfor
1515
from SUITE.gprutils import GPRswitches
1616

1717
tmp = Wdir("tmp_")

tools/gnatcov/coverage-source.adb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,6 +1948,7 @@ package body Coverage.Source is
19481948
is
19491949
CU : CU_Id;
19501950
BM : CU_Bit_Maps;
1951+
ST : Scope_Traversal_Type;
19511952

19521953
procedure Set_Executed (SCI : in out Source_Coverage_Info);
19531954
-- Mark SCI as executed
@@ -1962,6 +1963,12 @@ package body Coverage.Source is
19621963
when File_Based_Language => +CU_Name.Filename);
19631964
-- Helper to refer to the instrumented unit in an error message
19641965

1966+
procedure Update_SCI_Wrapper
1967+
(SCO : SCO_Id;
1968+
Tag : SC_Tag;
1969+
Process : access procedure (SCI : in out Source_Coverage_Info));
1970+
-- Execute Process on the SCI for the given SCO and tag
1971+
19651972
------------------
19661973
-- Set_Executed --
19671974
------------------
@@ -1985,13 +1992,9 @@ package body Coverage.Source is
19851992
when Unit_Separate => "separate");
19861993
end Part_Image;
19871994

1988-
ST : Scope_Traversal_Type;
1989-
1990-
procedure Update_SCI_Wrapper
1991-
(SCO : SCO_Id;
1992-
Tag : SC_Tag;
1993-
Process : access procedure (SCI : in out Source_Coverage_Info));
1994-
-- Execute Process on the SCI for the given SCO and tag
1995+
------------------------
1996+
-- Update_SCI_Wrapper --
1997+
------------------------
19951998

19961999
procedure Update_SCI_Wrapper
19972000
(SCO : SCO_Id;

tools/gnatcov/gnatcov_bits_specific.adb

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,15 @@ procedure GNATcov_Bits_Specific is
367367
-- Process_Subp_Input --
368368
------------------------
369369

370-
procedure Process_Subp_Input (Subp_Input : String)
371-
is
372-
Colon_Index : constant Natural :=
370+
procedure Process_Subp_Input (Subp_Input : String) is
371+
Column_Index : constant Natural :=
373372
Ada.Strings.Fixed.Index (Subp_Input, Ada.Strings.Maps.To_Set (':'));
374-
Filename : constant String :=
375-
Subp_Input (Subp_Input'First .. Colon_Index - 1);
373+
Filename : String renames
374+
Subp_Input (Subp_Input'First .. Column_Index - 1);
375+
Column : String renames
376+
Subp_Input (Column_Index + 1 .. Subp_Input'Last);
376377
begin
377-
if Colon_Index = 0 then
378+
if Column_Index = 0 then
378379
raise Constraint_Error;
379380
end if;
380381
if not Exists (Filename) then
@@ -385,14 +386,10 @@ procedure GNATcov_Bits_Specific is
385386
Subps_Of_Interest.Include
386387
(Scope_Entity_Identifier'
387388
(Decl_SFI =>
388-
Get_Index_From_Full_Name
389-
(Full_Name (Filename), Source_File),
390-
Decl_Line =>
391-
Natural'Value
392-
(Subp_Input (Colon_Index + 1 .. Subp_Input'Last))));
393-
389+
Get_Index_From_Full_Name (Full_Name (Filename), Source_File),
390+
Decl_Line => Natural'Value (Column)));
394391
exception
395-
-- Deal gracefully with parsing errors
392+
-- Deal gracefully with parsing errors
396393

397394
when Constraint_Error =>
398395
Outputs.Fatal_Error
@@ -1771,8 +1768,7 @@ begin
17711768
-- Warn when the user hasn't explicitly set a coverage level and
17721769
-- default to stmt.
17731770

1774-
if not (Source_Coverage_Enabled or else Object_Coverage_Enabled)
1775-
then
1771+
if not (Source_Coverage_Enabled or else Object_Coverage_Enabled) then
17761772
Warn ("Coverage level not specified on the command line or in the"
17771773
& " project file (--level=" & Source_Level_Options
17781774
& "|" & Object_Level_Options ("|") & "), defaulting to"

tools/gnatcov/sc_obligations.adb

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,7 @@ package body SC_Obligations is
601601
-- Scope_Traversal --
602602
---------------------
603603

604-
function Scope_Traversal (CU : CU_Id) return Scope_Traversal_Type
605-
is
604+
function Scope_Traversal (CU : CU_Id) return Scope_Traversal_Type is
606605
Result : Scope_Traversal_Type;
607606
begin
608607
if CU = No_CU_Id then
@@ -614,19 +613,15 @@ package body SC_Obligations is
614613
(CU_Vector.Reference (CU).Element.Scope_Entities));
615614
Result.Scope_Stack := Scope_Stacks.Empty_List;
616615
Result.Active_Scopes := Scope_Id_Sets.Empty;
617-
Result.Active_Scope_Ent := Result.It.First;
618-
Result.Next_Scope_Ent := Result.It.Next (Result.Active_Scope_Ent);
616+
Set_Active_Scope_Ent (Result, Result.It.First);
619617
return Result;
620618
end Scope_Traversal;
621619

622620
------------------
623621
-- Traverse_SCO --
624622
------------------
625623

626-
procedure Traverse_SCO
627-
(ST : in out Scope_Traversal_Type;
628-
SCO : SCO_Id)
629-
is
624+
procedure Traverse_SCO (ST : in out Scope_Traversal_Type; SCO : SCO_Id) is
630625
use Scope_Entities_Trees;
631626
begin
632627
-- In some cases (C metaprogramming instances), e.g.
@@ -662,18 +657,17 @@ package body SC_Obligations is
662657

663658
while SCO > Element (ST.Active_Scope_Ent).To
664659
or else (ST.Next_Scope_Ent /= No_Element
665-
and then SCO >= Element (ST.Next_Scope_Ent).From)
660+
and then SCO >= Element (ST.Next_Scope_Ent).From)
666661
loop
667-
-- We can enter the next scope only when we have reached its
668-
-- parent scope. If the next scope is null, this means that we
669-
-- are in the last scope of the unit.
662+
-- We can enter the next scope only when we have reached its parent
663+
-- scope. If the next scope is null, this means that we are in the
664+
-- last scope of the unit.
670665

671666
if ST.Next_Scope_Ent /= No_Element
672667
and then ST.Active_Scope_Ent = Parent (ST.Next_Scope_Ent)
673668
and then SCO >= Element (ST.Next_Scope_Ent).From
674669
then
675-
ST.Active_Scope_Ent := ST.Next_Scope_Ent;
676-
ST.Next_Scope_Ent := ST.It.Next (ST.Next_Scope_Ent);
670+
Set_Active_Scope_Ent (ST, ST.Next_Scope_Ent);
677671
ST.Scope_Stack.Append (ST.Active_Scope_Ent);
678672
ST.Active_Scopes.Insert
679673
(Element (ST.Active_Scope_Ent).Identifier);
@@ -689,6 +683,18 @@ package body SC_Obligations is
689683
end loop;
690684
end Traverse_SCO;
691685

686+
--------------------------
687+
-- Set_Active_Scope_Ent --
688+
--------------------------
689+
690+
procedure Set_Active_Scope_Ent
691+
(ST : in out Scope_Traversal_Type;
692+
Scope_Ent : Scope_Entities_Trees.Cursor) is
693+
begin
694+
ST.Active_Scope_Ent := Scope_Ent;
695+
ST.Next_Scope_Ent := ST.It.Next (Scope_Ent);
696+
end Set_Active_Scope_Ent;
697+
692698
---------------
693699
-- Is_Active --
694700
---------------
@@ -1376,6 +1382,10 @@ package body SC_Obligations is
13761382
end if;
13771383
end Checkpoint_Load_Unit;
13781384

1385+
----------
1386+
-- Free --
1387+
----------
1388+
13791389
procedure Free (CU : in out CU_Info) is
13801390
procedure Free is new Ada.Unchecked_Deallocation
13811391
(Statement_Bit_Map, Statement_Bit_Map_Access);

tools/gnatcov/sc_obligations.ads

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ package SC_Obligations is
180180
type Scope_Entity is record
181181
From, To : SCO_Id;
182182
-- SCO range for this scope. As scope entities are computed during
183-
-- instrumentation, From and To designates low level SCOs that are then
183+
-- instrumentation, From and To designate low level SCOs that are then
184184
-- converted to high level SCOs after processing the low level SCOs.
185185

186186
Name : Unbounded_String;
@@ -232,9 +232,7 @@ package SC_Obligations is
232232
function Scope_Traversal (CU : CU_Id) return Scope_Traversal_Type;
233233
-- Return a scope traversal for the given compilation unit
234234

235-
procedure Traverse_SCO
236-
(ST : in out Scope_Traversal_Type;
237-
SCO : SCO_Id);
235+
procedure Traverse_SCO (ST : in out Scope_Traversal_Type; SCO : SCO_Id);
238236
-- Traverse the given SCO and update the Scope_Traversal accordingly. Note
239237
-- that the scope traversal must be done on increasing SCOs identifiers.
240238

@@ -1366,6 +1364,12 @@ private
13661364
-- Iterator to traverse the scope tree
13671365
end record;
13681366

1367+
procedure Set_Active_Scope_Ent
1368+
(ST : in out Scope_Traversal_Type;
1369+
Scope_Ent : Scope_Entities_Trees.Cursor);
1370+
-- Set ST.Active_Scope_Ent to Scope_Ent and set ST.Next_Scope_Ent to the
1371+
-- next one according to ST's iterator.
1372+
13691373
No_Scope_Traversal : Scope_Traversal_Type :=
13701374
(Scope_Entities => Scope_Entities_Trees.Empty_Tree,
13711375
Scope_Stack => Scope_Stacks.Empty_List,

0 commit comments

Comments
 (0)