Skip to content

Commit 2e856b4

Browse files
committed
Merge branch 'master' into yaml-witness-2.1
2 parents 8ed3329 + 5c83c18 commit 2e856b4

File tree

60 files changed

+2806
-3724
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2806
-3724
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": {

conf/svcomp-validate.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@
9898
"strict": true,
9999
"format-version": "2.0",
100100
"entry-types": [
101-
"location_invariant",
102-
"loop_invariant",
103101
"invariant_set",
104102
"violation_sequence"
105103
],

conf/svcomp24-validate.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@
117117
"strict": true,
118118
"format-version": "2.0",
119119
"entry-types": [
120-
"location_invariant",
121-
"loop_invariant",
122120
"invariant_set"
123121
],
124122
"invariant-types": [

conf/svcomp25-validate.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@
9898
"strict": true,
9999
"format-version": "2.0",
100100
"entry-types": [
101-
"location_invariant",
102-
"loop_invariant",
103101
"invariant_set",
104102
"violation_sequence"
105103
],

src/analyses/unassumeAnalysis.ml

Lines changed: 5 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,12 @@ open Analyses
77
module Cil = GoblintCil.Cil
88

99
module NH = CfgTools.NH
10-
module FH = Hashtbl.Make (CilType.Fundec)
11-
module EH = Hashtbl.Make (CilType.Exp)
1210

1311
module Spec =
1412
struct
15-
(* TODO: Should be context-sensitive? Some spurious widening in knot_comb fails self-validation after self-unassume. *)
16-
include Analyses.IdentityUnitContextsSpec
13+
include UnitAnalysis.Spec
1714
let name () = "unassume"
1815

19-
module D = SetDomain.Make (CilType.Exp)
20-
21-
let startstate _ = D.empty ()
22-
let morphstate _ _ = D.empty ()
23-
let exitstate _ = D.empty ()
24-
2516
module Locator = WitnessUtil.Locator (Node)
2617

2718
let location_locator: Locator.t = Locator.create () (* empty default, so don't have to use option everywhere *)
@@ -34,9 +25,6 @@ struct
3425

3526
let invs: inv NH.t = NH.create 100
3627

37-
let fun_pres: Cil.exp FH.t = FH.create 100
38-
let pre_invs: inv EH.t NH.t = NH.create 100
39-
4028
let init _ =
4129
Locator.clear location_locator;
4230
Locator.clear loop_locator;
@@ -83,8 +71,6 @@ struct
8371
let inv_parser = InvariantParser.create !Cilfacade.current_file in
8472

8573
NH.clear invs;
86-
FH.clear fun_pres;
87-
NH.clear pre_invs;
8874

8975
let unassume_entry (entry: YamlWitnessType.Entry.t) =
9076
let uuid = entry.metadata.uuid in
@@ -112,81 +98,6 @@ struct
11298
M.info ~category:Witness ~loc:msgLoc "invariant has invalid syntax: %s" inv
11399
in
114100

115-
let unassume_location_invariant (location_invariant: YamlWitnessType.LocationInvariant.t) =
116-
let loc = YamlWitness.loc_of_location location_invariant.location in
117-
let inv = location_invariant.location_invariant.string in
118-
let msgLoc: M.Location.t = CilLocation loc in
119-
120-
match Locator.find_opt location_locator loc with
121-
| Some nodes ->
122-
unassume_nodes_invariant ~loc ~nodes inv
123-
| None ->
124-
M.warn ~category:Witness ~loc:msgLoc "couldn't locate invariant: %s" inv
125-
in
126-
127-
let unassume_loop_invariant (loop_invariant: YamlWitnessType.LoopInvariant.t) =
128-
let loc = YamlWitness.loc_of_location loop_invariant.location in
129-
let inv = loop_invariant.loop_invariant.string in
130-
let msgLoc: M.Location.t = CilLocation loc in
131-
132-
match Locator.find_opt loop_locator loc with
133-
| Some nodes ->
134-
unassume_nodes_invariant ~loc ~nodes inv
135-
| None ->
136-
M.warn ~category:Witness ~loc:msgLoc "couldn't locate invariant: %s" inv
137-
in
138-
139-
let unassume_precondition_nodes_invariant ~loc ~nodes pre inv =
140-
let msgLoc: M.Location.t = CilLocation loc in
141-
match InvariantParser.parse_cabs pre, InvariantParser.parse_cabs inv with
142-
| Ok pre_cabs, Ok inv_cabs ->
143-
144-
Locator.ES.iter (fun n ->
145-
let fundec = Node.find_fundec n in
146-
147-
match InvariantParser.parse_cil inv_parser ~check:false ~fundec ~loc pre_cabs with
148-
| Ok pre_exp ->
149-
M.debug ~category:Witness ~loc:msgLoc "located precondition to %a: %a" CilType.Fundec.pretty fundec Cil.d_exp pre_exp;
150-
FH.add fun_pres fundec pre_exp;
151-
152-
begin match InvariantParser.parse_cil inv_parser ~check:false ~fundec ~loc inv_cabs with
153-
| Ok inv_exp ->
154-
M.debug ~category:Witness ~loc:msgLoc "located invariant to %a: %a" Node.pretty n Cil.d_exp inv_exp;
155-
if not (NH.mem pre_invs n) then
156-
NH.replace pre_invs n (EH.create 10);
157-
EH.add (NH.find pre_invs n) pre_exp {exp = inv_exp; token = (uuid, None)}
158-
| Error e ->
159-
M.error ~category:Witness ~loc:msgLoc "CIL couldn't parse invariant: %s" inv;
160-
M.info ~category:Witness ~loc:msgLoc "invariant has undefined variables or side effects: %s" inv
161-
end
162-
163-
| Error e ->
164-
M.error ~category:Witness ~loc:msgLoc "CIL couldn't parse precondition: %s" pre;
165-
M.info ~category:Witness ~loc:msgLoc "precondition has undefined variables or side effects: %s" pre
166-
) nodes;
167-
168-
| Error e, _ ->
169-
M.error ~category:Witness ~loc:msgLoc "Frontc couldn't parse precondition: %s" pre;
170-
M.info ~category:Witness ~loc:msgLoc "precondition has invalid syntax: %s" pre
171-
172-
| _, Error e ->
173-
M.error ~category:Witness ~loc:msgLoc "Frontc couldn't parse invariant: %s" inv;
174-
M.info ~category:Witness ~loc:msgLoc "invariant has invalid syntax: %s" inv
175-
in
176-
177-
let unassume_precondition_loop_invariant (precondition_loop_invariant: YamlWitnessType.PreconditionLoopInvariant.t) =
178-
let loc = YamlWitness.loc_of_location precondition_loop_invariant.location in
179-
let pre = precondition_loop_invariant.precondition.string in
180-
let inv = precondition_loop_invariant.loop_invariant.string in
181-
let msgLoc: M.Location.t = CilLocation loc in
182-
183-
match Locator.find_opt loop_locator loc with
184-
| Some nodes ->
185-
unassume_precondition_nodes_invariant ~loc ~nodes pre inv
186-
| None ->
187-
M.warn ~category:Witness ~loc:msgLoc "couldn't locate invariant: %s" inv
188-
in
189-
190101
let unassume_invariant_set (invariant_set: YamlWitnessType.InvariantSet.t) =
191102

192103
let unassume_location_invariant ~i (location_invariant: YamlWitnessType.InvariantSet.LocationInvariant.t) =
@@ -239,15 +150,9 @@ struct
239150
in
240151

241152
match YamlWitness.entry_type_enabled target_type, entry.entry_type with
242-
| true, LocationInvariant x ->
243-
unassume_location_invariant x
244-
| true, LoopInvariant x ->
245-
unassume_loop_invariant x
246-
| true, PreconditionLoopInvariant x ->
247-
unassume_precondition_loop_invariant x
248153
| true, InvariantSet x ->
249154
unassume_invariant_set x
250-
| false, (LocationInvariant _ | LoopInvariant _ | PreconditionLoopInvariant _ | InvariantSet _) ->
155+
| false, InvariantSet _ ->
251156
M.info_noloc ~category:Witness "disabled entry of type %s" target_type
252157
| _ ->
253158
M.warn_noloc ~category:Witness "cannot unassume entry of type %s" target_type
@@ -261,12 +166,6 @@ struct
261166

262167
let emit_unassume man =
263168
let es = NH.find_all invs man.node in
264-
let es = D.fold (fun pre acc ->
265-
match NH.find_option pre_invs man.node with
266-
| Some eh -> EH.find_all eh pre @ acc
267-
| None -> acc
268-
) man.local es
269-
in
270169
match es with
271170
| x :: xs ->
272171
let e = List.fold_left (fun a {exp = b; _} -> Cil.(BinOp (LAnd, a, b, intType))) x.exp xs in
@@ -277,10 +176,9 @@ struct
277176
man.emit (Unassume {exp = e; tokens});
278177
List.iter WideningTokenLifter.add tokens
279178
)
280-
);
281-
man.local
179+
)
282180
| [] ->
283-
man.local
181+
()
284182

