@@ -80,14 +80,6 @@ struct
8080 metadata = metadata ~task () ;
8181 }
8282
83- (* non-standard extension *)
84- let flow_insensitive_invariant ~task ~(invariant ): Entry.t = {
85- entry_type = FlowInsensitiveInvariant {
86- flow_insensitive_invariant = invariant;
87- };
88- metadata = metadata ~task () ;
89- }
90-
9183 (* non-standard extension *)
9284 let precondition_loop_invariant ~task ~location ~precondition ~(invariant ): Entry.t = {
9385 entry_type = PreconditionLoopInvariant {
@@ -114,6 +106,14 @@ struct
114106 };
115107 }
116108
109+ (* non-standard extension *)
110+ let flow_insensitive_invariant' ~(invariant ): InvariantSet.Invariant.t = {
111+ invariant_type = FlowInsensitiveInvariant {
112+ value = invariant;
113+ format = " c_expression" ;
114+ };
115+ }
116+
117117 let invariant_set ~task ~(invariants ): Entry.t = {
118118 entry_type = InvariantSet {
119119 content = invariants;
@@ -338,40 +338,6 @@ struct
338338 ) (Lazy. force invariant_global_nodes) acc
339339 in
340340
341- (* Generate flow-insensitive invariants *)
342- let entries =
343- if entry_type_enabled YamlWitnessType.FlowInsensitiveInvariant. entry_type then (
344- GHT. fold (fun g v acc ->
345- match g with
346- | `Left g -> (* global unknown from analysis Spec *)
347- begin match R. ask_global (InvariantGlobal (Obj. repr g)), GobConfig. get_string " witness.invariant.flow_insensitive-as" with
348- | `Lifted inv , "flow_insensitive_invariant" ->
349- let invs = WitnessUtil.InvariantExp. process_exp inv in
350- List. fold_left (fun acc inv ->
351- let invariant = Entry. invariant (CilType.Exp. show inv) in
352- let entry = Entry. flow_insensitive_invariant ~task ~invariant in
353- incr cnt_flow_insensitive_invariant;
354- entry :: acc
355- ) acc invs
356- | `Lifted inv , "location_invariant" ->
357- fold_flow_insensitive_as_location ~inv (fun ~location ~inv acc ->
358- let invariant = Entry. invariant (CilType.Exp. show inv) in
359- let entry = Entry. location_invariant ~task ~location ~invariant in
360- incr cnt_location_invariant;
361- entry :: acc
362- ) acc
363- | `Lifted _, _
364- | `Bot , _ | `Top , _ -> (* global bot might only be possible for alloc variables, if at all, so emit nothing *)
365- acc
366- end
367- | `Right _ -> (* global unknown for FromSpec contexts *)
368- acc
369- ) gh entries
370- )
371- else
372- entries
373- in
374-
375341 (* Generate flow-insensitive entries (ghost instrumentation) *)
376342 let entries =
377343 if entry_type_enabled YamlWitnessType.GhostInstrumentation. entry_type then (
@@ -502,12 +468,12 @@ struct
502468
503469 (* Generate invariant set *)
504470 let entries =
505- if entry_type_enabled YamlWitnessType.InvariantSet. entry_type || entry_type_enabled YamlWitnessType.FlowInsensitiveInvariant. entry_type && GobConfig. get_string " witness.invariant.flow_insensitive-as " = " invariant_set-location_invariant " then (
471+ if entry_type_enabled YamlWitnessType.InvariantSet. entry_type then (
506472 let invariants = [] in
507473
508474 (* Generate location invariants *)
509475 let invariants =
510- if entry_type_enabled YamlWitnessType.InvariantSet. entry_type && invariant_type_enabled YamlWitnessType.InvariantSet.LocationInvariant. invariant_type then (
476+ if invariant_type_enabled YamlWitnessType.InvariantSet.LocationInvariant. invariant_type then (
511477 LH. fold (fun loc ns acc ->
512478 let inv = List. fold_left (fun acc n ->
513479 let local = try NH. find (Lazy. force nh) n with Not_found -> Spec.D. bot () in
@@ -537,7 +503,7 @@ struct
537503
538504 (* Generate loop invariants *)
539505 let invariants =
540- if entry_type_enabled YamlWitnessType.InvariantSet. entry_type && invariant_type_enabled YamlWitnessType.InvariantSet.LoopInvariant. invariant_type then (
506+ if invariant_type_enabled YamlWitnessType.InvariantSet.LoopInvariant. invariant_type then (
541507 LH. fold (fun loc ns acc ->
542508 if WitnessInvariant. emit_loop_head then ( (* TODO: remove double condition? *)
543509 let inv = List. fold_left (fun acc n ->
@@ -568,21 +534,31 @@ struct
568534 invariants
569535 in
570536
571- (* Generate flow-insensitive invariants as location invariants *)
537+ (* Generate flow-insensitive invariants *)
572538 let invariants =
573- if entry_type_enabled YamlWitnessType.FlowInsensitiveInvariant. entry_type && GobConfig. get_string " witness.invariant.flow_insensitive-as " = " invariant_set-location_invariant " then (
539+ if invariant_type_enabled YamlWitnessType.InvariantSet. FlowInsensitiveInvariant. invariant_type then (
574540 GHT. fold (fun g v acc ->
575541 match g with
576542 | `Left g -> (* global unknown from analysis Spec *)
577- begin match R. ask_global (InvariantGlobal (Obj. repr g)) with
578- | `Lifted inv ->
543+ begin match R. ask_global (InvariantGlobal (Obj. repr g)), GobConfig. get_string " witness.invariant.flow_insensitive-as" with
544+ | `Lifted inv , "invariant_set-flow_insensitive_invariant" ->
545+ let invs = WitnessUtil.InvariantExp. process_exp inv in
546+ List. fold_left (fun acc inv ->
547+ let invariant = CilType.Exp. show inv in
548+ let invariant = Entry. flow_insensitive_invariant' ~invariant in
549+ incr cnt_flow_insensitive_invariant;
550+ invariant :: acc
551+ ) acc invs
552+ | `Lifted inv , "invariant_set-location_invariant" ->
553+ (* TODO: fold_flow_insensitive_as_location is now only used here, inline/move? *)
579554 fold_flow_insensitive_as_location ~inv (fun ~location ~inv acc ->
580555 let invariant = CilType.Exp. show inv in
581556 let invariant = Entry. location_invariant' ~location ~invariant in
582557 incr cnt_location_invariant;
583558 invariant :: acc
584559 ) acc
585- | `Bot | `Top -> (* global bot might only be possible for alloc variables, if at all, so emit nothing *)
560+ | `Lifted _, _
561+ | `Bot , _ | `Top , _ -> (* global bot might only be possible for alloc variables, if at all, so emit nothing *)
586562 acc
587563 end
588564 | `Right _ -> (* global unknown for FromSpec contexts *)
@@ -866,7 +842,10 @@ struct
866842 validate_loop_invariant x
867843 | false , (LocationInvariant _ | LoopInvariant _ ) ->
868844 incr cnt_disabled;
869- M. info_noloc ~category: Witness " disabled invariant of type %s" target_type;
845+ M. info_noloc ~category: Witness " disabled invariant of type %s" target_type
846+ | _ ->
847+ incr cnt_unsupported;
848+ M. warn_noloc ~category: Witness " cannot validate invariant of type %s" target_type
870849 in
871850
872851 List. iter validate_invariant invariant_set.content
0 commit comments