[sledge] Change type of warn to be consistent with fail

Summary:
Require a final `()` argument to explicitly indicate the end of the
arguments to the printf-like functions. For `warn` this is not
any safer because the return type is `unit` anyhow, but for `fail` the
return type is polymorphic so the final `()` prevents unintentionally
forgetting an argument.

Reviewed By: ngorogiannis

Differential Revision: D15403367

fbshipit-source-id: ce3fe4035
master
Josh Berdine 6 years ago committed by Facebook Github Bot
parent d9853aa53d
commit c8943f946c

@ -58,7 +58,7 @@ let warn fmt =
Format.pp_open_box fs 2 ; Format.pp_open_box fs 2 ;
Format.pp_print_string fs "Warning: " ; Format.pp_print_string fs "Warning: " ;
Format.kfprintf Format.kfprintf
(fun fs -> (fun fs () ->
Format.pp_close_box fs () ; Format.pp_close_box fs () ;
Format.pp_force_newline fs () ) Format.pp_force_newline fs () )
fs fmt fs fmt

@ -75,7 +75,7 @@ type ('a, 'b) fmt = ('a, Formatter.t, unit, 'b) format4
exception Unimplemented of string exception Unimplemented of string
val warn : ('a, unit) fmt -> 'a val warn : ('a, unit -> unit) fmt -> 'a
(** Issue a warning for a survivable problem. *) (** Issue a warning for a survivable problem. *)
val todo : ('a, unit -> _) fmt -> 'a val todo : ('a, unit -> _) fmt -> 'a

@ -58,7 +58,7 @@ let (scan_locs : Llvm.llmodule -> unit), (find_loc : Llvm.llvalue -> Loc.t)
(List.find_a_dup ~compare:Loc.compare [loc; data; Loc.none]) (List.find_a_dup ~compare:Loc.compare [loc; data; Loc.none])
then then
warn "ignoring location %a conflicting with %a for %a" Loc.pp warn "ignoring location %a conflicting with %a for %a" Loc.pp
loc Loc.pp data pp_llvalue key ) ; loc Loc.pp data pp_llvalue key () ) ;
data ) data )
in in
let scan_locs m = let scan_locs m =
@ -76,7 +76,7 @@ let (scan_locs : Llvm.llmodule -> unit), (find_loc : Llvm.llvalue -> Loc.t)
"could not find variable for debug info %a at %a with \ "could not find variable for debug info %a at %a with \
metadata %a" metadata %a"
pp_llvalue (Llvm.operand i 0) Loc.pp loc pp_llvalue (Llvm.operand i 0) Loc.pp loc
(List.pp ", " pp_llvalue) (Array.to_list md) (List.pp ", " pp_llvalue) (Array.to_list md) ()
| _ -> () ) | _ -> () )
| _ -> () | _ -> ()
in in
@ -913,7 +913,7 @@ let xlate_instr :
let fname = Llvm.value_name llfunc in let fname = Llvm.value_name llfunc in
let skip msg = let skip msg =
( match Hash_set.strict_add ignored_callees fname with ( match Hash_set.strict_add ignored_callees fname with
| Ok () -> warn "ignoring uninterpreted %s %s" msg fname | Ok () -> warn "ignoring uninterpreted %s %s" msg fname ()
| Error _ -> () ) ; | Error _ -> () ) ;
let reg = xlate_name_opt instr in let reg = xlate_name_opt instr in
let msg = Llvm.string_of_llvalue instr in let msg = Llvm.string_of_llvalue instr in
@ -980,7 +980,7 @@ let xlate_instr :
else ( else (
warn warn
"ignoring variable arguments to variadic function: %a" "ignoring variable arguments to variadic function: %a"
pp_llvalue instr ; pp_llvalue instr () ;
Array.length (Llvm.param_types (Llvm.element_type lltyp)) ) Array.length (Llvm.param_types (Llvm.element_type lltyp)) )
in in
List.rev_init num_args ~f:(fun i -> List.rev_init num_args ~f:(fun i ->
@ -1009,7 +1009,7 @@ let xlate_instr :
Llvm.num_arg_operands instr Llvm.num_arg_operands instr
else ( else (
warn "ignoring variable arguments to variadic function: %a" warn "ignoring variable arguments to variadic function: %a"
pp_llvalue instr ; pp_llvalue instr () ;
Array.length (Llvm.param_types (Llvm.element_type lltyp)) ) Array.length (Llvm.param_types (Llvm.element_type lltyp)) )
in in
let args = let args =
@ -1244,7 +1244,7 @@ let xlate_instr :
| VAArg -> | VAArg ->
let reg = xlate_name_opt instr in let reg = xlate_name_opt instr in
let msg = Llvm.string_of_llvalue instr in let msg = Llvm.string_of_llvalue instr in
warn "variadic function argument: %s" msg ; warn "variadic function argument: %s" msg () ;
emit_inst (Llair.Inst.nondet ~reg ~msg ~loc) emit_inst (Llair.Inst.nondet ~reg ~msg ~loc)
| CleanupRet | CatchRet | CatchPad | CleanupPad | CatchSwitch -> | CleanupRet | CatchRet | CatchPad | CleanupPad | CatchSwitch ->
todo "windows exception handling: %a" pp_llvalue instr () todo "windows exception handling: %a" pp_llvalue instr ()

Loading…
Cancel
Save