17
17
-- ----------------------------------------------------------------------------
18
18
19
19
with Ada.Characters.Handling ; use Ada.Characters.Handling;
20
- with Ada.Characters.Latin_1 ; use Ada.Characters.Latin_1;
21
20
with Ada.Containers.Hashed_Maps ;
22
21
with Ada.Containers.Indefinite_Ordered_Maps ;
23
22
with Ada.Containers.Indefinite_Ordered_Sets ;
@@ -853,131 +852,123 @@ is
853
852
-- that belong to a non-root project.
854
853
855
854
begin
856
- for Source_C in Project_Sources.Iterate loop
857
- declare
858
- Source : constant File_Info := File_Info_Sets.Element (Source_C);
859
- begin
860
- if To_Language (Source.Language) = Language then
861
- declare
862
- use Prj_Has_Manual_Helper_Sets;
863
-
864
- Prj_Info : constant Project_Info_Access :=
865
- Get_Or_Create_Project_Info (IC, Source.Project);
866
- Prj : Prj_Desc renames Prj_Info.Desc;
867
- Is_Root_Prj : constant Boolean :=
868
- Prj.Prj_Name = Root_Project_Info.Project.Name;
869
- Source_Name : constant String :=
870
- GNATCOLL.VFS." +" (Source.File.Full_Name);
871
- Helper_Unit : Unbounded_String;
872
- Contained_Indication : Boolean := False;
873
-
874
- begin
875
- Instrumenter.Replace_Manual_Dump_Indication
876
- (Contained_Indication,
877
- Prj_Info.Desc,
878
- Source);
879
-
880
- if Contained_Indication and then not Is_Root_Prj
881
- then
882
- -- A call to the dump buffers procedure is only able to
883
- -- dump the buffers of the project it is in and its
884
- -- subprojects, meaning coverage data for all projects
885
- -- higher in the project tree will be missing. Record
886
- -- what file this call was in to warn the user later.
887
-
888
- Non_Root_Src_Calls.Include (Source_Name);
889
- end if ;
890
-
891
- -- Only generate one manual dump helper unit per project.
892
- -- At this point, if the project's object directory and the
893
- -- instrumented sources directory do not exist there is no
894
- -- need to emit the dump helper unit. There are no units of
895
- -- interest or call to a manual dump procedure for this
896
- -- project.
855
+ for Source of Project_Sources loop
856
+ if To_Language (Source.Language) = Language then
857
+ declare
858
+ use Prj_Has_Manual_Helper_Sets;
859
+
860
+ Prj_Info : constant Project_Info_Access :=
861
+ Get_Or_Create_Project_Info (IC, Source.Project);
862
+ Prj : Prj_Desc renames Prj_Info.Desc;
863
+ Is_Root_Prj : constant Boolean :=
864
+ Prj.Prj_Name = Root_Project_Info.Project.Name;
865
+ Source_Name : constant String :=
866
+ GNATCOLL.VFS." +" (Source.File.Full_Name);
867
+ Helper_Unit : Unbounded_String;
868
+ Contained_Indication : Boolean := False;
869
+ begin
870
+ Instrumenter.Replace_Manual_Dump_Indication
871
+ (Contained_Indication,
872
+ Prj_Info.Desc,
873
+ Source);
897
874
898
- if Prj_Has_Manual_Helper.Find (Prj.Prj_Name) = No_Element
899
- and then Dump_Helper_Output_Dir_Exists (Source, Prj)
900
- then
901
- Instrumenter.Emit_Dump_Helper_Unit_Manual
902
- (Helper_Unit, Dump_Config, Prj);
875
+ if Contained_Indication and then not Is_Root_Prj then
903
876
904
- declare
905
- use Files_Table;
906
- Instr_Units : Unit_Sets.Set;
907
- Source_Files : GNATCOLL.VFS.File_Array_Access
908
- := Source.Project.Source_Files (Recursive => True);
909
- begin
910
- for S of Source_Files.all loop
911
- declare
912
- use Unit_Maps;
913
- Unit_C : constant Unit_Maps.Cursor :=
914
- Instrumented_Sources.Find
915
- (+To_Compilation_Unit
916
- (Project.Project.Info (S)).Unit_Name);
917
- begin
918
- if Unit_C /= Unit_Maps.No_Element then
919
- declare
920
- Unit : constant Library_Unit_Info :=
921
- Element (Unit_C);
922
- Instr_Unit : constant Compilation_Unit :=
923
- Compilation_Unit'
924
- (Unit.Language_Kind,
925
- Unit.Unit_Name);
926
- begin
927
- if not Instr_Units.Contains (Instr_Unit)
928
- then
929
- Instr_Units.Insert (Instr_Unit);
930
- end if ;
931
- end ;
932
- end if ;
933
- end ;
934
- end loop ;
877
+ -- A call to the dump buffers procedure is only able to dump
878
+ -- the buffers of the project it is in and its subprojects,
879
+ -- meaning coverage data for all projects higher in the
880
+ -- project tree will be missing. Record what file this call
881
+ -- was in to warn the user later.
935
882
936
- -- The creation of the root project's buffers list
937
- -- unit is already taken care of by the regular
938
- -- instrumentation process, so skip it.
883
+ Non_Root_Src_Calls.Include (Source_Name);
884
+ end if ;
939
885
940
- if not Is_Root_Prj then
941
- Instrumenter.Emit_Buffers_List_Unit
942
- (Instr_Units, Prj);
943
- end if ;
886
+ -- Only generate one manual dump helper unit per project. At
887
+ -- this point, if the project's object directory and the
888
+ -- instrumented sources directory do not exist there is no need
889
+ -- to emit the dump helper unit. There are no units of interest
890
+ -- or call to a manual dump procedure for this project.
891
+
892
+ if Prj_Has_Manual_Helper.Find (Prj.Prj_Name) = No_Element
893
+ and then Dump_Helper_Output_Dir_Exists (Source, Prj)
894
+ then
895
+ Instrumenter.Emit_Dump_Helper_Unit_Manual
896
+ (Helper_Unit, Dump_Config, Prj);
897
+
898
+ declare
899
+ use Files_Table;
900
+ Instr_Units : Unit_Sets.Set;
901
+ Source_Files : GNATCOLL.VFS.File_Array_Access :=
902
+ Source.Project.Source_Files (Recursive => True);
903
+ begin
904
+ for S of Source_Files.all loop
905
+ declare
906
+ use Unit_Maps;
907
+ Unit_C : constant Unit_Maps.Cursor :=
908
+ Instrumented_Sources.Find
909
+ (+To_Compilation_Unit
910
+ (Project.Project.Info (S)).Unit_Name);
911
+ begin
912
+ if Unit_C /= Unit_Maps.No_Element then
913
+ declare
914
+ Unit : constant Library_Unit_Info :=
915
+ Element (Unit_C);
916
+ Instr_Unit : constant Compilation_Unit :=
917
+ Compilation_Unit'
918
+ (Unit.Language_Kind,
919
+ Unit.Unit_Name);
920
+ begin
921
+ if not Instr_Units.Contains (Instr_Unit) then
922
+ Instr_Units.Insert (Instr_Unit);
923
+ end if ;
924
+ end ;
925
+ end if ;
926
+ end ;
927
+ end loop ;
928
+
929
+ -- The creation of the root project's buffers list unit
930
+ -- is already taken care of by the regular
931
+ -- instrumentation process, so skip it.
932
+
933
+ if not Is_Root_Prj then
934
+ Instrumenter.Emit_Buffers_List_Unit (Instr_Units, Prj);
935
+ end if ;
944
936
945
- GNATCOLL.VFS.Unchecked_Free (Source_Files);
946
- end ;
937
+ GNATCOLL.VFS.Unchecked_Free (Source_Files);
938
+ end ;
947
939
948
- Prj_Has_Manual_Helper.Insert (Prj.Prj_Name);
949
- end if ;
940
+ Prj_Has_Manual_Helper.Insert (Prj.Prj_Name);
941
+ end if ;
950
942
951
- Manual_Dump_Inserted :=
952
- Manual_Dump_Inserted or else Contained_Indication;
953
- end ;
954
- end if ;
955
- end ;
943
+ Manual_Dump_Inserted :=
944
+ Manual_Dump_Inserted or else Contained_Indication;
945
+ end ;
946
+ end if ;
956
947
end loop ;
957
948
958
949
if not Non_Root_Src_Calls.Is_Empty then
950
+
959
951
-- For each manual dump call inserted in a file belonging to a
960
952
-- non-root project, warn the user the coverage data it will produce
961
953
-- will not cover the whole project tree.
962
954
963
955
declare
964
- All_File_Names : Unbounded_String := + " " ;
956
+ All_File_Names : Unbounded_String;
965
957
begin
966
958
for File_Name of Non_Root_Src_Calls loop
967
- All_File_Names :=
968
- All_File_Names & (+File_Name) & Ada.Characters.Latin_1.LF ;
959
+ Append ( All_File_Names, File_Name);
960
+ Append ( All_File_Names, ASCII.LF) ;
969
961
end loop ;
970
962
971
- Outputs.Warn (" Manual dump trigger indications were found in"
972
- & " subprojects in the following files:"
973
- & Ada.Characters.Latin_1.LF
974
- & (+All_File_Names)
975
- & " The coverage report built from the source traces"
976
- & " they will produce will show all code from"
977
- & " projects higher in the project tree as not"
978
- & " covered. To get a full coverage analysis,"
979
- & " consider placing the manual dump buffers"
980
- & " indication in the root project." );
963
+ Outputs.Warn
964
+ (" Manual dump trigger indications were found in subprojects in"
965
+ & " the following files:" & ASCII.LF
966
+ & (+All_File_Names)
967
+ & " The coverage report built from the source traces they will"
968
+ & " produce will show all code from projects higher in the"
969
+ & " project tree as not covered. To get a full coverage"
970
+ & " analysis, consider placing the manual dump buffers"
971
+ & " indication in the root project." );
981
972
end ;
982
973
end if ;
983
974
end Insert_Manual_Dump_Trigger ;
1047
1038
C_Language => C_Instrumenter'Access ,
1048
1039
CPP_Language => CPP_Instrumenter'Access );
1049
1040
1050
- -- Start of processing for Instrument_Units_Of_Interest
1041
+ -- Start of processing for Instrument_Units_Of_Interest
1051
1042
1052
1043
begin
1053
1044
-- Set the instrumentation tag
@@ -1212,6 +1203,7 @@ begin
1212
1203
CPP_Instrumenter := Create_CPP_Instrumenter (IC.Tag);
1213
1204
1214
1205
if Dump_Config.Trigger = Manual then
1206
+
1215
1207
-- Replace manual dump indications for C-like languages
1216
1208
1217
1209
for Lang in C_Family_Language loop
@@ -1257,7 +1249,6 @@ begin
1257
1249
Instrument_Source_Args.Append
1258
1250
(Common_Switches (Cmd_Instrument_Source));
1259
1251
for Cur in Instrumented_Sources.Iterate loop
1260
-
1261
1252
declare
1262
1253
Unit_Args : String_Vectors.Vector :=
1263
1254
Instrument_Source_Args.Copy;
@@ -1283,12 +1274,7 @@ begin
1283
1274
1284
1275
-- Add the arguments that are specific to the compilation unit
1285
1276
1286
- Unit_Args.Append
1287
- (Compilation_Unit_Options
1288
- (IC,
1289
- Desc,
1290
- LU_Info));
1291
-
1277
+ Unit_Args.Append (Compilation_Unit_Options (IC, Desc, LU_Info));
1292
1278
Unit_Args.Append (+" --sid=" & Obj_SID);
1293
1279
1294
1280
-- We instrument the body, spec and separates as a whole
0 commit comments