-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathabortUnless.ml
More file actions
72 lines (57 loc) · 1.97 KB
/
abortUnless.ml
File metadata and controls
72 lines (57 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(** Analysis of [assume_abort_if_not]-style functions ([abortUnless]).
Such a function only returns if its only argument has a non-zero value. *)
open GoblintCil
open Analyses
module Spec =
struct
include Analyses.DefaultSpec
let name () = "abortUnless"
module D = BoolDomain.MustBool
module C = Printable.Unit
let context man _ _ = ()
let startcontext () = ()
(* transfer functions *)
let assign man (lval:lval) (rval:exp) : D.t =
false
let branch man (exp:exp) (tv:bool) : D.t =
man.local
let body man (f:fundec) : D.t =
man.local
let return man (exp:exp option) (f:fundec) : D.t =
if man.local then
match f.sformals with
| [arg] when isIntegralType arg.vtype ->
(match man.ask (EvalInt (Lval (Var arg, NoOffset))) with
| v when Queries.ID.is_bot v -> false
| v -> BatOption.default false (Queries.ID.to_bool v))
| _ ->
(* should not happen, man.local should always be false in this case *)
false
else
false
let enter man (lval: lval option) (f:fundec) (args:exp list) : (D.t * D.t) list =
let candidate = match f.sformals with
| [arg] when isIntegralType arg.vtype -> true
| _ -> false
in
[false, candidate]
let combine_env man lval fexp f args fc au f_ask =
if au then (
(* Assert before combine_assign, so if variables in `arg` are assigned to, asserting doesn't unsoundly yield bot *)
(* See test 62/03 *)
match args with
| [arg] -> man.emit (Events.Assert arg)
| _ -> ()
);
false
let combine_assign man (lval:lval option) fexp (f:fundec) (args:exp list) fc (au:D.t) (f_ask: Queries.ask) : D.t =
false
let special man (lval: lval option) (f:varinfo) (arglist:exp list) : D.t =
false
let startstate v = false
let threadenter man ~multiple lval f args = [false]
let threadspawn man ~multiple lval f args fman = false
let exitstate v = false
end
let _ =
MCP.register_analysis (module Spec : MCPSpec)