Skip to content

Commit 44576fb

Browse files
committed
instr-c: Simplify declaration of Make_(Stmt|Expr)_Witness functions
1 parent b0013c8 commit 44576fb

File tree

1 file changed

+21
-41
lines changed

1 file changed

+21
-41
lines changed

tools/gnatcov/instrument-c.adb

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -305,20 +305,6 @@ package body Instrument.C is
305305
-- Note that while Buffers_Index is 1-based, C arrays are 0-based, hence
306306
-- the index "off-by-1" conversion.
307307

308-
function Make_Expr_Witness
309-
(UIC : C_Unit_Inst_Context;
310-
Buffer_Index : Positive;
311-
Bit : Bit_Id) return String;
312-
-- Create a procedure call expression on to witness execution of the low
313-
-- level SCO with the given Bit id in the statement buffer at Buffer_Index.
314-
315-
function Make_Statement_Witness
316-
(UIC : C_Unit_Inst_Context;
317-
Buffer_Index : Positive;
318-
Bit : Bit_Id) return String;
319-
-- Create a procedure call statement to witness execution of the low level
320-
-- SCO with the given Bit id in the statement buffer at Buffer_Index.
321-
322308
procedure Insert_Statement_Witness
323309
(UIC : in out C_Unit_Inst_Context;
324310
Buffers_Index : Positive;
@@ -1317,33 +1303,6 @@ package body Instrument.C is
13171303
Kind);
13181304
end Report;
13191305

1320-
-----------------------
1321-
-- Make_Expr_Witness --
1322-
-----------------------
1323-
1324-
function Make_Expr_Witness
1325-
(UIC : C_Unit_Inst_Context;
1326-
Buffer_Index : Positive;
1327-
Bit : Bit_Id) return String is
1328-
begin
1329-
return
1330-
"gnatcov_rts_witness ("
1331-
& Statement_Buffer_Symbol (UIC.Instrumented_Unit)
1332-
& Buffers_Subscript (Buffer_Index) & ", " & Img (Bit) & ")";
1333-
end Make_Expr_Witness;
1334-
1335-
----------------------------
1336-
-- Make_Statement_Witness --
1337-
----------------------------
1338-
1339-
function Make_Statement_Witness
1340-
(UIC : C_Unit_Inst_Context;
1341-
Buffer_Index : Positive;
1342-
Bit : Bit_Id) return String is
1343-
begin
1344-
return Make_Expr_Witness (UIC, Buffer_Index, Bit) & ";";
1345-
end Make_Statement_Witness;
1346-
13471306
------------------------------
13481307
-- Insert_Statement_Witness --
13491308
------------------------------
@@ -1359,6 +1318,27 @@ package body Instrument.C is
13591318

13601319
Bit : constant Bit_Id :=
13611320
Allocate_Statement_Bit (Unit_Bits, SS.LL_SCO);
1321+
1322+
function Make_Expr_Witness
1323+
(UIC : C_Unit_Inst_Context;
1324+
Buffer_Index : Positive;
1325+
Bit : Bit_Id) return String
1326+
is ("gnatcov_rts_witness ("
1327+
& Statement_Buffer_Symbol (UIC.Instrumented_Unit)
1328+
& Buffers_Subscript (Buffer_Index) & ", " & Img (Bit) & ")");
1329+
-- Create a procedure call expression on to witness execution of the low
1330+
-- level SCO with the given Bit id in the statement buffer at
1331+
-- Buffer_Index.
1332+
1333+
function Make_Statement_Witness
1334+
(UIC : C_Unit_Inst_Context;
1335+
Buffer_Index : Positive;
1336+
Bit : Bit_Id) return String
1337+
is (Make_Expr_Witness (UIC, Buffer_Index, Bit) & ";");
1338+
-- Create a procedure call statement to witness execution of the low
1339+
-- level SCO with the given Bit id in the statement buffer at
1340+
-- Buffer_Index.
1341+
13621342
begin
13631343
-- Insert the call to the witness function: as a foregoing statement if
13641344
-- SS.Statement is a statement, or as a previous expression (using the

0 commit comments

Comments
 (0)