Skip to content

Commit 42c3745

Browse files
committed
manual dump: rename Done formal to Has_Manual_Indication
And make it an `out` parameter, rather than an `in out`.
1 parent 41dab7c commit 42c3745

6 files changed

+33
-29
lines changed

Diff for: tools/gnatcov/instrument-ada_unit.adb

+9-8
Original file line numberDiff line numberDiff line change
@@ -7799,10 +7799,10 @@ package body Instrument.Ada_Unit is
77997799
------------------------------------
78007800

78017801
overriding procedure Replace_Manual_Dump_Indication
7802-
(Self : in out Ada_Instrumenter_Type;
7803-
Done : in out Boolean;
7804-
Prj : in out Prj_Desc;
7805-
Source : GNATCOLL.Projects.File_Info)
7802+
(Self : in out Ada_Instrumenter_Type;
7803+
Prj : in out Prj_Desc;
7804+
Source : GNATCOLL.Projects.File_Info;
7805+
Has_Manual_Indication : out Boolean)
78067806
is
78077807
Instrumented_Filename : constant String :=
78087808
+(Prj.Output_Dir & "/" & GNATCOLL.VFS."+" (Source.File.Base_Name));
@@ -7853,7 +7853,7 @@ package body Instrument.Ada_Unit is
78537853
-- The pragma statement to be replaced by the actual call
78547854
-- to Dump_Buffers has been found.
78557855

7856-
if not Done then
7856+
if not Has_Manual_Indication then
78577857
Start_Rewriting (Rewriter, Self, Prj, File_To_Search);
78587858
end if;
78597859

@@ -7870,7 +7870,7 @@ package body Instrument.Ada_Unit is
78707870
begin
78717871
-- Add the with clause only once in the file
78727872

7873-
if not Done then
7873+
if not Has_Manual_Indication then
78747874
Insert_Last
78757875
(Handle (Unit.Root.As_Compilation_Unit.F_Prelude),
78767876
Create_From_Template
@@ -7891,7 +7891,7 @@ package body Instrument.Ada_Unit is
78917891
Rule => Call_Stmt_Rule));
78927892
end;
78937893

7894-
Done := True;
7894+
Has_Manual_Indication := True;
78957895
return Over;
78967896
end if;
78977897
end;
@@ -7913,11 +7913,12 @@ package body Instrument.Ada_Unit is
79137913
-- initialized which will lead to finalization issues. To avoid this,
79147914
-- make sure it is set to No_Rewriting_Handle.
79157915

7916+
Has_Manual_Indication := False;
79167917
Rewriter.Handle := No_Rewriting_Handle;
79177918

79187919
Unit.Root.Traverse (Find_And_Replace_Pragma'Access);
79197920

7920-
if Done then
7921+
if Has_Manual_Indication then
79217922
Create_Directory_If_Not_Exists
79227923
(GNATCOLL.VFS."+" (Source.Project.Object_Dir.Base_Dir_Name));
79237924
Create_Directory_If_Not_Exists (+Prj.Output_Dir);

Diff for: tools/gnatcov/instrument-ada_unit.ads

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ package Instrument.Ada_Unit is
8686
Prj : Prj_Desc);
8787

8888
overriding procedure Replace_Manual_Dump_Indication
89-
(Self : in out Ada_Instrumenter_Type;
90-
Done : in out Boolean;
91-
Prj : in out Prj_Desc;
92-
Source : GNATCOLL.Projects.File_Info);
89+
(Self : in out Ada_Instrumenter_Type;
90+
Prj : in out Prj_Desc;
91+
Source : GNATCOLL.Projects.File_Info;
92+
Has_Manual_Indication : out Boolean);
9393
-- Once the instrumentation has finished, if the dump trigger is "manual"
9494
-- we expect the user to have indicated the place where a call to the
9595
-- manual dump buffers procedure should be inserted by the pragma

Diff for: tools/gnatcov/instrument-c.adb

