Skip to content

Commit 7951588

Browse files
committed
Merge branch 'yaml-witness-test' into yaml-witness-ghost
2 parents 932ac3b + bb1a2ae commit 7951588

65 files changed

Lines changed: 2122 additions & 514 deletions

Some content is hidden

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

conf/svcomp.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
"congruence",
8585
"octagon",
8686
"wideningThresholds",
87-
"loopUnrollHeuristic",
8887
"memsafetySpecification",
8988
"termination",
9089
"tmpSpecialAnalysis"

goblint.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git"
7878
available: os-distribution != "alpine" & arch != "arm64"
7979
pin-depends: [
8080
# published goblint-cil 2.0.3 is currently up-to-date, so no pin needed
81-
[ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#833378d9102578bab7b62174cb029d385db417a5" ]
81+
[ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#079b426b5cf6ebeade55f11de0b33d6e63ab50b6" ]
8282
# TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252)
8383
[ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ]
8484
]

goblint.opam.locked

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ post-messages: [
134134
pin-depends: [
135135
[
136136
"goblint-cil.2.0.3"
137-
"git+https://github.com/goblint/cil.git#833378d9102578bab7b62174cb029d385db417a5"
137+
"git+https://github.com/goblint/cil.git#079b426b5cf6ebeade55f11de0b33d6e63ab50b6"
138138
]
139139
[
140140
"ppx_deriving.5.2.1"

goblint.opam.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
available: os-distribution != "alpine" & arch != "arm64"
44
pin-depends: [
55
# published goblint-cil 2.0.3 is currently up-to-date, so no pin needed
6-
[ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#833378d9102578bab7b62174cb029d385db417a5" ]
6+
[ "goblint-cil.2.0.3" "git+https://github.com/goblint/cil.git#079b426b5cf6ebeade55f11de0b33d6e63ab50b6" ]
77
# TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252)
88
[ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ]
99
]

src/analyses/unassumeAnalysis.ml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct
2727

2828
module Locator = WitnessUtil.Locator (Node)
2929

30-
let locator: Locator.t = Locator.create () (* empty default, so don't have to use option everywhere *)
30+
let location_locator: Locator.t = Locator.create () (* empty default, so don't have to use option everywhere *)
3131
let loop_locator: Locator.t = Locator.create () (* empty default, so don't have to use option everywhere *)
3232

3333
type inv = {
@@ -41,26 +41,26 @@ struct
4141
let pre_invs: inv EH.t NH.t = NH.create 100
4242

4343
let init _ =
44-
Locator.clear locator;
44+
Locator.clear location_locator;
4545
Locator.clear loop_locator;
4646
let module FileCfg =
4747
struct
4848
let file = !Cilfacade.current_file
4949
module Cfg = (val !MyCFG.current_cfg)
5050
end in
51-
let module WitnessInvariant = WitnessUtil.Invariant (FileCfg) in
51+
let module WitnessInvariant = WitnessUtil.YamlInvariant (FileCfg) in
5252

5353
(* DFS, copied from CfgTools.find_backwards_reachable *)
5454
let reachable = NH.create 100 in
5555
let rec iter_node node =
5656
if not (NH.mem reachable node) then begin
5757
NH.replace reachable node ();
58-
(* TODO: filter synthetic?
59-
See YamlWitness. *)
60-
if WitnessInvariant.is_invariant_node node then
61-
Locator.add locator (Node.location node) node;
62-
if WitnessUtil.NH.mem WitnessInvariant.loop_heads node then
63-
Locator.add loop_locator (Node.location node) node;
58+
Option.iter (fun loc ->
59+
Locator.add location_locator loc node
60+
) (WitnessInvariant.location_location node);
61+
Option.iter (fun loc ->
62+
Locator.add loop_locator loc node
63+
) (WitnessInvariant.loop_location node);
6464
List.iter (fun (_, prev_node) ->
6565
iter_node prev_node
6666
) (FileCfg.Cfg.prev node)
@@ -130,7 +130,7 @@ struct
130130
let inv = location_invariant.location_invariant.string in
131131
let msgLoc: M.Location.t = CilLocation loc in
132132

133-
match Locator.find_opt locator loc with
133+
match Locator.find_opt location_locator loc with
134134
| Some nodes ->
135135
unassume_nodes_invariant ~loc ~nodes inv
136136
| None ->
@@ -193,7 +193,7 @@ struct
193193
let inv = precondition_loop_invariant.loop_invariant.string in
194194
let msgLoc: M.Location.t = CilLocation loc in
195195

196-
match Locator.find_opt locator loc with
196+
match Locator.find_opt loop_locator loc with
197197
| Some nodes ->
198198
unassume_precondition_nodes_invariant ~loc ~nodes pre inv
199199
| None ->
@@ -207,7 +207,7 @@ struct
207207
let inv = location_invariant.value in
208208
let msgLoc: M.Location.t = CilLocation loc in
209209

210-
match Locator.find_opt locator loc with
210+
match Locator.find_opt location_locator loc with
211211
| Some nodes ->
212212
unassume_nodes_invariant ~loc ~nodes inv
213213
| None ->

src/common/framework/cfgTools.ml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,7 @@ let () = Printexc.register_printer (function
132132
| _ -> None (* for other exceptions *)
133133
)
134134

135-
(** Type of CFG "edges": keyed by 'from' and 'to' nodes,
136-
along with the list of connecting instructions. *)
137-
module CfgEdge = struct
138-
type t = Node.t * MyCFG.edges * Node.t [@@deriving eq, hash]
139-
end
140135

141-
module CfgEdgeH = BatHashtbl.Make (CfgEdge)
142136

143137
let createCFG (file: file) =
144138
let cfgF = H.create 113 in
@@ -254,7 +248,7 @@ let createCFG (file: file) =
254248
let pseudo_return = lazy (
255249
if Messages.tracing then Messages.trace "cfg" "adding pseudo-return to the function %s.\n" fd.svar.vname;
256250
let fd_end_loc = {fd_loc with line = fd_loc.endLine; byte = fd_loc.endByte; column = fd_loc.endColumn} in
257-
let newst = mkStmt (Return (None, fd_end_loc)) in
251+
let newst = mkStmt (Return (None, fd_end_loc, locUnknown)) in
258252
newst.sid <- Cilfacade.get_pseudo_return_id fd;
259253
Cilfacade.StmtH.add Cilfacade.pseudo_return_to_fun newst fd;
260254
Cilfacade.IntH.replace Cilfacade.pseudo_return_stmt_sids newst.sid newst;
@@ -340,8 +334,8 @@ let createCFG (file: file) =
340334
(* CIL's xform_switch_stmt (via prepareCFG) always adds both continue and break statements to all Loops. *)
341335
failwith "MyCFG.createCFG: unprepared Loop"
342336

343-
| Return (exp, loc) ->
344-
addEdge (Statement stmt) (loc, Ret (exp, fd)) (Function fd)
337+
| Return (exp, loc, eloc) ->
338+
addEdge (Statement stmt) (Cilfacade.eloc_fallback ~eloc ~loc, Ret (exp, fd)) (Function fd)
345339

346340
| Goto (_, loc) ->
347341
(* Gotos are generally unnecessary and unwanted because find_real_stmt skips over these. *)
@@ -608,7 +602,7 @@ let fprint_hash_dot cfg =
608602
close_out out
609603

610604

611-
let getCFG (file: file) : cfg * cfg * stmt list CfgEdgeH.t =
605+
let getCFG (file: file) : cfg * cfg * _ =
612606
let cfgF, cfgB, skippedByEdge = createCFG file in
613607
let cfgF, cfgB, skippedByEdge =
614608
if get_bool "exp.mincfg" then
@@ -617,13 +611,11 @@ let getCFG (file: file) : cfg * cfg * stmt list CfgEdgeH.t =
617611
(cfgF, cfgB, skippedByEdge)
618612
in
619613
if get_bool "justcfg" then fprint_hash_dot cfgB;
620-
(fun n -> H.find_default cfgF n []), (fun n -> H.find_default cfgB n []), skippedByEdge
614+
(fun n -> H.find_default cfgF n []), (fun n -> H.find_default cfgB n []), (fun u e v -> CfgEdgeH.find skippedByEdge (u, e, v))
621615

622-
let compute_cfg_skips file =
616+
let compute_cfg file =
623617
let cfgF, cfgB, skippedByEdge = getCFG file in
624-
(module struct let prev = cfgB let next = cfgF end : CfgBidir), skippedByEdge
625-
626-
let compute_cfg file = fst (compute_cfg_skips file)
618+
(module struct let prev = cfgB let next = cfgF let skippedByEdge = skippedByEdge end : CfgBidirSkip)
627619

628620

629621
let iter_fd_edges (module Cfg : CfgBackward) fd =

src/common/framework/myCFG.ml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,34 @@ sig
4242
include CfgForward
4343
end
4444

45+
(** Type of CFG "edges": keyed by 'from' and 'to' nodes,
46+
along with the list of connecting instructions. *)
47+
module CfgEdge = struct
48+
type t = Node.t * edges * Node.t [@@deriving eq, hash]
49+
end
50+
51+
module CfgEdgeH = BatHashtbl.Make (CfgEdge)
52+
53+
module type CfgBidirSkip =
54+
sig
55+
include CfgBidir
56+
val skippedByEdge: node -> edges -> node -> stmt list
57+
end
58+
4559

4660
module NodeH = BatHashtbl.Make (Node)
4761

4862

4963
let current_node = Node.current_node
50-
let current_cfg : (module CfgBidir) ref =
64+
let current_cfg : (module CfgBidirSkip) ref =
5165
let module Cfg =
5266
struct
5367
let next _ = raise Not_found
5468
let prev _ = raise Not_found
69+
let skippedByEdge _ _ _ = raise Not_found
5570
end
5671
in
57-
ref (module Cfg: CfgBidir)
72+
ref (module Cfg: CfgBidirSkip)
5873

5974
let unknown_exp : exp = mkString "__unknown_value__"
6075
let dummy_func = emptyFunction "__goblint_dummy_init" (* TODO get rid of this? *)
@@ -64,5 +79,5 @@ let dummy_node = FunctionEntry Cil.dummyFunDec
6479
module type FileCfg =
6580
sig
6681
val file: Cil.file
67-
module Cfg: CfgBidir
82+
module Cfg: CfgBidirSkip
6883
end

src/common/util/cilLocation.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let rec get_stmtLoc stmt: locs =
3434
{loc = locUnknown; eloc = locUnknown}
3535

3636
| Instr (hd :: _) -> get_instrLoc hd
37-
| Return (_, loc) -> {loc; eloc = locUnknown}
37+
| Return (_, loc, eloc) -> {loc; eloc}
3838
| Goto (_, loc) -> {loc; eloc = locUnknown}
3939
| ComputedGoto (_, loc) -> {loc; eloc = locUnknown}
4040
| Break loc -> {loc; eloc = locUnknown}

src/common/util/cilfacade.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ class countFnVisitor = object
494494
inherit nopCilVisitor
495495
method! vstmt s =
496496
match s.skind with
497-
| Return (_, loc)
497+
| Return (_, loc, _)
498498
| Goto (_, loc)
499499
| ComputedGoto (_, loc)
500500
| Break loc

0 commit comments

Comments
 (0)