Skip to content

Commit a23e4f4

Browse files
authored
Merge pull request #590 from goblint/mcp-ctx
Refactor MCP transfer functions and add query cache
2 parents 560eb6f + 4fb6e45 commit a23e4f4

File tree

11 files changed

+215
-475
lines changed

11 files changed

+215
-475
lines changed

src/analyses/arinc.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ struct
337337
let assign_id exp id =
338338
match exp with
339339
(* call assign for all analyses (we only need base)! *)
340-
| AddrOf lval -> ctx.assign ~name:"base" lval (mkAddrOf @@ var id)
340+
| AddrOf lval -> ctx.emit (Assign {lval; exp = mkAddrOf @@ var id})
341341
(* TODO not needed for the given code, but we could use Queries.MayPointTo exp in this case *)
342342
| _ -> failwith @@ "Could not assign id. Expected &id. Found "^sprint d_exp exp
343343
in

src/analyses/base.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,13 +1027,13 @@ struct
10271027
match e1_val, e2_val with
10281028
| `Int i1, `Int i2 -> begin
10291029
match ID.to_int i1, ID.to_int i2 with
1030-
| Some i1', Some i2' when i1' = i2' -> true
1030+
| Some i1', Some i2' when Z.equal i1' i2' -> true
10311031
| _ -> false
10321032
end
10331033
| _ -> false
10341034
end
10351035
| Q.MayBeEqual (e1, e2) -> begin
1036-
(* Printf.printf "----------------------> may equality check for %s and %s \n" (ExpDomain.short 20 (`Lifted e1)) (ExpDomain.short 20 (`Lifted e2)); *)
1036+
(* Printf.printf "----------------------> may equality check for %s and %s \n" (CilType.Exp.show e1) (CilType.Exp.show e2); *)
10371037
let e1_val = eval_rv (Analyses.ask_of_ctx ctx) ctx.global ctx.local e1 in
10381038
let e2_val = eval_rv (Analyses.ask_of_ctx ctx) ctx.global ctx.local e2 in
10391039
match e1_val, e2_val with
@@ -1044,24 +1044,24 @@ struct
10441044
let ik= Cil.commonIntKind e1_ik e2_ik in
10451045
if ID.is_bot (ID.meet (ID.cast_to ik i1) (ID.cast_to ik i2)) then
10461046
begin
1047-
(* Printf.printf "----------------------> NOPE may equality check for %s and %s \n" (ExpDomain.short 20 (`Lifted e1)) (ExpDomain.short 20 (`Lifted e2)); *)
1047+
(* Printf.printf "----------------------> NOPE may equality check for %s and %s \n" (CilType.Exp.show e1) (CilType.Exp.show e2); *)
10481048
false
10491049
end
10501050
else true
10511051
end
10521052
| _ -> true
10531053
end
10541054
| Q.MayBeLess (e1, e2) -> begin
1055-
(* Printf.printf "----------------------> may check for %s < %s \n" (ExpDomain.short 20 (`Lifted e1)) (ExpDomain.short 20 (`Lifted e2)); *)
1055+
(* Printf.printf "----------------------> may check for %s < %s \n" (CilType.Exp.show e1) (CilType.Exp.show e2); *)
10561056
let e1_val = eval_rv (Analyses.ask_of_ctx ctx) ctx.global ctx.local e1 in
10571057
let e2_val = eval_rv (Analyses.ask_of_ctx ctx) ctx.global ctx.local e2 in
10581058
match e1_val, e2_val with
10591059
| `Int i1, `Int i2 -> begin
10601060
match (ID.minimal i1), (ID.maximal i2) with
10611061
| Some i1', Some i2' ->
1062-
if i1' >= i2' then
1062+
if Z.geq i1' i2' then
10631063
begin
1064-
(* Printf.printf "----------------------> NOPE may check for %s < %s \n" (ExpDomain.short 20 (`Lifted e1)) (ExpDomain.short 20 (`Lifted e2)); *)
1064+
(* Printf.printf "----------------------> NOPE may check for %s < %s \n" (CilType.Exp.show e1) (CilType.Exp.show e2); *)
10651065
false
10661066
end
10671067
else true

src/analyses/extract_arinc.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ struct
272272
let assign_id exp id =
273273
if M.tracing then M.trace "extract_arinc" "assign_id %a %s\n" d_exp exp id.vname;
274274
match exp with
275-
| AddrOf lval -> ctx.assign ~name:"base" lval (mkAddrOf @@ var id)
275+
| AddrOf lval -> ctx.emit (Assign {lval; exp = mkAddrOf @@ var id})
276276
| _ -> failwith @@ "Could not assign id. Expected &id. Found "^sprint d_exp exp
277277
in
278278
(* evaluates an argument and returns a list of possible values for that argument. *)

src/analyses/extract_osek.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ struct
265265
let assign_id exp id =
266266
if M.tracing then M.trace "extract_osek" "assign_id %a %s\n" d_exp exp id.vname;
267267
match exp with
268-
| AddrOf lval -> ctx.assign ~name:"base" lval (mkAddrOf @@ var id)
268+
| AddrOf lval -> ctx.emit (Assign {lval; exp = mkAddrOf @@ var id})
269269
| _ -> failwith @@ "Could not assign id. Expected &id. Found "^sprint d_exp exp
270270
in
271271
(* evaluates an argument and returns a list of possible values for that argument. *)

0 commit comments

Comments
 (0)