Skip to content

Commit 86c6c60

Browse files
committed
Remove YAML witness 0.1 entry types
1 parent 02996ab commit 86c6c60

File tree

5 files changed

+6
-202
lines changed

5 files changed

+6
-202
lines changed

src/analyses/unassumeAnalysis.ml

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -113,30 +113,6 @@ struct
113113
M.info ~category:Witness ~loc:msgLoc "invariant has invalid syntax: %s" inv
114114
in
115115

116-
let unassume_location_invariant (location_invariant: YamlWitnessType.LocationInvariant.t) =
117-
let loc = YamlWitness.loc_of_location location_invariant.location in
118-
let inv = location_invariant.location_invariant.string in
119-
let msgLoc: M.Location.t = CilLocation loc in
120-
121-
match Locator.find_opt location_locator loc with
122-
| Some nodes ->
123-
unassume_nodes_invariant ~loc ~nodes inv
124-
| None ->
125-
M.warn ~category:Witness ~loc:msgLoc "couldn't locate invariant: %s" inv
126-
in
127-
128-
let unassume_loop_invariant (loop_invariant: YamlWitnessType.LoopInvariant.t) =
129-
let loc = YamlWitness.loc_of_location loop_invariant.location in
130-
let inv = loop_invariant.loop_invariant.string in
131-
let msgLoc: M.Location.t = CilLocation loc in
132-
133-
match Locator.find_opt loop_locator loc with
134-
| Some nodes ->
135-
unassume_nodes_invariant ~loc ~nodes inv
136-
| None ->
137-
M.warn ~category:Witness ~loc:msgLoc "couldn't locate invariant: %s" inv
138-
in
139-
140116
let unassume_invariant_set (invariant_set: YamlWitnessType.InvariantSet.t) =
141117

142118
let unassume_location_invariant ~i (location_invariant: YamlWitnessType.InvariantSet.LocationInvariant.t) =
@@ -180,13 +156,9 @@ struct
180156
in
181157

182158
match YamlWitness.entry_type_enabled target_type, entry.entry_type with
183-
| true, LocationInvariant x ->
184-
unassume_location_invariant x
185-
| true, LoopInvariant x ->
186-
unassume_loop_invariant x
187159
| true, InvariantSet x ->
188160
unassume_invariant_set x
189-
| false, (LocationInvariant _ | LoopInvariant _ | InvariantSet _) ->
161+
| false, InvariantSet _ ->
190162
M.info_noloc ~category:Witness "disabled entry of type %s" target_type
191163
| _ ->
192164
M.warn_noloc ~category:Witness "cannot unassume entry of type %s" target_type

