Skip to content

Commit c2a588f

Browse files
committed
Use pretty instead of show in C-2PO analysis (issue #1795)
1 parent 31b2e1c commit c2a588f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/analyses/c2poAnalysis.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ struct
138138
let cc = assign_lval d ask lval (T.of_cil ask expr) in
139139
let cc = reset_normal_form cc in
140140
let res = `Lifted cc in
141-
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);
141+
if M.tracing then M.trace "c2po-assign" "assign: var: %a; expr: %a; result: %a." d_lval lval d_plainexp expr D.pretty res;
142142
res
143143

144144
let branch ctx e pos =
@@ -188,7 +188,7 @@ struct
188188
end
189189
| None -> ctx.local
190190
in
191-
if M.tracing then M.trace "c2po-function" "return: exp_opt: %a; state: %s; result: %s\n" d_exp (BatOption.default (MayBeEqual.dummy_lval_print (TVoid [])) exp_opt) (D.show ctx.local) (D.show res);
191+
if M.tracing then M.trace "c2po-function" "return: exp_opt: %a; state: %a; result: %a" d_exp (BatOption.default (MayBeEqual.dummy_lval_print (TVoid [])) exp_opt) D.pretty ctx.local D.pretty res;
192192
res
193193

194194
(** var_opt is the variable we assign to. It has type lval. v=malloc.*)
@@ -249,7 +249,7 @@ struct
249249
if M.tracing then begin
250250
let dummy_lval = Var (Var.dummy_varinfo (TVoid [])), NoOffset in
251251
let lval = BatOption.default dummy_lval var_opt in
252-
M.trace "c2po-function" "enter1: var_opt: %a; state: %s; state_with_ghosts: %s\n" d_lval lval (D.show ctx.local) (C2PODomain.show state_with_ghosts);
252+
M.trace "c2po-function" "enter1: var_opt: %a; state: %a; state_with_ghosts: %a" d_lval lval D.pretty ctx.local C2PODomain.pretty state_with_ghosts;
253253
end;
254254
(* remove callee vars that are not reachable and not global *)
255255
let reachable_variables =
@@ -258,7 +258,7 @@ struct
258258
in
259259
let new_state = D.remove_terms_not_containing_variables reachable_variables state_with_ghosts.data in
260260
let new_state = data_to_t new_state in
261-
if M.tracing then M.trace "c2po-function" "enter2: result: %s\n" (C2PODomain.show new_state);
261+
if M.tracing then M.trace "c2po-function" "enter2: result: %a" C2PODomain.pretty new_state;
262262
let new_state = reset_normal_form new_state in
263263
[ctx.local, `Lifted new_state]
264264

@@ -282,7 +282,7 @@ struct
282282
in
283283
let state_with_assignments = List.fold_left assign_term d arg_assigns in
284284

285-
if M.tracing then M.trace "c2po-function" "combine_env0: state_with_assignments: %s\n" (C2PODomain.show state_with_assignments);
285+
if M.tracing then M.trace "c2po-function" "combine_env0: state_with_assignments: %a" C2PODomain.pretty state_with_assignments;
286286

287287
(*remove all variables that were tainted by the function*)
288288
let tainted = f_ask.f (MayBeTainted) in
@@ -298,7 +298,7 @@ struct
298298
if M.tracing then begin
299299
let dummy_lval = Var (Var.dummy_varinfo (TVoid[])), NoOffset in
300300
let lval = BatOption.default dummy_lval lval_opt in
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)
301+
M.trace "c2po-function" "combine_env2: var_opt: %a; local_state: %a; f_state: %a; meeting everything: %a" d_lval lval D.pretty ctx.local D.pretty f_d C2PODomain.pretty d
302302
end;
303303
`Lifted d
304304

@@ -327,10 +327,10 @@ struct
327327
let return_var = (Some return_var, Some Z.zero) in
328328
assign_lval d f_ask lval return_var
329329
in
330-
if M.tracing then M.trace "c2po-function" "combine_assign1: assigning return value: %s\n" (C2PODomain.show d);
330+
if M.tracing then M.trace "c2po-function" "combine_assign1: assigning return value: %a" C2PODomain.pretty d;
331331
let d = remove_out_of_scope_vars d.data f in
332332
let d = data_to_t d in
333-
if M.tracing then M.trace "c2po-function" "combine_assign2: result: %s\n" (C2PODomain.show d);
333+
if M.tracing then M.trace "c2po-function" "combine_assign2: result: %a" C2PODomain.pretty d;
334334
`Lifted d
335335

336336
let startstate v =

src/cdomains/c2poDomain.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ module D = struct
251251
It removes all terms which contain one of the "vars",
252252
while maintaining all equalities about variables that are not being removed.*)
253253
let remove_terms_containing_variables vars cc =
254-
if M.tracing then M.trace "c2po" "remove_terms_containing_variables: %s\n" (List.fold_left (fun s v -> s ^"; " ^Var.show v) "" vars);
254+
if M.tracing then M.trace "c2po" "remove_terms_containing_variables: %a" (Pretty.d_list "; " Var.pretty) vars;
255255
remove_terms (T.contains_variable vars) cc
256256

257257
(** Remove terms from the data structure.
258258
It removes all terms which do not contain one of the "vars",
259259
except the global vars are also kept (when vglob = true),
260260
while maintaining all equalities about variables that are not being removed.*)
261261
let remove_terms_not_containing_variables vars cc =
262-
if M.tracing then M.trace "c2po" "remove_terms_not_containing_variables: %s\n" (List.fold_left (fun s v -> s ^"; " ^Var.show v) "" vars);
262+
if M.tracing then M.trace "c2po" "remove_terms_not_containing_variables: %a" (Pretty.d_list "; " Var.pretty) vars;
263263
let not_global_and_not_contains_variable t =
264264
let var = T.get_var t in
265265
not (DuplicateVars.VarType.vglob var) && not (T.contains_variable vars t)

0 commit comments

Comments
 (0)