Skip to content

Commit d525dac

Browse files
committed
Add YAML witness invariant labels parsing support
1 parent bec5181 commit d525dac

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/analyses/unassumeAnalysis.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ struct
216216
let validate_invariant i (invariant: YamlWitnessType.InvariantSet.Invariant.t) =
217217
let target_type = YamlWitnessType.InvariantSet.InvariantType.invariant_type invariant.invariant_type in
218218
match YamlWitness.invariant_type_enabled target_type, invariant.invariant_type with
219-
| true, LocationInvariant x ->
219+
| true, LocationInvariant ({labels = []; _} as x) ->
220220
unassume_location_invariant ~i x
221-
| true, LoopInvariant x ->
221+
| true, LoopInvariant ({labels = []; _} as x) ->
222222
unassume_loop_invariant ~i x
223223
| false, (LocationInvariant _ | LoopInvariant _) ->
224224
M.info_noloc ~category:Witness "disabled invariant of type %s" target_type

src/witness/yamlWitness.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ struct
103103
location;
104104
value = invariant;
105105
format = "c_expression";
106+
labels = [];
106107
};
107108
}
108109

@@ -111,6 +112,7 @@ struct
111112
location;
112113
value = invariant;
113114
format = "c_expression";
115+
labels = [];
114116
};
115117
}
116118

@@ -860,9 +862,9 @@ struct
860862
let validate_invariant (invariant: YamlWitnessType.InvariantSet.Invariant.t) =
861863
let target_type = YamlWitnessType.InvariantSet.InvariantType.invariant_type invariant.invariant_type in
862864
match invariant_type_enabled target_type, invariant.invariant_type with
863-
| true, LocationInvariant x ->
865+
| true, LocationInvariant ({labels = []; _} as x) ->
864866
validate_location_invariant x
865-
| true, LoopInvariant x ->
867+
| true, LoopInvariant ({labels = []; _} as x) ->
866868
validate_loop_invariant x
867869
| false, (LocationInvariant _ | LoopInvariant _) ->
868870
incr cnt_disabled;

src/witness/yamlWitnessType.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,24 +275,27 @@ struct
275275
location: Location.t;
276276
value: string;
277277
format: string;
278+
labels: string list;
278279
}
279280
[@@deriving eq, ord, hash]
280281

281282
let invariant_type = "loop_invariant"
282283

283-
let to_yaml' {location; value; format} =
284+
let to_yaml' {location; value; format; labels} =
284285
[
285286
("location", Location.to_yaml location);
286287
("value", `String value);
287288
("format", `String format);
289+
("labels", `A (List.map (fun label -> `String label) labels));
288290
]
289291

290292
let of_yaml y =
291293
let open GobYaml in
292294
let+ location = y |> find "location" >>= Location.of_yaml
293295
and+ value = y |> find "value" >>= to_string
294-
and+ format = y |> find "format" >>= to_string in
295-
{location; value; format}
296+
and+ format = y |> find "format" >>= to_string
297+
and+ labels = y |> find "labels" >>= list >>= list_map to_string in
298+
{location; value; format; labels}
296299
end
297300

298301
module LocationInvariant =

0 commit comments

Comments
 (0)