[infer][ondemand] rename the logging functions to outline the deprecated ones

Summary:
Now that we can run several inter-procedural analyses at the same time, we should no longer use the function `Reporting.log_error_deprecated` as it logs the errors in the specs table. This specs table is normally used for caching and will be deprecated in favor of having a cache summaries for the callees in the `Ondemand` module (to avoid deserialising a callee more than once within the same process).

This revision just renames the reporting functions.

Reviewed By: sblackshear

Differential Revision: D5205009

fbshipit-source-id: b066549
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent 7b8eef52f8
commit cddd1b4ca2

@ -1178,7 +1178,7 @@ let check_junk ?original_prop pname tenv prop =
if not report_and_continue then raise exn
else
begin
Reporting.log_error pname exn;
Reporting.log_error_deprecated pname exn;
leaks_reported := alloc_attribute :: !leaks_reported;
end in
if not ignore_leak then report_leak ();

@ -453,7 +453,7 @@ let check_assignement_guard pdesc node =
if (is_prune_exp e) && not ((node_contains_call node) && (is_frontend_tmp e)) then (
let desc = Errdesc.explain_condition_is_assignment l_node in
let exn = Exceptions.Condition_is_assignment (desc, __POS__) in
Reporting.log_warning pname ~loc:l_node exn
Reporting.log_warning_deprecated pname ~loc:l_node exn
)
else ()
| _ ->
@ -516,7 +516,7 @@ let forward_tabulate tenv pdesc wl =
| None -> ());
L.d_strln "SIL INSTR:";
Procdesc.Node.d_instrs ~sub_instrs: true (State.get_instr ()) curr_node; L.d_ln ();
Reporting.log_error pname exn;
Reporting.log_error_deprecated pname exn;
State.mark_instr_fail exn in
let exe_iter f pathset =
@ -666,7 +666,7 @@ let report_context_leaks pname sigma tenv =
let err_desc =
Errdesc.explain_context_leak pname (Typ.mk (Tstruct name)) fld_name leak_path in
let exn = Exceptions.Context_leak (err_desc, __POS__) in
Reporting.log_error pname exn)
Reporting.log_error_deprecated pname exn)
context_exps in
(* get the set of pointed-to expressions of type T <: Context *)
let context_exps =
@ -701,7 +701,7 @@ let remove_locals_formals_and_check tenv pdesc p =
let dexp_opt, _ = Errdesc.vpath_find tenv p (Exp.Lvar pvar) in
let desc = Errdesc.explain_stack_variable_address_escape loc pvar dexp_opt in
let exn = Exceptions.Stack_variable_address_escape (desc, __POS__) in
Reporting.log_warning pname exn in
Reporting.log_warning_deprecated pname exn in
List.iter ~f:check_pvar pvars;
p'
@ -1017,7 +1017,7 @@ let perform_analysis_phase tenv (summary : Specs.summary) (pdesc : Procdesc.t)
ignore (path_set_put_todo wl start_node init_edgeset);
forward_tabulate tenv pdesc wl in
let get_results (wl : Worklist.t) () =
State.process_execution_failures Reporting.log_warning pname;
State.process_execution_failures Reporting.log_warning_deprecated pname;
let results = collect_analysis_result tenv wl pdesc in
L.(debug Analysis Medium) "#### [FUNCTION %a] ... OK #####@\n" Typ.Procname.pp pname;
L.(debug Analysis Medium) "#### Finished: Footprint Computation for %a %a ####@."
@ -1031,7 +1031,7 @@ let perform_analysis_phase tenv (summary : Specs.summary) (pdesc : Procdesc.t)
let exn =
Exceptions.Internal_error
(Localise.verbatim_desc "Leak_while_collecting_specs_after_footprint") in
Reporting.log_error pname exn;
Reporting.log_error_deprecated pname exn;
[] (* retuning no specs *) in
specs, Specs.FOOTPRINT in
let wl = path_set_create_worklist pdesc in
@ -1189,7 +1189,7 @@ let report_runtime_exceptions tenv pdesc summary =
F.asprintf "%a" (Prop.pp_prop Pp.text) (Specs.Jprop.to_prop pre) in
let exn_desc = Localise.java_unchecked_exn_desc pname runtime_exception pre_str in
let exn = Exceptions.Java_runtime_exception (runtime_exception, pre_str, exn_desc) in
Reporting.log_error pname exn in
Reporting.log_error_deprecated pname exn in
List.iter ~f:report exn_preconditions
@ -1202,7 +1202,7 @@ let report_custom_errors tenv summary =
let loc = summary.Specs.attributes.ProcAttributes.loc in
let err_desc = Localise.desc_custom_error loc in
let exn = Exceptions.Custom_error (custom_error, err_desc) in
Reporting.log_error pname exn in
Reporting.log_error_deprecated pname exn in
List.iter ~f:report error_preconditions
module SpecMap = Caml.Map.Make (struct

@ -147,7 +147,7 @@ let run_proc_analysis ~propagate_exceptions analyze_proc curr_pdesc callee_pdesc
summary in
let log_error_and_continue exn summary kind =
Reporting.log_error_from_summary summary exn;
Reporting.log_error summary exn;
let stats = { summary.Specs.stats with Specs.stats_failure = Some kind } in
let payload =
{ summary.Specs.payload with Specs.preposts = Some []; } in

@ -2209,7 +2209,7 @@ let check_implication_base pname tenv check_frame_empty calc_missing prop1 prop2
L.d_strln ("WARNING: footprint failed to find MISSING because: " ^ s);
None
| (Exceptions.Abduction_case_not_implemented _ as exn) ->
Reporting.log_error pname exn;
Reporting.log_error_deprecated pname exn;
None
type implication_result =

@ -63,14 +63,14 @@ let check_bad_index tenv pname p len index loc =
let exn =
Exceptions.Array_out_of_bounds_l1
(Errdesc.explain_array_access tenv deref_str p loc, __POS__) in
Reporting.log_warning pname exn
Reporting.log_warning_deprecated pname exn
else if len_is_constant then
let deref_str = Localise.deref_str_array_bound len_const_opt index_const_opt in
let desc = Errdesc.explain_array_access tenv deref_str p loc in
let exn = if index_has_bounds ()
then Exceptions.Array_out_of_bounds_l2 (desc, __POS__)
else Exceptions.Array_out_of_bounds_l3 (desc, __POS__) in
Reporting.log_warning pname exn
Reporting.log_warning_deprecated pname exn
end
(** Perform bounds checking *)
@ -817,7 +817,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc =
let err_desc =
Localise.desc_unsafe_guarded_by_access accessed_fld guarded_by_str loc in
let exn = Exceptions.Unsafe_guarded_by_access (err_desc, __POS__) in
Reporting.log_error pname exn in
Reporting.log_error_deprecated pname exn in
let rec is_read_write_lock typ =
let str_is_read_write_lock str = String.is_suffix ~suffix:"ReadWriteUpdateLock" str ||
String.is_suffix ~suffix:"ReadWriteLock" str in
@ -1171,7 +1171,7 @@ let check_type_size tenv pname prop texp off typ_from_instr =
let exn =
Exceptions.Pointer_size_mismatch (
Errdesc.explain_dereference tenv deref_str prop loc, __POS__) in
Reporting.log_warning pname exn
Reporting.log_warning_deprecated pname exn
end
| None ->
L.d_str "texp: "; Sil.d_texp_full texp; L.d_ln ()

@ -53,7 +53,7 @@ let log_issue_from_summary err_kind summary ?loc ?node_id ?session ?ltr ?linters
let err_log = summary.Specs.attributes.ProcAttributes.err_log in
log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr ?linters_def_file exn
let log_issue
let log_issue_deprecated
?(store_summary=false)
err_kind
proc_name
@ -80,10 +80,15 @@ let log_error_from_errlog = log_issue_from_errlog Exceptions.Kerror
let log_warning_from_errlog = log_issue_from_errlog Exceptions.Kwarning
let log_info_from_errlog = log_issue_from_errlog Exceptions.Kinfo
let log_error_from_summary = log_issue_from_summary Exceptions.Kerror
let log_warning_from_summary = log_issue_from_summary Exceptions.Kwarning
let log_info_from_summary = log_issue_from_summary Exceptions.Kwarning
let log_error = log_issue_from_summary Exceptions.Kerror
let log_warning = log_issue_from_summary Exceptions.Kwarning
let log_info = log_issue_from_summary Exceptions.Kwarning
let log_error ?(store_summary=false) = log_issue ~store_summary Exceptions.Kerror
let log_warning ?(store_summary=false) = log_issue ~store_summary Exceptions.Kwarning
let log_info ?(store_summary=false) = log_issue ~store_summary Exceptions.Kinfo
let log_error_deprecated ?(store_summary=false) =
log_issue_deprecated ~store_summary Exceptions.Kerror
let log_warning_deprecated ?(store_summary=false) =
log_issue_deprecated ~store_summary Exceptions.Kwarning
let log_info_deprecated ?(store_summary=false) =
log_issue_deprecated ~store_summary Exceptions.Kinfo

@ -22,14 +22,20 @@ type log_t =
type log_issue_from_errlog = Errlog.t -> log_t
(** Report an error in the given procedure. *)
val log_error : ?store_summary:bool -> Typ.Procname.t -> log_t
(** Report an error in the given procedure.
DEPRECATED as it can create race conditions between checkers.
Use log_error instead *)
val log_error_deprecated : ?store_summary:bool -> Typ.Procname.t -> log_t
(** Report a warning in the given procedure. *)
val log_warning : ?store_summary:bool -> Typ.Procname.t -> log_t
(** Report a warning in the given procedure.
DEPRECATED as it can create race conditions between checkers.
Use log_warning instead *)
val log_warning_deprecated : ?store_summary:bool -> Typ.Procname.t -> log_t
(** Report an info in the given procedure. *)
val log_info : ?store_summary:bool -> Typ.Procname.t -> log_t
(** Report an info in the given procedure.
DEPRECATED as it can create race conditions between checkers.
Use log_info instead *)
val log_info_deprecated : ?store_summary:bool -> Typ.Procname.t -> log_t
(** Report an issue of a given kind in the given error log. *)
val log_issue_from_errlog : Exceptions.err_kind -> log_issue_from_errlog
@ -44,10 +50,10 @@ val log_warning_from_errlog : log_issue_from_errlog
val log_info_from_errlog : log_issue_from_errlog
(** Add an error to the given summary. *)
val log_error_from_summary : Specs.summary -> log_t
val log_error : Specs.summary -> log_t
(** Add an warning to the given summary. *)
val log_warning_from_summary : Specs.summary -> log_t
val log_warning : Specs.summary -> log_t
(** Add an info to the given summary. *)
val log_info_from_summary : Specs.summary -> log_t
val log_info : Specs.summary -> log_t

@ -114,7 +114,7 @@ let rec apply_offlist
let deref_str = Localise.deref_str_uninitialized alloc_attribute_opt in
let err_desc = Errdesc.explain_memory_access tenv deref_str p (State.get_loc ()) in
let exn = (Exceptions.Uninitialized_value (err_desc, __POS__)) in
Reporting.log_warning pname exn;
Reporting.log_warning_deprecated pname exn;
Sil.update_inst inst_curr inst
| Sil.Ilookup -> (* a lookup does not change an inst unless it is inst_initial *)
lookup_inst := Some inst_curr;
@ -380,7 +380,7 @@ let check_inherently_dangerous_function caller_pname callee_pname =
let exn =
Exceptions.Inherently_dangerous_function
(Localise.desc_inherently_dangerous_function callee_pname) in
Reporting.log_warning caller_pname exn
Reporting.log_warning_deprecated caller_pname exn
let call_should_be_skipped callee_summary =
(* check skip flag *)
@ -415,14 +415,14 @@ let check_arith_norm_exp tenv pname exp prop =
| Some (Attribute.Div0 div), prop' ->
let desc = Errdesc.explain_divide_by_zero tenv div (State.get_node ()) (State.get_loc ()) in
let exn = Exceptions.Divide_by_zero (desc, __POS__) in
Reporting.log_warning pname exn;
Reporting.log_warning_deprecated pname exn;
Prop.exp_normalize_prop tenv prop exp, prop'
| Some (Attribute.UminusUnsigned (e, typ)), prop' ->
let desc =
Errdesc.explain_unary_minus_applied_to_unsigned_expression tenv
e typ (State.get_node ()) (State.get_loc ()) in
let exn = Exceptions.Unary_minus_applied_to_unsigned_expression (desc, __POS__) in
Reporting.log_warning pname exn;
Reporting.log_warning_deprecated pname exn;
Prop.exp_normalize_prop tenv prop exp, prop'
| None, prop' -> Prop.exp_normalize_prop tenv prop exp, prop'
@ -458,7 +458,7 @@ let check_already_dereferenced tenv pname cond prop =
(Exp.Var id) (State.get_node ()) n (State.get_loc ()) in
let exn =
(Exceptions.Null_test_after_dereference (desc, __POS__)) in
Reporting.log_warning pname exn
Reporting.log_warning_deprecated pname exn
| None -> ()
(** Check whether symbolic execution de-allocated a stack variable or a constant string,
@ -1027,7 +1027,7 @@ let rec sym_exec tenv current_pdesc _instr (prop_: Prop.normal Prop.t) path
ret_typ_opt actual_args =
let skip_res () =
let exn = Exceptions.Skip_function (Localise.desc_skip_function callee_pname) in
Reporting.log_info current_pname exn;
Reporting.log_info_deprecated current_pname exn;
L.d_strln
("Undefined function " ^ Typ.Procname.to_string callee_pname
^ ", returning undefined value.");
@ -1074,7 +1074,7 @@ let rec sym_exec tenv current_pdesc _instr (prop_: Prop.normal Prop.t) path
let desc = Errdesc.explain_condition_always_true_false tenv i cond node loc in
let exn =
Exceptions.Condition_always_true_false (desc, not (IntLit.iszero i), __POS__) in
Reporting.log_warning current_pname exn
Reporting.log_warning_deprecated current_pname exn
| _ -> () in
if not Config.tracing then
check_already_dereferenced tenv current_pname cond prop__;
@ -1390,7 +1390,7 @@ and check_untainted tenv exp taint_kind caller_pname callee_pname prop =
let exn =
Exceptions.Tainted_value_reaching_sensitive_function
(err_desc, __POS__) in
Reporting.log_warning caller_pname exn;
Reporting.log_warning_deprecated caller_pname exn;
Attribute.add_or_replace tenv prop (Apred (Auntaint taint_info, [exp]))
| _ ->
if !Config.footprint then
@ -1577,7 +1577,7 @@ and proc_call
&& is_none (Specs.get_flag callee_summary ProcAttributes.proc_flag_ignore_return) then
let err_desc = Localise.desc_return_value_ignored callee_pname loc in
let exn = (Exceptions.Return_value_ignored (err_desc, __POS__)) in
Reporting.log_warning caller_pname exn in
Reporting.log_warning_deprecated caller_pname exn in
check_inherently_dangerous_function caller_pname callee_pname;
begin
let formal_types = List.map ~f:snd (Specs.get_formals callee_summary) in

@ -377,7 +377,7 @@ let check_path_errors_in_post tenv caller_pname post post_path =
else current_path, None (* position not found, only use the path up to the callee *) in
State.set_path new_path path_pos_opt;
let exn = Exceptions.Divide_by_zero (desc, __POS__) in
Reporting.log_warning caller_pname exn
Reporting.log_warning_deprecated caller_pname exn
| _ -> () in
List.iter ~f:check_attr (Attribute.get_all post)
@ -831,7 +831,7 @@ let report_taint_error e taint_info callee_pname caller_pname calling_prop =
let exn =
Exceptions.Tainted_value_reaching_sensitive_function
(err_desc, __POS__) in
Reporting.log_warning caller_pname exn
Reporting.log_warning_deprecated caller_pname exn
let check_taint_on_variadic_function tenv callee_pname caller_pname actual_params calling_prop =
let rec n_tail lst n = (* return the tail of a list from element n *)
@ -1038,7 +1038,7 @@ let exe_spec
frame_fld, missing_fld, frame_typ, missing_typ) ->
let log_check_exn check =
let exn = get_check_exn tenv check callee_pname loc __POS__ in
Reporting.log_warning caller_pname exn in
Reporting.log_warning_deprecated caller_pname exn in
let do_split () =
let missing_pi' =
if Config.taint_analysis then

@ -424,7 +424,7 @@ struct
let desc = Errdesc.explain_condition_always_true_false tenv i cond node loc in
let exn =
Exceptions.Condition_always_true_false (desc, not true_branch, __POS__) in
Reporting.log_warning pname ~loc exn
Reporting.log_warning_deprecated pname ~loc exn
| Sil.Call (_, Const (Cfun pname), _, _, _) when
String.equal (Typ.Procname.get_method pname) "exit" &&
is_last_statement_of_if_branch rem_instrs node -> ()
@ -432,7 +432,7 @@ struct
let loc = Sil.instr_get_loc instr in
let desc = Errdesc.explain_unreachable_code_after loc in
let exn = Exceptions.Unreachable_code_after (desc, __POS__) in
Reporting.log_error pname ~loc exn)
Reporting.log_error_deprecated pname ~loc exn)
| _ -> ()
in
print_debug_info instr mem' cond_set;
@ -471,7 +471,7 @@ struct
let exn =
Exceptions.Checkers (Localise.to_issue_id Localise.buffer_overrun, error_desc) in
let trace = [Errlog.make_trace_element 0 loc description []] in
Reporting.log_error pname ~loc ~ltr:trace exn
Reporting.log_error_deprecated pname ~loc ~ltr:trace exn
| _ -> ()
in
Dom.ConditionSet.iter report1 conds

