@@ -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 | _ ->
0 commit comments