Skip to content

Commit 9c0b5dd

Browse files
committed
Merge branch 'mr/pmderodat/unbounded_strings' into 'master'
Unify references to unbounded strings See merge request eng/das/cov/gnatcoverage!356 For https://gitlab.adacore-it.com/eng/das/cov/gnatcoverage/-/issues/176
2 parents 4b76591 + 9434173 commit 9c0b5dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+865
-1271
lines changed

tools/gnatcov/ali_files.adb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
------------------------------------------------------------------------------
1818

1919
with Ada.Characters.Handling; use Ada.Characters.Handling;
20-
with Ada.Strings.Unbounded;
2120
with Ada.Text_IO; use Ada.Text_IO;
2221

2322
with GNAT.Regpat; use GNAT.Regpat;
@@ -29,9 +28,12 @@ with Files_Table; use Files_Table;
2928
with Get_SCOs;
3029
with Inputs; use Inputs;
3130
with Outputs; use Outputs;
31+
with Strings; use Strings;
3232

3333
package body ALI_Files is
3434

35+
use all type Unbounded_String;
36+
3537
procedure Read
3638
(CLS : in out Checkpoint_Load_State; Value : out ALI_Annotation);
3739
-- Read a ALI_Annotation from CLS
@@ -72,8 +74,6 @@ package body ALI_Files is
7274
-------------
7375

7476
function Unquote (Filename : String) return String is
75-
use Ada.Strings.Unbounded;
76-
7777
Result : Unbounded_String;
7878
In_Quote : Boolean := False;
7979
-- True when we just met a double quote inside a quoted filename. False
@@ -96,7 +96,7 @@ package body ALI_Files is
9696
Append (Result, C);
9797
end if;
9898
end loop;
99-
return To_String (Result);
99+
return +Result;
100100
end if;
101101
end Unquote;
102102

@@ -366,17 +366,13 @@ package body ALI_Files is
366366
-- Check that the first line is a valid ALI V line.
367367

