3232 (* Returns Some true if we know for sure that it is true,
3333 and Some false if we know for sure that it is false,
3434 and None if we don't know anyhing. *)
35- let eval_guard ask cc e ik =
35+ let eval_guard ask d e ik =
36+ let cc = d.data in
3637 let open Queries in
3738 let prop_list = T. prop_of_cil ask e true in
3839 match split prop_list with
@@ -71,28 +72,30 @@ struct
7172 let open Queries in
7273 match ctx.local with
7374 | `Bot -> Result. top q
74- | `Lifted cc ->
75+ | `Lifted d ->
7576 match q with
7677 | EvalInt e ->
7778 let ik = Cilfacade. get_ikind_exp e in
78- eval_guard (ask_of_man ctx) cc e ik
79+ eval_guard (ask_of_man ctx) d e ik
7980 | Queries. Invariant context ->
8081 let scope = Node. find_fundec ctx.node in
81- let t = D. remove_vars_not_in_scope scope cc in
82- let conj = get_conjunction t in
82+ let cc = D. remove_vars_not_in_scope scope d.data in
83+ let conj = get_conjunction_from_data cc in
8384 let ask = ask_of_man ctx in
8485 conj_to_invariant ask conj
8586 | _ ->
8687 Result. top q
8788
8889 (* * Assign the right hand side rhs (that is already
8990 converted to a C-2PO term) to the term `lterm`. *)
90- let assign_term cc ask lterm rhs lval_t =
91+ let assign_term d ask lterm rhs lval_t =
92+ let cc = d.data in
9193 (* ignore assignments to values that are not 64 bits *)
9294 match T. get_element_size_in_bits lval_t, rhs with
9395 (* Indefinite assignment *)
9496 | lval_size , (None, _ ) ->
95- D. remove_may_equal_terms ask lval_size lterm cc
97+ let cc = D. remove_may_equal_terms ask lval_size lterm cc in
98+ data_to_t cc
9699 (* Definite assignment *)
97100 | lval_size , (Some rterm , Some roffset ) ->
98101 let dummy_var = MayBeEqual. dummy_var lval_t in
@@ -106,8 +109,8 @@ struct
106109 meet_conjs_opt equal_dummy_rterm |>
107110 D. remove_may_equal_terms ask lval_size lterm |>
108111 meet_conjs_opt equal_dummy_lterm |>
109- D. remove_terms_containing_aux_variable
110-
112+ D. remove_terms_containing_aux_variable |>
113+ data_to_t
111114 | _ -> (* this is impossible *)
112115 C2PODomain. top ()
113116
@@ -131,8 +134,8 @@ struct
131134 match ctx.local with
132135 | `Bot ->
133136 `Bot
134- | `Lifted cc ->
135- let cc = assign_lval cc ask lval (T. of_cil ask expr) in
137+ | `Lifted d ->
138+ let cc = assign_lval d ask lval (T. of_cil ask expr) in
136139 let cc = reset_normal_form cc in
137140 let res = `Lifted cc in
138141 if M. tracing then M. trace " c2po-assign" " assign: var: %a; expr: %a; result: %s.\n " d_lval lval d_plainexp expr (D. show res);
@@ -144,13 +147,13 @@ struct
144147 let res =
145148 match ctx.local with
146149 | `Bot -> `Bot
147- | `Lifted cc ->
150+ | `Lifted d ->
148151 if List. is_empty valid_props then
149- `Lifted cc
152+ `Lifted d
150153 else
151154 try
152- let meet = meet_conjs_opt valid_props cc in
153- let t = reset_normal_form meet in
155+ let meet = meet_conjs_opt valid_props d.data in
156+ let t = data_to_t meet in
154157 `Lifted t
155158 with Unsat ->
156159 `Bot
@@ -167,8 +170,8 @@ struct
167170 match T. of_cil ask expr with
168171 | (Some term , Some offset ) ->
169172 let ret_var_eq_term = [Equal (return_var, term, offset)] in
170- let assign_by_meet = meet_conjs_opt ret_var_eq_term d in
171- reset_normal_form assign_by_meet
173+ let assign_by_meet = meet_conjs_opt ret_var_eq_term d.data in
174+ data_to_t assign_by_meet
172175 | _ -> d
173176
174177 let return ctx exp_opt f =
@@ -194,25 +197,27 @@ struct
194197 let ask = ask_of_man ctx in
195198 match ctx.local with
196199 | `Bot -> `Bot
197- | `Lifted cc ->
200+ | `Lifted d ->
198201 let t =
199202 begin match lval_opt with
200203 | None ->
201- cc
204+ d
202205 | Some lval ->
203206 (* forget information about var,
204207 but ignore assignments to values that are not 64 bits *)
205208 try
206209 let size = T. get_element_size_in_bits (typeOfLval lval) in
207210 let lterm = T. of_lval ask lval in
208- let cc = D. remove_may_equal_terms ask size lterm cc in
209- begin match desc.special exprs with
211+ let cc = D. remove_may_equal_terms ask size lterm d.data in
212+ let cc = begin match desc.special exprs with
210213 | Malloc _
211214 | Calloc _
212215 | Alloca _ ->
213216 add_block_diseqs cc lterm
214217 | _ -> cc
215218 end
219+ in
220+ data_to_t cc
216221 with T. UnsupportedCilExpression _ ->
217222 C2PODomain. top ()
218223 end
@@ -224,7 +229,7 @@ struct
224229 else
225230 branch ctx exp true
226231 | _ ->
227- `Lifted (reset_normal_form t)
232+ `Lifted t
228233
229234 (* * First all local variables of the function are duplicated,
230235 then we remember the value of each local variable at the beginning of the function by using the analysis startState.
@@ -233,13 +238,14 @@ struct
233238 (* add duplicated variables, and set them equal to the original variables *)
234239 match ctx.local with
235240 | `Bot -> [`Bot , `Bot ]
236- | `Lifted cc ->
241+ | `Lifted d ->
237242 let ghost_equality v =
238243 Equal (T. term_of_varinfo (DuplicVar v), T. term_of_varinfo (NormalVar v), Z. zero)
239244 in
240245 let ghost_equalities_for_params = List. map ghost_equality f.sformals in
241246 let equalities_to_add = T. filter_valid_pointers ghost_equalities_for_params in
242- let state_with_ghosts = meet_conjs_opt equalities_to_add cc in
247+ let state_with_ghosts = meet_conjs_opt equalities_to_add d.data in
248+ let state_with_ghosts = data_to_t state_with_ghosts in
243249 if M. tracing then begin
244250 let dummy_lval = Var (Var. dummy_varinfo (TVoid [] )), NoOffset in
245251 let lval = BatOption. default dummy_lval var_opt in
@@ -250,7 +256,8 @@ struct
250256 let reachable = f.sformals @ f.slocals @ reachable_from_args ctx args in
251257 Var. from_varinfo reachable f.sformals
252258 in
253- let new_state = D. remove_terms_not_containing_variables reachable_variables state_with_ghosts in
259+ let new_state = D. remove_terms_not_containing_variables reachable_variables state_with_ghosts.data in
260+ let new_state = data_to_t new_state in
254261 if M. tracing then M. trace " c2po-function" " enter2: result: %s\n " (C2PODomain. show new_state);
255262 let new_state = reset_normal_form new_state in
256263 [ctx.local, `Lifted new_state]
@@ -264,7 +271,7 @@ struct
264271 let combine_env ctx lval_opt expr f args t_context_opt f_d (f_ask : Queries.ask ) =
265272 match ctx.local with
266273 | `Bot -> `Bot
267- | `Lifted cc ->
274+ | `Lifted d ->
268275 let caller_ask = ask_of_man ctx in
269276 (* assign function parameters to duplicated values *)
270277 let arg_assigns = GobList. combine_short f.sformals args in
@@ -273,30 +280,32 @@ struct
273280 let arg = T. of_cil f_ask arg in
274281 assign_term st caller_ask ghost_var arg var.vtype
275282 in
276- let state_with_assignments = List. fold_left assign_term cc arg_assigns in
283+ let state_with_assignments = List. fold_left assign_term d arg_assigns in
277284
278285 if M. tracing then M. trace " c2po-function" " combine_env0: state_with_assignments: %s\n " (C2PODomain. show state_with_assignments);
279286
280287 (* remove all variables that were tainted by the function*)
281288 let tainted = f_ask.f (MayBeTainted ) in
282289 if M. tracing then M. trace " c2po-tainted" " combine_env1: %a\n " MayBeEqual.AD. pretty tainted;
283290
284- let local = D. remove_tainted_terms caller_ask tainted state_with_assignments in
291+ let local = D. remove_tainted_terms caller_ask tainted state_with_assignments.data in
292+ let local = data_to_t local in
285293 match D. meet (`Lifted local) f_d with
286294 | `Bot -> `Bot
287- | `Lifted cc ->
288- let cc = reset_normal_form @@ remove_out_of_scope_vars cc f in
295+ | `Lifted d ->
296+ let cc = remove_out_of_scope_vars d.data f in
297+ let d = data_to_t cc in
289298 if M. tracing then begin
290299 let dummy_lval = Var (Var. dummy_varinfo (TVoid [] )), NoOffset in
291300 let lval = BatOption. default dummy_lval lval_opt in
292- M. trace " c2po-function" " combine_env2: var_opt: %a; local_state: %s; f_state: %s; meeting everything: %s\n " d_lval lval (D. show ctx.local) (D. show f_d) (C2PODomain. show cc )
301+ M. trace " c2po-function" " combine_env2: var_opt: %a; local_state: %s; f_state: %s; meeting everything: %s\n " d_lval lval (D. show ctx.local) (D. show f_d) (C2PODomain. show d )
293302 end ;
294- `Lifted cc
303+ `Lifted d
295304
296305 let combine_assign ctx var_opt expr f args t_context_opt f_d (f_ask : Queries.ask ) =
297306 match ctx.local with
298307 | `Bot -> `Bot
299- | `Lifted cc ->
308+ | `Lifted d ->
300309 let caller_ask = ask_of_man ctx in
301310 (* assign function parameters to duplicated values *)
302311 let arg_assigns = GobList. combine_short f.sformals args in
@@ -305,24 +314,24 @@ struct
305314 let arg = T. of_cil f_ask arg in
306315 assign_term st caller_ask ghost_var arg var.vtype
307316 in
308- let state_with_assignments = List. fold_left assign_term cc arg_assigns in
317+ let state_with_assignments = List. fold_left assign_term d arg_assigns in
309318 match D. meet (`Lifted state_with_assignments) f_d with
310319 | `Bot -> `Bot
311- | `Lifted cc ->
312- let cc = match var_opt with
320+ | `Lifted d ->
321+ let d = match var_opt with
313322 | None ->
314- cc
323+ d
315324 | Some lval ->
316325 let return_type = typeOfLval lval in
317326 let return_var = MayBeEqual. return_var return_type in
318327 let return_var = (Some return_var, Some Z. zero) in
319- assign_lval cc f_ask lval return_var
328+ assign_lval d f_ask lval return_var
320329 in
321- if M. tracing then M. trace " c2po-function" " combine_assign1: assigning return value: %s\n " (C2PODomain. show cc );
322- let cc = remove_out_of_scope_vars cc f in
323- let cc = reset_normal_form cc in
324- if M. tracing then M. trace " c2po-function" " combine_assign2: result: %s\n " (C2PODomain. show cc );
325- `Lifted cc
330+ if M. tracing then M. trace " c2po-function" " combine_assign1: assigning return value: %s\n " (C2PODomain. show d );
331+ let d = remove_out_of_scope_vars d.data f in
332+ let d = data_to_t d in
333+ if M. tracing then M. trace " c2po-function" " combine_assign2: result: %s\n " (C2PODomain. show d );
334+ `Lifted d
326335
327336 let startstate v =
328337 D. top ()
0 commit comments