285183
let assign man lv e =
286184
emit_unassume man
@@ -289,17 +187,7 @@ struct
289187
emit_unassume man
290188

291189
let body man fd =
292-
let pres = FH.find_all fun_pres fd in
293-
let st = List.fold_left (fun acc pre ->
294-
(* M.debug ~category:Witness "%a precondition %a evaluated to %a" CilType.Fundec.pretty fd CilType.Exp.pretty pre Queries.ID.pretty v; *)
295-
if Queries.eval_bool (Analyses.ask_of_man man) pre = `Lifted true then
296-
D.add pre acc
297-
else
298-
acc
299-
) (D.empty ()) pres
300-
in
301-
302-
emit_unassume {man with local = st} (* doesn't query, so no need to redefine ask *)
190+
emit_unassume man
303191

304192
let asm man =
305193
emit_unassume man
@@ -310,9 +198,6 @@ struct
310198
let special man lv f args =
311199
emit_unassume man
312200

313-
let enter man lv f args =
314-
[(man.local, D.empty ())]
315-
316201
let combine_env man lval fexp f args fc au f_ask =
317202
man.local (* not here because isn't final transfer function on edge *)
318203

src/arg/myARG.ml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ struct
156156
| n :: stack ->
157157
let cfgnode = Arg.Node.cfgnode n in
158158
match cfgnode with
159-
| Function _ -> (* TODO: can this be done without cfgnode? *)
159+
| Function cfgnode_fd -> (* TODO: can this be done without cfgnode? *)
160160
begin match stack with
161161
(* | [] -> failwith "StackArg.next: return stack empty" *)
162162
| [] -> [] (* main return *)
@@ -171,14 +171,33 @@ struct
171171
| _ -> None
172172
)
173173
in
174+
let (entry_lval, entry_args) =
175+
Arg.next call_n
176+
(* filter because infinite loops starting with function call
177+
will have another Neg(1) edge from the head *)
178+
|> List.filter_map (fun (edge, to_n) ->
179+
match edge with
180+
| InlineEntry (lval, _, args) -> Some (lval, args)
181+
| _ -> None
182+
)
183+
|> List.sort_uniq [%ord: CilType.Lval.t option * CilType.Exp.t list] (* TODO: deduplicate unique element in O(n) *)
184+
|> (function
185+
| [lval_args] -> lval_args
186+
| _ -> assert false (* all calls from a node must have same args and lval, even if called function might be different via function pointer *)
187+
)
188+
in
174189
Arg.next n
175190
|> List.filter_map (fun (edge, to_n) ->
176-
if BatList.mem_cmp Arg.Node.compare to_n call_next then (
177-
let to_n' = to_n :: call_stack in
178-
Some (edge, to_n')
179-
)
180-
else
181-
None
191+
match edge with
192+
| InlineReturn (lval, fd, args) ->
193+
assert (CilType.Fundec.equal fd cfgnode_fd); (* fd in return node should be the same as in InlineReturn edge *)
194+
if BatList.mem_cmp Arg.Node.compare to_n call_next && [%eq: CilType.Lval.t option] lval entry_lval && [%eq: CilType.Exp.t list] args entry_args then (
195+
let to_n' = to_n :: call_stack in
196+
Some (edge, to_n')
197+
)
198+
else
199+
None
200+
| _ -> assert false
182201
)
183202
end
184203
| _ ->

src/config/options.schema.json

Lines changed: 4 additions & 8 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
@@ -2790,7 +2790,6 @@
27902790
"description": "YAML witness format version",
27912791
"type": "string",
27922792
"enum": [
2793-
"0.1",
27942793
"2.0",
27952794
"2.1"
27962795
],
@@ -2803,10 +2802,6 @@
28032802
"items": {
28042803
"type": "string",
28052804
"enum": [
2806-
"location_invariant",
2807-
"loop_invariant",
2808-
"flow_insensitive_invariant",
2809-
"precondition_loop_invariant",
28102805
"invariant_set",
28112806
"violation_sequence",
28122807
"ghost_instrumentation"
@@ -2824,7 +2819,8 @@
28242819
"type": "string",
28252820
"enum": [
28262821
"location_invariant",
2827-
"loop_invariant"
2822+
"loop_invariant",
2823+
"flow_insensitive_invariant"
28282824
]
28292825
},
28302826
"default": [

0 commit comments

Comments
 (0)