src/config/options.schema.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,8 +2803,6 @@
28032803
"items": {
28042804
"type": "string",
28052805
"enum": [
2806-
"location_invariant",
2807-
"loop_invariant",
28082806
"invariant_set",
28092807
"violation_sequence",
28102808
"ghost_instrumentation"

src/witness/yamlWitness.ml

Lines changed: 3 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,9 @@ struct
6363
type_ = "assertion";
6464
format = "C";
6565
}
66+
(* TODO: remove above? *)
6667

67-
let location_invariant ~task ~location ~(invariant): Entry.t = {
68-
entry_type = LocationInvariant {
69-
location;
70-
location_invariant = invariant;
71-
};
72-
metadata = metadata ~task ();
73-
}
74-
75-
let loop_invariant ~task ~location ~(invariant): Entry.t = {
76-
entry_type = LoopInvariant {
77-
location;
78-
loop_invariant = invariant;
79-
};
80-
metadata = metadata ~task ();
81-
}
82-
68+
(* TODO: remove primes from name *)
8369
let location_invariant' ~location ~(invariant): InvariantSet.Invariant.t = {
8470
invariant_type = LocationInvariant {
8571
location;
@@ -245,69 +231,6 @@ struct
245231
let cnt_flow_insensitive_invariant = ref 0 in
246232
(* TODO: precondition invariants? *)
247233

248-
(* Generate location invariants (without precondition) *)
249-
let entries =
250-
if entry_type_enabled YamlWitnessType.LocationInvariant.entry_type then (
251-
LH.fold (fun loc ns acc ->
252-
let inv = List.fold_left (fun acc n ->
253-
let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in
254-
let lvals = local_lvals n local in
255-
Invariant.(acc || R.ask_local_node n ~local (Invariant {Invariant.default_context with lvals})) [@coverage off] (* bisect_ppx cannot handle redefined (||) *)
256-
) (Invariant.bot ()) ns
257-
in
258-
match inv with
259-
| `Lifted inv ->
260-
let fundec = Node.find_fundec (List.hd ns) in (* TODO: fix location hack *)
261-
let location_function = fundec.svar.vname in
262-
let location = Entry.location ~location:loc ~location_function in
263-
let invs = WitnessUtil.InvariantExp.process_exp inv in
264-
List.fold_left (fun acc inv ->
265-
let invariant = Entry.invariant (CilType.Exp.show inv) in
266-
let entry = Entry.location_invariant ~task ~location ~invariant in
267-
incr cnt_location_invariant;
268-
entry :: acc
269-
) acc invs
270-
| `Bot | `Top -> (* TODO: 0 for bot (dead code)? *)
271-
acc
272-
) (Lazy.force location_nodes) entries
273-
)
274-
else
275-
entries
276-
in
277-
278-
(* Generate loop invariants (without precondition) *)
279-
let entries =
280-
if entry_type_enabled YamlWitnessType.LoopInvariant.entry_type then (
281-
LH.fold (fun loc ns acc ->
282-
if WitnessInvariant.emit_loop_head then ( (* TODO: remove double condition? needs both loop_invariant entry enabled and witness.invariant.loop-head option enabled *)
283-
let inv = List.fold_left (fun acc n ->
284-
let local = try NH.find (Lazy.force nh) n with Not_found -> Spec.D.bot () in
285-
Invariant.(acc || R.ask_local_node n ~local (Invariant Invariant.default_context)) [@coverage off] (* bisect_ppx cannot handle redefined (||) *)
286-
) (Invariant.bot ()) ns
287-
in
288-
match inv with
289-
| `Lifted inv ->
290-
let fundec = Node.find_fundec (List.hd ns) in (* TODO: fix location hack *)
291-
let location_function = fundec.svar.vname in
292-
let location = Entry.location ~location:loc ~location_function in
293-
let invs = WitnessUtil.InvariantExp.process_exp inv in
294-
List.fold_left (fun acc inv ->
295-
let invariant = Entry.invariant (CilType.Exp.show inv) in
296-
let entry = Entry.loop_invariant ~task ~location ~invariant in
297-
incr cnt_loop_invariant;
298-
entry :: acc
299-
) acc invs
300-
| `Bot | `Top -> (* TODO: 0 for bot (dead code)? *)
301-
acc
302-
)
303-
else
304-
acc
305-
) (Lazy.force loop_nodes) entries
306-
)
307-
else
308-
entries
309-
in
310-
311234
let invariant_global_nodes = lazy (R.ask_global InvariantGlobalNodes) in
312235

313236
let fold_flow_insensitive_as_location ~inv f acc =
@@ -627,30 +550,6 @@ struct
627550
M.info ~category:Witness ~loc:msgLoc "invariant has invalid syntax: %s" inv
628551
in
629552

630-
let validate_location_invariant (location_invariant: YamlWitnessType.LocationInvariant.t) =
631-
let loc = loc_of_location location_invariant.location in
632-
let inv = location_invariant.location_invariant.string in
633-
634-
match Locator.find_opt location_locator loc with
635-
| Some lvars ->
636-
validate_lvars_invariant ~loc ~lvars inv
637-
| None ->
638-
incr cnt_error;
639-
M.warn ~category:Witness ~loc:(CilLocation loc) "couldn't locate invariant: %s" inv
640-
in
641-
642-
let validate_loop_invariant (loop_invariant: YamlWitnessType.LoopInvariant.t) =
643-
let loc = loc_of_location loop_invariant.location in
644-
let inv = loop_invariant.loop_invariant.string in
645-
646-
match Locator.find_opt loop_locator loc with
647-
| Some lvars ->
648-
validate_lvars_invariant ~loc ~lvars inv
649-
| None ->
650-
incr cnt_error;
651-
M.warn ~category:Witness ~loc:(CilLocation loc) "couldn't locate invariant: %s" inv
652-
in
653-
654553
let validate_invariant_set (invariant_set: YamlWitnessType.InvariantSet.t) =
655554

656555
let validate_location_invariant (location_invariant: YamlWitnessType.InvariantSet.LocationInvariant.t) =
@@ -705,15 +604,11 @@ struct
705604
in
706605

707606
match entry_type_enabled target_type, entry.entry_type with
708-
| true, LocationInvariant x ->
709-
validate_location_invariant x
710-
| true, LoopInvariant x ->
711-
validate_loop_invariant x
712607
| true, InvariantSet x ->
713608
validate_invariant_set x
714609
| true, ViolationSequence x ->
715610
validate_violation_sequence x
716-
| false, (LocationInvariant _ | LoopInvariant _ | InvariantSet _ | ViolationSequence _) ->
611+
| false, (InvariantSet _ | ViolationSequence _) ->
717612
incr cnt_disabled;
718613
M.info_noloc ~category:Witness "disabled entry of type %s" target_type
719614
| _ ->

src/witness/yamlWitnessType.ml

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -174,52 +174,7 @@ struct
174174
and+ format = y |> find "format" >>= to_string in
175175
{string; type_; format}
176176
end
177-
178-
module LoopInvariant =
179-
struct
180-
type t = {
181-
location: Location.t;
182-
loop_invariant: Invariant.t;
183-
}
184-
[@@deriving eq, ord, hash]
185-
186-
let entry_type = "loop_invariant"
187-
188-
let to_yaml' {location; loop_invariant} =
189-
[
190-
("location", Location.to_yaml location);
191-
("loop_invariant", Invariant.to_yaml loop_invariant);
192-
]
193-
194-
let of_yaml y =
195-
let open GobYaml in
196-
let+ location = y |> find "location" >>= Location.of_yaml
197-
and+ loop_invariant = y |> find "loop_invariant" >>= Invariant.of_yaml in
198-
{location; loop_invariant}
199-
end
200-
201-
module LocationInvariant =
202-
struct
203-
type t = {
204-
location: Location.t;
205-
location_invariant: Invariant.t;
206-
}
207-
[@@deriving eq, ord, hash]
208-
209-
let entry_type = "location_invariant"
210-
211-
let to_yaml' {location; location_invariant} =
212-
[
213-
("location", Location.to_yaml location);
214-
("location_invariant", Invariant.to_yaml location_invariant);
215-
]
216-
217-
let of_yaml y =
218-
let open GobYaml in
219-
let+ location = y |> find "location" >>= Location.of_yaml
220-
and+ location_invariant = y |> find "location_invariant" >>= Invariant.of_yaml in
221-
{location; location_invariant}
222-
end
177+
(* TODO: remove above things? *)
223178

224179
module InvariantSet =
225180
struct
@@ -693,37 +648,25 @@ end
693648
module EntryType =
694649
struct
695650
type t =
696-
| LocationInvariant of LocationInvariant.t
697-
| LoopInvariant of LoopInvariant.t
698651
| InvariantSet of InvariantSet.t
699652
| ViolationSequence of ViolationSequence.t
700653
| GhostInstrumentation of GhostInstrumentation.t
701654
[@@deriving eq, ord, hash]
702655

703656
let entry_type = function
704-
| LocationInvariant _ -> LocationInvariant.entry_type
705-
| LoopInvariant _ -> LoopInvariant.entry_type
706657
| InvariantSet _ -> InvariantSet.entry_type
707658
| ViolationSequence _ -> ViolationSequence.entry_type
708659
| GhostInstrumentation _ -> GhostInstrumentation.entry_type
709660

710661
let to_yaml' = function
711-
| LocationInvariant x -> LocationInvariant.to_yaml' x
712-
| LoopInvariant x -> LoopInvariant.to_yaml' x
713662
| InvariantSet x -> InvariantSet.to_yaml' x
714663
| ViolationSequence x -> ViolationSequence.to_yaml' x
715664
| GhostInstrumentation x -> GhostInstrumentation.to_yaml' x
716665

717666
let of_yaml y =
718667
let open GobYaml in
719668
let* entry_type = y |> find "entry_type" >>= to_string in
720-
if entry_type = LocationInvariant.entry_type then
721-
let+ x = y |> LocationInvariant.of_yaml in
722-
LocationInvariant x
723-
else if entry_type = LoopInvariant.entry_type then
724-
let+ x = y |> LoopInvariant.of_yaml in
725-
LoopInvariant x
726-
else if entry_type = InvariantSet.entry_type then
669+
if entry_type = InvariantSet.entry_type then
727670
let+ x = y |> InvariantSet.of_yaml in
728671
InvariantSet x
729672
else if entry_type = ViolationSequence.entry_type then

tests/util/yamlWitnessStripCommon.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ struct
5757
in
5858
let entry_type: EntryType.t =
5959
match entry_type with
60-
| LocationInvariant x ->
61-
LocationInvariant {x with location = location_strip_file_hash x.location}
62-
| LoopInvariant x ->
63-
LoopInvariant {x with location = location_strip_file_hash x.location}
6460
| InvariantSet x ->
6561
InvariantSet {content = List.sort InvariantSet.Invariant.compare (List.map invariant_strip_file_hash x.content)} (* Sort, so order is deterministic regardless of Goblint. *)
6662
| ViolationSequence x ->

0 commit comments

Comments
 (0)