From 812ac265a8f3413658a4777b9d19367b3658c32c Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Wed, 16 Dec 2015 09:18:48 -0800 Subject: [PATCH] more logging cleanup: only print Errdesc.warning_err in developer mode Reviewed By: jeremydubreil Differential Revision: D2762994 fb-gh-sync-id: 780e7eb --- infer/src/backend/errdesc.ml | 16 +++++++++------- infer/src/backend/errdesc.mli | 5 +---- infer/src/backend/interproc.ml | 2 +- infer/src/backend/logging.ml | 3 --- infer/src/backend/logging.mli | 3 --- infer/src/backend/symExec.ml | 4 +++- 6 files changed, 14 insertions(+), 19 deletions(-) diff --git a/infer/src/backend/errdesc.ml b/infer/src/backend/errdesc.ml index 2a7924ebe..40063fdba 100644 --- a/infer/src/backend/errdesc.ml +++ b/infer/src/backend/errdesc.ml @@ -1027,13 +1027,15 @@ let explain_null_test_after_dereference exp node line loc = | None -> Localise.no_desc let _warning loc fmt fmt_string = - F.fprintf fmt "%s:%d: Warning: " (DB.source_file_to_string !DB.current_source) loc.Location.line; - F.fprintf fmt fmt_string - -(** Print a warning to the out stream, at the given location *) -let warning_out loc fmt_string = - _warning loc (Logging.get_out_formatter ()) fmt_string + if !Config.developer_mode then + begin + F.fprintf + fmt "%s:%d: Warning: " (DB.source_file_to_string !DB.current_source) loc.Location.line; + F.fprintf fmt fmt_string + end + else + F.ifprintf fmt fmt_string -(** Print a warning to the err stream, at the given location *) +(** Print a warning to the err stream at the given location (note: only prints in developer mode) *) let warning_err loc fmt_string = _warning loc (Logging.get_err_formatter ()) fmt_string diff --git a/infer/src/backend/errdesc.mli b/infer/src/backend/errdesc.mli index cb0a26c3e..e9b316329 100644 --- a/infer/src/backend/errdesc.mli +++ b/infer/src/backend/errdesc.mli @@ -140,10 +140,7 @@ val pvar_is_edg_tmp : Sil.pvar -> bool (** Check whether the program variable is a temporary generated by the front-end *) val pvar_is_frontend_tmp : Sil.pvar -> bool -(** Print a warning to the out stream, at the given location *) -val warning_out : Location.t -> ('a, Format.formatter, unit) format -> 'a - -(** Print a warning to the err stream, at the given location *) +(** Print a warning to the err stream at the given location (note: only prints in developer mode) *) val warning_err : Location.t -> ('a, Format.formatter, unit) format -> 'a (* offset of an expression found following a program variable *) diff --git a/infer/src/backend/interproc.ml b/infer/src/backend/interproc.ml index cc028c536..373925f9d 100644 --- a/infer/src/backend/interproc.ml +++ b/infer/src/backend/interproc.ml @@ -279,7 +279,7 @@ let propagate_nodes_divergence | None -> _succ_nodes in if !Config.footprint && not (Paths.PathSet.is_empty (State.get_diverging_states_node ())) then begin - if !Config.developer_mode then Errdesc.warning_err (State.get_loc ()) "Propagating Divergence@."; + Errdesc.warning_err (State.get_loc ()) "Propagating Divergence@."; let exit_node = Cfg.Procdesc.get_exit_node pdesc in let diverging_states = State.get_diverging_states_node () in let prop_incons = diff --git a/infer/src/backend/logging.ml b/infer/src/backend/logging.ml index 0c7adbd0b..88b7b26d2 100644 --- a/infer/src/backend/logging.ml +++ b/infer/src/backend/logging.ml @@ -70,9 +70,6 @@ let current_out_formatter = ref F.std_formatter (** Current formatter for the err stream *) let current_err_formatter = ref F.err_formatter -(** Get the current out formatter *) -let get_out_formatter () = !current_out_formatter - (** Get the current err formatter *) let get_err_formatter fmt = !current_err_formatter diff --git a/infer/src/backend/logging.mli b/infer/src/backend/logging.mli index 90872b251..74d036b7e 100644 --- a/infer/src/backend/logging.mli +++ b/infer/src/backend/logging.mli @@ -80,9 +80,6 @@ val stderr : ('a, Format.formatter, unit) format -> 'a (** print immediately to standard output *) val stdout : ('a, Format.formatter, unit) format -> 'a -(** Get the current out formatter *) -val get_out_formatter : unit -> Format.formatter - (** Get the current err formatter *) val get_err_formatter : unit -> Format.formatter diff --git a/infer/src/backend/symExec.ml b/infer/src/backend/symExec.ml index 7f35c46e9..5ef5998da 100644 --- a/infer/src/backend/symExec.ml +++ b/infer/src/backend/symExec.ml @@ -1429,7 +1429,9 @@ and sym_exec_call cfg pdesc tenv pre path ret_ids actual_pars summary loc = !Config.curr_language = Config.Java) then t_e else t) :: comb etl' tl' | _,[] -> - if !Config.developer_mode then Errdesc.warning_err (State.get_loc ()) "likely use of variable-arguments function, or function prototype missing@."; + Errdesc.warning_err + (State.get_loc ()) + "likely use of variable-arguments function, or function prototype missing@."; L.d_warning "likely use of variable-arguments function, or function prototype missing"; L.d_ln(); L.d_str "actual parameters: "; Sil.d_exp_list (IList.map fst actual_pars); L.d_ln (); L.d_str "formal parameters: "; Sil.d_typ_list formal_types; L.d_ln ();