Skip to content

Commit 1a5f19a

Browse files
committed
Instrument.Common.To_Filename: remove the language argument
Ada is the only supported languages that is unit-based, so hardcode it for now. The upcoming transition to GPR2 will delegate the handling of unit-based languages to the GPR2 project (Ada projects are always instrumented using a GPR file).
1 parent bfae98a commit 1a5f19a

File tree

3 files changed

+30
-40
lines changed

3 files changed

+30
-40
lines changed

tools/gnatcov/instrument-ada_unit.adb

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10269,8 +10269,7 @@ package body Instrument.Ada_Unit is
1026910269
Pkg_Name : constant String := To_Ada (Buffer_Unit.Unit);
1027010270
-- Package name for the buffer unit
1027110271

10272-
Filename : constant String :=
10273-
To_Filename (Prj, Ada_Language, Buffer_Unit);
10272+
Filename : constant String := To_Filename (Prj, Buffer_Unit);
1027410273

1027510274
File : Text_Files.File_Type;
1027610275
Last_Buffer_Index : constant Natural := Natural (Unit_Bits.Length);
@@ -10456,8 +10455,7 @@ package body Instrument.Ada_Unit is
1045610455
is
1045710456
Last_Buffer_Index : constant Natural := Natural (CU_Names.Length);
1045810457
Pkg_Name : constant String := To_Ada (PB_Unit.Unit);
10459-
Filename : constant String :=
10460-
New_File (Prj, To_Filename (Prj, Ada_Language, PB_Unit));
10458+
Filename : constant String := New_File (Prj, To_Filename (Prj, PB_Unit));
1046110459
File : Text_Files.File_Type;
1046210460

1046310461
procedure Put_Language_Version_Pragma;
@@ -10551,7 +10549,7 @@ package body Instrument.Ada_Unit is
1055110549
Unit => PB_Unit.Unit,
1055210550
Part => GNATCOLL.Projects.Unit_Body);
1055310551
PB_Filename : constant String :=
10554-
New_File (Prj, To_Filename (Prj, Ada_Language, PB_Unit_Body));
10552+
New_File (Prj, To_Filename (Prj, PB_Unit_Body));
1055510553
begin
1055610554
File.Create (PB_Filename);
1055710555

@@ -10676,12 +10674,10 @@ package body Instrument.Ada_Unit is
1067610674
Spec_Filename : constant String :=
1067710675
To_Filename
1067810676
(Prj,
10679-
Ada_Language,
1068010677
CU_Name_For_Unit (Helper_Unit, GNATCOLL.Projects.Unit_Spec));
1068110678
Body_Filename : constant String :=
1068210679
To_Filename
1068310680
(Prj,
10684-
Ada_Language,
1068510681
CU_Name_For_Unit (Helper_Unit, GNATCOLL.Projects.Unit_Body));
1068610682

1068710683
Helper_Unit_Name : constant String := To_Ada (Helper_Unit);
@@ -11017,8 +11013,7 @@ package body Instrument.Ada_Unit is
1101711013
CU_Name_For_Unit
1101811014
(Buffers_List_Unit (Prj.Prj_Name), GNATCOLL.Projects.Unit_Spec);
1101911015
Unit_Name : constant String := To_Ada (Buffers_CU_Name.Unit);
11020-
Filename : constant String :=
11021-
To_Filename (Prj, Ada_Language, Buffers_CU_Name);
11016+
Filename : constant String := To_Filename (Prj, Buffers_CU_Name);
1102211017
File : Text_Files.File_Type;
1102311018
begin
1102411019
if Sources_Trace.Is_Active then
@@ -11137,13 +11132,9 @@ package body Instrument.Ada_Unit is
1113711132
Obs_Unit_Name : constant String := To_Ada (Obs_Unit);
1113811133

1113911134
Obs_Spec_Filename : constant String := To_Filename
11140-
(Prj,
11141-
Ada_Language,
11142-
CU_Name_For_Unit (Obs_Unit, GNATCOLL.Projects.Unit_Spec));
11135+
(Prj, CU_Name_For_Unit (Obs_Unit, GNATCOLL.Projects.Unit_Spec));
1114311136
Obs_Body_Filename : constant String := To_Filename
11144-
(Prj,
11145-
Ada_Language,
11146-
CU_Name_For_Unit (Obs_Unit, GNATCOLL.Projects.Unit_Body));
11137+
(Prj, CU_Name_For_Unit (Obs_Unit, GNATCOLL.Projects.Unit_Body));
1114711138

1114811139
Spec_File : Text_Files.File_Type;
1114911140
Body_File : Text_Files.File_Type;

tools/gnatcov/instrument-common.adb

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -427,33 +427,34 @@ package body Instrument.Common is
427427
-----------------
428428

429429
function To_Filename
430-
(Prj : Prj_Desc;
431-
Lang : Src_Supported_Language;
432-
CU_Name : Compilation_Unit_Part) return String
433-
is
434-
Filename : Unbounded_String;
430+
(Prj : Prj_Desc; CU_Name : Compilation_Unit_Part) return String is
435431
begin
436432
case CU_Name.Language_Kind is
437433
when Unit_Based_Language =>
438-
for Id of CU_Name.Unit loop
439-
if Filename /= "" then
440-
Append (Filename, Prj.Dot_Replacement);
441-
end if;
442-
Append (Filename, To_Lower (To_String (Id)));
443-
end loop;
444-
445-
case CU_Name.Part is
446-
when GNATCOLL.Projects.Unit_Body
447-
| GNATCOLL.Projects.Unit_Separate
448-
=>
449-
Append (Filename, Prj.Body_Suffix (Lang));
450-
when GNATCOLL.Projects.Unit_Spec =>
451-
Append (Filename, Prj.Spec_Suffix (Lang));
452-
end case;
434+
declare
435+
Filename : Unbounded_String;
436+
begin
437+
for Id of CU_Name.Unit loop
438+
if Filename /= "" then
439+
Append (Filename, Prj.Dot_Replacement);
440+
end if;
441+
Append (Filename, To_Lower (To_String (Id)));
442+
end loop;
443+
444+
case CU_Name.Part is
445+
when GNATCOLL.Projects.Unit_Body
446+
| GNATCOLL.Projects.Unit_Separate
447+
=>
448+
Append (Filename, Prj.Body_Suffix (Ada_Language));
449+
when GNATCOLL.Projects.Unit_Spec =>
450+
Append (Filename, Prj.Spec_Suffix (Ada_Language));
451+
end case;
452+
453+
return +Filename;
454+
end;
453455
when File_Based_Language =>
454-
Filename := CU_Name.Filename;
456+
return +CU_Name.Filename;
455457
end case;
456-
return +Filename;
457458
end To_Filename;
458459

459460
-----------------

tools/gnatcov/instrument-common.ads

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,7 @@ package Instrument.Common is
576576
-- cases, the basename is taken and the file is created in Prj.Output_Dir.
577577

578578
function To_Filename
579-
(Prj : Prj_Desc;
580-
Lang : Src_Supported_Language;
581-
CU_Name : Compilation_Unit_Part) return String;
579+
(Prj : Prj_Desc; CU_Name : Compilation_Unit_Part) return String;
582580
-- Convert a Compilation_Unit_Name to a file basename, using the body /
583581
-- spec suffix and dot replacement (for unit based languages) defined in
584582
-- Prj.

0 commit comments

Comments
 (0)