Skip to content

Commit a14b93f

Browse files
committed
Merge branch 'master' into preprocessing-adaptations
2 parents 75cfe4c + a0bb640 commit a14b93f

Some content is hidden

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

42 files changed

+368
-630
lines changed

goblint.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git"
6363
# on `dune build` goblint.opam will be generated from goblint.opam.template and dune-project
6464
# also remember to generate/adjust goblint.opam.locked!
6565
pin-depends: [
66-
[ "goblint-cil.1.8.2" "git+https://github.com/goblint/cil.git#f8c8fe4da12ebe59a7b87851366dfc49b6e4b9ae" ]
66+
[ "goblint-cil.1.8.2" "git+https://github.com/goblint/cil.git#4356eb39fd9ea5192fc96f7b8e135586c65c3a19" ]
6767
# TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252)
6868
[ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ]
6969
# quoter workaround reverted for release, so no pin needed

goblint.opam.locked

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ version: "dev"
110110
pin-depends: [
111111
[
112112
"goblint-cil.1.8.2"
113-
"git+https://github.com/goblint/cil.git#f8c8fe4da12ebe59a7b87851366dfc49b6e4b9ae"
113+
"git+https://github.com/goblint/cil.git#4356eb39fd9ea5192fc96f7b8e135586c65c3a19"
114114
]
115115
[
116116
"apron.v0.9.13"

goblint.opam.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# on `dune build` goblint.opam will be generated from goblint.opam.template and dune-project
22
# also remember to generate/adjust goblint.opam.locked!
33
pin-depends: [
4-
[ "goblint-cil.1.8.2" "git+https://github.com/goblint/cil.git#f8c8fe4da12ebe59a7b87851366dfc49b6e4b9ae" ]
4+
[ "goblint-cil.1.8.2" "git+https://github.com/goblint/cil.git#4356eb39fd9ea5192fc96f7b8e135586c65c3a19" ]
55
# TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252)
66
[ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ]
77
# quoter workaround reverted for release, so no pin needed

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: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ struct
199199
| `NoOffset -> `Index(iDtoIdx n, `NoOffset)
200200
in
201201
let default = function
202-
| Addr.NullPtr when GU.opt_predicate (BI.equal BI.zero) (ID.to_int n) -> Addr.NullPtr
202+
| Addr.NullPtr when GobOption.exists (BI.equal BI.zero) (ID.to_int n) -> Addr.NullPtr
203203
| _ -> Addr.UnknownPtr
204204
in
205205
match Addr.to_var_offset addr with
@@ -346,7 +346,7 @@ struct
346346
* which part of an array is involved. *)
347347
let rec get ?(full=false) a (gs: glob_fun) (st: store) (addrs:address) (exp:exp option): value =
348348
let at = AD.get_type addrs in
349-
let firstvar = if M.tracing then try (List.hd (AD.to_var_may addrs)).vname with _ -> "" else "" in
349+
let firstvar = if M.tracing then match AD.to_var_may addrs with [] -> "" | x :: _ -> x.vname else "" in
350350
if M.tracing then M.traceli "get" ~var:firstvar "Address: %a\nState: %a\n" AD.pretty addrs CPA.pretty st.cpa;
351351
(* Finding a single varinfo*offset pair *)
352352
let res =
@@ -359,20 +359,19 @@ struct
359359
| `Blob (c,s,_) -> c
360360
| x -> x
361361
in
362-
let f x =
363-
match Addr.to_var_offset x with
364-
| Some x -> f_addr x (* normal reference *)
365-
| None when x = Addr.NullPtr -> VD.bot () (* null pointer *)
366-
| None -> `Int (ID.top_of IChar) (* string pointer *)
362+
let f = function
363+
| Addr.Addr (x, o) -> f_addr (x, o)
364+
| Addr.NullPtr -> VD.bot () (* TODO: why bot? *)
365+
| Addr.UnknownPtr -> VD.top ()
366+
| Addr.StrPtr _ -> `Int (ID.top_of IChar)
367367
in
368368
(* We form the collecting function by joining *)
369369
let c x = match x with (* If address type is arithmetic, and our value is an int, we cast to the correct ik *)
370370
| `Int _ when Cil.isArithmeticType at -> VD.cast at x
371371
| _ -> x
372372
in
373-
let f x a = VD.join (c @@ f x) a in (* Finally we join over all the addresses in the set. If any of the
374-
* addresses is a topped value, joining will fail. *)
375-
try AD.fold f addrs (VD.bot ()) with SetDomain.Unsupported _ -> VD.top ()
373+
let f x a = VD.join (c @@ f x) a in (* Finally we join over all the addresses in the set. *)
374+
AD.fold f addrs (VD.bot ())
376375
in
377376
if M.tracing then M.traceu "get" "Result: %a\n" VD.pretty res;
378377
res
@@ -929,7 +928,7 @@ struct
929928
| `Address a ->
930929
let slen = List.map String.length (AD.to_string a) in
931930
let lenOf = function
932-
| TArray (_, l, _) -> (try Some (lenOfArray l) with _ -> None)
931+
| TArray (_, l, _) -> (try Some (lenOfArray l) with LenOfArray -> None)
933932
| _ -> None
934933
in
935934
let alen = List.filter_map (fun v -> lenOf v.vtype) (AD.to_var_may a) in
@@ -1027,13 +1026,13 @@ struct
10271026
match e1_val, e2_val with
10281027
| `Int i1, `Int i2 -> begin
10291028
match ID.to_int i1, ID.to_int i2 with
1030-
| Some i1', Some i2' when i1' = i2' -> true
1029+
| Some i1', Some i2' when Z.equal i1' i2' -> true
10311030
| _ -> false
10321031
end
10331032
| _ -> false
10341033
end
10351034
| 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)); *)
1035+
(* Printf.printf "----------------------> may equality check for %s and %s \n" (CilType.Exp.show e1) (CilType.Exp.show e2); *)
10371036
let e1_val = eval_rv (Analyses.ask_of_ctx ctx) ctx.global ctx.local e1 in
10381037
let e2_val = eval_rv (Analyses.ask_of_ctx ctx) ctx.global ctx.local e2 in
10391038
match e1_val, e2_val with
@@ -1044,24 +1043,24 @@ struct
10441043
let ik= Cil.commonIntKind e1_ik e2_ik in
10451044
if ID.is_bot (ID.meet (ID.cast_to ik i1) (ID.cast_to ik i2)) then
10461045
begin
1047-
(* Printf.printf "----------------------> NOPE may equality check for %s and %s \n" (ExpDomain.short 20 (`Lifted e1)) (ExpDomain.short 20 (`Lifted e2)); *)
1046+
(* Printf.printf "----------------------> NOPE may equality check for %s and %s \n" (CilType.Exp.show e1) (CilType.Exp.show e2); *)
10481047
false
10491048
end
10501049
else true
10511050
end
10521051
| _ -> true
10531052
end
10541053
| Q.MayBeLess (e1, e2) -> begin
1055-
(* Printf.printf "----------------------> may check for %s < %s \n" (ExpDomain.short 20 (`Lifted e1)) (ExpDomain.short 20 (`Lifted e2)); *)
1054+
(* Printf.printf "----------------------> may check for %s < %s \n" (CilType.Exp.show e1) (CilType.Exp.show e2); *)
10561055
let e1_val = eval_rv (Analyses.ask_of_ctx ctx) ctx.global ctx.local e1 in
10571056
let e2_val = eval_rv (Analyses.ask_of_ctx ctx) ctx.global ctx.local e2 in
10581057
match e1_val, e2_val with
10591058
| `Int i1, `Int i2 -> begin
10601059
match (ID.minimal i1), (ID.maximal i2) with
10611060
| Some i1', Some i2' ->
1062-
if i1' >= i2' then
1061+
if Z.geq i1' i2' then
10631062
begin
1064-
(* Printf.printf "----------------------> NOPE may check for %s < %s \n" (ExpDomain.short 20 (`Lifted e1)) (ExpDomain.short 20 (`Lifted e2)); *)
1063+
(* Printf.printf "----------------------> NOPE may check for %s < %s \n" (CilType.Exp.show e1) (CilType.Exp.show e2); *)
10651064
false
10661065
end
10671066
else true
@@ -1107,7 +1106,7 @@ struct
11071106
if M.tracing then M.tracel "setosek" ~var:x.vname "update_variable: start '%s' '%a'\nto\n%a\nresults in\n%a\n" x.vname VD.pretty y CPA.pretty z CPA.pretty r;
11081107
r
11091108
in
1110-
let firstvar = if M.tracing then try (List.hd (AD.to_var_may lval)).vname with _ -> "" else "" in
1109+
let firstvar = if M.tracing then match AD.to_var_may lval with [] -> "" | x :: _ -> x.vname else "" in
11111110
let lval_raw = (Option.map (fun x -> Lval x) lval_raw) in
11121111
if M.tracing then M.tracel "set" ~var:firstvar "lval: %a\nvalue: %a\nstate: %a\n" AD.pretty lval VD.pretty value CPA.pretty st.cpa;
11131112
(* Updating a single varinfo*offset pair. NB! This function's type does
@@ -1458,7 +1457,7 @@ struct
14581457
(* ikind is the type of a for limiting ranges of the operands a, b. The only binops which can have different types for a, b are Shiftlt, Shiftrt (not handled below; don't use ikind to limit b there). *)
14591458
let inv_bin_int (a, b) ikind c op =
14601459
let warn_and_top_on_zero x =
1461-
if GU.opt_predicate (BI.equal BI.zero) (ID.to_int x) then
1460+
if GobOption.exists (BI.equal BI.zero) (ID.to_int x) then
14621461
(M.warn "Must Undefined Behavior: Second argument of div or mod is 0, continuing with top";
14631462
ID.top_of ikind)
14641463
else
@@ -1512,7 +1511,9 @@ struct
15121511
* If the upper bound of a is divisible by b, we can also meet with the result of a/b*b - c to get the precise [3,3].
15131512
* If b is negative we have to look at the lower bound. *)
15141513
let is_divisible bound =
1515-
try ID.rem (bound a |> Option.get |> ID.of_int ikind) b |> ID.to_int = Some BI.zero with _ -> false
1514+
match bound a with
1515+
| Some ba -> ID.rem (ID.of_int ikind ba) b |> ID.to_int = Some BI.zero
1516+
| None -> false
15161517
in
15171518
let max_pos = match ID.maximal b with None -> true | Some x -> BI.compare x BI.zero >= 0 in
15181519
let min_neg = match ID.minimal b with None -> true | Some x -> BI.compare x BI.zero < 0 in
@@ -2210,7 +2211,7 @@ struct
22102211
| `ThreadJoin (id,ret_var) ->
22112212
let st' =
22122213
match (eval_rv (Analyses.ask_of_ctx ctx) gs st ret_var) with
2213-
| `Int n when GU.opt_predicate (BI.equal BI.zero) (ID.to_int n) -> st
2214+
| `Int n when GobOption.exists (BI.equal BI.zero) (ID.to_int n) -> st
22142215
| `Address ret_a ->
22152216
begin match eval_rv (Analyses.ask_of_ctx ctx) gs st id with
22162217
| `Thread a ->

src/analyses/extract_arinc.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,13 @@ 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. *)
279279
let eval = function
280280
| Pml.EvalSkip -> const None
281-
| Pml.EvalInt -> fun e -> Some (try eval_int e with _ -> eval_id e)
281+
| Pml.EvalInt -> fun e -> Some (try eval_int e with Failure _ -> eval_id e)
282282
| Pml.EvalString -> fun e -> Some (List.map (fun x -> "\""^x^"\"") (eval_str e))
283283
| Pml.EvalEnum f -> fun e -> Some (List.map (fun x -> Option.get (f (int_of_string x))) (eval_int e))
284284
| Pml.AssignIdOfString (res, pos) -> fun e ->

src/analyses/extract_osek.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ 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. *)
272272
let eval = function
273273
| Pml.EvalSkip -> const None
274-
| Pml.EvalInt -> fun e -> Some (try eval_int e with _ -> eval_id e)
274+
| Pml.EvalInt -> fun e -> Some (try eval_int e with Failure _ -> eval_id e)
275275
| Pml.EvalString -> fun e -> Some (List.map (fun x -> "\""^x^"\"") (eval_str e))
276276
| Pml.EvalEnum f -> fun e -> Some (List.map (fun x -> Option.get (f (int_of_string x))) (eval_int e))
277277
| Pml.AssignIdOfString (res, pos) -> fun e ->

src/analyses/flag.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ struct
122122

123123
let special ctx (lval: lval option) (f:varinfo) (arglist:exp list) : D.t =
124124
let _ = List.iter no_addr_of_flag arglist in
125-
match f.vname with _ -> D.top ()
125+
D.top ()
126126

127127
let startstate v = D.top ()
128128
let threadenter ctx lval f args = [D.top ()]

0 commit comments

Comments
 (0)