diff --git a/infer/src/backend/interproc.ml b/infer/src/backend/interproc.ml index e1a618744..b51360811 100644 --- a/infer/src/backend/interproc.ml +++ b/infer/src/backend/interproc.ml @@ -458,7 +458,7 @@ let check_assignement_guard node = let desc = Errdesc.explain_condition_is_assignment l_node in let exn = Exceptions.Condition_is_assignment (desc, __POS__) in let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop pname) in - Reporting.log_warning pname ~loc: (Some l_node) ~pre: pre_opt exn + Reporting.log_warning pname ~loc:l_node ?pre:pre_opt exn ) else () | _ -> @@ -508,7 +508,7 @@ let forward_tabulate tenv wl = | None -> ()); L.d_strln "SIL INSTR:"; Cfg.Node.d_instrs ~sub_instrs: true (State.get_instr ()) curr_node; L.d_ln (); - Reporting.log_error ~pre: pre_opt curr_pname exn; + Reporting.log_error ?pre:pre_opt curr_pname exn; State.mark_instr_fail pre_opt exn; handled_some_exception := true in @@ -1044,7 +1044,7 @@ let perform_analysis_phase tenv (pname : Procname.t) (pdesc : Cfg.Procdesc.t) Exceptions.Internal_error (Localise.verbatim_desc "Leak_while_collecting_specs_after_footprint") in let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop pname) in - Reporting.log_error pname ~pre: pre_opt exn; + Reporting.log_error pname ?pre:pre_opt exn; [] (* retuning no specs *) in specs, Specs.FOOTPRINT in let wl = path_set_create_worklist pdesc in @@ -1204,7 +1204,7 @@ let report_runtime_exceptions tenv pdesc summary = pp_to_string (Prop.pp_prop pe_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 ~pre: (Some (Specs.Jprop.to_prop pre)) exn in + Reporting.log_error pname ~pre:(Specs.Jprop.to_prop pre) exn in IList.iter report exn_preconditions @@ -1217,7 +1217,7 @@ let report_custom_errors 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 ~pre: (Some (Specs.Jprop.to_prop pre)) exn in + Reporting.log_error pname ~pre:(Specs.Jprop.to_prop pre) exn in IList.iter report error_preconditions module SpecMap = Map.Make (struct diff --git a/infer/src/backend/rearrange.ml b/infer/src/backend/rearrange.ml index 19fb0ee1c..c1efa31e0 100644 --- a/infer/src/backend/rearrange.ml +++ b/infer/src/backend/rearrange.ml @@ -63,7 +63,7 @@ let check_bad_index pname p len index loc = Exceptions.Array_out_of_bounds_l1 (Errdesc.explain_array_access deref_str p loc, __POS__) in let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop pname) in - Reporting.log_warning pname ~pre: pre_opt exn + Reporting.log_warning pname ?pre:pre_opt 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 deref_str p loc in @@ -71,7 +71,7 @@ let check_bad_index pname p len index loc = then Exceptions.Array_out_of_bounds_l2 (desc, __POS__) else Exceptions.Array_out_of_bounds_l3 (desc, __POS__) in let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop pname) in - Reporting.log_warning pname ~pre: pre_opt exn + Reporting.log_warning pname ?pre:pre_opt exn end (** Perform bounds checking *) @@ -1058,7 +1058,7 @@ let check_type_size pname prop texp off typ_from_instr = Exceptions.Pointer_size_mismatch ( Errdesc.explain_dereference deref_str prop loc, __POS__) in let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop pname) in - Reporting.log_warning pname ~pre: pre_opt exn + Reporting.log_warning pname ?pre:pre_opt exn end | None -> L.d_str "texp: "; Sil.d_texp_full texp; L.d_ln () diff --git a/infer/src/backend/reporting.ml b/infer/src/backend/reporting.ml index c93b8c101..a62444a76 100644 --- a/infer/src/backend/reporting.ml +++ b/infer/src/backend/reporting.ml @@ -12,11 +12,11 @@ open! Utils module L = Logging type log_t = - ?loc: Location.t option -> - ?node_id: (int * int) option -> - ?session: int option -> - ?ltr: Errlog.loc_trace option -> - ?pre: Prop.normal Prop.t option -> + ?loc: Location.t -> + ?node_id: (int * int) -> + ?session: int -> + ?ltr: Errlog.loc_trace -> + ?pre: Prop.normal Prop.t -> exn -> unit @@ -24,15 +24,7 @@ type log_issue = Procname.t -> log_t type log_issue_from_errlog = Errlog.t -> log_t -let log_issue_from_errlog - err_kind - err_log - ?(loc = None) - ?(node_id = None) - ?(session = None) - ?(ltr = None) - ?(pre = None) - exn = +let log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr ?pre exn = let loc = match loc with | None -> State.get_loc () | Some loc -> loc in @@ -56,11 +48,11 @@ let log_issue_from_errlog let log_issue err_kind proc_name - ?(loc = None) - ?(node_id = None) - ?(session = None) - ?(ltr = None) - ?(pre = None) + ?loc + ?node_id + ?session + ?ltr + ?pre exn = let should_suppress_warnings summary = !Config.curr_language = Config.Java && @@ -72,8 +64,7 @@ let log_issue | Some summary when should_suppress_warnings summary -> () | Some summary -> let err_log = summary.Specs.attributes.ProcAttributes.err_log in - log_issue_from_errlog err_kind err_log ~loc:loc ~node_id:node_id - ~session:session ~ltr:ltr ~pre:pre exn + log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr ?pre exn | None -> () let log_error = log_issue Exceptions.Kerror diff --git a/infer/src/backend/reporting.mli b/infer/src/backend/reporting.mli index 4559c5307..76247a031 100644 --- a/infer/src/backend/reporting.mli +++ b/infer/src/backend/reporting.mli @@ -12,11 +12,11 @@ open! Utils (** Type of functions to report issues to the error_log in a spec. *) type log_t = - ?loc: Location.t option -> - ?node_id: (int * int) option -> - ?session: int option -> - ?ltr: Errlog.loc_trace option -> - ?pre: Prop.normal Prop.t option -> + ?loc: Location.t -> + ?node_id: (int * int) -> + ?session: int -> + ?ltr: Errlog.loc_trace -> + ?pre: Prop.normal Prop.t -> exn -> unit diff --git a/infer/src/backend/state.ml b/infer/src/backend/state.ml index 51fa437bc..8607d3024 100644 --- a/infer/src/backend/state.ml +++ b/infer/src/backend/state.ml @@ -309,11 +309,11 @@ let mark_instr_fail pre_opt exn = type log_issue = Procname.t -> - ?loc: Location.t option -> - ?node_id: (int * int) option -> - ?session: int option -> - ?ltr: Errlog.loc_trace option -> - ?pre: Prop.normal Prop.t option -> + ?loc: Location.t -> + ?node_id: (int * int) -> + ?session: int -> + ?ltr: Errlog.loc_trace -> + ?pre: Prop.normal Prop.t -> exn -> unit @@ -326,7 +326,7 @@ let process_execution_failures (log_issue : log_issue) pname = let desc' = Localise.verbatim_desc ("exception: " ^ Localise.to_string ex_name) in let exn' = Exceptions.Analysis_stops (desc', ml_loc_opt) in log_issue - pname ~loc: (Some loc) ~node_id: (Some key) ~ltr: (Some loc_trace) ~pre: pre_opt exn' + pname ~loc ~node_id:key ~ltr:loc_trace ?pre:pre_opt exn' | _ -> () in NodeHash.iter do_failure !gs.failure_map diff --git a/infer/src/backend/state.mli b/infer/src/backend/state.mli index d8fcd7db2..bdd582afb 100644 --- a/infer/src/backend/state.mli +++ b/infer/src/backend/state.mli @@ -86,11 +86,11 @@ val mk_find_duplicate_nodes: Cfg.Procdesc.t -> (Cfg.Node.t -> Cfg.NodeSet.t) type log_issue = Procname.t -> - ?loc: Location.t option -> - ?node_id: (int * int) option -> - ?session: int option -> - ?ltr: Errlog.loc_trace option -> - ?pre: Prop.normal Prop.t option -> + ?loc: Location.t -> + ?node_id: (int * int) -> + ?session: int -> + ?ltr: Errlog.loc_trace -> + ?pre: Prop.normal Prop.t -> exn -> unit diff --git a/infer/src/backend/symExec.ml b/infer/src/backend/symExec.ml index 1bbe9f6e1..15b428749 100644 --- a/infer/src/backend/symExec.ml +++ b/infer/src/backend/symExec.ml @@ -114,7 +114,7 @@ let rec apply_offlist let err_desc = Errdesc.explain_memory_access deref_str p (State.get_loc ()) in let exn = (Exceptions.Uninitialized_value (err_desc, __POS__)) in let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop pname) in - Reporting.log_warning pname ~pre: pre_opt exn; + Reporting.log_warning pname ?pre:pre_opt 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 = Exceptions.Inherently_dangerous_function (Localise.desc_inherently_dangerous_function callee_pname) in let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop caller_pname) in - Reporting.log_warning caller_pname ~pre: pre_opt exn + Reporting.log_warning caller_pname ?pre:pre_opt exn let proc_is_defined proc_name = match AttributesTable.load_attributes proc_name with @@ -423,7 +423,7 @@ let check_arith_norm_exp pname exp prop = let desc = Errdesc.explain_divide_by_zero div (State.get_node ()) (State.get_loc ()) in let exn = Exceptions.Divide_by_zero (desc, __POS__) in let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop pname) in - Reporting.log_warning pname ~pre: pre_opt exn; + Reporting.log_warning pname ?pre:pre_opt exn; Prop.exp_normalize_prop prop exp, prop' | Some (Attribute.UminusUnsigned (e, typ)), prop' -> let desc = @@ -431,7 +431,7 @@ let check_arith_norm_exp pname exp prop = e typ (State.get_node ()) (State.get_loc ()) in let exn = Exceptions.Unary_minus_applied_to_unsigned_expression (desc, __POS__) in let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop pname) in - Reporting.log_warning pname ~pre: pre_opt exn; + Reporting.log_warning pname ?pre:pre_opt exn; Prop.exp_normalize_prop prop exp, prop' | None, prop' -> Prop.exp_normalize_prop prop exp, prop' @@ -469,7 +469,7 @@ let check_already_dereferenced pname cond prop = let exn = (Exceptions.Null_test_after_dereference (desc, __POS__)) in let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop pname) in - Reporting.log_warning pname ~pre: pre_opt exn + Reporting.log_warning pname ?pre:pre_opt exn | None -> () (** Check whether symbolic execution de-allocated a stack variable or a constant string, @@ -1064,7 +1064,7 @@ let rec sym_exec tenv current_pdesc _instr (prop_: Prop.normal Prop.t) path let exn = Exceptions.Condition_always_true_false (desc, not (IntLit.iszero i), __POS__) in let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop current_pname) in - Reporting.log_warning current_pname ~pre: pre_opt exn + Reporting.log_warning current_pname ?pre:pre_opt exn | _ -> () in if not Config.report_runtime_exceptions then check_already_dereferenced current_pname cond prop__; @@ -1583,7 +1583,7 @@ and proc_call summary {Builtin.pdesc; tenv; prop_= pre; path; ret_ids; args= act let err_desc = Localise.desc_return_value_ignored callee_pname loc in let exn = (Exceptions.Return_value_ignored (err_desc, __POS__)) in let pre_opt = State.get_normalized_pre (Abs.abstract_no_symop caller_pname) in - Reporting.log_warning caller_pname ~pre: pre_opt exn in + Reporting.log_warning caller_pname ?pre:pre_opt exn in check_inherently_dangerous_function caller_pname callee_pname; begin let formal_types = IList.map (fun (_, typ) -> typ) (Specs.get_formals summary) in diff --git a/infer/src/backend/tabulation.ml b/infer/src/backend/tabulation.ml index 2037457ce..888e51399 100644 --- a/infer/src/backend/tabulation.ml +++ b/infer/src/backend/tabulation.ml @@ -373,7 +373,7 @@ let check_path_errors_in_post caller_pname post post_path = State.set_path new_path path_pos_opt; let exn = Exceptions.Divide_by_zero (desc, __POS__) in let pre_opt = State.get_normalized_pre (fun _ p -> p) (* Abs.abstract_no_symop *) in - Reporting.log_warning caller_pname ~pre: pre_opt exn + Reporting.log_warning caller_pname ?pre:pre_opt exn | _ -> () in IList.iter check_attr (Attribute.get_all post) diff --git a/infer/src/checkers/annotationReachability.ml b/infer/src/checkers/annotationReachability.ml index d23b076d5..3547fd36d 100644 --- a/infer/src/checkers/annotationReachability.ml +++ b/infer/src/checkers/annotationReachability.ml @@ -216,7 +216,7 @@ let report_allocation_stack ("new "^constr_str) in let exn = Exceptions.Checkers (allocates_memory, Localise.verbatim_desc description) in - Reporting.log_error pname ~loc: (Some fst_call_loc) ~ltr: (Some final_trace) exn + Reporting.log_error pname ~loc:fst_call_loc ~ltr:final_trace exn let report_annotation_stack src_annot snk_annot src_pname loc trace stack_str snk_pname call_loc = if snk_annot = dummy_constructor_annot @@ -239,7 +239,7 @@ let report_annotation_stack src_annot snk_annot src_pname loc trace stack_str sn else annotation_reachability_error in let exn = Exceptions.Checkers (msg, Localise.verbatim_desc description) in - Reporting.log_error src_pname ~loc: (Some loc) ~ltr: (Some final_trace) exn + Reporting.log_error src_pname ~loc ~ltr:final_trace exn let report_call_stack end_of_stack lookup_next_calls report call_site calls = (* TODO: stop using this; we can use the call site instead *) @@ -394,7 +394,7 @@ module Interprocedural = struct let exn = Exceptions.Checkers (expensive_overrides_unexpensive, Localise.verbatim_desc description) in - Reporting.log_error proc_name ~loc: (Some loc) ~ltr: None exn in + Reporting.log_error proc_name ~loc exn in if expensive then PatternMatch.proc_iter_overridden_methods diff --git a/infer/src/checkers/checkers.ml b/infer/src/checkers/checkers.ml index f27fa676a..f5b87cd9f 100644 --- a/infer/src/checkers/checkers.ml +++ b/infer/src/checkers/checkers.ml @@ -154,7 +154,7 @@ module ST = struct (Procname.to_string proc_name); L.stdout "%s@." description end; - Reporting.log_error proc_name ~loc: (Some loc) ~ltr: (Some trace) exn + Reporting.log_error proc_name ~loc ~ltr:trace exn end end diff --git a/infer/src/checkers/fragmentRetainsViewChecker.ml b/infer/src/checkers/fragmentRetainsViewChecker.ml index 47893c6c5..8924554dc 100644 --- a/infer/src/checkers/fragmentRetainsViewChecker.ml +++ b/infer/src/checkers/fragmentRetainsViewChecker.ml @@ -18,7 +18,7 @@ let report_error fragment_typ fld fld_typ pname 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 = Cfg.Procdesc.get_loc pdesc in - Reporting.log_error pname ~loc:(Some loc) exn + Reporting.log_error pname ~loc exn let callback_fragment_retains_view_java pname_java { Callbacks.proc_desc; tenv } = diff --git a/infer/src/clang/cFrontend_errors.ml b/infer/src/clang/cFrontend_errors.ml index 3a490cc8b..44d00e7d1 100644 --- a/infer/src/clang/cFrontend_errors.ml +++ b/infer/src/clang/cFrontend_errors.ml @@ -103,8 +103,8 @@ let log_frontend_issue cfg cg method_decl_opt key issue_desc = let err_kind = CIssue.severity_of_issue issue in let method_name = Ast_utils.full_name_of_decl_opt method_decl_opt in let key = Hashtbl.hash (key ^ method_name) in - Reporting.log_issue_from_errlog err_kind errlog exn ~loc:(Some loc) ~ltr:(Some trace) - ~node_id:(Some (0, key)) + Reporting.log_issue_from_errlog err_kind errlog exn ~loc ~ltr:trace + ~node_id:(0, key) (* General invocation function for checkers Takes