Skip to content

Commit 4b77174

Browse files
committed
Make BaseInvariant fallback reason printing lazy
1 parent 8a2a977 commit 4b77174

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/analyses/baseInvariant.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ struct
248248

249249
let invariant ctx a gs st exp tv: D.t =
250250
let fallback reason st =
251-
if M.tracing then M.tracel "inv" "Can't handle %a.\n%s\n" d_plainexp exp reason;
251+
if M.tracing then M.tracel "inv" "Can't handle %a.\n%t\n" d_plainexp exp reason;
252252
invariant_fallback ctx a gs st exp tv
253253
in
254254
(* inverse values for binary operation a `op` b == c *)
@@ -689,7 +689,7 @@ struct
689689
(* Mixed Float and Int cases should never happen, as there are no binary operators with one float and one int parameter ?!*)
690690
| Int _, Float _ | Float _, Int _ -> failwith "ill-typed program";
691691
(* | Address a, Address b -> ... *)
692-
| a1, a2 -> fallback (GobPretty.sprintf "binop: got abstract values that are not Int: %a and %a" VD.pretty a1 VD.pretty a2) st)
692+
| a1, a2 -> fallback (fun () -> Pretty.dprintf "binop: got abstract values that are not Int: %a and %a" VD.pretty a1 VD.pretty a2) st)
693693
(* use closures to avoid unused casts *)
694694
in (match c_typed with
695695
| Int c -> invert_binary_op c ID.pretty (fun ik -> ID.cast_to ik c) (fun fk -> FD.of_int fk c)
@@ -778,7 +778,7 @@ struct
778778
| TFloat (fk, _), FLongDouble
779779
| TFloat (FDouble as fk, _), FDouble
780780
| TFloat (FFloat as fk, _), FFloat -> inv_exp (Float (FD.cast_to fk c)) e st
781-
| _ -> fallback ("CastE: incompatible types") st)
781+
| _ -> fallback (fun () -> Pretty.text "CastE: incompatible types") st)
782782
| CastE ((TInt (ik, _)) as t, e), Int c
783783
| CastE ((TEnum ({ekind = ik; _ }, _)) as t, e), Int c -> (* Can only meet the t part of an Lval in e with c (unless we meet with all overflow possibilities)! Since there is no good way to do this, we only continue if e has no values outside of t. *)
784784
(match eval e st with
@@ -791,11 +791,11 @@ struct
791791
let c' = ID.cast_to ik_e (ID.meet c (ID.cast_to ik (ID.top_of ik_e))) in (* TODO: cast without overflow, is this right for normal invariant? *)
792792
if M.tracing then M.tracel "inv" "cast: %a from %a to %a: i = %a; cast c = %a to %a = %a\n" d_exp e d_ikind ik_e d_ikind ik ID.pretty i ID.pretty c d_ikind ik_e ID.pretty c';
793793
inv_exp (Int c') e st
794-
| x -> fallback (GobPretty.sprintf "CastE: e did evaluate to Int, but the type did not match %a" CilType.Typ.pretty t) st
794+
| x -> fallback (fun () -> Pretty.dprintf "CastE: e did evaluate to Int, but the type did not match %a" CilType.Typ.pretty t) st
795795
else
796-
fallback (GobPretty.sprintf "CastE: %a evaluates to %a which is bigger than the type it is cast to which is %a" d_plainexp e ID.pretty i CilType.Typ.pretty t) st
797-
| v -> fallback (GobPretty.sprintf "CastE: e did not evaluate to Int, but %a" VD.pretty v) st)
798-
| e, _ -> fallback (GobPretty.sprintf "%a not implemented" d_plainexp e) st
796+
fallback (fun () -> Pretty.dprintf "CastE: %a evaluates to %a which is bigger than the type it is cast to which is %a" d_plainexp e ID.pretty i CilType.Typ.pretty t) st
797+
| v -> fallback (fun () -> Pretty.dprintf "CastE: e did not evaluate to Int, but %a" VD.pretty v) st)
798+
| e, _ -> fallback (fun () -> Pretty.dprintf "%a not implemented" d_plainexp e) st
799799
in
800800
if eval_bool exp st = Some (not tv) then contra st (* we already know that the branch is dead *)
801801
else

0 commit comments

Comments
 (0)