@ -180,9 +180,9 @@ let checker callback =
begin
match make_error_trace astate ap udchain with
| Some (loc, ltr) ->
Reporting.log_warning pname ~loc ~ltr exn
Reporting.log_warning_deprecated pname ~loc ~ltr exn
| None ->
Reporting.log_warning pname exn
Reporting.log_warning_deprecated pname exn
end
| _ -> ()
in

@ -211,7 +211,7 @@ let report_siof summary trace pdesc gname loc =
let ltr = SiofTrace.trace_of_error loc gname sink_path' in
let msg = Localise.to_issue_id Localise.static_initialization_order_fiasco in
let exn = Exceptions.Checkers (msg, Localise.verbatim_desc description) in
Reporting.log_error_from_summary summary ~loc ~ltr exn in
Reporting.log_error summary ~loc ~ltr exn in
let has_foreign_sink (_, path) =
List.exists

@ -1040,7 +1040,7 @@ let report_thread_safety_violation tenv pdesc ~make_description ~conflicts acces
let msg = Localise.to_issue_id Localise.thread_safety_violation in
let description = make_description tenv pname final_sink_site initial_sink_site final_sink in
let exn = Exceptions.Checkers (msg, Localise.verbatim_desc description) in
Reporting.log_error ~store_summary:true pname ~loc ~ltr exn in
Reporting.log_error_deprecated ~store_summary:true pname ~loc ~ltr exn in
let trace_of_pname = trace_of_pname access pdesc in
Option.iter ~f:report_one_path (PathDomain.get_reportable_sink_path access ~trace_of_pname)