368368
declare
369-
use Ada.Strings.Unbounded;
370-
371369
V_Line : constant String := Get_Stripped_Line (ALI_File);
372-
373370
Error_Msg : Unbounded_String;
374371
begin
375372
Match (V_Matcher, V_Line, Matches);
376373
if Matches (0) = No_Match then
377374
Error_Msg :=
378-
To_Unbounded_String
379-
("malformed ALI file """ & ALI_Filename & """");
375+
+("malformed ALI file """ & ALI_Filename & """");
380376

381377
if V_Line'Length > 3
382378
and then
@@ -388,7 +384,7 @@ package body ALI_Files is
388384
& "to load ALIs from list use ""--scos=@"
389385
& ALI_Filename & """");
390386
end if;
391-
Fatal_Error (To_String (Error_Msg));
387+
Fatal_Error (+Error_Msg);
392388
end if;
393389
end;
394390

tools/gnatcov/annotations-cobertura.adb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ with Ada.Containers.Ordered_Maps;
2222
with Ada.Directories;
2323
with Ada.Text_IO; use Ada.Text_IO;
2424
with Ada.Strings.Fixed;
25-
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
2625
with Ada.Unchecked_Deallocation;
2726

2827
with GNAT.OS_Lib;
@@ -424,7 +423,7 @@ package body Annotations.Cobertura is
424423
Branches_Valid, Branches_Covered : Natural;
425424
Branch_Rate : Rate_Type;
426425

427-
Filename : Unbounded_String := To_Unbounded_String (Info.Full_Name.all);
426+
Filename : Unbounded_String := +Info.Full_Name.all;
428427
-- Filename to mention in the coverage report. Use the full name, unless
429428
-- we can remove the prefix according to the --source-root option.
430429
begin
@@ -459,15 +458,14 @@ package body Annotations.Cobertura is
459458
Matches : GNAT.Regpat.Match_Array (0 .. 0);
460459
First, Last : Natural;
461460
Normalized_Filename : constant String :=
462-
Paths.Normalize_For_Regexp (To_String (Filename));
461+
Paths.Normalize_For_Regexp (+Filename);
463462
begin
464463
GNAT.Regpat.Match
465464
(Pp.Source_Prefix_Pattern.all, Normalized_Filename, Matches);
466465
if Matches (0) /= GNAT.Regpat.No_Match then
467466
First := Matches (0).Last + 1;
468467
Last := Normalized_Filename'Last;
469-
Filename :=
470-
To_Unbounded_String (Normalized_Filename (First .. Last));
468+
Filename := +Normalized_Filename (First .. Last);
471469
end if;
472470
end;
473471
end if;
@@ -480,7 +478,7 @@ package body Annotations.Cobertura is
480478
Pp.ST ("classes");
481479
Pp.ST ("class",
482480
A ("name", Simple_Source_Filename)
483-
& A ("filename", To_String (Filename))
481+
& A ("filename", +Filename)
484482
& A ("line-rate", Img (Line_Rate))
485483
& A ("branch-rate", Img (Branch_Rate))
486484
& A ("complexity", "-1"));

tools/gnatcov/annotations-dynamic_html.adb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
with Ada.Characters.Handling;
2020
with Ada.Directories; use Ada.Directories;
2121
with Ada.Exceptions; use Ada.Exceptions;
22-
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
2322
with Ada.Text_IO;
2423

2524
pragma Warnings (Off, "* is an internal GNAT unit");
@@ -125,7 +124,7 @@ package body Annotations.Dynamic_Html is
125124
Source_List : JSON_Array;
126125
-- The sources array in the index, containing all source mappings
127126

128-
Title_Prefix : Ada.Strings.Unbounded.Unbounded_String;
127+
Title_Prefix : Unbounded_String;
129128
-- Prefix to use for titles in generated HTML documents
130129

131130
Scope_Metrics : JSON_Value;
@@ -226,7 +225,7 @@ package body Annotations.Dynamic_Html is
226225
-- Write Item (String) into Output
227226

228227
procedure W
229-
(Item : Ada.Strings.Unbounded.Unbounded_String;
228+
(Item : Unbounded_String;
230229
Output : Ada.Text_IO.File_Type;
231230
New_Line : Boolean := True)
232231
with Pre => Ada.Text_IO.Is_Open (Output);
@@ -812,7 +811,7 @@ package body Annotations.Dynamic_Html is
812811
Message.Set_Field ("sco", Image (M.SCO, With_Sloc => False));
813812
end if;
814813

815-
Message.Set_Field ("message", To_String (M.Msg));
814+
Message.Set_Field ("message", +M.Msg);
816815
Pp.Current_Mapping.Get ("messages").Append (Message);
817816
end Pretty_Print_Message;
818817

@@ -835,18 +834,18 @@ package body Annotations.Dynamic_Html is
835834
end W;
836835

837836
procedure W
838-
(Item : Ada.Strings.Unbounded.Unbounded_String;
837+
(Item : Unbounded_String;
839838
Output : Ada.Text_IO.File_Type;
840839
New_Line : Boolean := True)
841840
is
842841
use Ada.Text_IO;
843842

844-
Buffer : Aux.Big_String_Access;
843+
Buffer : US.Aux.Big_String_Access;
845844
Last : Natural;
846-
First : constant Natural := Aux.Big_String'First;
845+
First : constant Natural := US.Aux.Big_String'First;
847846

848847
begin
849-
Aux.Get_String (Item, Buffer, Last);
848+
US.Aux.Get_String (Item, Buffer, Last);
850849
Put (File => Output, Item => Buffer (First .. Last));
851850

852851
if New_Line then
@@ -1119,7 +1118,7 @@ package body Annotations.Dynamic_Html is
11191118
(In_Filename => Source_Name,
11201119
Out_Filename => Target_Name,
11211120
Pattern => "<title>.*</title>",
1122-
Replacement => " <title>" & To_String (Pp.Title_Prefix)
1121+
Replacement => " <title>" & (+Pp.Title_Prefix)
11231122
& "GNATcoverage Report</title>");
11241123
else
11251124
Copy_File (Source_Name, Target_Name);

tools/gnatcov/annotations-html.adb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ package body Annotations.Html is
458458

459459
Pi ("<html lang=""en"">");
460460
Pi ("<head>");
461-
Pi (" <title>" & To_String (Pp.Title_Prefix)
461+
Pi (" <title>" & (+Pp.Title_Prefix)
462462
& "Coverage results</title>");
463463
Pi (" <link rel=""stylesheet"" type=""text/css"" href=""xcov.css"">");
464464
Pi ("</head>");
@@ -484,11 +484,11 @@ package body Annotations.Html is
484484

485485
for El of Sorted_Traces_Files loop
486486
Pi (" <tr>");
487-
Pi (" <td>" & To_String (El.Filename) & "</td>");
487+
Pi (" <td>" & (+El.Filename) & "</td>");
488488
Pi (" <td>" & Image (El.Kind) & "</td>");
489-
Pi (" <td>" & To_String (El.Program_Name) & "</td>");
490-
Pi (" <td>" & To_String (El.Time) & "</td>");
491-
Pi (" <td>" & To_String (El.User_Data) & "</td>");
489+
Pi (" <td>" & (+El.Program_Name) & "</td>");
490+
Pi (" <td>" & (+El.Time) & "</td>");
491+
Pi (" <td>" & (+El.User_Data) & "</td>");
492492
Pi (" </tr>");
493493
end loop;
494494

@@ -598,7 +598,7 @@ package body Annotations.Html is
598598

599599
Plh (Pp, "<html lang=""en"">");
600600
Plh (Pp, "<head>");
601-
Plh (Pp, " <title>" & To_String (Pp.Title_Prefix) & "Coverage of "
601+
Plh (Pp, " <title>" & (+Pp.Title_Prefix) & "Coverage of "
602602
& To_Xml_String (Simple_Source_Filename) & "</title>");
603603
Plh (Pp, " <link rel=""stylesheet"" type=""text/css"" "
604604
& "href=""xcov.css"">");

tools/gnatcov/annotations-html.ads

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
-- of the license. --
1717
------------------------------------------------------------------------------
1818

19-
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
20-
2119
with Annotations.Xml; use Annotations.Xml;
2220
with Command_Line;
2321
with Coverage;
@@ -37,8 +35,7 @@ package Annotations.Html is
3735
(Report_Title : Command_Line.Parser.String_Option)
3836
return Unbounded_String
3937
is ((if Report_Title.Present and then Length (Report_Title.Value) > 0
40-
then To_Unbounded_String
41-
(To_Xml_String (To_String (Report_Title.Value & " - ")))
38+
then +(To_Xml_String (+Report_Title.Value & " - "))
4239
else Null_Unbounded_String));
4340
-- If Report_Title is present and non-empty, return the corresponding
4441
-- report title prefix (for instance: "foo" -> "foo - "). Return an empty

tools/gnatcov/annotations-report.adb

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
with Ada.Characters.Handling; use Ada.Characters.Handling;
2020
with Ada.Containers.Vectors;
2121
with Ada.Containers.Indefinite_Ordered_Maps;
22-
with Ada.Strings.Unbounded;
2322
with Ada.Text_IO; use Ada.Text_IO;
2423

2524
with ALI_Files;
@@ -104,10 +103,7 @@ package body Annotations.Report is
104103
"=" => Message_Vectors."=");
105104

106105
package String_Vectors is
107-
new Ada.Containers.Vectors
108-
(Natural,
109-
Ada.Strings.Unbounded.Unbounded_String,
110-
Ada.Strings.Unbounded."=");
106+
new Ada.Containers.Vectors (Natural, Unbounded_String, "=");
111107

112108
type Report_Pretty_Printer is new Pretty_Printer with record
113109
Current_File_Index : Source_File_Index;
@@ -302,7 +298,6 @@ package body Annotations.Report is
302298

303299
procedure Pretty_Print_End (Pp : in out Report_Pretty_Printer) is
304300
use ALI_Files, ALI_Files.ALI_Annotation_Maps;
305-
use Ada.Strings.Unbounded;
306301

307302
Output : constant File_Access := Get_Output;
308303

@@ -397,7 +392,7 @@ package body Annotations.Report is
397392

398393
procedure Output_Message (C : Message_Vectors.Cursor) is
399394
M : Message renames Message_Vectors.Element (C);
400-
Msg : constant String := To_String (M.Msg);
395+
Msg : constant String := +M.Msg;
401396
First : Natural := Msg'First;
402397
begin
403398

@@ -551,7 +546,7 @@ package body Annotations.Report is
551546

552547
procedure Output_Message (C : Message_Vectors.Cursor) is
553548
M : Message renames Message_Vectors.Element (C);
554-
Msg : constant String := To_String (M.Msg);
549+
Msg : constant String := +M.Msg;
555550
First : Natural := Msg'First;
556551
Show_Vectors : constant Boolean :=
557552
(Switches.Show_MCDC_Vectors
@@ -625,19 +620,18 @@ package body Annotations.Report is
625620
-- Append summary line for general summary chapter
626621

627622
Pp.Summary.Append
628-
(To_Unbounded_String
629-
(Pluralize
630-
(Item_Count,
631-
(case MC is
632-
when Coverage_Violations =>
633-
Non_Exempted
634-
& Coverage_Level'Val (MC)'Img & " " & Item,
635-
when Other_Errors =>
636-
"other message",
637-
when Coverage_Exclusions =>
638-
"coverage exclusion",
639-
when Undetermined_Coverage =>
640-
"undetermined coverage item")) & "."));
623+
(+(Pluralize
624+
(Item_Count,
625+
(case MC is
626+
when Coverage_Violations =>
627+
Non_Exempted
628+
& Coverage_Level'Val (MC)'Img & " " & Item,
629+
when Other_Errors =>
630+
"other message",
631+
when Coverage_Exclusions =>
632+
"coverage exclusion",
633+
when Undetermined_Coverage =>
634+
"undetermined coverage item")) & "."));
641635

642636
-- Count of total (coverable) and covered SCOs is displayed only
643637
-- if --all-messages is specified.
@@ -725,7 +719,7 @@ package body Annotations.Report is
725719
New_Line (Output.all);
726720

727721
for L of Pp.Summary loop
728-
Put_Line (Output.all, To_String (L));
722+
Put_Line (Output.all, +L);
729723
end loop;
730724

731725
if Has_Exempted_Region then
@@ -835,8 +829,6 @@ package body Annotations.Report is
835829
------------------------
836830

837831
procedure Pretty_Print_Start (Pp : in out Report_Pretty_Printer) is
838-
use Ada.Strings.Unbounded;
839-
840832
Output : constant File_Access := Get_Output;
841833

842834
procedure Process_One_Trace (TF : Trace_File_Element);
@@ -850,11 +842,11 @@ package body Annotations.Report is
850842
Orig_Context : constant String := Original_Processing_Context (TF);
851843
begin
852844
New_Line (Output.all);
853-
Put_Line (Output.all, To_String (TF.Filename));
845+
Put_Line (Output.all, +TF.Filename);
854846
Put_Line (Output.all, " kind : " & Image (TF.Kind));
855-
Put_Line (Output.all, " program : " & To_String (TF.Program_Name));
856-
Put_Line (Output.all, " date : " & To_String (TF.Time));
857-
Put_Line (Output.all, " tag : " & To_String (TF.User_Data));
847+
Put_Line (Output.all, " program : " & (+TF.Program_Name));
848+
Put_Line (Output.all, " date : " & (+TF.Time));
849+
Put_Line (Output.all, " tag : " & (+TF.User_Data));
858850

859851
-- For a trace that has been processed in an earlier run, provide
860852
-- information on original coverage assessment context.
@@ -875,15 +867,14 @@ package body Annotations.Report is
875867
Put_Line (Output.all, "Date and time of execution: "
876868
& Image (Pp.Context.Timestamp));
877869
Put_Line (Output.all, "Tool version: XCOV "
878-
& To_String (Pp.Context.Version));
870+
& (+Pp.Context.Version));
879871
New_Line (Output.all);
880872

881873
Put_Line (Output.all, "Command line:");
882-
Put_Line (Output.all, To_String (Pp.Context.Command));
874+
Put_Line (Output.all, +Pp.Context.Command);
883875
New_Line (Output.all);
884876

885-
Put_Line (Output.all, "Coverage level: "
886-
& To_String (Pp.Context.Levels));
877+
Put_Line (Output.all, "Coverage level: " & (+Pp.Context.Levels));
887878
New_Line (Output.all);
888879

889880
Put_Line (Output.all, "Trace files:");

0 commit comments

Comments
 (0)