+6-6
Original file line numberDiff line numberDiff line change
@@ -3838,10 +3838,10 @@ package body Instrument.C is
38383838
------------------------------------
38393839

38403840
overriding procedure Replace_Manual_Dump_Indication
3841-
(Self : in out C_Family_Instrumenter_Type;
3842-
Done : in out Boolean;
3843-
Prj : in out Prj_Desc;
3844-
Source : GNATCOLL.Projects.File_Info)
3841+
(Self : in out C_Family_Instrumenter_Type;
3842+
Prj : in out Prj_Desc;
3843+
Source : GNATCOLL.Projects.File_Info;
3844+
Has_Manual_Indication : out Boolean)
38453845
is
38463846
use GNATCOLL.VFS;
38473847
Orig_Filename : constant String := +Source.File.Full_Name;
@@ -3902,7 +3902,7 @@ package body Instrument.C is
39023902

39033903
if Matches (0) /= No_Match then
39043904
Contents := Contents & Dump_Procedure & "();";
3905-
Done := True;
3905+
Has_Manual_Indication := True;
39063906
else
39073907
Contents := Contents & Line;
39083908
end if;
@@ -3913,7 +3913,7 @@ package body Instrument.C is
39133913

39143914
Ada.Text_IO.Close (File);
39153915

3916-
if Done then
3916+
if Has_Manual_Indication then
39173917
-- Content now holds the text of the original file with calls to
39183918
-- the manual dump procedure where the indications and its extern
39193919
-- declaration were. Replace the original content of the file with

Diff for: tools/gnatcov/instrument-c.ads

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ package Instrument.C is
5454
Prj : Prj_Desc);
5555

5656
overriding procedure Replace_Manual_Dump_Indication
57-
(Self : in out C_Family_Instrumenter_Type;
58-
Done : in out Boolean;
59-
Prj : in out Prj_Desc;
60-
Source : GNATCOLL.Projects.File_Info);
57+
(Self : in out C_Family_Instrumenter_Type;
58+
Prj : in out Prj_Desc;
59+
Source : GNATCOLL.Projects.File_Info;
60+
Has_Manual_Indication : out Boolean);
6161
-- Preprocess Source and look through the text content of the preprocessed
6262
-- file looking for manual dump indications. The C-like languages, the
6363
-- expected indication is the comment alone on its line:

Diff for: tools/gnatcov/instrument-common.ads

+7-4
Original file line numberDiff line numberDiff line change
@@ -486,14 +486,17 @@ package Instrument.Common is
486486
-- the instrumented source files.
487487

488488
procedure Replace_Manual_Dump_Indication
489-
(Self : in out Language_Instrumenter;
490-
Done : in out Boolean;
491-
Prj : in out Prj_Desc;
492-
Source : GNATCOLL.Projects.File_Info) is null;
489+
(Self : in out Language_Instrumenter;
490+
Prj : in out Prj_Desc;
491+
Source : GNATCOLL.Projects.File_Info;
492+
Has_Manual_Indication : out Boolean) is null;
493493
-- Look for the pragma (for Ada) or comment (for C family languages)
494494
-- indicating where the user wishes to the buffers to be dumped in Source.
495495
-- When found, replace it with a call to the buffers dump procedure defined
496496
-- in the dump helper unit.
497+
--
498+
-- Has_Manual_Indication indicates whether a manual dump indication was
499+
-- found - and replaced with a call to dump buffers - in the given source.
497500

498501
function New_File
499502
(Prj : Prj_Desc; Name : String) return String;

Diff for: tools/gnatcov/instrument-projects.adb

+3-3
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,9 @@ is
865865
Contained_Indication : Boolean := False;
866866
begin
867867
Instrumenter.Replace_Manual_Dump_Indication
868-
(Contained_Indication,
869-
Prj_Info.Desc,
870-
Source);
868+
(Prj_Info.Desc,
869+
Source,
870+
Contained_Indication);
871871

872872
if Contained_Indication and then not Is_Root_Prj then
873873

0 commit comments

Comments
 (0)