Skip to content

Commit 457233f

Browse files
committed
Checkpoints: rework use of last checkpoint format version when writing
gnatcov always use the version of the checkpoint file format when writing a SID/checkpoint. Using this fact, move the "Version" information from read/write common code to read-specific code.
1 parent c1972f9 commit 457233f

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

tools/gnatcov/checkpoints.adb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,7 @@ package body Checkpoints is
443443
Context : access Coverage.Context;
444444
Purpose : Checkpoint_Purpose)
445445
is
446-
Version : constant Checkpoint_Version := Checkpoint_Version'Last;
447-
SF : Ada.Streams.Stream_IO.File_Type;
446+
SF : Ada.Streams.Stream_IO.File_Type;
448447
begin
449448
Create (SF, Out_File, Filename);
450449

@@ -455,12 +454,11 @@ package body Checkpoints is
455454
(Root_Stream_Type with
456455
Stream => Stream (SF),
457456
Filename => To_Unbounded_String (Filename),
458-
Version => Version,
459457
Purpose => Purpose);
460458
Supported_Levels : Levels_Type := Current_Levels;
461459
begin
462460
Checkpoint_Header'Write
463-
(CSS.Stream, (Version => Version, others => <>));
461+
(CSS.Stream, (Version => Checkpoint_Version'Last, others => <>));
464462

465463
Checkpoint_Purpose'Write (CSS.Stream, Purpose);
466464

tools/gnatcov/checkpoints.ads

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,6 @@ package Checkpoints is
241241
Filename : Unbounded_String;
242242
-- Name of the checkpoint being written/read
243243

244-
Version : Checkpoint_Version;
245-
-- Format version for the checkpoint being written/read
246-
247244
Purpose : Checkpoint_Purpose;
248245
-- Purpose for the checkpoint being written/read
249246
end record;
@@ -257,14 +254,6 @@ package Checkpoints is
257254
Item : Stream_Element_Array);
258255
-- Read/write from/to underlying stream
259256

260-
use type Interfaces.Unsigned_32;
261-
function Version_Less
262-
(SS : Stateful_Stream'Class; Than : Checkpoint_Version) return Boolean
263-
is (SS.Version < Than)
264-
with Inline;
265-
-- This is provided as a function to prevent the compiler from generating
266-
-- "can never be greater than" warnings.
267-
268257
function Purpose_Of
269258
(SS : Stateful_Stream'Class) return Checkpoint_Purpose
270259
is (SS.Purpose)
@@ -279,9 +268,20 @@ package Checkpoints is
279268
-- Global state shared across phases of a checkpoint load
280269

281270
type Checkpoint_Load_State is new Stateful_Stream with record
271+
Version : Checkpoint_Version;
272+
-- Format version for the checkpoint being read
273+
282274
Relocations : Checkpoint_Relocations;
283275
end record;
284276

277+
use type Interfaces.Unsigned_32;
278+
function Version_Less
279+
(CLS : Checkpoint_Load_State; Than : Checkpoint_Version) return Boolean
280+
is (CLS.Version < Than)
281+
with Inline;
282+
-- This is provided as a function to prevent the compiler from generating
283+
-- "can never be greater than" warnings.
284+
285285
procedure Checkpoint_Save
286286
(Filename : String;
287287
Context : access Coverage.Context;

0 commit comments

Comments
 (0)