@ -189,7 +189,7 @@ let report_allocation_stack
MF.pp_monospaced (stack_str ^ ("new "^constr_str)) in
let exn =
Exceptions.Checkers (allocates_memory, Localise.verbatim_desc description) in
Reporting.log_error_from_summary summary ~loc:fst_call_loc ~ltr:final_trace exn
Reporting.log_error summary ~loc:fst_call_loc ~ltr:final_trace exn
let report_annotation_stack src_annot snk_annot src_summary loc trace stack_str snk_pname call_loc =
let src_pname = Specs.get_proc_name src_summary in
@ -212,7 +212,7 @@ let report_annotation_stack src_annot snk_annot src_summary loc trace stack_str
else annotation_reachability_error in
let exn =
Exceptions.Checkers (msg, Localise.verbatim_desc description) in
Reporting.log_error_from_summary src_summary ~loc ~ltr:final_trace exn
Reporting.log_error src_summary ~loc ~ltr:final_trace exn
let report_call_stack summary end_of_stack lookup_next_calls report call_site sink_map =
(* TODO: stop using this; we can use the call site instead *)
@ -387,7 +387,7 @@ let check_expensive_subtyping_rules { Callbacks.proc_desc; tenv; summary } overr
let exn =
Exceptions.Checkers
(expensive_overrides_unexpensive, Localise.verbatim_desc description) in
Reporting.log_error_from_summary summary ~loc exn
Reporting.log_error summary ~loc exn
module Interprocedural = struct
include AbstractInterpreter.Interprocedural(Summary)

