Skip to content

Commit 916913a

Browse files
committed
Use format strings for assert messages
1 parent a95793e commit 916913a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/analyses/assert.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ struct
1414
(* transfer functions *)
1515

1616
let assert_fn man e check refine =
17-
let expr = CilType.Exp.show e in
18-
let warn warn_fn msg =
17+
let assert_msg severity fmt =
1918
if check then
20-
warn_fn msg
19+
M.msg severity ~category:Assert fmt
20+
else
21+
GobPretty.igprintf () fmt
2122
in
22-
(* TODO: use format instead of %s for the following messages *)
2323
match Queries.eval_bool (Analyses.ask_of_man man) e with
2424
| `Lifted false ->
25-
warn (M.error ~category:Assert "%s") ("Assertion \"" ^ expr ^ "\" will fail.");
25+
assert_msg Error "Assertion \"%a\" will fail." CilType.Exp.pretty e;
2626
if refine then raise Analyses.Deadcode else man.local
2727
| `Lifted true ->
28-
warn (M.success ~category:Assert "%s") ("Assertion \"" ^ expr ^ "\" will succeed");
28+
assert_msg Success "Assertion \"%a\" will succeed" CilType.Exp.pretty e;
2929
man.local
3030
| `Bot ->
31-
M.error ~category:Assert "%s" ("Assertion \"" ^ expr ^ "\" produces a bottom. What does that mean? (currently uninitialized arrays' content is bottom)");
31+
M.error ~category:Assert "Assertion \"%a\" produces a bottom. What does that mean? (currently uninitialized arrays' content is bottom)" CilType.Exp.pretty e;
3232
man.local
3333
| `Top ->
34-
warn (M.warn ~category:Assert "%s") ("Assertion \"" ^ expr ^ "\" is unknown.");
34+
assert_msg Warning "Assertion \"%a\" is unknown." CilType.Exp.pretty e;
3535
man.local
3636

3737
let special man (lval: lval option) (f:varinfo) (args:exp list) : D.t =

0 commit comments

Comments
 (0)