Skip to content

Commit beece1d

Browse files
Merge branch 'master' into affineeq-refine
2 parents ba198c9 + 4d60a82 commit beece1d

Some content is hidden

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

77 files changed

+2744
-2728
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ c3e2cc848479ae86de5542b6ab0e75a74e9cf8c9
3737

3838
# Fix LibraryFunctions.invalidate_actions indentation
3939
5662024232f32fe74dd25c9317dee4436ecb212d
40+
41+
# Rename ctx -> man
42+
0c155e68607fede6fab17704a9a7aee38df5408e

src/analyses/abortUnless.ml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,61 +13,61 @@ struct
1313
module D = BoolDomain.MustBool
1414
module C = Printable.Unit
1515

16-
let context ctx _ _ = ()
16+
let context man _ _ = ()
1717
let startcontext () = ()
1818

1919
(* transfer functions *)
20-
let assign ctx (lval:lval) (rval:exp) : D.t =
20+
let assign man (lval:lval) (rval:exp) : D.t =
2121
false
2222

23-
let branch ctx (exp:exp) (tv:bool) : D.t =
24-
ctx.local
23+
let branch man (exp:exp) (tv:bool) : D.t =
24+
man.local
2525

26-
let body ctx (f:fundec) : D.t =
27-
ctx.local
26+
let body man (f:fundec) : D.t =
27+
man.local
2828