@ -114,6 +114,6 @@ module ST = struct
SourceFile.pp loc.Location.file
(Typ.Procname.to_string proc_name);
L.progress "%s@." description;
Reporting.log_error proc_name ~loc ~ltr:trace exn
Reporting.log_error_deprecated proc_name ~loc ~ltr:trace exn
end
end

@ -19,7 +19,7 @@ let report_error fragment_typ fld fld_typ summary pdesc =
let description = Localise.desc_fragment_retains_view fragment_typ fld fld_typ pname in
let exn = Exceptions.Checkers (retained_view, description) in
let loc = Procdesc.get_loc pdesc in
Reporting.log_error_from_summary summary ~loc exn
Reporting.log_error summary ~loc exn
let callback_fragment_retains_view_java
pname_java { Callbacks.proc_desc; summary; tenv } =

@ -129,7 +129,7 @@ let check_printf_args_ok
(default_format_type_name ft)
gt in
let exn = Exceptions.Checkers (description, Localise.verbatim_desc description) in
Reporting.log_error_from_summary summary ~loc:instr_loc exn
Reporting.log_error summary ~loc:instr_loc exn
else
check_type_names instr_loc (n_arg + 1) instr_proc_name fs gs
| [], [] -> ()
@ -139,7 +139,7 @@ let check_printf_args_ok
instr_name
instr_line in
let exn = Exceptions.Checkers (description, Localise.verbatim_desc description) in
Reporting.log_error_from_summary summary ~loc:instr_loc exn in
Reporting.log_error summary ~loc:instr_loc exn in
(* Get the array ivar for a given nvar *)
let rec array_ivar instrs nvar =

@ -106,7 +106,7 @@ let checker ({ Callbacks.summary; } as callback) : Specs.summary =
let issue_kind = Localise.to_issue_id Localise.resource_leak in
let message = F.asprintf "Leaked %d resource(s)" leak_count in
let exn = Exceptions.Checkers (issue_kind, Localise.verbatim_desc message) in
Reporting.log_error_from_summary summary ~loc:last_loc exn in
Reporting.log_error summary ~loc:last_loc exn in
(* Convert the abstract state to a summary. for now, just the identity function *)
let convert_to_summary (post : Domain.astate) : Domain.summary =
(* 4(a) *)

@ -226,8 +226,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct
let trace_str = get_short_trace_string original_source final_sink in
let ltr = source_trace @ (List.rev sink_trace) in
let exn = Exceptions.Checkers (msg, Localise.verbatim_desc trace_str) in
Reporting.log_error_from_summary
proc_data.extras.summary ~loc:(CallSite.loc cur_site) ~ltr exn in
Reporting.log_error proc_data.extras.summary ~loc:(CallSite.loc cur_site) ~ltr exn in
List.iter ~f:report_one (TraceDomain.get_reports ~cur_site trace)

Loading…
Cancel
Save