Skip to content

Commit 7c53da4

Browse files
Merge branch 'master' into multishot-svcomp25
2 parents 76e3b5d + cfcef17 commit 7c53da4

35 files changed

+2321
-2730
lines changed

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
6767
PULL_REQUEST_NUMBER: ${{ github.event.number }}
6868

69-
- uses: actions/upload-artifact@v4
69+
- uses: actions/upload-artifact@v5
7070
if: always()
7171
with:
7272
name: suite_result

.github/workflows/locked.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
- name: Test
6161
run: opam exec -- dune runtest
6262

63-
- uses: actions/upload-artifact@v4
63+
- uses: actions/upload-artifact@v5
6464
if: always()
6565
with:
6666
name: suite_result-${{ matrix.os }}

conf/svcomp-ghost.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@
117117
"sv-comp-true-only": false,
118118
"format-version": "2.1",
119119
"entry-types": [
120-
"flow_insensitive_invariant",
121120
"ghost_instrumentation"
121+
],
122+
"invariant-types": [
123+
"flow_insensitive_invariant"
122124
]
123125
},
124126
"invariant": {

src/analyses/unassumeAnalysis.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ struct
222222
unassume_loop_invariant ~i x
223223
| false, (LocationInvariant _ | LoopInvariant _) ->
224224
M.info_noloc ~category:Witness "disabled invariant of type %s" target_type
225+
| _ ->
226+
M.warn_noloc ~category:Witness "cannot unassume invariant of type %s" target_type
225227
in
226228

227229
List.iteri validate_invariant invariant_set.content

src/config/options.schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,8 +2763,8 @@
27632763
"title": "witness.invariant.flow_insensitive-as",
27642764
"description": "Emit flow-insensitive invariants as location invariants at certain locations.",
27652765
"type": "string",
2766-
"enum": ["flow_insensitive_invariant", "location_invariant", "invariant_set-location_invariant"],
2767-
"default": "flow_insensitive_invariant"
2766+
"enum": ["invariant_set-flow_insensitive_invariant", "invariant_set-location_invariant"],
2767+
"default": "invariant_set-flow_insensitive_invariant"
27682768
}
27692769
},
27702770
"additionalProperties": false
@@ -2805,7 +2805,6 @@
28052805
"enum": [
28062806
"location_invariant",
28072807
"loop_invariant",
2808-
"flow_insensitive_invariant",
28092808
"precondition_loop_invariant",
28102809
"invariant_set",
28112810
"violation_sequence",
@@ -2824,7 +2823,8 @@
28242823
"type": "string",
28252824
"enum": [
28262825
"location_invariant",
2827-
"loop_invariant"
2826+
"loop_invariant",
2827+
"flow_insensitive_invariant"
28282828
]
28292829
},
28302830
"default": [

src/witness/yamlWitness.ml

Lines changed: 30 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/witness/yamlWitnessType.ml

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -221,26 +221,6 @@ struct
221221
{location; location_invariant}
222222
end
223223

224-
module FlowInsensitiveInvariant =
225-
struct
226-
type t = {
227-
flow_insensitive_invariant: Invariant.t;
228-
}
229-
[@@deriving eq, ord, hash]
230-
231-
let entry_type = "flow_insensitive_invariant"
232-
233-
let to_yaml' {flow_insensitive_invariant} =
234-
[
235-
("flow_insensitive_invariant", Invariant.to_yaml flow_insensitive_invariant);
236-
]
237-
238-
let of_yaml y =
239-
let open GobYaml in
240-
let+ flow_insensitive_invariant = y |> find "flow_insensitive_invariant" >>= Invariant.of_yaml in
241-
{flow_insensitive_invariant}
242-
end
243-
244224
module PreconditionLoopInvariant =
245225
struct
246226
type t = {
@@ -302,21 +282,47 @@ struct
302282
let invariant_type = "location_invariant"
303283
end
304284

285+
module FlowInsensitiveInvariant =
286+
struct
287+
type t = {
288+
value: string;
289+
format: string;
290+
}
291+
[@@deriving eq, ord, hash]
292+
293+
let invariant_type = "flow_insensitive_invariant"
294+
295+
let to_yaml' {value; format} =
296+
[
297+
("value", `String value);
298+
("format", `String format);
299+
]
300+
301+
let of_yaml y =
302+
let open GobYaml in
303+
let+ value = y |> find "value" >>= to_string
304+
and+ format = y |> find "format" >>= to_string in
305+
{value; format}
306+
end
307+
305308
(* TODO: could maybe use GADT, but adds ugly existential layer to entry type pattern matching *)
306309
module InvariantType =
307310
struct
308311
type t =
309312
| LocationInvariant of LocationInvariant.t
310313
| LoopInvariant of LoopInvariant.t
314+
| FlowInsensitiveInvariant of FlowInsensitiveInvariant.t
311315
[@@deriving eq, ord, hash]
312316

313317
let invariant_type = function
314318
| LocationInvariant _ -> LocationInvariant.invariant_type
315319
| LoopInvariant _ -> LoopInvariant.invariant_type
320+
| FlowInsensitiveInvariant _ -> FlowInsensitiveInvariant.invariant_type
316321

317322
let to_yaml' = function
318323
| LocationInvariant x -> LocationInvariant.to_yaml' x
319324
| LoopInvariant x -> LoopInvariant.to_yaml' x
325+
| FlowInsensitiveInvariant x -> FlowInsensitiveInvariant.to_yaml' x
320326

321327
let of_yaml y =
322328
let open GobYaml in
@@ -327,6 +333,9 @@ struct
327333
else if invariant_type = LoopInvariant.invariant_type then
328334
let+ x = y |> LoopInvariant.of_yaml in
329335
LoopInvariant x
336+
else if invariant_type = FlowInsensitiveInvariant.invariant_type then
337+
let+ x = y |> FlowInsensitiveInvariant.of_yaml in
338+
FlowInsensitiveInvariant x
330339
else
331340
Error (`Msg "type")
332341
end
@@ -712,7 +721,6 @@ struct
712721
type t =
713722
| LocationInvariant of LocationInvariant.t
714723
| LoopInvariant of LoopInvariant.t
715-
| FlowInsensitiveInvariant of FlowInsensitiveInvariant.t
716724
| PreconditionLoopInvariant of PreconditionLoopInvariant.t
717725
| InvariantSet of InvariantSet.t
718726
| ViolationSequence of ViolationSequence.t
@@ -722,7 +730,6 @@ struct
722730
let entry_type = function
723731
| LocationInvariant _ -> LocationInvariant.entry_type
724732
| LoopInvariant _ -> LoopInvariant.entry_type
725-
| FlowInsensitiveInvariant _ -> FlowInsensitiveInvariant.entry_type
726733
| PreconditionLoopInvariant _ -> PreconditionLoopInvariant.entry_type
727734
| InvariantSet _ -> InvariantSet.entry_type
728735
| ViolationSequence _ -> ViolationSequence.entry_type
@@ -731,7 +738,6 @@ struct
731738
let to_yaml' = function
732739
| LocationInvariant x -> LocationInvariant.to_yaml' x
733740
| LoopInvariant x -> LoopInvariant.to_yaml' x
734-
| FlowInsensitiveInvariant x -> FlowInsensitiveInvariant.to_yaml' x
735741
| PreconditionLoopInvariant x -> PreconditionLoopInvariant.to_yaml' x
736742
| InvariantSet x -> InvariantSet.to_yaml' x
737743
| ViolationSequence x -> ViolationSequence.to_yaml' x
@@ -746,9 +752,6 @@ struct
746752
else if entry_type = LoopInvariant.entry_type then
747753
let+ x = y |> LoopInvariant.of_yaml in
748754
LoopInvariant x
749-
else if entry_type = FlowInsensitiveInvariant.entry_type then
750-
let+ x = y |> FlowInsensitiveInvariant.of_yaml in
751-
FlowInsensitiveInvariant x
752755
else if entry_type = PreconditionLoopInvariant.entry_type then
753756
let+ x = y |> PreconditionLoopInvariant.of_yaml in
754757
PreconditionLoopInvariant x

0 commit comments

Comments
 (0)