29-
let return ctx (exp:exp option) (f:fundec) : D.t =
30-
if ctx.local then
29+
let return man (exp:exp option) (f:fundec) : D.t =
30+
if man.local then
3131
match f.sformals with
3232
| [arg] when isIntegralType arg.vtype ->
33-
(match ctx.ask (EvalInt (Lval (Var arg, NoOffset))) with
33+
(match man.ask (EvalInt (Lval (Var arg, NoOffset))) with
3434
| v when Queries.ID.is_bot v -> false
3535
| v ->
3636
match Queries.ID.to_bool v with
3737
| Some b -> b
3838
| None -> false)
3939
| _ ->
40-
(* should not happen, ctx.local should always be false in this case *)
40+
(* should not happen, man.local should always be false in this case *)
4141
false
4242
else
4343
false
4444

45-
let enter ctx (lval: lval option) (f:fundec) (args:exp list) : (D.t * D.t) list =
45+
let enter man (lval: lval option) (f:fundec) (args:exp list) : (D.t * D.t) list =
4646
let candidate = match f.sformals with
4747
| [arg] when isIntegralType arg.vtype -> true
4848
| _ -> false
4949
in
5050
[false, candidate]
5151

52-
let combine_env ctx lval fexp f args fc au f_ask =
52+
let combine_env man lval fexp f args fc au f_ask =
5353
if au then (
5454
(* Assert before combine_assign, so if variables in `arg` are assigned to, asserting doesn't unsoundly yield bot *)
5555
(* See test 62/03 *)
5656
match args with
57-
| [arg] -> ctx.emit (Events.Assert arg)
57+
| [arg] -> man.emit (Events.Assert arg)
5858
| _ -> ()
5959
);
6060
false
6161

62-
let combine_assign ctx (lval:lval option) fexp (f:fundec) (args:exp list) fc (au:D.t) (f_ask: Queries.ask) : D.t =
62+
let combine_assign man (lval:lval option) fexp (f:fundec) (args:exp list) fc (au:D.t) (f_ask: Queries.ask) : D.t =
6363
false
6464

65-
let special ctx (lval: lval option) (f:varinfo) (arglist:exp list) : D.t =
65+
let special man (lval: lval option) (f:varinfo) (arglist:exp list) : D.t =
6666
false
6767

6868
let startstate v = false
69-
let threadenter ctx ~multiple lval f args = [false]
70-
let threadspawn ctx ~multiple lval f args fctx = false
69+
let threadenter man ~multiple lval f args = [false]
70+
let threadspawn man ~multiple lval f args fman = false
7171
let exitstate v = false
7272
end
7373

src/analyses/accessAnalysis.ml

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -31,112 +31,112 @@ struct
3131
let activated = get_string_list "ana.activated" in
3232
emit_single_threaded := List.mem (ModifiedSinceSetjmp.Spec.name ()) activated || List.mem (PoisonVariables.Spec.name ()) activated
3333

34-
let do_access (ctx: (D.t, G.t, C.t, V.t) ctx) (kind:AccessKind.t) (reach:bool) (e:exp) =
34+
let do_access (man: (D.t, G.t, C.t, V.t) man) (kind:AccessKind.t) (reach:bool) (e:exp) =
3535
if M.tracing then M.trace "access" "do_access %a %a %B" d_exp e AccessKind.pretty kind reach;
3636
let reach_or_mpt: _ Queries.t = if reach then ReachableFrom e else MayPointTo e in
37-
let ad = ctx.ask reach_or_mpt in
38-
ctx.emit (Access {exp=e; ad; kind; reach})
37+
let ad = man.ask reach_or_mpt in
38+
man.emit (Access {exp=e; ad; kind; reach})
3939

4040
(** Three access levels:
4141
+ [deref=false], [reach=false] - Access [exp] without dereferencing, used for all normal reads and all function call arguments.
4242
+ [deref=true], [reach=false] - Access [exp] by dereferencing once (may-point-to), used for lval writes and shallow special accesses.
4343
+ [deref=true], [reach=true] - Access [exp] by dereferencing transitively (reachable), used for deep special accesses. *)
44-
let access_one_top ?(force=false) ?(deref=false) ctx (kind: AccessKind.t) reach exp =
44+
let access_one_top ?(force=false) ?(deref=false) man (kind: AccessKind.t) reach exp =
4545
if M.tracing then M.traceli "access" "access_one_top %a (kind = %a, reach = %B, deref = %B)" CilType.Exp.pretty exp AccessKind.pretty kind reach deref;
46-
if force || !collect_local || !emit_single_threaded || ThreadFlag.has_ever_been_multi (Analyses.ask_of_ctx ctx) then (
46+
if force || !collect_local || !emit_single_threaded || ThreadFlag.has_ever_been_multi (Analyses.ask_of_man man) then (
4747
if deref && Cil.isPointerType (Cilfacade.typeOf exp) then (* avoid dereferencing integers to unknown pointers, which cause many spurious type-based accesses *)
48-
do_access ctx kind reach exp;
48+
do_access man kind reach exp;
4949
if M.tracing then M.tracei "access" "distribute_access_exp";
50-
Access.distribute_access_exp (do_access ctx Read false) exp;
50+
Access.distribute_access_exp (do_access man Read false) exp;
5151
if M.tracing then M.traceu "access" "distribute_access_exp";
5252
);
5353
if M.tracing then M.traceu "access" "access_one_top"
5454

5555

5656
(** We just lift start state, global and dependency functions: *)
5757
let startstate v = ()
58-
let threadenter ctx ~multiple lval f args = [()]
58+
let threadenter man ~multiple lval f args = [()]
5959
let exitstate v = ()
60-
let context ctx fd d = ()
60+
let context man fd d = ()
6161

6262

6363
(** Transfer functions: *)
6464

65-
let vdecl ctx v =
66-
access_one_top ctx Read false (SizeOf v.vtype);
67-
ctx.local
65+
let vdecl man v =
66+
access_one_top man Read false (SizeOf v.vtype);
67+
man.local
6868

69-
let assign ctx lval rval : D.t =
69+
let assign man lval rval : D.t =
7070
(* ignore global inits *)
71-
if !AnalysisState.global_initialization then ctx.local else begin
72-
access_one_top ~deref:true ctx Write false (AddrOf lval);
73-
access_one_top ctx Read false rval;
74-
ctx.local
71+
if !AnalysisState.global_initialization then man.local else begin
72+
access_one_top ~deref:true man Write false (AddrOf lval);
73+
access_one_top man Read false rval;
74+
man.local
7575
end
7676

77-
let branch ctx exp tv : D.t =
78-
access_one_top ctx Read false exp;
79-
ctx.local
77+
let branch man exp tv : D.t =
78+
access_one_top man Read false exp;
79+
man.local
8080

81-
let return ctx exp fundec : D.t =
81+
let return man exp fundec : D.t =
8282
begin match exp with
83-
| Some exp -> access_one_top ctx Read false exp
83+
| Some exp -> access_one_top man Read false exp
8484
| None -> ()
8585
end;
86-
ctx.local
86+
man.local
8787

88-
let body ctx f : D.t =
89-
ctx.local
88+
let body man f : D.t =
89+
man.local
9090

91-
let special ctx lv f arglist : D.t =
91+
let special man lv f arglist : D.t =
9292
let desc = LF.find f in
9393
match desc.special arglist with
9494
(* TODO: remove Lock/Unlock cases when all those libraryfunctions use librarydescs and don't read mutex contents *)
9595
| Lock _
9696
| Unlock _ ->
97-
ctx.local
97+
man.local
9898
| _ ->
9999
LibraryDesc.Accesses.iter desc.accs (fun {kind; deep = reach} exp ->
100-
access_one_top ~deref:true ctx kind reach exp (* access dereferenced using special accesses *)
100+
access_one_top ~deref:true man kind reach exp (* access dereferenced using special accesses *)
101101
) arglist;
102102
(match lv with
103-
| Some x -> access_one_top ~deref:true ctx Write false (AddrOf x)
103+
| Some x -> access_one_top ~deref:true man Write false (AddrOf x)
104104
| None -> ());
105-
List.iter (access_one_top ctx Read false) arglist; (* always read all argument expressions without dereferencing *)
106-
ctx.local
105+
List.iter (access_one_top man Read false) arglist; (* always read all argument expressions without dereferencing *)
106+
man.local
107107

108-
let enter ctx lv f args : (D.t * D.t) list =
109-
[(ctx.local,ctx.local)]
108+
let enter man lv f args : (D.t * D.t) list =
109+
[(man.local,man.local)]
110110

111-
let combine_env ctx lval fexp f args fc au f_ask =
111+
let combine_env man lval fexp f args fc au f_ask =
112112
(* These should be in enter, but enter cannot emit events, nor has fexp argument *)
113-
access_one_top ctx Read false fexp;
114-
List.iter (access_one_top ctx Read false) args;
113+
access_one_top man Read false fexp;
114+
List.iter (access_one_top man Read false) args;
115115
au
116116

117-
let combine_assign ctx lv fexp f args fc al f_ask =
117+
let combine_assign man lv fexp f args fc al f_ask =
118118
begin match lv with
119119
| None -> ()
120-
| Some lval -> access_one_top ~deref:true ctx Write false (AddrOf lval)
120+
| Some lval -> access_one_top ~deref:true man Write false (AddrOf lval)
121121
end;
122-
ctx.local
122+
man.local
123123

124124

125-
let threadspawn ctx ~multiple lval f args fctx =
125+
let threadspawn man ~multiple lval f args fman =
126126
(* must explicitly access thread ID lval because special to pthread_create doesn't if singlethreaded before *)
127127
begin match lval with
128128
| None -> ()
129-
| Some lval -> access_one_top ~force:true ~deref:true ctx Write false (AddrOf lval) (* must force because otherwise doesn't if singlethreaded before *)
129+
| Some lval -> access_one_top ~force:true ~deref:true man Write false (AddrOf lval) (* must force because otherwise doesn't if singlethreaded before *)
130130
end;
131-
ctx.local
131+
man.local
132132

133-
let query ctx (type a) (q: a Queries.t): a Queries.result =
133+
let query man (type a) (q: a Queries.t): a Queries.result =
134134
match q with
135135
| MayAccessed ->
136-
(ctx.global ctx.node: G.t)
136+
(man.global man.node: G.t)
137137
| _ -> Queries.Result.top q
138138

139-
let event ctx e octx =
139+
let event man e oman =
140140
match e with
141141
| Events.Access {ad; kind; _} when !collect_local && !AnalysisState.postsolving ->
142142
let events = Queries.AD.fold (fun addr es ->
@@ -151,9 +151,9 @@ struct
151151
| _ -> es
152152
) ad (G.empty ())
153153
in
154-
ctx.sideg ctx.node events
154+
man.sideg man.node events
155155
| _ ->
156-
ctx.local
156+
man.local
157157
end
158158

159159
let _ =

src/analyses/activeLongjmp.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ struct
1212
(* The first component are the longjmp targets, the second are the longjmp callers *)
1313
module D = JmpBufDomain.ActiveLongjmps
1414

15-
let special ctx (lval: lval option) (f:varinfo) (arglist:exp list) : D.t =
15+
let special man (lval: lval option) (f:varinfo) (arglist:exp list) : D.t =
1616
let desc = LibraryFunctions.find f in
1717
match desc.special arglist, f.vname with
1818
| Longjmp {env; value}, _ ->
1919
(* Set target to current value of env *)
20-
let bufs = ctx.ask (EvalJumpBuf env) in
21-
bufs, JmpBufDomain.NodeSet.singleton(ctx.prev_node)
22-
| _ -> ctx.local
20+
let bufs = man.ask (EvalJumpBuf env) in
21+
bufs, JmpBufDomain.NodeSet.singleton(man.prev_node)
22+
| _ -> man.local
2323

2424
(* Initial values don't really matter: overwritten at longjmp call. *)
2525
let startstate v = D.bot ()
26-
let threadenter ctx ~multiple lval f args = [D.bot ()]
26+
let threadenter man ~multiple lval f args = [D.bot ()]
2727
let exitstate v = D.top ()
2828

29-
let query ctx (type a) (q: a Queries.t): a Queries.result =
29+
let query man (type a) (q: a Queries.t): a Queries.result =
3030
match q with
3131
| ActiveJumpBuf ->
3232
(* Does not compile without annotation: "This instance (...) is ambiguous: it would escape the scope of its equation" *)
33-
(ctx.local:JmpBufDomain.ActiveLongjmps.t)
33+
(man.local:JmpBufDomain.ActiveLongjmps.t)
3434
| _ -> Queries.Result.top q
3535
end
3636

src/analyses/activeSetjmp.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ struct
1313
include Analyses.ValueContexts(D)
1414
module P = IdentityP (D)
1515

16-
let combine_env ctx (lval:lval option) fexp (f:fundec) (args:exp list) fc (au:D.t) (f_ask:Queries.ask): D.t =
17-
ctx.local (* keep local as opposed to IdentitySpec *)
16+
let combine_env man (lval:lval option) fexp (f:fundec) (args:exp list) fc (au:D.t) (f_ask:Queries.ask): D.t =
17+
man.local (* keep local as opposed to IdentitySpec *)
1818

19-
let special ctx (lval: lval option) (f:varinfo) (arglist:exp list) : D.t =
19+
let special man (lval: lval option) (f:varinfo) (arglist:exp list) : D.t =
2020
let desc = LibraryFunctions.find f in
2121
match desc.special arglist with
2222
| Setjmp _ ->
23-
let entry = (ctx.prev_node, ctx.control_context ()) in
24-
D.add (Target entry) ctx.local
25-
| _ -> ctx.local
23+
let entry = (man.prev_node, man.control_context ()) in
24+
D.add (Target entry) man.local
25+
| _ -> man.local
2626

2727
let startstate v = D.bot ()
28-
let threadenter ctx ~multiple lval f args = [D.bot ()]
28+
let threadenter man ~multiple lval f args = [D.bot ()]
2929
let exitstate v = D.top ()
3030

31-
let query ctx (type a) (q: a Queries.t): a Queries.result =
31+
let query man (type a) (q: a Queries.t): a Queries.result =
3232
match q with
33-
| ValidLongJmp -> (ctx.local: D.t)
33+
| ValidLongJmp -> (man.local: D.t)
3434
| _ -> Queries.Result.top q
3535
end
3636

0 commit comments

Comments
 (0)